TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

TeX creates a document by solving an optimization problem, where different spacings etc. are assigned different costs, or "badness".

All writers of papers, especially for conferences proceedings have to battle with page limits. Right now it is very late and my coauthor removed a sentence, only to have the document grow beyond the page limit because TeX rearranged some figures.

Is it possible to assign an infinite "badness" to using more than a set number of pages? (I am not looking for a solution for this particular deadline, we'll solve our problem anyway)

share|improve this question
up vote 6 down vote accepted

It is not possible, TeX's page building algorithm optimizes the output page by page, i.e, when TeX is happy that the page text is optimized it ships it out. It is not affected by the total number of pages. Optimizing over the full source requires a tremendous amount of iteration and memory and currently there is no typesetting program that does that. (See An explanation of LaTeX's output routine for some more information)

share|improve this answer
It might be possible though to do it on several runs of LaTeX, automatically increasing the page size (or decreasing the size of blank spaces, etc?) if needed. The thing is, I don't know exactly where space can be gained. If anyone can help me on that, I can write the rest.something. – Bruno Le Floch Mar 10 '11 at 10:15
Thank you for your answer. However, there must be some inter-page optimization going on, since TeX avoids pages with a single line (doesn't it?). – Ben Mar 10 '11 at 12:08
TeX always process a complete paragraph and then decide if and where to insert a page break. That's why it can avoid widows/orphans. (It only means that you can perhaps shorten the number of pages by allowing widows/orphans. You can also try \enlargethispage to enlarge the page, and \looseness=-1 to try to shorten a paragraph.) – Ulrike Fischer Mar 10 '11 at 12:46
@Ben @Bruno Le Floch There is no such thing as an interpage optimization, but rather a breakpoint optimization. (See books.google.com.qa/…) – Yiannis Lazarides Mar 10 '11 at 13:38
@Yiannis: I don't think you're right with "currently there is no typesetting program that does that." From the Lout FAQ: "Lout uses Knuth's (the author of TeX, on which LaTeX is based) optimal line breaking algorithm, and has extended it to paragraph breaking across pages." – Hendrik Vogt Mar 10 '11 at 15:06

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.