I'd like to emulate HTML's infinite page height using LaTeX/XeTeX, i.e. have the PDF pages grow higher until a manual \newpage is issued.

This could be emulated by setting a very large page height and using pdfcrop on the output (or just setting the page height manually), but I'd like a pure TeX variant and if possible support for footnotes etc at the bottom of the cropped page.

4 Answers 4


You could use the preview package for this. It's basically the "pure (La)TeX variant of pdfcrop" you are looking for. You need to set the text height to \maxdimen e.g. using geometry and wrap every page in \begin{preview} ... \end{preview}. To do this simply have a \begin{preview} after \begin{document}, a \end{preview} before \end{document} and define a \newpage variant as \end{preview}\begin{preview}. You will loose some of the border which can be readded using the \PreviewBorder macro. However, AFAIK this doesn't support header and footer.

Here now some example code. Apparently preview already takes care to suppress automatic page breaks and the modification of the text height is not required.





  • 2
    Enclosing the content in a minipage takes care of the footnotes (or would that be more restrictive than necessary?)
    – pascal
    May 27, 2011 at 21:43
  • 1
    @pascal: If you need footnotes you can add minipages. However they number footnotes differently. Floats won't work either. May 27, 2011 at 22:25
  • This works very well --- except for floats, as you mention. I tried working around it with \begin{figure}[h]... but that still doesn't work because of "Not in outer par mode". Any idea of getting around that, and getting an image with a caption? Sep 2, 2016 at 13:48
  • 1
    @Supernormal: The point of a float is that if floats over multiple pages to a place where it fits according to professional typesetting rules. Most users have issues understanding this at first. If you simply want to add a caption then use alternatives. The topic is further described in these posts: How to influence the position of float environments like figure and table in LaTeX? , Keeping tables/figures close to where they are mentioned Sep 9, 2016 at 8:08
  • @Supernormal: Also check out my standalone package which I created since I wrote this post. It is either based on preview or uses its own technique, depending on the used options. It can also be used to turn floats into non-floats automatically (but I'm not sure if I published that feature already). Sep 9, 2016 at 8:10

Another ConTeXt solution. This takes care of footnotes, but you need to mark the start and stop of the page.


\setupTEXpage[width=\textwidth, offset=2mm]

which can then be used as

\section {Some section}
\input knuth \footnote{A random footnote}
\input ward
  • Wow. I really have to look into ConTeXt...
    – pascal
    May 27, 2011 at 21:46
  • 1
    IMO nicer then the solution I've posted (from 10 years ago)
    – topskip
    May 28, 2011 at 5:39

Thanks for the replies, I'm using Martin's solution, from my class file:





This works for me, if I would want to print the document, I can just disable the block.


Martin's answer works well up to a limited size, but TeX has an upper limit on every length, including the page height. This limit is fairly small, equivalent to only around 20 sheets of letter paper placed end to end. To work around this limitation, I scaled everything in the document down by 40 times, then used pdfposter to scale it back up after compiling the document.

\newcommand{\pagescale}{0.025}  % 1/40

% Use these instead of the usual units.
\newlength{\PT}\setlength{\PT}{\pagescale pt}
\newlength{\IN}\setlength{\IN}{\pagescale in}
\newlength{\CM}\setlength{\CM}{\pagescale cm}
\newlength{\MM}\setlength{\MM}{\pagescale mm}

% LaTeX defaults are almost all defined using \p@, which is supposed to be 1pt.

% Reset separations that were coded with pt not \p@.
\setlength{\jot}{3\PT} % Math display line separation.
\parskip=0\PT plus 1\PT
\abovedisplayskip=12\PT plus 3\PT minus 9\PT
\abovedisplayshortskip=0\PT plus 3\PT
\belowdisplayskip=12\PT plus 3\PT minus 9\PT
\belowdisplayshortskip=7\PT plus 3\PT minus 4\PT
\parfillskip=0\PT plus 1fil
\smallskipamount=3\PT plus 1\PT minus 1\PT
\medskipamount  =6\PT plus 2\PT minus 2\PT
\bigskipamount =12\PT plus 4\PT minus 4\PT
\unitlength = 1\PT
\fboxsep = 3\PT
\fboxrule = .4\PT
\def\hrule{\Oldhrule height 0.4\PT}
\def\vrule{\Oldvrule width 0.4\PT}





% No point in page numbers if there is only one page.

% Need to rerun math font definitions to get the sizes right. Loading amsfonts
% is sufficient.



$\int_0^1 x^2 dx = \frac13$. \footnote{A footnote}

\hrule height \PT width 100\PT

    \int_{-\infty}^\infty e^{-x^2} dx &= \sqrt{\pi} \\
    z &= w

\vrule height 100\PT


{\huge \lipsum


{\tiny \lipsum


% Very long example text, which couldn't fit on a single page at normal scale.
    \advance \foo -1
\ifnum \foo>0


If you have floats then you likely want to follow Andy's advise and set \setcounter{totalnumber}{100}, so that LaTeX can put more of them on a page.

The following script uses pdfposter to scale the pdf back to its usual dimensions after it has been built.


if [ $# -ne 3 ]
    echo "Usage: $0 <scale factor> <input> <output>"
    exit 1

newpagesize=$(pdfinfo "$2" | awk '/Page size:/ { print ('"$scale"' * $3) "x" ('"$scale"' * $5) "pt" }')

pdfposter "$2" -s "$scale" -m "$newpagesize" $3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .