Do not change page dimensions - change offsets to center the output on A4 page.
TeX does not care about "paper size".
It is the job of the user to ensure that the output does not fall off the edge of the physical medium on which it is being printed through adjusting \hoffset
, \hsize
, \voffset
and \vsize
.
I choose to adjust \hoffset
and \voffset
to preserve layout of documents using plain.tex if I want to print them on A4 paper.
Quoting TeXbook, page 251:
If you want your output to be positioned differently when it is ultimately
printed, you can offset it by giving nonzero values to \hoffset and \voffset.
The idea is to set \hoffset
and \voffset
in format file so that default \hsize and \vsize will be centered on A4 page. But you also have to fix a bug in cwebmac.tex (it overwrites user settings for \hoffset
).
To see this, perform the following steps:
cd <cweb_source>
cweave cweave.w
tex -ini -jobname tex '\input plain \hoffset=-1in \dump'
tex cweave.tex
dvi-viewer cweave.dvi
You will see that the margins are "jumping" from one page to another.
In the example I used \hoffset=-1in
just for demonstration.
In reality, in my format file I have \hoffset=-2.95mm
(\voffset
is also changed in my format
file, but in this case it does not matter).
The following code in the output routine overwrites user settings for
\hoffset
which are set in format file.
\ifodd\pageno\hoffset=\pageshift\fi
This code is supposed to be used for duplex printing, where even and odd
pages should have different offset - to leave more space on the left side
where binding is done.
When duplex printing is not used (i.e, when \hoffset
and \pageshift
are not
set by the user in web file), there should be no offset.
In other words, by default (i.e., not in duplex mode), \hoffset
must
not change,
i.e., it must have one and the same value throughout the whole TeX run.
This is guaranteed to be when \pageshift is equal to \hoffset by default,
i.e., the code above becomes:
\ifodd\pageno\hoffset=\hoffset\fi
But with default settings, in such case the code is equivalent to
\ifodd\pageno\hoffset=0in\fi
which overwrites user settings.
The \hoffset
etc... values are used during format gereration (tex -ini ...), which is separate
from when TeX is run with the generated format and \input cwebmac
is done.
So, to fix this problem, in cwebmac.tex
instead of
\pageshift=0in
we should say
\pageshift=\hoffset
Besides, \hoffset
is 0in
by default, so there will be no problems.
You may also see cwebmal.tex
and cwebmar.tex
at github.com/igor-liferenko/cweb-git/
For completeness, following is the example of format file (omitting encTeX settings and setting catcodes for non-ascii letters)
\hoffset=-2.95mm % (210mm - 6.5in)/2 - 1in = (210mm - 8.5in)/2
\voffset=8.8mm % (297mm - 11in)/2
\catcode`\@=11
\def\m@g{\mag\count@
\hsize6.5truein
\vsize8.9truein
\dimen\footins8truein
\hoffset=-2.95truemm
\voffset=8.8truemm}
\catcode`\@=12
\dump
UPDATE the bug was fixed in cweb-3.64c