Skip to content

27 of 128 papers lose their running head: \markboth is a no-op and \pagestyle{headings} falls to plain #426

Closed

Description

@tannevaled

27 of the 128 corpus papers with a reference lose their running head entirely.
Measured on page 2, comparing ink in the top 90pt: the reference has some, we have
none.

papers
reference has a running head 99
…and so do we 72
…and we have nothing 27
reference has none 28

Two witnesses, checked in the render

2111.13456 page 2, top band:

reference   2      E. ELISEUSSEN, M. E. ROGNES, AND T. B. THOMPSON
ours        (blank)

2408.04846 page 2:

reference          Title Suppressed Due to Excessive Size
            ─────────────────────────────────────────────
ours        ─────────────────────────────────────────────

— we draw the rule and not the text above it, which is the clearest statement of
the gap: the page style is running, its content is not.

Mechanism

Two pieces, both small and both missing:

  1. classkernel.go:523 is \def\markboth#1#2{} — a no-op. \markboth is what
    LaTeX's page styles read back through \leftmark/\rightmark, so nothing can
    reach a head even where one is drawn.
  2. pagenum.go:32-39 knows three styles — empty, fancy, plain — and
    \pagestyle{headings} falls to plain, a bottom-centred number with no head
    at all. \ps@headings and \ps@myheadings are not implemented.

The rendering path already exists: assembleFancyPage/fancyHeader (footnote.go)
draws a head with its rule for \pagestyle{fancy}, so what is missing is the
marks and the two standard styles, not the machinery to put them on the page.

What it costs

A line of text on every page of a fifth of the corpus. It is also why those pages'
ink starts lower than the reference's: sweeping the papers whose pagination is
already exact, our ink span is ~25pt short on 17 of 18, and splitting that into
top and bottom edges puts the whole difference at the TOP. The missing head is a
large part of that.

It does not move Σ — the head sits outside \textheight — which is why a
page-count metric never surfaced it. Found by comparing ink positions, not counts.

🤖 Generated with Claude Code

Activity

  1. tannevaled commented on Sep 25, 2026

    @tannevaled
    ContributorAuthor

    Correcting my own count: it is 23, not 27, and the first measurement was not sound.

    The band test above — ink in the top 90pt of page 2 — counts a section heading as a running head. 1810.07903 was in my list and declares \pagestyle{empty}; its reference's top band is "1 Introduction". A thin isolated block near the top of a page is not enough.

    What distinguishes a running head is that it repeats: same shape, at the same height, on consecutive pages. Re-measured on pages 2, 3 and 4 together — first ink block within 90pt of the top, at most one line tall, followed by at least 1.5 lines of white, and starting within 2pt of the same y on all three:

    papers
    reference has a repeating head 23
    …and so do we 0
    we have one the reference does not 1

    So the shape of the finding is unchanged and slightly sharper: we draw none at all, on 23 of 128. Spot-checked in the render on four of them —

    • 2405.18549: Learning from Uncertain Data: From Possible Worlds to Possible Models — A PREPRINT, under a rule
    • 2111.13456: 2 E. ELISEUSSEN, M. E. ROGNES, AND T. B. THOMPSON
    • 2408.04846: Title Suppressed Due to Excessive Size, where we draw the rule and not the text
    • 1810.07903: not a head — this is the one that showed the first measure was wrong

    The mechanism in the issue body is unaffected: \markboth is \def\markboth#1#2{} at classkernel.go:523, and \pagestyle{headings} falls to plain.

    One thing the corrected sweep adds: the 23 are heterogeneous — amsart, iopart, iucr, sn-jnl, acmart, l4dc2024 and plain article. Implementing article's \ps@headings alone would not reach most of them; each class states its own head. So the marks (\markboth/\markright/\leftmark/\rightmark) are the part worth doing first, since every one of those styles reads them.

    🤖 Generated with Claude Code

  2. tannevaled commented on Sep 25, 2026

    @tannevaled
    ContributorAuthor

    #427 covers the first two pieces and measures what is left.

    The root cause turned out to be \thispagestyle, not the marks. It took \pagestyle's path, so the \thispagestyle{plain} that \maketitle issues on nearly every paper turned the running head off for the whole document. That is why the count was 0 and not 'a few': not one style survived its own title page.

    Both pieces landed:

    • \thispagestyle now applies to the page that carries it. The override rides the vertical list as a node, because the page builder runs after the document is read and nothing knows at call time which page the command falls on — the same reason TeX's output routine reads \@specialstyle for the page it is shipping.
    • \markboth/\markright/\leftmark/\rightmark record the pair. \@mkboth stays inert, as latex.ltx:13335 leaves it.

    Measured: Σ 294 → 292, +7702 glyphs, no paper loses content. Read word by word, those glyphs are the heads: 2405.18549 gains 537 words, mostly "Learning from Uncertain Data: From Possible Worlds to Possible Models A Preprint", once per page.

    What is left, with numbers

    Papers drawing a head at all: 3 → 6 of the 28 whose reference has one.

    1. Placement. Where we draw a head it sits too low and too close to the body. On 2405.18549 page 3, first ink block: ours at 72pt from the top with a 10pt gap below it, the reference at 37pt with 31pt. \headsep is not modelled — assembleFancyPage uses a fixed 6pt gap.
    2. Per-class styles. The remaining 22 are heterogeneous — amsart, iopart, iucr, sn-jnl, acmart, l4dc2024 and plain article. Only fancyhdr's path is implemented; \ps@headings and \ps@myheadings still fall to plain. Of 17 sampled, 7 use fancyhdr (these are the ones \thispagestyle styles one page, and the running marks are recorded #427 reaches), 2 use headings, and 8 rely on the class.

    A note on measuring this

    My first count in the issue body — 27 — was wrong, and the corrected one is 23; the comment above has the details. Both were taken on pages 2–4, and a head that only starts on page 3 (a title page spilling over) is missed there. Measured on pages 3–5 the reference count is 28 rather than 23, which is the figure used here. Whichever window, we drew none before and the shape of the finding is unchanged.

    🤖 Generated with Claude Code

  3. tannevaled commented on Sep 25, 2026

    @tannevaled
    ContributorAuthor

    Attempted the placement half and shelved it: it puts the head where it belongs and costs 5 pages on one paper for a reason I could not pin down.

    What the change does

    Three parts, all source-backed by classes.dtx "Page Layout" (the text starts at 1in + \voffset + \topmargin + \headheight + \headsep, so the band above it is exactly those two lengths):

    1. \headsep as the gap under the head instead of a fixed 6pt;
    2. the page lifted by \headheight + \headsep when it carries a head, since renderVMargin answers where the TEXT starts and a headed page begins with the head;
    3. the box packed to \vsize + band, so the head does not eat the text block.

    Measured on 2405.18549 page 3, first ink block:

    head top gap below
    before 72pt 10pt
    after 33pt 29pt
    reference 37pt 31pt

    Why it is not proposed

    Σ 292 → 297. One paper moves: 2301.11256, 55 → 60 pages against a reference of 50.

    Bisected to part 2 alone — the margin lift — which should not be able to touch pagination at all. RenderPages calls e.Pages() before reading the margin; pdfdriver.go:57 reads it before e.Pages(), which looked like the answer, and my first version made it worse by calling fancyHeader() from the margin accessor — that one TYPESETS the line, so a geometry question was being answered by running the typesetter. Fixing that to test the fields directly did not change the result: 60 either way.

    So there is a coupling between the render margin and pagination that I have not found, and shipping a change whose effect I cannot explain is not worth 4pt of head placement. The patch and its measurements are in a stash; whoever picks this up should start by finding that coupling, because it is a defect in its own right.

    Part 1 alone is not shippable either: widening the gap from 6pt to 25pt without lifting the page takes the difference straight out of the text block.

    🤖 Generated with Claude Code

  4. tannevaled commented on Sep 25, 2026

    @tannevaled
    ContributorAuthor

    State after #427, #429 and #434, all merged.

    at filing now
    papers drawing a running head 0 13 of 28
    glyphs restored — ~72000 across the corpus
    Σ 294 292 (#427) then 288 → 292 (#434)

    Three causes, and only the first was the one this issue named:

    1. \thispagestyle styled the whole document (\thispagestyle styles one page, and the running marks are recorded #427). \maketitle issues one on nearly every paper, so a single title page turned the head off everywhere — which is why the count was 0 rather than 'a few'. The marks were empty stubs too.
    2. The head sat inside the text block (The running head sits above the text block, not inside it #429), 35pt too low with 10pt of \headsep where the reference has 31. It is lifted by \headheight + \headsep now, and the box packed to \vsize plus that band so the head does not eat the text.
    3. LaTeX's own page styles were never read (LaTeX's own page styles draw their head #434). \ps@headings/\ps@myheadings did not exist, \@oddhead was never read back, \@startsection never called \sectionmark, and \MakeUppercase was not \protected — so \markright{\MakeUppercase{…}}, which \ps@headings writes, broke the expansion and swallowed the rest of the paragraph.

    What is left

    15 papers still draw no head. They are the ones whose class states its own style and is loaded for real — amsart, iopart, iucr, sn-jnl, acmart. Two things are likely needed:

    • \@evenhead, for a two-sided class: latexHead reads only \@oddhead, which is right for a one-sided document and wrong for a class that alternates. This engine has no two-sided page model at all, so that is the larger half.
    • whatever those classes use that \ps@name + \@oddhead does not cover — worth checking one of them before assuming.

    A caution on measuring this

    Three times in this issue a count had to be narrowed before it meant anything: the band test counted 1 Introduction as a head (27 → 23), the pages-2-4 window missed heads starting on page 3 (23 → 28), and the "we have one the reference does not" category is noise — checked in the render, 2403.10748 is blank at the top on both sides and 2408.04846, whose reference head I read myself, is in it. A thin isolated block near the top of a page is not distinguishable from a section heading by shape. The numbers worth quoting here are the glyph counts and the side-by-side renders against tectonic.

    🤖 Generated with Claude Code

  5. tannevaled commented on Sep 26, 2026

    @tannevaled
    ContributorAuthor

    Traced the remaining 15 to the end, and shelved the increment: it is correct by the sources, costs 991 glyphs on five papers and buys nothing measurable.

    The chain, for whoever takes it

    I assumed \@evenhead was what the 15 needed. It is one link of four, and reading the classes rather than guessing found the rest:

    1. \@evenhead — amsart.cls:306-319 declares both heads and alternates; the corpus witness 2111.13456 shows its page 2 as 2 E. ELISEUSSEN, M. E. ROGNES, AND T. B. THOMPSON, which is the EVEN head. latexHead reads only \@oddhead. Implemented against \if@twoside and curPageNum.
    2. \topmark/\firstmark/\botmark — amsart.cls:325-326 redefines \leftmark/\rightmark to read them rather than using LaTeX's, so the marks this engine stores were bypassed entirely.
    3. \mark — amsart.cls:335-339 redefines \markboth too, and its version writes \mark{{#1}{#2}}. amssubstrate.go:413 is \def\mark#1{}, with the comment "page marks feed running heads the engine does not build" — true when written, false since LaTeX's own page styles draw their head #434.
    4. \maketitle — still broken. amsart.cls:622 does \@mkboth{\shortauthors}{\shorttitle}, and after fixing 1-3 the marks are still empty on a minimal amsart document, so the engine's \maketitle does not reach it. That is where the next attempt should start.

    Why it is shelved

    Σ 292 → 292
    glyphs −991
    papers losing content 5

    Read word by word, the lost words are a running head: 2403.10748 loses "A Comprehensive LaSDI Review for Reduced Order Modelling", once per page. So implementing \mark breaks a head that already worked — a \mark{} with an empty or non-pair argument clobbers the stored pair, and \gotex@mark#1#2\@nil splits it wrongly. TeX's \mark takes one argument of any shape; only LaTeX's convention makes it a pair.

    So \mark needs to distinguish a pair from anything else before storing, and that has to be right before any of this is worth landing. The patch is in a stash.

    🤖 Generated with Claude Code

  6. tannevaled commented on Nov 7, 2026

    @tannevaled
    ContributorAuthor

    Your second piece is fixed in #726, and your first one was already done. Reporting against your own two-part mechanism.

    Piece 1 — \markboth is a no-op: already fixed

    classkernel.go:635-637 now sets the pair and \rightmark reads it back:

    \def\markboth#1#2{\protected@xdef\gotex@leftmark{#1}\protected@xdef\gotex@rightmark{#2}}
    \def\markright#1{\protected@xdef\gotex@rightmark{#1}}
    \def\rightmark{\gotex@rightmark}

    Probed on \pagestyle{myheadings} with an explicit \markright:

    [oddhead=macro:->{\slshape \rightmark }\hfil \thepage ]
    [rightmark=MARQUE EXPLICITE ZZZ]
    

    So the mark arrives and \@oddhead is defined. Nothing was reaching the page anyway, because of piece 2.

    Piece 2 — \pagestyle{headings} falls to plain: #726

    doPagestyle recorded every name but empty/fancy as "plain", and two sites then asked different questions about the same page: assemblePage routes on the name (style != "plain" && hasLatexHead()), while headBand routes on \@oddhead being defined. So the band was reserved — \headheight + \headsep = 37pt — and the plain path drew a centred folio at the foot instead of a head.

    Measured against tectonic with fontcmp -pagefill (26 sections breaking naturally, y of page 1's last body line):

    \pagestyle before after tectonic
    empty 672.74 672.74 672.75
    plain 653.73 653.73 672.75
    headings 616.87 648.59 672.75

    31.7pt of text recovered per page, the head drawn, and the folio out of the band \ps@headings leaves empty.

    Your sharpest observation turns out to be the signature of exactly this: on 2408.04846 we drew "the rule under the head and no text above it". The rule comes from the fancy assembly's headRule; the head text comes from fancyHeader() → latexHead(), which that path never reached. The band, the rule and the absence were all one dispatch.

    What remains after #726, and it is a third piece you did not name

    The head now draws, with the wrong content: the document's last mark on every page. fontcmp -pagefill's witness has 26 sections and page 1's head reads 26 SECTION NUMERO 26 against the oracle's 1 SECTION NUMERO 1 1.

    That is per-page mark selection — \topmark/\firstmark/\botmark (tex.web:7864-7866, maintained at every break in :19718-19729), which \rightmark reads as \firstmark (latex.ltx:13361). Marks do not travel with page breaking here, so there is one live pair and it is the final one. Filed as #727.

    So your 27 papers go from no head to a head whose text is wrong where it tracks sections, and correct where it is set once (a title, a preprint banner). Geometrically it is a clear gain; for the content it is a trade, and #727 is what closes it.

    (#725 was me re-deriving your piece 2 without finding this issue first. Closing that one in favour of this.)

  7. tannevaled commented on Nov 7, 2026

    @tannevaled
    ContributorAuthor

    ⛔ Correction: I said your piece 1 was "already fixed". It is not, and your own witness proves it

    I rendered 2111.13456 — the paper you name — with #726 applied. Page 2:

    ours        y= 98.60   "2"
    reference   y= 79.97   "2 E. ELISEUSSEN, M. E. ROGNES, AND T. B. THOMPSON"
    

    The band and the folio are now right. The mark text is still absent, which is exactly what you reported. \markboth being a working primitive was not the question.

    Why, traced to the line

    The paper is \documentclass[10pt,reqno]{amsart} and ships no class files, so it runs the embedded texmf/amsart.cls — and amsart redefines \markboth itself (amsart.cls:335-340):

    \def\markboth#1#2{%
      \begingroup
        \@temptokena{{#1}{#2}}\xdef\@themark{\the\@temptokena}%
        \mark{\the\@temptokena}%
      \endgroup
      \if@nobreak\ifvmode\nobreak\fi\fi}

    It writes \@themark and emits a \mark node — LaTeX's own mechanism (latex.ltx:13358-13362 keeps \@themark as the current pair and reads \leftmark/\rightmark out of \botmark/\firstmark).

    Our \leftmark/\rightmark read \gotex@leftmark/\gotex@rightmark (classkernel.go:643-644), a private pair that only our \markboth writes. amsart overrode that \markboth, so nothing writes the pair, and \@themark — which amsart does write — is read nowhere in the engine: git grep '@themark' -- '*.go' returns nothing.

    So the private pair is a stand-in for \@themark under a name no class knows. A class that brings its own \markboth — and amsart is one of the four classes this engine advertises running — writes the standard name and is silently dropped.

    The call that should have filled this head is amsart.cls:622:

    \@mkboth{\@nx\shortauthors}{\@nx\shorttitle}%

    with \ps@headings doing \let\@mkboth\markboth at :318. Every link exists; the last one reads the wrong variable.

    And amsart makes the per-page question moot for itself

    amsart.cls:344-346:

    \let\sectionmark\@gobble
    \let\subsectionmark\@gobble
    \let\subsubsectionmark\@gobble

    amsart's head is set once, from the authors and the short title, and never tracks sections. So the single live pair this engine keeps is exactly right for it — #727's per-page selection does not bite here at all. Your witness is the easy case, and it is still empty.

    Shape of the fix

    Read what the class writes: define \@themark and destructure \leftmark/\rightmark out of it the way latex.ltx does with \@leftmark/\@rightmark, instead of reading a private pair. That keeps the documented simplification (one live pair rather than per-page marks, #727) while using the name every class and the kernel already agree on.

    It is small, and it would fill the head on your own witness without touching page breaking.

    (My earlier comment on this issue claimed piece 1 was done because the primitive works in isolation. It does — and no real class uses it. That is the difference between a primitive that answers and a mechanism that is reached, and I should have rendered the witness before writing the claim rather than after.)

  8. tannevaled commented on Nov 7, 2026

    @tannevaled
    ContributorAuthor

    ⛔ Correction, second one on this issue: \@themark is not the route your paper takes

    I wrote here that the fix was to "read what the class writes: define \@themark and destructure \leftmark/\rightmark out of it". I have now done exactly that (class-mark-pair), rendered your witness with it and #726 applied, and page 2 is still bare:

    y=98.99  font-size=7  "2"        ← the folio, and nothing else in the band
    

    The reason is three lines further down the same file than the ones I quoted. amsart overrides both ends of the mechanism (texmf/amsart.cls:325-326):

    \def\leftmark{\expandafter\@firstoftwo\topmark{}{}}
    \def\rightmark{\expandafter\@secondoftwo\botmark{}{}}

    So amsart's \markboth writes \@themark and emits \mark{{#1}{#2}} (:335-340) — and its heads read \topmark / \botmark. It never reads \@themark back; it only writes it. I had read the write and inferred the read.

    And this engine has no \mark, \topmark, \firstmark or \botmark at all:

    $ git grep -n 'topmark\|botmark\|firstmark' -- '*.go'
    classkernel.go:627:% \firstmark / \botmark, so a head shows the mark that applies to THAT page…
    classkernel.go:679:%	\def\leftmark{\expandafter\@leftmark\botmark\@empty\@empty}
    …
    

    Five hits, all of them inside comments. \mark itself is undefined, which is why amsart's \markboth quietly contributes nothing and why the paper needs -lenient to render at all.

    So your issue and #727 are one piece of work, and it is sized now

    Not "a head whose text is wrong" versus "a head with no text": for amsart there is no route of any kind until marks exist. What that takes, from the reference:

    • \mark{…} as a node on the vertical list, expanded at mark time, travelling with page breaking. pageStyleNode (pagenum.go:28-35) is the shape — \thispagestyle already solves the same "which page does this land on" problem by contributing a node and letting the builder find it.
    • \topmark, \firstmark, \botmark maintained per page, tex.web:7864-7866 with the per-break arithmetic at :19718-19729: top = the previous page's bot, first = this page's first mark or else top, bot = this page's last mark or else top.
    • They must hold their values before the head is drawn, since the head expands them during page assembly.

    What class-mark-pair is still worth, stated honestly

    It moves the pair to \@themark and the accessors to the kernel's own (ltpage.dtx:167-174, 341-342, 355-357), so a class that brings its own \markboth and reads the kernel's \leftmark/\rightmark — report.cls does — reaches the head. Before it, only this engine's own \markboth wrote the pair anything read. It does nothing for amsart, and the PR says so rather than counting your 27 papers as fixed.

    (Two corrections on this issue now: first that piece 1 was already done, because the primitive answered in isolation; now that \@themark was the route, because I read the class's write and inferred its read. Both times the render was the thing that settled it, and both times I wrote before rendering.)

  9. tannevaled commented on Nov 7, 2026

    @tannevaled
    ContributorAuthor

    6 of your 27 now draw their head, measured. #729 merged

    Your witness first, read at the pixel:

    2111.13456 page 2, before:  y=98.99  "2"
                        after:  y=99.17  "A POSTERIORI ESTIMATION FOR
                                          MULTIPLE-NETWORK POROELASTICITY"  "2"
    

    And the corpus, control = main at #728's merge:

    154 comparable; 6 render DIFFERENTLY, all 6 at identical page counts
    
    2111.13456   35 pages (unchanged)   ink 66887 → 68723
    2401.03325    9 pages (unchanged)   ink 12213 → 12437
    2401.13343   32 pages (unchanged)   ink 69344 → 70243
    2402.05579   15 pages (unchanged)   ink 40430 → 41074
    2406.10437   36 pages (unchanged)   ink 71922 → 73952
    2408.06962   13 pages (unchanged)   ink 32975 → 33539
    

    Σ 272, bias −12, exact 47 — identical to main, so nothing was traded for it. Six papers gain ink at unchanged page counts, which is a head appearing and nothing else moving. hashdiff is the only channel that reports them, and your issue's own method — ink in the top 90pt of page 2 — is the same kind of measurement, which is why it saw 27 where page counts saw nothing.

    Why six and not twenty-seven, stated precisely

    These six are the papers whose class brings its own \markboth and reads \topmark/\botmark — amsart and its kin. For them the chain is now complete: the class's \markboth emits a \mark, the mark travels to its page, and the class's own \leftmark/\rightmark read it there.

    The rest of your 27 use our own \markboth, which writes \@themark (#728) but does not emit a \mark, so the pair does not travel. That is the kernel-marks branch on #727, measured there: three sections on three pages give "2 DEUXIEME SECTION" and "3 TROISIEME SECTION", each page carrying its own. It is held because six tests probe \leftmark at document time, where TeX itself has nothing to give, and converting them to read the drawn head is work to do properly rather than quickly.

    So this issue is not closed: six of its papers are, by measurement, and the remainder has a branch with a number on it.

    What it cost to get right, since it bears on how to read my earlier comments here

    Four fixes, three of them correct and insufficient — the band (#726), the dispatch, the pair's name (#728) — and the fourth a single line that threw the mark away: \def\mark#1{}, a stub that discarded its argument, with the reason it stated ("page marks feed running heads the engine does not build") true when written. It survived all three because it sat one layer below them. What found it was a unit test asking not "is this layer right?" but "does the node arrive?".

    And two mechanisms I wrote on #729 before measuring were refuted by one paper out of 154: a mark has no dimension so it cannot move a page (it did), then the breakpoint after a mark was lost (the re-sweep came back byte-for-byte unchanged). The cause was a bare \mark{{}{}} in ws-fnl.cls's preamble being contributed to a page that does not exist yet. Both are written up on #729 with the numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions