Repository navigation
the running mark pair lives under the name the classes write, \@themark - #728
Merged
Merged
Conversation
#726 gave \pagestyle{headings} its band, its folio and its rule, and #426's own witness still came out with an EMPTY head. The cause is the last link, and it is a name: \leftmark / \rightmark read \gotex@leftmark / \gotex@rightmark, a PRIVATE pair that only this engine's own \markboth ever wrote. A class may bring its own \markboth, and amsart.cls does — one of the four classes this engine advertises running (texmf/amsart.cls:335-340): \def\markboth#1#2{\begingroup \@temptokena{{#1}{#2}}\xdef\@theMark{\the\@temptokena}% \mark{\the\@temptokena}\endgroup …} It writes \@theMark, the kernel's name (ltpage.dtx:355 \def\@theMark{{}{}}), and touches no private pair. Every other link already worked: \ps@headings does \let\@mkboth\markboth (amsart.cls:318), amsart calls \@mkboth{\@nx\shortauthors}{\@nx\shorttitle} (:622), the mark was set. Only the read was looking elsewhere. So the pair moves to \@theMark and the accessors become the kernel's own (ltpage.dtx:167-174, 341-342, 356-357): \let\@leftmark\@FirstOfTwo \let\@rightmark\@secondoftwo \def\@theMark{{}{}} \def\markboth#1#2{\protected@xdef\@theMark{{#1}{#2}}} \def\@markright#1#2#3{\@temptokena{#1}% \protected@xdef\@theMark{{\the\@temptokena}{#3}}} \def\markright#1{\expandafter\@markright\@theMark{#1}} \def\leftmark{\expandafter\@leftmark\@theMark\@empty\@empty} \def\rightmark{\expandafter\@rightmark\@theMark\@empty\@empty} \markright keeps the LEFT half, which is why the kernel routes it through \@markright rather than assigning both — and \ps@headings's \sectionmark IS a \markright, so the wrong shape would wipe half the head at every section. The two \@empty are the kernel's guard for a pair never set. ⛔ WHAT WAS WRONG WITH THE TESTS, not just with the code. Two tests probed \gotex@rightmark — the STORAGE — so they were green for every document whose class brings its own \markboth, which is the only case that was broken. They now probe \rightmark, the name a page style reads. Two tests added: - a class's own \markboth (amsart's idiom verbatim in shape) must reach \leftmark/\rightmark — the test #426 needed; - \markright keeps the left half. Run against the previous commit, which is the control a new test needs or it proves nothing, they do NOT both fail — and the difference matters: class's own \markboth FAILS, "[|]" — both halves empty. #426 reproduced. \markright keeps left PASSES. The old private pair kept the left too, since \markright wrote only \gotex@rightmark. So the second one is not a regression test for this change; it is a guard that the new \@markright shape — which destructures the pair and rebuilds it — did not lose what the simpler assignment got right. Keeping it, labelled for what it is, rather than letting it be counted as evidence. Still NOT done, and unchanged by this: the pair is the single live one, where the kernel reads \botmark and \firstmark so a head shows the mark of THAT page (#727). amsart is immune to that difference by construction — it \@Gobbles \sectionmark and friends (amsart.cls:344-346), so its head is set once from the authors and the short title. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Nov 7, 2026
tannevaled
added a commit
that referenced
this pull request
Nov 7, 2026
#729) * the running mark pair lives under the name the classes write, \@theMark #726 gave \pagestyle{headings} its band, its folio and its rule, and #426's own witness still came out with an EMPTY head. The cause is the last link, and it is a name: \leftmark / \rightmark read \gotex@leftmark / \gotex@rightmark, a PRIVATE pair that only this engine's own \markboth ever wrote. A class may bring its own \markboth, and amsart.cls does — one of the four classes this engine advertises running (texmf/amsart.cls:335-340): \def\markboth#1#2{\begingroup \@temptokena{{#1}{#2}}\xdef\@theMark{\the\@temptokena}% \mark{\the\@temptokena}\endgroup …} It writes \@theMark, the kernel's name (ltpage.dtx:355 \def\@theMark{{}{}}), and touches no private pair. Every other link already worked: \ps@headings does \let\@mkboth\markboth (amsart.cls:318), amsart calls \@mkboth{\@nx\shortauthors}{\@nx\shorttitle} (:622), the mark was set. Only the read was looking elsewhere. So the pair moves to \@theMark and the accessors become the kernel's own (ltpage.dtx:167-174, 341-342, 356-357): \let\@leftmark\@FirstOfTwo \let\@rightmark\@secondoftwo \def\@theMark{{}{}} \def\markboth#1#2{\protected@xdef\@theMark{{#1}{#2}}} \def\@markright#1#2#3{\@temptokena{#1}% \protected@xdef\@theMark{{\the\@temptokena}{#3}}} \def\markright#1{\expandafter\@markright\@theMark{#1}} \def\leftmark{\expandafter\@leftmark\@theMark\@empty\@empty} \def\rightmark{\expandafter\@rightmark\@theMark\@empty\@empty} \markright keeps the LEFT half, which is why the kernel routes it through \@markright rather than assigning both — and \ps@headings's \sectionmark IS a \markright, so the wrong shape would wipe half the head at every section. The two \@empty are the kernel's guard for a pair never set. ⛔ WHAT WAS WRONG WITH THE TESTS, not just with the code. Two tests probed \gotex@rightmark — the STORAGE — so they were green for every document whose class brings its own \markboth, which is the only case that was broken. They now probe \rightmark, the name a page style reads. Two tests added: - a class's own \markboth (amsart's idiom verbatim in shape) must reach \leftmark/\rightmark — the test #426 needed; - \markright keeps the left half. Run against the previous commit, which is the control a new test needs or it proves nothing, they do NOT both fail — and the difference matters: class's own \markboth FAILS, "[|]" — both halves empty. #426 reproduced. \markright keeps left PASSES. The old private pair kept the left too, since \markright wrote only \gotex@rightmark. So the second one is not a regression test for this change; it is a guard that the new \@markright shape — which destructures the pair and rebuilds it — did not lose what the simpler assignment got right. Keeping it, labelled for what it is, rather than letting it be counted as evidence. Still NOT done, and unchanged by this: the pair is the single live one, where the kernel reads \botmark and \firstmark so a head shows the mark of THAT page (#727). amsart is immune to that difference by construction — it \@Gobbles \sectionmark and friends (amsart.cls:344-346), so its head is set once from the authors and the short title. Co-Authored-By: Claude Opus 5 <[email protected]> * marks travel with page breaking: \mark, \topmark, \firstmark, \botmark #426's witness has its running head. It took four fixes, three of which were right and insufficient, and the fourth is one line that threw the mark away. 2111.13456 page 2, before: y=98.99 "2" after: y=99.17 "A POSTERIORI ESTIMATION FOR MULTIPLE-NETWORK POROELASTICITY" "2" ⛔⛔ THE LINE. amssubstrate.go carried `\def\mark#1{}` — a stub that DISCARDS its argument — with the reason it stated: "page marks feed running heads the engine does not build; drop the mark". True when written. It then survived every fix to the chain above it: the band and the folio (#726), the page-style dispatch, and the pair's name (#728). Each of those was correct, and each left the head empty, because the mark was being dropped one layer below all of them. A stub that discards its argument is the one shape no channel can see: the document says what it wants, the engine says nothing, the suite stays green, and the loss appears only as ink that is not on the page. The measurement harness has a section about exactly this trap ("the blind spot no channel has"), and it still cost 27 of the 128 corpus papers with a reference their head, through three rounds of fixing the wrong layer. WHAT IS IMPLEMENTED, from tex.web: \mark{…} a node on the vertical list (markNode), the argument EXPANDED at mark time — scan_toks(false,true). Not a detail: amsart writes \@temptokena{{#1}{#2}}…\mark{\the\@temptokena}, so an unexpanded mark would store "\the\@temptokena" and the head would read \the. It travels like pageStyleNode, for the same reason: at mark time nothing knows which page it lands on. \topmark / \firstmark / \botmark republished before each page's head is built, from §1012's arithmetic (:19718-19729, :19782-19789): if bot<>null then top:=bot; first:=null walking the page: if first=null then first:=p; bot:=p if top<>null and first=null then first:=top Two consequences a plainer reading misses, and both are what a head depends on: bot is NOT cleared for a page with no marks, so a head set once at \maketitle stays on every later page; and first falls back to top, so a page broken mid-section reports the mark in force at its own top. They are published in assemblePage, which every page passes through, BEFORE anything draws a head — a head expands \topmark/\botmark while the page is assembled (amsart.cls:325-326), so values set after it would be one page late. tex.web updates them at the top of fire_up for the same reason. \splitfirstmark / \splitbotmark belong to \vsplit and are not here. Tests: the node reaches the vertical list (it did not, and that is how the stub was found — the arithmetic was already right while the node never arrived); and the three-page arithmetic above, including the markless page that keeps the previous bot. ⛔ THE CORPUS SWEEP IS DEFERRED, NOT RUN: 1-minute load average 20.05 against a ceiling of ~8. This change adds ink to pages without changing their count, so the channel that can see it is `hashdiff`, not Σ — and a render that times out under load would report a page count that is simply wrong. It runs behind `loadwait` and the numbers go on the pull request. Co-Authored-By: Claude Opus 5 <[email protected]> * a mark is type 4, so a break may be taken after it (tex.web:3109) 2405.05720 went 9 pages -> 10 with the ink IDENTICAL on both sides (23282), against a reference of 9: the one paper the engine had exactly right, lost. Same content, one more page, because the glue after a mark had stopped being a legal breakpoint -- precedesBreak answered false for markNode, while precedes_break(#) == (type(#) < math_node) is true for mark 4, which the comment above that very function already listed. Sigma 272 -> 273 and exact 47 -> 46 for that one paper. 'A mark carries no dimension, so no page can change height' was written on #729 before the sweep ran: true, and beside the point. Having no dimension is a different claim from having no effect on where a page MAY break. Co-Authored-By: Claude Opus 5 <[email protected]> * a \mark in the PREAMBLE is read and dropped (2405.05720: 10 pages -> 9) The paper the marks cost its exact match, found by the corpus and fixed by experiment rather than by the mechanism I first proposed. ws-fnl.cls:804 carries a bare \mark{{}{}} at class level, OUTSIDE the document body, and 2405.05720 uses that class. Contributed there, it is material on a page that does not exist yet: 9 pages became 10 with the ink IDENTICAL on both sides (23282 glyph units) against a reference of 9. Dropping the preamble's mark returns it to 9, measured on that paper. The argument is still SCANNED, so its tokens are consumed exactly as they would be inside the body; only the node is withheld. Nothing in the preamble is typeset (see inBody). ⛔ And the previous commit, which made precedesBreak answer true for a markNode, FIXED NOTHING: the re-sweep came back 273 and 46, byte-for-byte what it was. It is kept because tex.web:3109 says a mark precedes a break (type 4 < 9) and the engine should agree -- not because it repaired that paper. Its comment now says so where the line is, instead of claiming the measurement that refuted it. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Nov 7, 2026
The behaviour is RIGHT and measured; six tests encode the old one, and converting them is not a thing to rush. Pushed so the work is not lost, not proposed. WHAT IT DOES, and it is #727's residual: \markboth / \markright emit the pair as a \mark beside writing \@theMark, as the kernel does (ltpage.dtx:239-244, 265-267) — the pair is for a class to read back, the mark is for the page builder; \leftmark / \rightmark read \botmark / \firstmark (ltpage.dtx:341-342) instead of the single live pair. MEASURED on three sections forced onto three pages, \pagestyle{headings}: page 2 head "2 DEUXIEME SECTION" page 3 head "3 TROISIEME SECTION" Each page carries ITS OWN section. With one live pair every page showed the document's last one, which is exactly what #727 reports. Our \ps@headings redefines \sectionmark as a \markright, so with one pair the final section won everywhere. ⛔ WHY IT IS HELD. Six tests fail, all of them probing \leftmark / \rightmark at DOCUMENT time: TestClassKernelDeclarations/marks TestOnlyNumberedSectionsMark TestPagestyleHeadingsDeclaresAHead TestRunningMarks TestAClassThatBringsItsOwnMarkbothReachesTheHead TestMarkrightKeepsTheLeftHalf They are not wrong about the engine; they are wrong about TeX. The values belong to a page, so outside a page there are none — a real LaTeX answers empty there too, and latex.ltx has carried a note about this since 1993: "Stopgap solution to make \leftmark and \rightmark work without initializing mark until the problem is solved" (ltpage.dtx:318-323), with an upstream \task still open on it. And in THIS engine the page builder runs after the whole document is read, so document time can never see a page's marks at all. So the six have to be rewritten against the DRAWN HEAD rather than against an expansion — the same move as #728's test, which stopped probing \gotex@rightmark (the storage) and started probing \rightmark (what a page style reads). Doing that properly needs a helper for reading a rendered page's text, and six careful conversions. Rushing them is how a suite ends up asserting the implementation instead of the behaviour. Nothing is measured on the corpus either: the machine's 1-minute load was 20.05 against a ceiling of ~8. Depends on #729 (the mark primitives); this branch sits on top of it. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Nov 8, 2026
tannevaled
added a commit
that referenced
this pull request
Nov 16, 2026
* HELD: the kernel's own \leftmark/\rightmark read the page's marks (#727) The behaviour is RIGHT and measured; six tests encode the old one, and converting them is not a thing to rush. Pushed so the work is not lost, not proposed. WHAT IT DOES, and it is #727's residual: \markboth / \markright emit the pair as a \mark beside writing \@theMark, as the kernel does (ltpage.dtx:239-244, 265-267) — the pair is for a class to read back, the mark is for the page builder; \leftmark / \rightmark read \botmark / \firstmark (ltpage.dtx:341-342) instead of the single live pair. MEASURED on three sections forced onto three pages, \pagestyle{headings}: page 2 head "2 DEUXIEME SECTION" page 3 head "3 TROISIEME SECTION" Each page carries ITS OWN section. With one live pair every page showed the document's last one, which is exactly what #727 reports. Our \ps@headings redefines \sectionmark as a \markright, so with one pair the final section won everywhere. ⛔ WHY IT IS HELD. Six tests fail, all of them probing \leftmark / \rightmark at DOCUMENT time: TestClassKernelDeclarations/marks TestOnlyNumberedSectionsMark TestPagestyleHeadingsDeclaresAHead TestRunningMarks TestAClassThatBringsItsOwnMarkbothReachesTheHead TestMarkrightKeepsTheLeftHalf They are not wrong about the engine; they are wrong about TeX. The values belong to a page, so outside a page there are none — a real LaTeX answers empty there too, and latex.ltx has carried a note about this since 1993: "Stopgap solution to make \leftmark and \rightmark work without initializing mark until the problem is solved" (ltpage.dtx:318-323), with an upstream \task still open on it. And in THIS engine the page builder runs after the whole document is read, so document time can never see a page's marks at all. So the six have to be rewritten against the DRAWN HEAD rather than against an expansion — the same move as #728's test, which stopped probing \gotex@rightmark (the storage) and started probing \rightmark (what a page style reads). Doing that properly needs a helper for reading a rendered page's text, and six careful conversions. Rushing them is how a suite ends up asserting the implementation instead of the behaviour. Nothing is measured on the corpus either: the machine's 1-minute load was 20.05 against a ceiling of ~8. Depends on #729 (the mark primitives); this branch sits on top of it. Co-Authored-By: Claude Opus 5 <[email protected]> * the six mark tests read the drawn HEAD, so kernel-marks is no longer held They probed \leftmark/\rightmark at DOCUMENT time, where those now expand \botmark/\firstmark -- values that belong to a page, published by the page builder, which runs after the whole document has been read. A real LaTeX answers empty there too; latex.ltx has carried a note about it since 1993 (ltpage.dtx:318-323, upstream \task still open). So the tests were not wrong about the engine, they were wrong about TeX. The split they become: SEMANTICS at document time through \@theMark, the kernel's own name for the live pair (ltpage.dtx:355) -- a documented variable classes write and read, amsart among them -- and REACHABILITY through the head actually drawn, read with pageText(). TestClassKernelDeclarations/marks, TestMarkrightKeepsTheLeftHalf and TestRunningMarks take the first; TestPagestyleHeadingsDeclaresAHead, TestOnlyNumberedSectionsMark and TestAClassThatBringsItsOwnMarkbothReachesTheHead take the second. ⛔ Two things the conversion exposed. The class-own-markboth fixture copied only the \@theMark half of amsart's idiom and left out \mark{\the\@temptokena}: enough while \rightmark read the pair directly, and not a class at all once the pair travels -- a fixture missing the line that makes the mechanism work was testing it not working. And the needles carry no spaces, because pageText collects glyphs and not the glue between them. The obsolete comment in classkernel_test.go went with it: it stated the divergence as permanent ("which this page builder does not do yet"). --------- Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The running mark pair now lives in
\@themark, the name the kernel and the classes use, instead of a private pair only this engine's own\markbothever wrote.Straight from
ltpage.dtx—:167-174for the two accessors ("we can't get rid of them since they are sometimes used in applications"),:355for the initial{{}{}},:356-357for\@markright,:341-342for the destructuring.\markrightkeeps the left half and replaces only the right, which is why the kernel routes it through\@markrightrather than assigning both — and\ps@headings's\sectionmarkis a\markright, so the wrong shape would wipe half the head at every section.What was wrong with the tests, not only with the code
Two tests probed
\gotex@rightmark— the storage. They were green for every document whose class brings its own\markboth, which is the only case that was broken. They now probe\rightmark, the name a page style reads. Two tests added; run against the parent commit, which is the control a new test needs or it proves nothing, they do not both fail:\markbothreaches the head"[|]"— both halves empty\markrightkeeps the left halfSo the second is a guard that the new
\@markrightshape did not lose what the simpler assignment got right, not evidence for this change. Labelled as such rather than counted.⛔ It does NOT fix #426's witness, and I had said it would
I wrote on #426 that the shape of the fix was to read
\@themark. That is right for the kernel and wrong for the paper I was looking at. Rendered with this change and #726 applied,2111.13456page 2 still has only the folio:Because amsart overrides both ends of the mechanism (
texmf/amsart.cls:325-326):Its
\markbothwrites\@themarkand emits\mark{{#1}{#2}}(:335-340), and its heads read\topmark/\botmark— never\@themark, which it only ever writes. And this engine implements no\mark,\topmark,\firstmarkor\botmark:git grepfinds those names only inside comments. So for amsart there is no route at all, and\@themarkis not the one it would take.What this change does fix is the kernel path and every class that brings its own
\markbothand reads the kernel's accessors —report.cls's\markboth{\MakeUppercase\…}among them — which is what the new test pins.What remains for #426 is therefore #727's substance, now sized rather than guessed:
\markas a node that travels with page breaking, and\topmark/\firstmark/\botmarkmaintained per page (tex.web:7864-7866, per-break at:19718-19729: top = the previous page's bot, first = the page's first mark or top, bot = its last mark or top).pageStyleNodealready shows the shape a per-page node takes here.Checks
go test ./...green (the full suite, 16.7s),go vetclean.🤖 Generated with Claude Code