Take the 2-minute tour ×
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.

Suppose I am preparing multi-page handouts using LaTeX.

I don't care much about the font and margins size (while they are reasonable), but I would like all the pages to be filled, ie. avoid the situation when the last page is mostly blank.

I could achieve this using an external program, which would analyze TeX's output (or the resulting document) to determine the number of pages, and then iteratively find the values of the mentioned parameters which are "marginal".

However, I would prefer an "internal" solution for a number of reasons:

  1. More cross-platform
  2. Would avoid some extra/duplicate work like writing the output file on each iteration
  3. In general, I think, would be a cleaner approach

Is there any ready-to-use package for this, or could this be implemented reasonably easy (maybe using LuaTeX)?

share|improve this question
2  
I think a TeX solution is impossible, because it's only when writing the output that things like the whitespace on the final page become known to TeX... I guess it might be possible to get TeX to save that value (and others) to the .aux file and then use it on the next run. But if you're doing that, you might as well have an external program examine the output and fix parameters, since this would likely be quicker. –  Seamus May 29 '11 at 13:24
2  
You can use a cross reference to get the position at the end of document. savepos module of zref package may help. –  Leo Liu May 29 '11 at 14:20

2 Answers 2

There is the fullpage package, that makes margins smaller. When you use beamer, you can use the shrink option to fit everything to the page, which is not recommended.

share|improve this answer
    
I'm beginning to understand your question better. You want to control en.wikipedia.org/wiki/Widows_and_orphans? You can do so by playing around with \widowpenalty and \clubpenalty. –  Turion Jul 4 '11 at 14:21
1  
Widows and orphans are defined in terms of paragraphs. I don't care about paragraphs per se. I'll try to rephrase the question a bit. Suppose we have some text which takes n pages when formatted using the font size f and the margins m. (These are the minimum acceptable font size and margins.) Then my question is: how much can I increase the font size and the margins so that the text still fits in n pages. –  Roman Cheplyaka Jul 4 '11 at 15:39
    
Please try the tcolorbox package and its fitting library if it fits your needs, see page 229+ in the documentation. –  Malipivo Apr 14 at 14:07

TeX typesets material a paragraph at a time (at least for the main vertical list), and as a result by the time the space on the last page is known most of the typesetting is already done. That means that a multi-pass approach is the only way to make the adjustments required. However, it will not be a simple as scaling the font size and/or margins for a second pass, as the line-breaking in a second run will be different, and this may alter the total number of lines typeset.

There are also some wider concerns. First, what algorithm would be used to decide on what changes to make. If both font size and margins can change, there needs to be a decision on which one to go for. There would also need to be some setting for how much change is acceptable.

That takes me on to the biggest worry of all here, and one which is not programmatic at all. (La)TeX is a typesetting system, and typesetting is all about the balance between text and the rest of the page. Read something like The Elements of Typographic Style by Bringhurst to see how complicated this is. Arbitrary changes of page layout are really well outside of the scope of good-quality typesetting. Now, not every LaTeX user cares about typesetting, but the TeX engine itself was designed to address the typesetting challenge. So it is not surprising that human input on this type of issue is required. You might also want to take a look at Squeezing scientific paper to fit within page limits.

With all of that said, I can imagine how one might program this. On the first pass, you'd typeset at 'natural' size, then save the position of the last item on the last page along with the total pages. For the second run, you'd then need decide one whether to make the material larger or smaller, which of course would require a set of thresholds for this. Within this, there would need to be a window of 'ideal' size (i.e. I think that some variation on the number of lines on the last page would be needed). Based on the amount of stretch/shrink, you'd then set font size and margins and do the typesetting. You're then looking at an iterative process, storing each set of trial values in the .aux file and doing typesetting runs until the page looks 'right'. That would be handled with a log message, I guess.

share|improve this answer

Your Answer

 
discard

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.