# Left margin wider than right one

Why is the left margin wider than the right one? Each of them should be 1 inch wide:

If you run TEX without modifying the plain TEX format, you get pages that are numbered at the bottom; and each page will be approximately 8.5 inches wide and 11 inches tall, including 1-inch margins at all four sides. [The TeXbook, p.251]

\moveleft2cm\vbox{\hrule width2cm}
\moveright\hsize\vbox{\hrule width2cm}


UPDATE

How can the document know the size of paper it is being typeset on?

• I would suggest some implicit binding correction at least on the odd page numbers. – user31729 Jun 9 '14 at 17:23
• When you convert the output DVI to PDF, what is the actual page size? – Werner Jun 9 '14 at 17:23
• if you're using a4 paper, the paper itself is narrower than the defined 8.5in, but the position on the page relative to the upper left-hand corner isn't changed. – barbara beeton Jun 9 '14 at 17:28
• It depends on paper format. Knuth use letter format, may be you have A4 which is narrower. The \hsize is set for letter format minus 2in in plain TeX. – wipet Jun 9 '14 at 17:29

This should explain the apparent contradiction; compile with pdftex

\pdfpageheight=11in
\pdfpagewidth=8.5in
\moveleft2cm\vbox{\hrule width2cm}
\moveright\hsize\vbox{\hrule width2cm}
\bye


If you use tex+dvips+ps2pdf for producing a PDF file, change the first two lines into

\special{papersize=8.5in,11in}


You'll get

The fact is that the standard setup of TeX distributions, regarding PDF output, is ISO A4 paper and not Letter paper.

A rudimentary test for the various situations might be as follows:

\def\dvipsletterpaper{\special{papersize=8.5in,11in}}
\def\pdfletterpaper{\pdfpagewidth=8.5in \pdfpageheight=11in }
\ifx\pdfoutput\undefined
% we're either with Knuth TeX or XeTeX
\ifx\XeTeXversion\undefined
% we're with Knuth TeX
\dvipsletterpaper
\else
% we're with XeTeX
\pdfletterpaper
\fi
\else
% we're either in pdfTeX or LuaTeX, we assume \pdfoutput is an integer
\ifnum\pdfoutput>0
% PDF output
\pdfletterpaper
\else
% DVI output
\dvipsletterpaper
\fi
\fi

• @AngelTsankov Yes, you're right. – egreg Jun 10 '14 at 8:33
• @AngelTsankov luatex uses PDF output by default, so you should use the \pdfpagewidth and \pdfpageheight method. If you use dviluatex the \special is passed to dvips without any problem. – egreg Jun 10 '14 at 8:48
• Any idea why LuaTeX supports the papersize \special when producing DVI output but ignores it when producing PDF output? After all, LuaTeX --output-mode=dvi + dvips + ps2pdf eventually produces a PDF file where the papersize \special is in effect, so why not also recognize the papersize \special when producing PDF output "directly"? – SJU Jun 10 '14 at 9:31
• @AngelTsankov The \special{papersize=...} command is not interpreted by LuaTeX in any way. It just issues a warning if it finds it while outputting a page in PDF mode. Maybe it could be implemented so that it is meaningful also in PDF mode, but pdfTeX doesn't do it and neither does LuaTeX. – egreg Jun 10 '14 at 9:35
• Does this mean that it is better to get the TeX engine produce DVI output and if necessary convert it to PS or PDF output? – SJU Jun 10 '14 at 9:44

In traditional typography for twosided printing, the inside margin has to be half the outside margin, simply because when you open a book, you see two inside margins next to each other, so that you see 3 horizontal white spaces of equal width.

Of course one also has to take into account a binding correction, so that the most common formula, known in France as the "Canon des Ateliers" — canon here meaning model, is the following: a fraction of paper width is reserved for the printing zone (most of the time 3/4 for ordinary printing, 2/3 or even 5/8 for high quality). The rest is white space, shared according to the proportion: 4:5:6:7.

This means that inside margin gets 4/10 of the white horizontal space, outside margin gets 6/10. 5/10 is for top margin and 7/10 for bottom margin (which makes a total of 12/10 for vertical white space).

Q: How can the document know the size of paper it is being typeset on?

Traditional TeX doesn't know the papersize. The pagebox is positioned to the point 1in from left, 1in from top of hypothetical paper: left/upper corner of the pagebox is here shifted by \hoffset right (or left, if negative) and \voffset down (or up if negative). This point (1in,1in left,top) is an origin of the typesetting of traditional TeX regardless of the actual papersize. May be the actual papersize can be smaller than pagebox and you'll not see all typesetting without any overfull box warnings.

pdfTeX is able to set the media size (i.e. papersize) by \pdfpageheight and \pdfpagewidth. The origin of the typesetting mentioned above as 1in,1in is possible to change in pdfTeX by \pdfhorigin and \pdfvorigin (they are set to 1in,1in by default).

If you set \pdfpagewidth then you can calculate \hsize as \pdfpagewidth minus left margin minus right margin. Moreover you have to set the sum of \pdfhorigin plus \hoffset as the amount of the left margin. The analogical princile is applicable for vertical margins.

The registers mentioned above have to be set before \shipout (shipping out the page). They can be changed to another values for another pages.

Edit: PostScript language uses different origin of its default coordinate system than TeX: 0,0 left,bottom of the paper. This implies that dvitops convertor needs to set the new origin and it needs to know the actual paper height. The paper width is irrelevant for this need. Moreover PostScript can set the media size by setpagedevice operator (4.11 in Redbook). The dvitops convertor can get the data about media size from \special or from command line or from configuration file. The data are used by setpagedevice operator in dvitops output.

The PostScript or PDF documents have the media size set. When this document is printed on the printer with different media size of paper sheets loaded in the printer then printer warns or makes trouble to the user.

• The primitive registers mentioned here can be comfortably set by \margins macro from OPmac. For example \margins/1 a4 (1,1,1,1)in. – wipet Jun 10 '14 at 6:14