TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using LyX and try to avoid the occurence of short text sections at the end of a page which start with a chapter/section etc. Is it possible to add a preamble line which can tell LyX that if a section only has less than e.g. 3 lines in the bottom of a page, it should be moved to the next page?

The way I solve this at the moment is to wait until my report is finished and then add \newpage where this occurs, but it's starting to bug me since I have quite large reports and feel that I loose a bit of control over the documents structure.

Here's an example: MWE

excerpt from generated pdf

share|improve this question
Anything that needs to be zipped up does not qualify as a MWE: meta.tex.stackexchange.com/questions/228/… – StrongBad Oct 10 '12 at 10:08
sorry, I didn't know that. Edited to just be the .lyx file. Thank you for the heads up – chwi Oct 10 '12 at 10:54

Assuming you mean lines and not sentences, you should be able to do this with the needspace package. The concept is as follows


\section{First section}

\section{Second section}
An extra line

A second extra line

\section{Third section}


In this case if there is not 6 baselineskips worth of space, the section gets moved to a new page (I chose 6 so I did not have to fiddle with the spacing to get things to move). It is not a perfect solution since I needed to add two lines to get the section to jump and not a single line.

You should be able to modify \section (and maybe \subsection etc) to include \needspace.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.