3

I have a document typeset using the memoir class and the content is primarily divided using sections. (I'm targeting an A5 paper and so I chose sections instead of chapters since they are more space-economical.)

I would like to generally insert a page break before each section (which is easy enough), but sometimes a section is very short and might fit on the rest of the current page well. Inserting a page break in such cases creates an awkward amount of blank space both on the current and next page.

Is it at all possible in LaTeX to detect when a section would fit on the rest of the page and not \clearpage in that case?

Thanks!

2

Instead of \clearpage you could substitute

\par
\FloatBlock % was \FloatBarrier from placeins.sty
\vfil
\pagebreak[2]
\vfilneg

That will usually fill the rest of the page with white space, but will forego the fill if some later page break with equally or more favorable (more negative) "penalty" can fit on the page.

And \filbreak is pretty much the same as \vfil \pagebreak[2]\vfilneg, so it can be simplified. If the document does not use floats the whole thing can be reduced to \filbreak.

It is best to put this into the definition of \section.

2
  • Thanks, I'll try this... – kralyk Mar 29 '20 at 18:18
  • Brilliant, this seems to do exactly what I wanted. Thank you! Edit: I should now read up on some of those commands to undertand what's going on... – kralyk Mar 29 '20 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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