Paint fancyhdr running heads and feet

Parse \pagestyle{fancy}, \fancyhf, \fancyhead/\fancyfoot with L/C/R positions,
the \lhead/\chead/\rhead/\lfoot/\cfoot/\rfoot shorthands and
\renewcommand{\headrulewidth}, and paint them on every page. Head fields are
placed at top margin - \headsep and feet at text height + \footskip, both in
content coordinates so the page origin shifts them with the body; left, centre
and right align against the text measure, \thepage is expanded per page, and
the head rule uses the requested width.

Size and shape declarations are stripped before macro expansion because class
files define \footnotesize in terms of itself; expanding it repeated
\@setfontsize internals on every pass. A title page with fancy style is treated
as \thispagestyle{empty}, matching class \maketitle definitions.

The arXiv template now shows "A Preprint" on the right and its short title in
the centre after the title page, with the page number in the footer; tests
cover field parsing, painted positions/alignment and the title-page
suppression.
This commit is contained in:
gloamxun committed 2026-10-26 23:32:52 +08:00
1 parent 7a615a8639
commit 15b5437987
3 files changed
+330 -3

No files matched your search

+6 -2
View File
@@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
PDF opt-in with `?engine=route-d`). 977 workspace tests are green and no oracle
PDF opt-in with `?engine=route-d`). 979 workspace tests are green and no oracle
fixture is ignored. Preview JSON also carries a `warnings` array naming
environments route-D cannot lay out and control words that survived layout, so
unsupported source is reported instead of being silently typeset.
@@ -389,7 +389,11 @@ filler text, comments and external `\bibliography` commands are dropped, and a
`center`/`flushleft`/`flushright` environment that follows text starts its own
block, and `geometry`'s `top`/`bottom` margins offset the page body (the arXiv
first baseline is at 1in + 12pt) while an explicit `textheight` wins over the
margins. Class files are still mapped semantically rather than executed by a VM.
margins. `\pagestyle{fancy}` and the fancyhdr head/foot fields paint L/C/R
running heads at `top margin - headsep` and feet at `text height + footskip`,
expand `\thepage` per page, draw `\headrulewidth`, and leave the title page
empty; the arXiv template shows `A Preprint` and its short title after page one.
Class files are still mapped semantically rather than executed by a VM.
### P7 — Service and incrementality