I have a listing as follows:
\lstdefinestyle{yamlCode} {
numbers=left,
language=Yaml,
backgroundcolor={\color{lightgray!40}},
breaklines=true,
frame=single,
columns=fixed
}
[...]
\begin{lstlisting}[style=yamlCode,label=YamlList,
caption=List of Maps in YAML.]
persons:
- name: Peter
email: peter@example.org
- name: Sally
email: sally@example.org
\end{lstlisting}
Now that listing might break after the last line of code, as can be seen in this screenshot:
How can I prevent the page break after the last line? At least one line should be moved to the next page as well. Just to be clear: I do want it to break pages, however, not after the last line. How can I achieve that?
PS: Are the white lines between the code lines rendering artefacts or real? When I open the PDF in Adobe Reader and zoom in, I can still see them. Not very nice.
float. – Oct 03 '13 at 20:18float,float=h,th,tbh. But none of these breaks the listing at the page end. It will either be completely on the first or on the second page. Should usingfloatpage-break the listing? – Oct 03 '13 at 20:31begin{lstlisting}[float,...]it is handled like a floatimng object and cannot have a pagebreak inside. It is moved to the other page. The only thing you can do if you want it on the same page is\enlagethispage{\normalbaselineskip}before the listing. – Oct 03 '13 at 20:34enlargethispagedoes not seem like a viable solution as I would have to add that to every single listing were such ugly page breaks occur. If there is no other solution to that problem, I will usefloat=hfor now. – Oct 03 '13 at 20:39