16

How do I tell LaTeX, "if you need to put a page break, this is a good place to put it" ?

5
  • 2
    Basically, that is what LaTeX does. :) Does this link help? It might be a possible duplicate of your question. tex.stackexchange.com/questions/736/pagebreak-vs-newpage.
    – hpesoj626
    Dec 8, 2012 at 4:31
  • @hpesoj626: Hmmmm, that's a tough one. \pagebreak seems to kind of do what I want, but I'm not sure yet... it's not that I want to put a page break anywhere per se, but if LaTeX wants to put a page break somewhere, I want it to consider my choice first, instead of (say) breaking two lines later. But if it doesn't need a page break at all then I don't want to make the system go out of its way to put a page break anywhere.
    – user541686
    Dec 8, 2012 at 4:37
  • 1
    I would normally put something like \pagebreak[3] to try to give LaTeX the message you are suggesting, but since I don't think I've ever seen this actually work for me, I can't recommend it as a solution. The only times I've actually seen LaTeX use a \linebreak or \pagebreak command with an optional argument of 3 or less were when the command fell at a place where a page/line break would otherwise be illegal, but was necessary to avoid an overfull or underfull box. Dec 8, 2012 at 4:53
  • 2
    Did you see this recent question?
    – egreg
    Dec 9, 2012 at 0:16
  • @egreg: Nope I hadn't seen that before, that's really useful, thanks!
    – user541686
    Dec 9, 2012 at 0:21

2 Answers 2

7

Since you are asking for a LaTeX solution: \pagebreak, which has an optional argument with an integer between 1 and 4: \pagebreak[1] to \pagebreak[4]. 1 inserts a \@lowpenalty, 2 a \@medpenalty, 3 a \@highpenalty and 4 is mostly equal to \newpage.

Leslie Lamport explains all about it in the manual.

4
  • 4
    \pagebreak[1] is not really equivalent to \smallbreak, as the latter also inserts a vertical space. The same for \medbreak and \bigbreak. Also \pagebreak[4] doesn't insert a \vfil, which \newpage does.
    – egreg
    Dec 8, 2012 at 23:38
  • \pagebreak[2] seems reasonable at least for now, thanks.
    – user541686
    Dec 9, 2012 at 0:21
  • @egreg: Yes. But: \smallbreak etc. insert a fixed penalty, while the penalties inserted by \pagebreak can be adjusted on the fly - i.e. by the document class. Dec 9, 2012 at 13:02
  • 1
    @MartinSchröder The main point in my comment was about the vertical space; \smallbreak and friends are not documented even in the LaTeX Companion, they are in the kernel of LaTeX2e just because they were in the older kernels based on Plain, for compatibility with legacy documents.
    – egreg
    Dec 9, 2012 at 13:21
6

Look at Chapter 15 of the TeXbook for all the details, but basically you should add negative penalty where those breaks are desired.

For example, the TeXbook says that if you say \penalty-100 between two paragraphs you are indicating that breaking the page there is favoured.

Plain TeX (and I believe LaTeX too) has macros to hint where breaks should occur with increasing likelyhood: \smallbreak, \medbreak and \bigbreak. They insert penalties of -50, -100 and -200 together with \smallskip, \medskip and \bigskip, respectively. Those vertical skips are added only when the break does not occur (despite being favoured).

Also worth mentioning is \goodbreak which is \par\penalty-500. In this case nothing happens if the hint to break is not taken.

There's also \fillbreak=\vfil\penalty-200\vfilneg which hints to break with a strength of -200 and fills the remaining space in the page (if any) with blanck space to avoid bad stretchings if the break indeed occurs there. In case the hint is ignored \vfilneg cancels the \vfil and nothing happens.

So you have many options, and I recommend reading Chapter 15 for much more information with better explanations.

4
  • He wants a LaTeX solution, so there's no need to point him to the TeXbook. Dec 8, 2012 at 23:30
  • 2
    @MartinSchröder Still, the question is about modifying penalties (despite OP not knowing it is called "penalties"), and then TeXbook is a very good source of information, that are valid for LaTeX as well.
    – yo'
    Dec 9, 2012 at 0:12
  • 4
    @MartinSchröder: But in your answer you make reference to \smallbreak etc, so I don't see why you worried. It does not hurt to have the knowledge that behind LaTeX commands stand some universal TeX concepts that make all the decisions.
    – Mafra
    Dec 9, 2012 at 0:15
  • 1
    @Mafra: But the first stop for LaTeX solutions should not be the TeXbook when LaTeX also has a solution. Dec 9, 2012 at 13:04

You must log in to answer this question.

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