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

This recent question on how to increase the width of the output, and this earlier question on how to increase the length of the output reminded me of something I have been wondering: I would like to fix the width and have the length to be longer than some minimum length, but only as long as necessary.

So far I have been using the geometry package to fix the width, and set the page length to be very long as per the above links, and this has been working. However, I would like to not have the extra blank space at the bottom for very short pages.

This is intended to generate individual pages for on screen viewing, and not a long document. Hence the desire for a single "page".

share|improve this question
@Peter: \newgeometry and \restoregeometry from geometry could be what you are looking for? – egreg Jun 2 '11 at 9:25
But how do I determine how long to set the page? The page length is not fixed. If I add more text I want the page length to grow, and if I delete text I want the page length to shrink (but not shrink below a certain minimum) – Peter Grill Jun 2 '11 at 9:46
@Peter paperheight=200cm? – egreg Jun 2 '11 at 9:54
See my answer to Automatically increase PDF page height for a solution based on preview. The minimal length would need to be implemented in addition. – Martin Scharrer Jun 2 '11 at 11:12
@egreg: I don't know upfront how long the page is going to be. So I need to wrap the \begin{document} and \end{document} in a \newcommand, somehow determine the length that would take, then set the pagelength, and use the \newcommand to print the text. Thats the theory, I just don't know how to do that.. – Peter Grill Jun 2 '11 at 17:37
up vote 9 down vote accepted


\ifdim\pdfpageheight<12cm \pdfpageheight=12cm \fi


If you try \lipsum[1] instead of \lipsum you get 12cm as height. This can be made automatic, I believe, by hooking into \begin{document} and \end{document}.

share|improve this answer
This seems to do exactly what I need. I'll see if I can figure out how to wrap it around \begin{document} and end{document}. Thanks. – Peter Grill Jun 2 '11 at 18:19
I am accepting this as it does what I want. I have not been able to automate this yet, but will keep trying to figure that out as it should not be that hard. – Peter Grill Jun 20 '11 at 17:40
The automation is described here: tex.stackexchange.com/a/27057/7323 – Patrick Häcker Apr 14 '14 at 14:27

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.