
我試圖使用列表包控制行號和代碼之間的間距。下面是我正在使用的程式碼:
\begin{figure*} [!ht]
\centering
\lstset{showstringspaces=false,
tabsize=1,
breaklines=true,
basicstyle=\footnotesize,
numbers=left,
showspaces=false,
extendedchars=false,
numberstyle=\scriptsize,
numbersep=0pt}
\begin{lstlisting}
INPORT::[name] => [rec.comp.] @ [rec. port]
OUTPORT::[name] <= [orig.comp.] @ [out port]
[PRIMITIVE]::[name]<=[rec.port2]<-[orig.comp1.]@[out port1] [rec.port2]<-[orig.comp2.]@[out port2]...
LUT[n] [logic_func]::[name]<=[rec.port2]<-[orig.comp1.]@[out port1] [rec.port2]<-[orig.comp2.]@[out port2]...
\end{lstlisting}
\caption{single line component netlist of the tiny circuit example.}
\label{fig:netlistSyntax}
\end{figure*}
我得到的結果如下:
我對程式碼和數字之間的間距不滿意,我試圖透過更改來更改它編號參數,正如包文檔中所說,“是數字和列表之間的距離”。即使當我使用“0pt”時,我也沒有得到接近的代碼和數字。
我在這裡缺少什麼?
答案1
lstlisting
是一個逐字型的環境,最重要的是保留了空間。您的程式碼以四個空格開頭,您將看到這四個空格。
如果您設定showspaces=true
了\lstset
(您目前將其設為false
),這將變得顯而易見。
附錄
要去除空格,您可以添加
gobble=4
到\lstset
.
還有一個名為 的套件lstautogobble
提供了一個名為 的選項autogobble
。使用此選項,起始空格將自動刪除。