6

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}
darthbith
  • 7,384

1 Answers1

4

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

Malipivo
  • 13,287
  • +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 '14 at 18:00