6

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)

Ben
  • 2,609

1 Answers1

6

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)

yannisl
  • 117,160
  • 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
  • 1
    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 http://books.google.com.qa/books?id=rstheMEAf2gC&pg=PA283&lpg=PA283&dq=text+page+breaking+algorithm&source=bl&ots=TS-IXsbOmm&sig=4G517M8rnlZCaBJoJEr-1jxPxcg&hl=en&ei=t9N4TbO1DsjjrAfJv5nEBQ&sa=X&oi=book_result&ct=result&resnum=8&ved=0CFsQ6AEwBw#v=onepage&q=text%20page%20breaking%20algorithm&f=false) – yannisl 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
  • @Hendrik Vogt There is a patent by Adobe where they look ahead by about 5 pages. IMHO there is no current system that looks ahead at the full document, i.e., I am typesetting a book with 700 pages and the 700th page can influence the layout of the first page. I don't believe that lout does it either - maybe partially. The op's problem can be resolved though partially by introducing a new penalty once the last page's depth is below a minimum. On second pass you redistribute extra space at pages. This though is not guaranteed to produce an "optimal" page layout. – yannisl Mar 10 '11 at 15:47
  • @Yiannis: It may well be right that Lout does this only partially. Actually, I found no place where they say any details. – Hendrik Vogt Mar 10 '11 at 16:24