tags:

views:

196

answers:

2

Hi: I use LaTeX listing package with \lstinputlisting to display text from an external file. The file contains a data format description with a blank line at the end. The package ignores the blank line. How can I show the blank line in a listing?

What it displays:

1 lorem ipsum...
2 more lorem ipsum
3 lorem lorem ipsum

What I want:

1 lorem ipsum
2 more lorem ipsum
3 lorem lorem ipsum
4
A: 

See the documentation, section 4.4

`showlines=(true|false) or showlines (default = false)

If true, the package prints empty lines at the end of listings. Otherwise these lines are dropped (but they count for line numbering).

Try adding this before your listing:

\lstset{
   showlines=true
}
John
No, this does not work as expected. At least with external file input with **\lstinputlisting**.
Sney
+1  A: 

You can escape to LaTeX from within listings by assigning an escape character like so:

\lstset{numbers=left, stepnumber=1, frame=none,basicstyle = \ttfamily}
\begin{lstlisting}[escapechar=\%]
codeline1
codeline2
%
\end{lstlisting}

Comes out as:

1 codeline1
2 codeline2
3

I know it's not \lstinputlisting but hopefully it'll help you anyway.

billynomates