[Tex/LaTex] Page Layout in plain tex

landscapemarginsplain-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?

Best Answer

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.