Text Formatting ⇒ 'listings' package line numbering problems
'listings' package line numbering problems
Any thoughts?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
'listings' package line numbering problems
yes, there seems to be some bug with the numberfirstline option. (I do not know if it is really a bug or if it was planned to work that way, and the documentation doesn't clarifies this). The following test code will produce (as you already experienced) a numbered first line:
Code: Select all
\documentclass{article}
\usepackage{listings}
\lstset{numbers=left, numberstyle=\tiny, stepnumber=5,%
numberfirstline=false, numbersep=5pt}
\begin{document}
The first line will be numbered:
\begin{lstlisting}[name=Test]
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write(’Case insensitive ’);
WritE(’Pascal keywords.’);
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write(’Case insensitive ’);
WritE(’Pascal keywords.’);
\end{lstlisting}
\end{document}Code: Select all
\documentclass{article}
\usepackage{listings}
\lstset{numbers=left, numberstyle=\tiny, stepnumber=5,%
numberfirstline=false, numbersep=5pt, firstnumber=1}
\begin{document}
The first line won't be numbered:
\begin{lstlisting}[name=Test]
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write(’Case insensitive ’);
WritE(’Pascal keywords.’);
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write(’Case insensitive ’);
WritE(’Pascal keywords.’);
\end{lstlisting}
\end{document}