Run AtBeginDocument setup and newgeometry as preamble

Class files such as the arXiv template set the page block inside
\AtBeginDocument{\newgeometry{...}}. Route-D treated the hook body as document
text, so the setup commands were typeset at the top of page one and the page
measure stayed at its default.

Lift \AtBeginDocument bodies in front of \begin{document}, join a multi-line
\newgeometry argument into one line, and read it through the geometry option
parser. Explicit textheight/textwidth options now win over margins, so
textheight=9in with top=1in keeps 9in instead of recomputing it from the
paper height.

The arXiv project now applies its 6.5in/9in block and no longer reports a
\newgeometry warning; unit tests cover the multi-line hook, the option
precedence, and the no-leak case. A remaining leak from multi-line macro
definitions in the same class file is separate work.
This commit is contained in:
gloamxun committed 2026-10-26 23:03:37 +08:00
1 parent 2f9b18c95c
commit ebf2070295
3 files changed
+117 -6

No files matched your search

+5 -1
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`). 967 workspace tests are green and no oracle
PDF opt-in with `?engine=route-d`). 969 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.
@@ -312,6 +312,10 @@ both penalties between line nodes (150 by default) and refuses any penalty of
above and `\belowdisplayskip` below (the 10/11/12pt class defaults, overridable
from the source in TeX's `7\p@ \@plus 2\p@` spelling too), and a page fixture
shows a display near the page goal moving to the next page with pdfLaTeX.
`\AtBeginDocument{...}` setup is lifted ahead of the body and `\newgeometry{...}`
is applied as preamble geometry, with an explicit `textheight`/`textwidth`
taking precedence over margins, so class files that set their page block in a
begin-document hook get the intended measure instead of a text warning.
### P3 — `\halign` / `\valign` (L2)