Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making Latex typeset given text on two facing pages

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:

  1. Will force a pagebreak on odd pages if that is needed to get all the text on facing pages;
  2. Allows up to one page break anywhere in the environment body, and fails noisily if that can't be ensured.
like image 687
Charles Stewart Avatar asked Feb 07 '10 17:02

Charles Stewart


1 Answers

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 \PackageWarning into \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 \vsplit with 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).

like image 55
Steve Avatar answered Oct 05 '22 21:10

Steve