The command \pagebreak[3]
only modifies the chances that the break appears at that place. Namely, it reduces the penalty for such a break by 301
. The command \pagebreak[4]
reduces the penalty by 10000
which is a sort-of "TeX's infinity", and it enforces a page break by making it not cost anything.
However, \pagebreak[3]
cannot work in cases where LaTeX does not see anything wrong with the output (which is the case of a section title quite close to the bottom of the page). So you have to tell LaTeX to consider bottomtitles as a bad thing, and the easiest way to do this is by using a feature of the titlesec
package:
\usepackage[nobottomtitles]{titlesec}
Its idea is simple: Enforce a page-break if there is not much space left on the page. The implementation is more complicated, and I am sure that I am not able to explain in here in a good way.
It’s a bit sad to see how easily people are inclined to forget the good ol’ ways of doing things… Seriously, this question (like others I have already seen on TeX.SX) looks like a classical problem which is discussed, and solved, on page 111 of The TeXbook, where the \filbreak
command is introduced. Quoting from there:
The most interesting macro that plain TeX provides for page make-up is
called \filbreak
. It means, roughly, “Break the page here and fill
the bottom with blank space, unless there is room for more copy that
is itself followed by \filbreak
.” Thus if you put \filbreak at the
end of every paragraph, and if your paragraphs aren’t too long, every
page break will occur between paragraphs, and TeX will fit as many
paragraphs as possible on each page. The precise meaning of
\filbreak
is
\vfil\penalty-200\vfilneg
according to Appendix B; and this simple combination of TeX’s
primitives produces the desired result…
The \filbreak
macro is defined in LaTeX too (in ltplain.dtx
), and the definition is exactly the same as that of Appendix B of The TeXbook:
\def\filbreak{\par\vfil\penalty-200\vfilneg}
So you could just use it in your documents, without loading any package:
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\begin{document}
\lipsum[1]\filbreak
\lipsum[2]\filbreak
\lipsum[3]\filbreak
\lipsum[4]\filbreak
\lipsum[5]\filbreak
\lipsum[6]\filbreak
\lipsum[7]\filbreak
\lipsum[8]\filbreak
\end{document}
This works as expected; but one might object that it requires typing \filbreak
at the end of every paragraph. Well, of course this can be made automatic:
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\makeatletter
\def\filbreak{\@@par\vfil\penalty-200\vfilneg}
\makeatother
\begin{document}
\begingroup
\let\par\filbreak
\lipsum[1-32]
\endgroup
\end{document}
Obviously, it is necessary to redefine \filbreak
to invoke \@@par
, instead of \par
, to avoid infinite recursion.
Best Answer
No, there is
sampage
but that isn't what you want I suspect. The whole memory model of TeX is to ship out pages as fast as you can and to free up the memory. That is why even on the machines of 1982 TeX could produce documents of hundreds of pages. Once a page has been shipped out it has gone.What you can do is collect more than one page worth of material in a box and then handle the box in some way before shipping it out.