GeneralLatex Listings and page break

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
schilf
Posts: 1
Joined: Wed Feb 25, 2009 1:45 pm

Latex Listings and page break

Post by schilf »

Hi!
I have a problem: I have some listings in my document inserted with \lstinputlisting. this works fine, but at some of the listings the last line doesn't fit the page and is cut and put on the next page. This looks ugly. Is there any way to prevent page break in the listing if it's only one line? How can i tell LaTeX to break a page only if there are 3 or more lines to break? Haven't found anything on the net except to put the listings on a single page, but i need them exactly in the text.
any ideas?

greetz
schilf

ps: sorry for my english :P

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Latex Listings and page break

Post by localghost »

There two possible solutions. You can enlarge a single page that contains such a listing.

Code: Select all

\enlargethispage{\baselineskip}
This would add one line to the text body. Or just make the listing float as described in the listings manual (Section 4.3 - Space and placement, p. 26).


Best regards and welcome to the board
Thorsten¹
Post Reply