% settings for A5 paper
\pdfpagewidth 148mm
\pdfpageheight 210mm
\hsize 99mm% width of text block; line length or measure.
\vsize 164mm% height of text block
\hsize=6.5in
, \vsize=8.9in
.\voffset
and \hoffset
.
Plain TeX’s default setting positions the text block one inch down from the top of the page (\voffset=0pt
) and one inch in from the left side of the page (\hoffset=0pt
). Assigning positive values to \voffset
and \hoffset
increases these distances; assigning negative values decreases them.
Knuth’s TeX does not have any commands for setting the size of the page: \pdfpagewidth
and \pdfpageheight
are pdfTeX commands which happen also to work in XeTeX. On American letter paper (8.5 inch × 11 inch) Plain TeX’s default settings produce a text block measuring 6.5 inch × 8.9 inch with left, right and top margins all equal to 1 inch and a bottom margin approximately equal to 1.1 inch.
Depending on where you live and how TeX is set up, the default page size will be A4 or American letter size. If you’re happy with this page size you can skip Step 1.
%+++++++++++++++++++++++++++++++++++++++++++
% page layout
\pdfpagewidth 129mm
\pdfpageheight 198mm
\hsize 99mm
\vsize 161mm
\voffset -9.4mm
\output{\ifodd\pageno\hoffset -11.4mm\else\hoffset -9.4mm\fi
\plainoutput}
% to adjust the space between the header and the text block
\def\makeheadline{\vbox to 0pt{\vskip-22.5pt
\line{\vbox to8.5pt{}\the\headline}\vss}\nointerlineskip}
% to adjust the space between the footer and the text block
\def\makefootline{\baselineskip24pt\lineskiplimit0pt\line{\the\footline}}
%+++++++++++++++++++++++++++++++++++++++++++
The text block is set 16mm from the top of the page: \voffset -9.4mm
, i.e. the Plain TeX default of 1 inch (25.4mm) minus 9.4mm.\hoffset
on odd- and even-numbered pages for mirrored page output (like the LaTeX book
Document Class):
\output{\ifodd\pageno\hoffset -11.4mm\else\hoffset -9.4mm\fi
\plainoutput}
\hsize
and the left margin of the recto (= right margin of verso) from the page width (129mm − 99mm − 14mm = 16mm).
So you end up with: spine margin of recto = spine margin of verso = 14mm; and fore-edge margin of recto = fore-edge margin of verso = 16mm. Here is a drawing to illustrate what I mean (right click for a larger view):
Usually in a book the spine margin is narrower than the fore-edge margin, and the two pages of a spread mirror each other. If you want to have the text block horizontally centered in the page you can subtract the width of the text block from the width of the page and divide the result by two: (129mm − 99mm) ÷ 2 = 15mm. The page layout then becomes:
\pdfpagewidth 129mm
\pdfpageheight 198mm
\hsize 99mm
\vsize 161mm
\hoffset -10.4mm
\voffset -9.4mm
You can adjust the dimensions in \def\makeheadline
and \def\makefootline
to change the amount of space between the header and the text block and the text block and the footer respectively. Plain TeX’s default setting is to have a lineskip (12pt) between the header and the text block and a lineskip between the text block and the footer. See page 255 of the TeXbook for an explanation of the dimensions in \makeheadline
.
Adjustments to \vsize
When I used the original \vsize
(161mm) for this document I noticed that there is some slack between the text block and the footer (the page number was a bit lower than it ought to be). This is probably because 161mm is slightly bigger than the space taken up by the number of lines on the page. I got the 161mm measurement from measuring a book. A way to correct this is to get the height of the text block in points by multiplying the leading (\baselineskip
) by the number of lines on a full page. But don’t forget that \topskip
sets the baseline of the first line 10pt down from the top of the text block. (The first line of a page does not need to have leading above it.) So, if there are n lines in a page, the height of the page in points can be got by [(n – 1) × \baselineskip
] + 10pt. In this example n = 38, and (37 × 12pt) + 10pt = 454pt.
\looseness1
at the beginning of the second paragraph on page one of B_format.tex is to avoid a widow line that would otherwise appear at the top of page two. (It makes the paragraph one line longer.)
For comparison, here is the same layout in LaTeX with the geometry
package:
\usepackage[paperheight={198mm}, paperwidth={129mm}, height={454pt}, width={99mm}, top={16mm}, left={14mm}, headsep={10.5pt}, footskip={24pt}]{geometry}
Files:
B_format.tex,
B_format.pdf;
B_format_latex.tex,
B_format_latex.pdf
\headline
defines a headline (header) for the page. Plain TeX’s default setting is an empty header: \headline={\hfil}
\footline
defines a footline (footer) for the page. Plain TeX’s default setting is to have the page number centered in the footer: \footline={\hss\tenrm\folio\hss}
\ifodd
conditonal; (b) sets the page numbers at the right side of the header on right-hand pages and vice versa for left-hand pages; (c) centres the text of the header over the text block, regardless of how much space the page numbers take up. The footer is empty.
\font\headerfont="EB Garamond 12 Regular:
+smcp,letterspace=6,mapping=tex-text" at 10pt
% macros to set the texts of the headers.
% \headerfont puts the text into a letterspaced smallcap font.
\def\lheader{\headerfont great expectations}
\def\rheader{\headerfont chapter i}
\headline={% % Do different headers for odd and even pages
\ifodd\pageno
% header for right-hand page
\rm\rlap{\centerline{\rheader}}\hss\folio%
\else
% header for left-hand page
\rm\folio\hss\llap{\centerline{\lheader}}%
\fi
}
\footline={}
\def\lheader{Great Expectations}
\def\rheader{Chapter II}
\headline={% % Do different headers for odd and even pages
\ifodd\pageno
% header for right-hand page
\rm\hfil\rheader\rlap{\hbox to 8.5mm{\hfil\folio}}%
\else
% header for left-hand page
\rm\llap{\hbox to 8.5mm{\folio\hfil}}\lheader\hfil%
\fi
}
\footline={}
\rm\hfil\rheader\rlap{\hbox to 8.5mm{\hfil\folio}}%
\rm\hfil\rheader\rlap{\lower12pc\hbox to 8.5mm{\hfil\folio}}%
\rm\llap{\hbox to 8.5mm{\folio\hfil}}\lheader\hfil%
\rm\llap{\lower12pc\hbox to 8.5mm{\folio\hfil}}\lheader\hfil%
\lower
to push down the \hbox
containing the page number 12 picas.
\font\headerfont="EB Garamond 12 Regular/I:mapping=tex-text" at 10pt
\def\lheader{\headerfont Great Expectations}
\def\rheader{\headerfont Chapter {\sci iii}}
\headline={% % Do different headers for odd and even pages
\ifodd\pageno
% header for right-hand page
\rm\hfil{\rheader}\quad$\diamond$\quad\folio%
\else
% header for left-hand page
\rm\folio\quad$\diamond$\quad{\lheader}\hfil%
\fi
}
\footline={}
Examples in these files:
headers.tex,
headers.pdf.
See the file ‘prelims.tex’ on the PDF page for a method of automatically switching off headers on the first page of the chapter (in the \chapter
and \headline
macros).
\footline={\rm\hss--\kern3pt\folio\kern3pt--\hss}
\footline={\rm\hss[\kern2pt\folio\kern2pt]\hss}
\footline={%
\ifodd\pageno
\rm\hss\folio% footer for right-hand page
\else
\rm\folio\hss% footer for left-hand page
\fi
}
\footline={%
\ifodd\pageno
\rm\hss\folio\quad% footer for right-hand page
\else
\rm\quad\folio\hss% footer for left-hand page
\fi
}
\footline={%
\ifodd\pageno
\rm\hss$\diamond$\enspace\folio% footer for right-hand page
\else
\rm\folio\enspace$\diamond$\hss% footer for left-hand page
\fi
}