Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following MWE using fancyvrb produces line numbers every other line, starting on the second line, like so:

  Writing some test
2
  third line
4 fourth line
  fifth line

so the numbers are 2, 4, 6,.... I would like the numbers to start on the first line and go every other line, as in:

1 Writing some test

3 third line
  fourth line
5 fifth line

How can I achieve this?

MWE:

\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\begin{Verbatim}[numbers=left,firstnumber=1,stepnumber=2]
Writing some test

third line
fourth line
fifth line
\end{Verbatim}
\end{document}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can try this small trick. Add an empty line at the beginning of your source code and use firstline=2 to skip that line. I enclose an example and a preview of it.

% run: *latex mal-fancyvrb.tex
\documentclass{article}
\pagestyle{empty}
\parindent=0pt
\usepackage{fancyvrb}
\begin{document}
Text before.
\begin{Verbatim}[numbers=left, firstnumber=1, stepnumber=2, firstline=2]

Writing some test

third line
fourth line
fifth line
\end{Verbatim}
Text after.
\end{document}

mwe

share|improve this answer
    
+1: Thanks for the workaround. I'll leave the question "unanswered" for a little while longer to see if there's a way to do it with options in fancyvrb :-) –  darthbith Apr 20 at 18:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.