How do I encourage/make Latex typeset some portion of text so that it will all appear on a consecutive even-page, odd-page pair of pages?
With trial and error, \nopagebreak can be coaxed into doing this, but is there a strategy that Just Works? Something like a samepage environment would be ideal, but one that:
- Will force a pagebreak on odd pages if that is needed to get all the text on facing pages;
- Allows up to one page break anywhere in the environment body, and fails noisily if that can’t be ensured.
You could put together an environment such as
\newenvironment{twopage}{% \begingroup\setbox0\vbox\bgroup }{% \egroup \ifdim\ht0>\textheight \setbox1\vsplit0 to \textheight \cleardoublepage\unvbox1\clearpage \ifdim\ht0>\textheight \PackageWarning{twopage}{Overflow in twopage environment}% \fi \unvbox0\clearpage \else \clearpage\unvbox0\clearpage \fi\endgroup }If you want a noisier failure, change
\PackageWarninginto\PackageError, The\unvboxes should allow for notes/floats to work properly – if you don’t need that, you might consider changing them all to\boxes instead (although I’m a bit rusty on the behavior of\vsplitwith respect to box depths and skips, so that might produce funny behavior, but it would guarantee that you only took two pages by flowing anything extra off the bottom of the second page).