I am trying to insert a code snippet with the listingspackage, and want the lines numbered. However I would like only every 5th line and the first to be numbered (numbers beeing(1,5,10,15,...)) according to the manual:
stepnumber=5
should do the trick, however using my minimal example (see bottom), I get the line numbers 1,6,11,16,...
May be I misinterpreted he manual 8did that once before), however I am clueless.
If a real latex guru is around, there would be something I would like even more, having every linenumber printed however every fifth in bold/ a different style numbers than beeing: 1 2 3 4 5 6 7 8 9 10 11 ... however since this is not in the doku I am sure it requires some deeper latex/listings knowledge.
P.S.: There is one more oddity, eventhough I put "numberfirstline=false" I get the line number 1 ( I get that linenumber as well without setting numberfirstline, which should default to false), it is jsu in there to point out that something is wrong.
I am using miktex for compilation, if that helps.
Thanks in advance.
\documentclass{scrreprt} %[twoside,headings=openright] %Sourcecode formatting \usepackage{listings} \lstset{ numbers=left, % Ort der Zeilennummern stepnumber=5, % Abstand zwischen den Zeilennummern numberfirstline=false } \begin{document} \lstinputlisting{sourcecode/AES/lookupSoftcoded.S} %codefile with 15 lines or so... \end{document}
To turn line numbers on, type :set nu and press Return. Line numbers appear in the left margin. Note that these numbers do not appear when you print out the file.
The listings package is a source code printer for LATEX. You can typeset stand alone files as well as listings with an environment similar to verbatim as well as you can print code snippets using a command similar to \verb.
At the top of the TeXworks window, select Edit, then Preferences. Select the "Editor" tab and check the "Line numbers" box. Click OK.
sty allows to refer to a line number with \ref{<label>} . The label is set by \linelabel{<label>} , anywhere in a paragraph that gets line numbers.
You can get the desired numbering like this:
\lstset{ numbers=left, stepnumber=5, firstnumber=1, numberfirstline=true }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With