A document I am working on has two kinds of pages: title pages and content pages. For the digital version, it would be preferable if content were typeset in single, continuous pages. These pages' height would have to be computed from that of the content, and I'm having trouble achieving that.
Here's an example:
\documentclass{article}
\usepackage{lipsum}
\newsavebox\stagingbox
\newenvironment{content}
{%
\begin{lrbox}{\stagingbox}%
\begin{minipage}{\textwidth}%
}
{%
\end{minipage}%
\end{lrbox}%
%
% \textheight is theoretically just the total height of the box
\textheight=0pt\relax%
\advance\textheight by \ht\stagingbox\relax%
\advance\textheight by \dp\stagingbox\relax%
%
% \paperheight is made up of the various margins and distances
% of the class' page layout parameters plus \textheight
\paperheight=0pt\relax%
\advance\paperheight by 1in\relax%
\advance\paperheight by \voffset\relax%
\advance\paperheight by \topmargin\relax%
\advance\paperheight by \headheight\relax%
\advance\paperheight by \headsep\relax%
\advance\paperheight by \textheight\relax%
\advance\paperheight by \footskip\relax%
%
\pdfpageheight=\paperheight\relax%
%
\noindent%
\usebox{\stagingbox}%
\newpage%
}
\parindent=0pt\relax
\begin{document}%
Page with default size.%
\newpage%
\begin{content}%
Page with height adjusted to content. Following pages' height should also be adjusted to their content.%
\end{content}%
\begin{content}%
\lipsum[1]%
\end{content}%
\begin{content}%
\lipsum%
\end{content}%
Another page with default size.%
\end{document}
LuaTeX 1.0.4 reports a couple overfull vboxes, as though I had forgotten something in the computation. The pages also seem cropped in the output. What am I missing here?
I am aware of another approach which involves hooking into \shipout and using \pagetotal to get the page's width. Unfortunately, I haven't been able to get it to work just for some pages (as opposed to for the whole document). On the topic:
- Is there a way to make “page” size match document length?
- Ebooks and paper sizes: Output routines made easier
I've tried \AtNextShipout and even messed with the output routine to no avail.
standaloneindeed seems to work, I would prefer a solution not based upon it, because its purpose isn't really my goal. Am currently skimming through the code to see if I can extract the bits useful to me. – djsp Jun 28 '17 at 00:58