1

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

2

1 Answer 1

1

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

\documentclass{article}
\usepackage{lipsum}
\usepackage{needspace}

\begin{document}
\section{First section}
\lipsum[1-4]

\needspace{6\baselineskip}
\section{Second section}
\lipsum[1-4]
An extra line

A second extra line

\needspace{6\baselineskip}
\section{Third section}
\lipsum[1-6]

\end{document}

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .