开发者

Making Latex typeset given text on two facing pages

开发者 https://www.devze.com 2022-12-19 22:57 出处:网络
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?

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 u开发者_Python百科p 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 \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).


There is a distinction between \clearpage and \cleardoublepage. By using \cleardoublepage just before the stuff you want on the left hand side and \clearpage before the stuff you want on the right hand side you can force the layout you're looking for.

Of course, the twoside option is must.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号