I am trying to find a way to make different pages with different printable areas. Changing the printable height between pages is easy but the width is much harder. The problem is that I can't figure out how to tell TeX to re-box the “overflow” output of a page to make it a different width.
Here is a minimal example to demonstrate the problem:
Code: Select all
\documentclass{letter}\usepackage{lipsum}\makeatletter\begin{document}% simple output routine to change hsize at each page break\output{\ifodd\c@page\global\hsize=2in\else\global\hsize=4in\fi\shipout\expandafter\box\@cclv\stepcounter{page}}% Generate some blurb\lipsum[1-50]\end{document}
I think I understand why this happens, but I don't know how to fix it. What seems to happen is this:
The page builder works on one paragraph at a time, setting the paragraph to the width of \hsize before working out the appropriate page break to fix the height at \vsize, and shoving the resulting page into box255. But it's already made the rest of the paragraph with the width of the old \hsize, and so it keeps hold of that.
My output routine then runs and ships out box255, changing \hsize (as shown), which tells the page builder to set the width of the next paragraph that it processes.
I want to change this to make it fix the width of the end-paragraph at the top of the page (what I call the “overflow text” from the previous page) to be the same as the rest of the page upon which it appears.
One option is to get the box that contains this text, and change its width myself (eg. by unpacking it into a parbox of appropriate width). This is not ideal as it would cause problems with existing hyphenation points, and possibly with vertical spacing – but I can't even find where the page builder stores its working text (box255 only contains the completed page, not the following paragraph).
Another option might be to record the point of the page break in an auxiliary file somehow, and have LaTeX change the page width at the correct point on the next run (by wrapping the last line in an \@@line, then introducing a \pagebreak, followed by a \par and \noindent). But I don't know if it's even possible to do that without inserting some new command between every glyph in the input document (to check for the page break), and I don't know of any way to identify the position in the input document in order to write it out to the aux file.
Beyond that, it may be possible to modify TeX's page builder (rather than its output routine) in some way. This would seem to be the best solution, in that any explicit penalties and spaces from the input would not yet have been discarded, but I can't find any information on how I might do that.
Any ideas?