# Page Layout in plain tex

I'm trying to start using plain tex (in fact, the pdftex that comes with texlive2010) to write a document but I'm having some trouble with the page layout. My question is at which point is it decided what the dimensions of the page and the margins will be?

As far as I investigated the `\plainoutput` routine in plain.tex only sets the height and width of the `\box255` plus headers, footers, etc, but page dimensions (like A4, letter, portrait, landscape, etc) and margins are never defined. Moreover the TEXBOOK says that by default the page layout has `1in` of margin at each side (page 251) but I don't know when are these margins defined nor why in my final pdf output the document appears with A4 size, `1in` of left margin and approximatley `0.7in` of right margin. So the question again is when are these dimensions decided?

• The default `\hsize` in plain TeX is `6.5in` and it centers content on page only when paper width is `8.5in`, leaving `1in` margin on both sides. US Letter paper has this page width. The default `\hsize` gives slightly shorter right margin (~`0.77in`) with default page size (A4 with width `8.27in`). Setting `\hsize=6.27in` corrects the margins for A4 paper. I figured this out while trying to make `\centerline` actually center the line on page. Jan 6, 2017 at 7:29

The 1 inch offsets come actually from TeX itself, and are kind of a pain because you need to take them into account as late as possible in any calculations.

The paper size is defined in a configuration file (I forget its name), but with PDFTeX, you should be able to use commands `\pdfpagewidth` (default `210 true mm` for A4), and `\pdfpageheight` (default `297 true mm` for A4).

Most relevant settings regarding page layout are:

• `\hsize` for h orizontal size (typeblock width)
• `\vsize` for v ertical size (typeblock height)
• `\hoffset` for h orizontal offset (offset from 1 inch from left edge of paper)
• `\voffset` for v ertical offset (offset from 1 inch from top edge of paper)

For spread layout, you can just toggle the `\hoffset` in the output routine.

Because you define the `\hsize` and `\hoffset`, there's no need to define margins, but I guess you could write a macro for counting `\hsize` and `\hoffset` based on given margins.

• Certainly in LaTeX margins are something that is calculated 'for convenience', since as you say the underlying mechanism doesn't need them. Depending on the use case, though, they may make a more sensible interface (with the calculation hidden away). Aug 7, 2013 at 13:08
• @morbusg So you are saying that the 1in margins come directly from the TEX82 program and cannot be changed by any parameter? Aug 7, 2013 at 14:03
• @Felipe: TEX82, yes, I think, but pdfTeX, I'm not so sure; there's a file, \$TEXLIVE/texmf-config/tex/generic/config/pdftexconfig.tex which has commands: `\pdfhorigin` and `\pdfvorigin` which seem like they could control those. Aug 7, 2013 at 16:08