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".

  • @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
  • 1
    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


\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}.

  • 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
  • 1
    The automation is described here: tex.stackexchange.com/a/27057/7323 – Patrick Häcker Apr 14 '14 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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