# Is there a way to make “page” size match document length?

Many PDFs are never printed but are read in electronic form, where, for at least some readers and reading styles, it would be advantageous to have a single page through which the reader could continuously scroll.

Is there a way to adjust "paper" size so that the entire document fits on a single "page"? Are there aspects of the TeX architecture that would make this difficult; features of packages or popular document styles that would break?

In particular, I'd be interested in doing this for Tufte-LaTeX, which (with it's sidenotes in place of footnotes and citations) is well-suited for this scenario.

-
You'll run into trouble if your document becomes longer than approx. 5.75 meters. –  doncherry Mar 27 '12 at 18:47
Related Question: How define a fixed width page, but length > some minimum length, but only as long as needed. Or is that a duplicate? –  Peter Grill Mar 27 '12 at 18:58
@PeterGrill: Similar question (and similar linked questions) but both are a bit more restrictive. I'll add to my question a bit to focus it though. –  raxacoricofallapatorius Mar 27 '12 at 19:08

There was a solution given by Veytsman and Ware in Tugboat 32 (2011) 261 in an article titled "Ebooks and paper sizes: Output routines made easier" to be found at https://www.tug.org/members/TUGboat/tb32-3/tb102veytsman-ebooks.pdf (Access to the content is restricted to members of the TeX Users Group until the end of 2012.)

Their idea is not to make one big page for the whole document, but one page for each section, and they found a trick to set the page size dynamically to the actual size of the text without white space.

I worked out a preliminary version of a package using their idea. At http://www.phys.psu.edu/~collins/screenread/ you can find the package, a test file and an example of the resulting pdf file. You could try modifying it to give one page for the whole of a document.

-
Thanks. I'll have a look at that. The real real question for me though will me: does it work with Tufte-LaTeX. –  raxacoricofallapatorius Mar 27 '12 at 22:02
No joy with Tufte-LaTeX, unfortunately. But this seems to be the state of the art, so I'll take this as the answer. –  raxacoricofallapatorius Mar 30 '12 at 15:18
\documentclass{article}
\setlength\textheight{30\textheight}


produces

! Dimension too large.


so simply making a very tall page causes problems for even quite modest documents.

TeX's architecture generally tries to clear out pages as quickly as possible, unlike line breaking which does a least cost analysis of the breaking over a whole paragraph, page breaking (usually) only considers one potential break at a time, and the memory taken up by the scroll for the page shipped out is recycled. This enabled TeX to process arbitrarily long documents even in the small memory available at the time.

Now of course, there is more memory available but it's not clear to see how TeX could adapt. Probably the thing to do would be to have a simplified output routine that continuously shipped out pages without adding header or footer at all; and then a simple post process with a pdf tool could stitch the pages back together.

-
Header and footer would be fairly easy as would the stitching. What settings are equivalent to telling TeX: "take the first possible page break that you can"? –  Loop Space Mar 27 '12 at 18:54
just a default output routine, with no floats/footnotes does essentially that. (Assuming you don't mean what you said, or it would break after every line and leave every page underfull, so you want some of the usual aspects of breaking within badness tolerances) but you'd also want to do some trick code so that the white space that is normally discarded when a break occurs is never discarded (usual dance with penalties and rules, probably, ie make sure TeX never breaks before vertical glue. –  David Carlisle Mar 27 '12 at 19:03

You can try the following 5 metre page and see the problems. Your users will have no idea or orientation as to where the document will end, can you scroll at the end?

\vsize500cm
\vbox to 575cm{
\vrule height500cm
}
\bye


(Most readers will fail to display this properly)

-
I'm not sure I understand: I want it to end where the text ends. –  raxacoricofallapatorius Mar 27 '12 at 19:25
@raxacoricofallapatorius Sorry maybe I misunderstood you. Approach in plain TeX, declare a large value of \vsize500cm. Provided you text is less than 5meters long it would compile. –  Yiannis Lazarides Mar 27 '12 at 19:28

I believe that modyfing some properties of your document will get you very close to what you want, even without the need of one long page. It will happen that there will be an empty vertical space, but not that often with these settings. See the commented MWE:

\documentclass[a4paper]{article}

\usepackage[margin=1mm]{geometry} % no margins
\usepackage[bottomtitles]{titlesec} % allow titles to be at the bottom of the page
\widowpenalty=0\relax % no empty lines at the end of page
\clubpenalty=0\relax % no empty lines at the end of page
\pagestyle{empty} % no headers or footers

\usepackage{lipsum}
\begin{document}
\lipsum[1-60]
\end{document}

-