I want to get rid of pages ending with a heading title only. I want at least 2 text rows following the heading title to make a better look.
What is the exact value to be passed to \Needspace*{}
to avoid this heading orphan?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI want to get rid of pages ending with a heading title only. I want at least 2 text rows following the heading title to make a better look.
What is the exact value to be passed to \Needspace*{}
to avoid this heading orphan?
The normal way to control orphans is to adjust the \clubpenalty
variable.
Try to set it to a high value. See http://www.tex.ac.uk/cgi-bin/texfaq2html?label=widows for more information.
If you want to use \Needspace*{}
I would assume that 4\baselineskip
is reasonable for the heading title plus two text rows. I'm simply counting the bigger heading title line twice, therefore the factor 4. You could experiment with factors between 3 and 4. The exact amount is of course dependent on the kind of heading that follows.
\clubpenalty
is relevant here: It controls how much first lines of paragraphs at the bottom of a page a discouraged. The present post is about single line headings.
Jan 24, 2011 at 11:19
I don't know if this is what you're looking for but you could always use \begin{samepage}
and \end{samepage}
to keep together the stuff that you don't want to be separated.
There should be a penalty counter though that omits this dreadful use of the samepage environment. Read this question for more info on the how to discourage latex in breaking pages after your headings.
Add the following to your preamble and you should be fine:
\usepackage{etex}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@afterheading}%
{\clubpenalty \@M}{\clubpenalties 3 \@M \@M 0}{}{}
\patchcmd{\@afterheading}%
{\clubpenalty \@clubpenalty}{\clubpenalties 2 \@clubpenalty 0}{}{}
\makeatother