General ⇒ lstlisting spread between two pages causes errors
-
- Posts: 2
- Joined: Tue Nov 10, 2009 10:05 pm
lstlisting spread between two pages causes errors
I'm making using of the listings package to format code. I frequently use the lstlisting environment to format blocks of inline (i.e. not floating) code:
"
Here is some code:
\begin{lstlisting}
example
example
example
example
example
example
example
\end{lstlisting}
"
This works fine most of the time. Every now and then, a lstlisting block will causes Latex errors after I add some extra text to the top of the document. One lstlisting block will sometimes generate 100 odd errors, all of the form:
"Extra }, or forgotten $. |"
This appears to happen when the lstlisting block starts on one page and ends on the other. Adding text above a block can push it onto the next page, meaning one can give me problems later when Latex was happy with it before.
The only workaround I have to to manually tweak the page so this doesn't happen. Is there anything better I can do?
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
lstlisting spread between two pages causes errors
can you please post a minimal working example (MWE) showing the mentioned problem?
I ask you for this MWE since the following example produces no errors on my system:
Code: Select all
\documentclass{article}
\usepackage{listings}
\usepackage{lipsum}
\begin{document}
%\lipsum[1-4]
\begin{lstlisting}
example
example
example
example
example
example
example
example
example
example
example
\end{lstlisting}
\end{document}
-
- Posts: 2
- Joined: Tue Nov 10, 2009 10:05 pm