Tell me more ×
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.

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.

share|improve this question

4 Answers

up vote 10 down vote accepted

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.

\documentclass{article}

\usepackage[active,tightpage]{preview}

\renewcommand{\PreviewBorder}{1in}

\newcommand{\Newpage}{\end{preview}\begin{preview}}

\usepackage{lipsum}
\begin{document}
\begin{preview}
\lipsum
\Newpage
\lipsum[1]
\Newpage
\lipsum[1-30]
\Newpage
\lipsum[4-22]
\end{preview}
\end{document}
share|improve this answer
1  
Enclosing the content in a minipage takes care of the footnotes (or would that be more restrictive than necessary?) – pascal May 27 '11 at 21:43
@pascal: If you need footnotes you can add minipages. However they number footnotes differently. Floats won't work either. – Martin Scharrer May 27 '11 at 22:25
This produces a 4 page document for me? Do I have run this wiht some special flags as opposed to just pdfLaTeX? – Peter Grill Jun 2 '11 at 17:27
@Peter: The above code indeed produces a four page document. Only manual page breaks using \Newpage are done, as requested by the OP of this question. – Martin Scharrer Jun 2 '11 at 17:44
Thanks, I should have seen that!! :-( – Peter Grill Jun 2 '11 at 17:55

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

\iftrue
  \usepackage[active,tightpage,psfixbb]{preview}
  \renewcommand{\PreviewBorder}{1cm}

  \newenvironment{stretchpage}%
    {\begin{preview}\begin{minipage}{\hsize}}%
    {\end{minipage}\end{preview}}
  \AtBeginDocument{\begin{stretchpage}}
  \AtEndDocument{\end{stretchpage}}

  \newcommand{\@@newpage}{\end{stretchpage}\begin{stretchpage}}

  \let\@real@section\section
  \renewcommand{\section}{\@@newpage\@real@section}
\fi

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

share|improve this answer

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

\definestartstop[infinite]
                [before={\startTEXpage
                         \setupfootnotedefinition[location=joinedup]%
                        \startlocalfootnotes},
                 after={\placelocalfootnotes
                         \stoplocalfootnotes
                         \stopTEXpage}]

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

which can then be used as

\starttext
\startinfinite
\section {Some section}
\input knuth \footnote{A random footnote}
\input ward
\stopinfinite
\stoptext
share|improve this answer
Wow. I really have to look into ConTeXt... – pascal May 27 '11 at 21:46
IMO nicer then the solution I've posted (from 10 years ago) – dıʞsdoʇ May 28 '11 at 5:39

The typical "with ConTeXt it works" statement, if I understand the question right.

http://archive.contextgarden.net/message/20011024.190509.f295fd71.en.html

share|improve this answer
It might be useful to explain how this is done - presumably this could be done in plain or LaTeX as well given the correct algorithm. – Joseph Wright May 28 '11 at 7:48

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.