TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two side document(so I use twoside option) in LaTeX. I need to keep some material (text, pictures...) on one double page. In another words I want to allow page break from odd to even page but I want to prohibit breaks from even to odd page.

I tried to write macro:

\\ \ifodd\c@page

and use it instead of \\ (I don't use any other line breaks commands in my document) but it does not work. Thanks for all answers.

EDIT: Thanks but Steves environment does not quite work for me. I tried to put my material into it but it does not cause it to fit on 2 pages, instead it says Overflow in twopage environment.

I will try to formulate exactly what I need to do:

  • Preferable an environment or a macro.
  • If the current page is even it must prevent LaTeX from breaking the page(it may break if it is absolutely impossible to keep the material on even page, but I need it to try hard). This may by done by setting penalty to 20000 or by anything else - please suggest as dirty tricks as you can make up.
  • If the current page is odd then the page break is allowed but not necessary.
  • The code that will make use of this environment or macro will be generated by java program so there is no point in generating errors if the material just can't fit into page or double page. Java have no way to know about LaTeX error.

Thanks for all ideas

share|improve this question

migrated from stackoverflow.com Feb 7 '12 at 17:24

This question came from our site for professional and enthusiast programmers.

IIRC, that error message was triggered by having more than two full \textheights in the environment. You say you can't tolerate a LaTeX error, so you need to specify what behavior you want when there's too much material to fit. You say "it may break if it is absolutely impossible" - how do you define that? If I understand correctly, where your requirements differ is that you don't want a break before your twopage material. It sounds to me like a job for the output routine, though that's difficult to deal with. – Steve Apr 10 '10 at 7:47
If you started a 1.2\textheight tall twopage at the bottom of the right-hand page, what should happen? Should it give up and allow the page break? Should it do a preemptive break so that it has room on the next page? What tricks did you have in mind to make things fit? Most vertical glue on the page has zero shrinkability, though you could adjust \baselineskip or the other skips to something like \baselineskip=12pt minus 4pt, which is as much squashiness as will still allow readability, right at the beginning of the environment. Shrinking the text retroactively would be near impossible. – Steve Apr 10 '10 at 7:55
Correction: It may NEVER break inside environment if on even page(so if the material just don't fit in it has to overfull vbox). "It sounds to me like a job for the output routine, though that's difficult to deal with". Yes it might be. That's what I'm afraid of. But there are some tricks to keep some material on one page(put it in one minipage...) I need to find similar tricks to keep it on double page. – drasto Apr 10 '10 at 14:53
Add: "If you started a 1.2\textheight tall twopage at the bottom of the right-hand page, what should happen?" Try to shorter spaces between lines to fit in \textheight. If that is not possible it should do a preemptive break so that it has room on the next double page(and ideally, allow some text from previous (odd) page to flow to the (even) clear page so it won't be absolutely empty). "Shrinking the text retroactively would be near impossible." - that is not good for me to hear it... – drasto Apr 10 '10 at 14:59
I was going to say that it would be nearly impossible to have text flow from the odd page forward to the even page, since that's already been shipped out, but it occurs to me that a nice solution to all of this might be to install a two-page-at-a-time output routine. I'm not quite sure what this would look like, and I don't really have time to work on it at the moment, but the idea would be to store even pages in a temporary box and then ship them both out together, so that they could be adjusted. You could then put twopage material in a box temporarily, then \unvbox it before splitting..? – Steve Apr 15 '10 at 7:28

Try the code that Steve posted to a question of mine.

share|improve this answer
Thanks but it did not really solved my problem - I added some details to original question to make it clearer. – drasto Apr 9 '10 at 12:24
@drasto: You'll have to fiddle with spacing. A starting point is stackoverflow.com/questions/1966778/… – Charles Stewart Apr 9 '10 at 12:58
I think I understand now what you meant. I'm to measure all the text in \vbox-es and decide if it will fit to pages correctly. If not than I may put it into minipage or something to prevent overflow from odd page to even. If nobody comes with better solution I will present this as an accepted answer to my question. – drasto Apr 11 '10 at 22:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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