I understand that TeX uses \headline
to place headers. If \headline
did not exist, how would one implement a simple version of the same? Additionally, where might one find simple documentation of how \headline
is implemented beyond The TeXbook? Of one particular interest is the use of the commands used to position the header text (or the box in which the header is set).
[Tex/LaTex] How does \headline work
formattingheader-footerplain-tex
Best Answer
\headline
is a named token register inplain.tex
, assigned with\newtoks\headline
, and set to\headline={\hfil}
(blank). Its content is then used in the output routine via the\makeheadline
macro (simplified, and written "open"):That is, the default contains "hard constants" for use with a 10pt setting. And the content of the register is used in horizontal mode (so cannot have vertical mode material if not inside a
\vbox
), spanning the h orizontal size of the textblock. That whole box is set so that it doesn't take any vertical space, and backed up by the constant of 22.5pt above the actual textblock.Knuth writes in the TeXbook regarding that 22.5pt constant:
The macro is also refraining inserting the normal interlineskip between the headline and the typeblock.
So setting for example:
would have "Testing headline" to the left, then the glue pushing the page number to the right.
Now, this would keep the same for every page, but say you want to have different head for verso and recto you could do something like