Skip to content

geometry: one margin beside a body does not cancel the body - #936

Merged
tannevaled merged 2 commits into
mainfrom
geometry-single-margin
Nov 24, 2026
Merged

tannevaled merged 2 commits into
mainfrom
geometry-single-margin

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Defect

\newgeometry{textheight=9in,textwidth=5.5in,top=1in,...} (neurips_2024.sty and arxiv.sty run exactly this at \begin{document}, after \usepackage[verbose=true,letterpaper]{geometry}) lost its text height. The top key cleared the text height, and the bottom margin then subtracted was the 0.7-body default that the first call had left in the state (#923). The text block came out 8in instead of 9in.

Found by bisecting the corpus regressions between v0.288.0 and v0.296.0 over git log --first-parent (one paper per step, gotex-abdiff): both 2405.16883 (29 to 34 pages, reference 26) and 2405.18549 (40 to 45, reference 37) are fine at 0900c51 and regress at 320be1e (#923). #923 is right per geometry.dtx; it exposed a second defect, which this PR fixes.

Refs #923 (merged, correct; not reverted).

Fix

geometry decides each direction from which of margin, body, margin was fixed (\Gm@detall, geometry.dtx:2237-2271). One margin beside the body fixes the body and derives the other margin; only margin + body + margin is over-specified, and then the body is dropped. top/bottom/left/right now clear the body only when the opposite margin is already named, and a fixed body derives the unnamed margin(s) (1:1, 2:3 two-sided, 2:3 top:bottom when neither is named) rather than keeping an earlier layout's.

Witness (tectonic 0.17.0, --print)

TW TH OS TM
tectonic 397.48499pt 650.43pt 36.13501pt -37.0pt
v0.296.0 397.48499pt 579.60394pt 19.8752pt -37.0pt
this PR 397.48499pt 650.43pt 36.13501pt -37.0pt

With bottom=2in,left=1in added (height dropped, width kept): tectonic and this PR both TH=578.16pt OS=0.0pt.

TestGeometryOneMarginKeepsTheBody asserts both.

Corpus

2405.16883 34 to 29, 2405.18549 45 to 40 (reference 26 and 37). Full-corpus numbers in a comment below.

🤖 Generated with Claude Code

tannevaled and others added 2 commits November 24, 2026 21:21
…missing margin is derived

\newgeometry{textheight=9in,textwidth=5.5in,top=1in,...} (neurips_2024.sty,
arxiv.sty, run at \begin{document} after \usepackage[letterpaper]{geometry}) lost
its text height: the `top` key cleared the textheight, and the bottom margin
subtracted instead was the 0.7-body default the first call had left in the state
(#923). The text block came out 8in instead of 9in: 2405.16883 29 -> 34 pages
(reference 26) and 2405.18549 40 -> 45 (reference 37), found by bisecting
v0.288.0..v0.296.0 to 320be1e.

geometry decides each direction from which of margin, body, margin the user
fixed (\Gm@detall, geometry.dtx:2237-2271). One margin beside the body fixes the
body and derives the other margin; only margin + body + margin is
over-specified, and then the body is dropped. top/bottom/left/right now clear
the body only when the opposite margin is already named, and a fixed body
derives the unnamed margin(s) (1:1, 2:3 two-sided, 2:3 top:bottom when neither
is named) instead of keeping an earlier layout's.

Witnesses, tectonic 0.17.0: TW=397.48499pt TH=650.43pt OS=36.13501pt TM=-37.0pt
(v0.296.0 said TH=579.60394pt OS=19.8752pt) and, with bottom=2in,left=1in,
TW=397.48499pt TH=578.16pt OS=0.0pt. TestGeometryOneMarginKeepsTheBody asserts
both.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mutsweep (-sites all) on the four margin guards of the previous commit
found three survivors (hasRight, hasLeft, hasBottom): the test only
exercised one order of the keys. Add tectonic's values for right-then-left
with bottom-then-top and the reverse; all four mutants are now caught.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@tannevaled
tannevaled merged commit 7997fa4 into main Nov 24, 2026
9 checks passed
@tannevaled
tannevaled deleted the geometry-single-margin branch November 24, 2026 22:12
tannevaled added a commit that referenced this pull request Nov 26, 2026
Documents font sizes in any TeX unit, a class's restated \normalsize as the
body size, \PassOptionsToClass option expansion, authblk, the elsarticle star
marks, LMSans bold and oblique, the page folio, geometry options and
heightrounded, eso-pic on even pages, align \tag placement and relation
spacing, \text spaces (go-tex/math v0.51.0), and the corpus A/B measured on
v0.299.0. Source: engine #936-#950, go-tex/math#69.

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant