Skip to content

tabular: a macro standing for several rows makes several rows (#629) - #630

Merged
tannevaled merged 1 commit into
mainfrom
tabular-row-macro
Oct 20, 2026
Merged

tannevaled merged 1 commit into
mainfrom
tabular-row-macro

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

A macro standing for several rows now makes several rows

Closes half of #629.

The defect

A tabular's body scanner reads raw tokens, so a macro whose replacement text
carries \\ arrived as one cell and every row it was meant to make collapsed
into it. Isolated in 17 lines — the same table written two ways:

\begin{tabular}[t]{c} Row one\\Row two\\Row three \end{tabular}   → three rows ✓
\def\mylist{Row one\\Row two\\Row three}
\begin{tabular}[t]{c} \mylist \end{tabular}                        → ONE row ✗

That is not a corner case. article.cls sets the author block as

\begin{tabular}[t]{c}%
  \@author
\end{tabular}

(article.cls:246-248), and \@author is exactly such a macro: authblk appends
\\[\affilsep] between the authors and each affiliation (authblk.sty:154-155, 167)
and this engine's own \affil does the same, for the same documented reason
(latex.go, \gotex@affiladd). So the affiliations we went to the trouble of
collecting were all run onto one line — and that line is not clipped, it is
drawn, off the side of the sheet.

Measured

Corpus of 154 papers, font-controlled, lines ending beyond 650pt (off any page size
this corpus uses), first two pages:

papers drawing off the page
before 49
after 25
reference (control) 2

The control's 2 are hyperref PostScript specials the reader surfaces as text runs,
not ink. Every one of the worst author-block cases is gone — 2308.00461 (4594pt),
2404.16039 (3921), 2206.05540 (3636), 2201.02101 (2573), 2208.08530 and
2208.08532 (2332 each).

On 2206.05540's title page, the author block goes from a single line ending at
x=1328pt to four lines, the widest ending at 518pt, each affiliation on its
own line — which is what the reference does.

measure alignsweep, the per-paper instrument from #628: papers whose pagination
first parts company in the first fifth of the document go 48 → 41, and the
median position of the first slip moves from 15% to 21%.

The page metric gets slightly worse, and that is the right trade

Corpus page A/B, control built as this commit's own first parent:

154 document(s) comparé(s), 2 ont bougé, Σ|·| = 2, biais = +2

Against the reference: Σ|·| 303 → 303 (unchanged), bias +145 → +147, exact
matches 33 → 33.

Recovering a page of front matter lengthens the documents that had been losing it,
so the bias moves away by two. That was stated in #629 before the measurement was
taken, and it is the same shape as the three held fixes in #589 — with one
difference that decides it
: those make us more compact where the corpus is already
too long, a typographic refinement Σ cannot arbitrate. This one recovers author
names, affiliations and e-mails that were being drawn off the sheet. Σ is not the
judge of content loss, and the README says so.

Why no existing channel saw it

Page counts cannot — the clearest witness is 15 pages against 15. Ink counts cannot
— every glyph is emitted. -report-skipped cannot — nothing is skipped. The text
layer carries the words. Only the geometry shows it, which is why it took
gotex-linediff's box widths to find.

Scope

hidesRowSeparator is as narrow as hidesTabularEnd beside it: no parameters, and
the \\ must be at brace depth 0 of the body, so a macro holding a braced group
that merely contains \\ is still one cell. Nesting below it is the scanner's
business — once an inner \begin{tabular} is read, envDepth is non-zero and its
\\ is not a row separator anyway.

⛔ The test asserts symmetry, not a threshold

A first version asserted that the macro's widest box fits the measure. It passed
with the fix disabled
, because three short words collapsed into one cell still fit.
Two spellings of the same table must produce the same geometry whatever the words
are. Checked against its own mutation: 8019641sp against 3664773sp with the case
turned off.

What is left in #629

The two worst remaining lines are abstracts, not author blocks — 2406.08646 and
2302.04180, both \documentclass[Afour,sageh,times]{sagej}, whose overfull line
begins AbstractThe Portable Extensible Toolkit…: the heading run into the body and
the whole abstract on one line. A different shape, left for its own change.

🤖 Generated with Claude Code

The body scanner reads RAW tokens, so a macro whose replacement text carries \\
arrived as ONE cell and every row it was meant to make collapsed into it.

That is not a corner case. article.cls sets the author block as

	\begin{tabular}[t]{c}%
	  \@author
	\end{tabular}

(article.cls:246-248) and \@author is exactly such a macro: authblk appends
"\\[\affilsep]" between the authors and each affiliation (authblk.sty:154-155,
167) and this engine's own \affil does the same, for the same documented reason.
So the affiliations we went to the trouble of collecting were all run onto one
line — and that line is not clipped, it is DRAWN, off the side of the sheet.

Measured over the 154-paper corpus, font-controlled: 49 papers draw a line past
the right edge of their own page in their first two pages, up to x=6619pt on a
612pt sheet, with author names, affiliations and e-mails outside the paper. The
control — the same measurement on the reference PDFs — is 2, and both of those are
hyperref PostScript specials the reader surfaces as text runs, not ink.

No channel here could see it: page counts cannot (the clearest witness is 15 pages
against 15), ink counts cannot (every glyph is emitted), -report-skipped cannot
(nothing is skipped), and the text layer carries the words. Only the geometry
shows it.

hidesRowSeparator is as narrow as hidesTabularEnd beside it: no parameters, and
the \\ must be at brace depth 0 of the body, so a macro holding a braced group
that merely contains \\ is still one cell. Nesting below it is the scanner's
business — once an inner \begin{tabular} is read, envDepth is non-zero and its \\
is not a row separator anyway.

⛔ The test asserts SYMMETRY, not a threshold. A first version asserted that the
macro's widest box fits the measure, and it PASSED with the fix disabled: three
short words collapsed into one cell still fit. Two spellings of the same table
must produce the same geometry whatever the words are. Checked against its own
mutation: 8019641sp against 3664773sp with the case disabled.

Co-Authored-By: Claude Opus 5 <[email protected]>
@tannevaled
tannevaled merged commit b08f4d3 into main Oct 20, 2026
18 checks passed
@tannevaled
tannevaled deleted the tabular-row-macro branch October 20, 2026 08:33
tannevaled added a commit that referenced this pull request Oct 20, 2026
…s closers (#629) (#631)

\end{X} IS \endX. LaTeX2e pairs an environment by running \X and then \endX, so a
class that composes one environment out of another writes the bare control
sequences. sagej.cls:238-242:

	\newbox\absbox
	\def\abstract{\lrbox\absbox\minipage{\textwidth}\section*{Abstract}}
	\def\endabstract{\endminipage\endlrbox}

Two things went wrong there, and each one alone was enough.

⛔ collectEnvBody hunted only the BRACED spelling, so the \endminipage that closes
this abstract never stopped the scan and the minipage constrained nothing. The
whole abstract came out as one horizontal list at its natural width, drawn off the
side of the sheet: 6619pt and 6019pt on a 612pt page, the two widest lines in the
corpus. Isolated — the same minipage inside \sbox, written \begin{minipage}{200pt}
… \end{minipage}, breaks into three lines 325pt wide; written \minipage{200pt} …
\endminipage it was one line 887pt wide.

⛔ And what \endX does BEFORE \endlrbox belongs INSIDE the box. \abstract opens the
minipage after \lrbox and \endabstract closes it before \endlrbox, but
collectEnvBody stops at \end{abstract}, so the closing half never ran at all.
lrboxClosers takes the tokens before \endlrbox, and only when \endlrbox is there:
that control sequence is the boundary, and a closing macro that does not name it is
not this shape — running its tokens here would run them twice.

⛔ NO endEnvGroup on the bare closer, unlike the \end{name} case beside it. That
call exists because \end{name} would have run an \endgroup matching the one
\begin{name} opened; a bare \X opened none, so closing one swallows the surrounding
group instead. Measured: with the call, the overfull line went away AND so did the
whole abstract.

Each half was mutated separately and each is caught by its own test. The assertion
is SYMMETRY — the same minipage written both ways must produce the same geometry —
because a threshold passes on any witness whose text happens to fit, which is how
the tabular test in #630 passed with its fix disabled.

Witness: 1790pt on one line to 484pt over four, the Abstract heading on its own.

Co-authored-by: Claude Opus 5 <[email protected]>
tannevaled added a commit that referenced this pull request Oct 20, 2026
A capability the README did not name, because until this week nothing could see
it. A vertical block that should fill a title page — an author/affiliation list,
an abstract — was emitted as one horizontal list that was never line-broken, so
everything past the right margin was DRAWN OFF THE PAPER: up to x=6619pt on a
612pt sheet, with author names, affiliations and e-mails outside it.

No channel this project measures with could see that. The page count cannot: the
clearest witness is 15 pages against 15. The ink count cannot: every glyph is
emitted. -report-skipped cannot: nothing is skipped. The text layer carries the
words. Only the geometry shows it, which is why it took gotex-linediff's box
widths to find (#629).

Four distinct causes, each with its own minimal witness and its own change:

  - a macro standing for several tabular rows (#630) — article.cls sets the author
    block as \begin{tabular}[t]{c}\@author\end{tabular} and authblk builds \@author
    with \\, so the body scanner's raw read collapsed every row into one cell;
  - a bare \endX closing what \X opened (#631) — sagej.cls writes
    \def\endabstract{\endminipage\endlrbox}, and \end{X} IS \endX;
  - calc expressions in a length argument (#632) — {\textwidth-57.625mm} read
    \textwidth, stopped, and typeset the rest;
  - \cite's optional note (#633) — the key list reached the page as text.

Measured over the 154-paper corpus: papers drawing text past their own page edge
49 → 25, widest line 6619pt → 3356pt, against a control of 2 on the reference
PDFs.

⚠ And it says what is NOT closed: 25 remain, and the top of that list is a
different population again.

Co-authored-by: Claude Opus 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