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
I choose to adjust
\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
\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
To see this, perform the following steps:
tex -ini -jobname tex '\input plain \hoffset=-1in \dump'
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
\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.
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
\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),
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:
But with default settings, in such case the code is equivalent to
which overwrites user settings.
\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
we should say
0in by default, so there will be no problems.
You may also see
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
UPDATE the bug was fixed in cweb-3.64c