Skip to content

render-pipeline: \twocolumn[\@maketitle] is \@topnewpage, and figure* is \@dbflt - #382

Merged
GoKubar merged 3 commits into
mainfrom
agent/engine-twocolumn/topnewpage
Sep 14, 2026
Merged

GoKubar merged 3 commits into
mainfrom
agent/engine-twocolumn/topnewpage

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Issue #2's dominant error in both two-column documents: \twocolumn[\@maketitle] with floats on the page drew the full-width title and then set the abstract inside it. The cause was let shift = if floats.is_empty() { height } else { 0.0 } — with floats present the spanning title contributed no vertical shift at all.

Fixing it by deleting the condition is not enough, because the shift and the page shortening are one number and only one of them reached the float placer. The second commit then does what the coordinator's figure* finding requires: a full-width float is placed by the same machinery, and both are now implemented against what latex.ltx actually does.

What \@topnewpage does that we did not

\@topnewpage (latex.ltx 20466-20505):

\global \setbox\@currbox \color@vbox \normalcolor
  \vbox {\hsize\textwidth \@parboxrestore \col@number \@ne #1 \vskip -\dbltextfloatsep}%
\ifdim \ht\@currbox>\textheight \ht\@currbox \textheight \fi
\global \count\@currbox \tw@
\@tempdima -\ht\@currbox  \advance \@tempdima -\dbltextfloatsep
\global \advance \@colht \@tempdima
\@cons \@dbltoplist \@currbox
\global \@dbltopnum \m@ne
... \global \vsize \@colht  \global \@colroom \@colht  \@floatplacement
  1. The trailing \vskip -\dbltextfloatsep is inside the box, so \ht\@currbox is the material's natural height less \dbltextfloatsep, with zero depth (the last list item is glue). \@colht then loses \ht\@currbox + \dbltextfloatsep — the natural height exactly. One number, and it is also the distance the columns move down, because \@combinedblfloats (21019) stacks the box, \vskip\dbltextfloatsep and the two-column box in a single \vbox to\textheight. pdflatex's own \showoutput on article-twocolumn: \vbox(686.56499) = \vbox(108.18784) + 12 − 12 + 20 + \hbox(558.37715).
  2. Both columns of the page are shortened. \@outputdblcol reaches \@outputpage — whose last act is \global\@colht\textheight — only after the second column, and \@opcol ends with \@floatplacement, which recomputes \@toproom, \@botroom and \@fpmin from whichever \@colht is in force. So the float placement in column 2 of page 1 also sees the reduced height.
  3. \ht\@currbox is capped at \textheight, and \@colht < 2.5\baselineskip is a named LaTeX warning with \@emptycol. Both are now reported rather than guessed at.
  4. \global\@dbltopnum\m@ne bars any full-width float from the page a spanning title opened.

Two more things \@makecol does that floatpage did not:

  • It has one shape. floatpage packed \vbox to\@colht only for a column carrying footnotes and placed every other column at natural size — so a \flushbottom column (\if@twocolumn \sloppy\flushbottom\fi) never stretched its glue. Under \raggedbottom the \@textbottom fil keeps the natural positions, so single-column documents are unchanged.
  • It contributes \skip\footins, the \footnoterule and the notes only \ifvoid\footins\else. Without notes the \vskip-\@outputbox@depth lands right after the body, so the body's last depth is outside \@colht.

Those two were worth 3.726bp and 0.485bp of drift per paragraph.

figure* (second commit)

\@float is \@dbflt \if@twocolumn (17419), and \@xdblfloat sets \hsize\textwidth \linewidth\textwidth, defaults to [tp], and leaves the box depth at 1sp. That depth is the whole dispatch: \@testwrongwidth (21187) compares it with \f@depth, which is \z@ everywhere except inside \@dblfloatplacement — so a full-width float is refused by \@addtocurcol, \@addtonextcol and \@startcolumn's \@tryfcolumn, and only \@addtodblcol (21280) takes it, into the next page's \@dbltoplist. Each accepted box costs \@colht its height plus \dbltextfloatsep (the first) or \dblfloatsep — the same spanning-area arithmetic as the title, so the shift generalises unchanged. \@startdblcolumn tries \@tryfcolumn first (\@fpmin \dblfloatpagefraction\textheight) and \@doclearpage's two-column branch flushes the rest the same way.

LengthEnv grows a line_width beside text_width, because in a two-column document style.text_width_pt is \columnwidth and the two were conflated: \textwidth is the whole block, \linewidth/\columnwidth/\hsize follow where the key is read.

Per-document, flashtex-render vs each fixture's committed reference.pdf

Page-1 median dy of matched words (words aligned by an LCS over their text, so a page whose material moved still aligns). Control built from cc3232b4 in the same cargo target directory as the branch build.

document page main cc3232b4 branch pages (ours / pdflatex)
article-twocolumn 1 +37.057 bp +4.257 bp 2 / 2 (unchanged)
article-twocolumn 2 −241.570 bp +0.010 bp (0 of 21 lines over 0.1pt)
conf-paper 1 −118.696 bp −0.000 bp (0 of 79 lines over 0.1pt) 3 → 4 / 4
conf-paper 2 −246.718 bp +0.000 bp (mean |dy| 0.323pt)
conf-paper 3 +63.761 bp −0.000 bp
conf-paper 4 (page did not exist) −0.069 bp, 24/25 words

Corpus page-count match against the references: 19/22 → 20/22.

Overfull verdict

  • conf-paper's 2.25pt overfull_vbox on page 1 — the extra head line the abstract fix added — is gone. It was a column set at natural size where pdflatex shrinks its glue (\vbox(449.79996), glue set −0.59065); packing every column through \@makecol removes it.
  • plain-article and thesis-chapter each lose an overfull_vbox too, from the same change.
  • No document gains one. article-twocolumn briefly gained a 12.03pt one from an intermediate state; it is not present here.

Fixtures

fixtures/twocolumn-title/, generated by tools/twocolumn-title-oracle/generate.py with TeX Live 2025 on this Linux host (pdfTeX 3.141592653-2.6-1.40.27), like fixtures/float-notes/ and unlike the MacTeX 2026 data under fixtures/footnotes/ and fixtures/floats/. No TeX runs in cargo.

fixture words page count
01-title-no-floats 852/852 2/2
02-title-top-float ([t] float on page 1) 957/957 2/2
03-title-float-too-large (too tall for the shortened column) 1075/1075 2/2
04-title-figure-star (full-width float beside the title) 1072/1072 2/2

All within 0.007bp in x and baseline; every image rectangle matched.

Gates

amsmath 59/59 · tabular 106/106 · float-notes 10/10 · floats 10/10 · float-body 11/11 · footnotes 35/39 (unchanged) · page-frame 11/11 · toc 11/11 · twocolumn-title 4/4 · HW1 and HW2 3 pages each via flashtex-render, 0 errors, 0 overfull · full render-pipeline suite green. Zero font-failure diagnostics with FLASHTEX_FONT_DIRS/FLASHTEX_TFM_DIRS set. Nothing else in the corpus changes status, page count or diagnostics.

article-twocolumn's bytes changed deliberately in #376; the further change here is the one #376's reasoning predicted.

What remains

  • article-twocolumn page 1, +4.257bp, is now line breaking and \cite, not page layout: we set [1,2] where pdflatex sets [1, 2] (cite is recognised but not implemented), and column 1 breaks …in force at its / first character… where pdflatex breaks …in force at its first / character…. Column 2 matches pdflatex exactly to the last line of the page.
  • conf-paper page 2 carries a uniform 0.06bp offset in column 2 — below a tenth of a point, above the harness's 0.1pt reporting threshold on 30 of 93 lines.
  • [p]-only full-width floats reach \@doclearpage's flush rather than \@startdblcolumn's mid-document \@tryfcolumn in every case; the code path exists but no fixture exercises the mid-document one.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 2 commits September 14, 2026 10:21
On main a spanning title with floats on the page drew the full-width title
and then set the column material *inside* it: `let shift = if
floats.is_empty() { height } else { 0.0 }`, plus a warning saying the float
path did not shorten the columns. Removing the condition alone is not the
fix -- the shift and the shortening are one number and both have to reach
the float placer.

\@topnewpage (latex.ltx 20466-20505) boxes the optional argument at
\hsize\textwidth with a trailing \vskip -\dbltextfloatsep, so \ht\@currbox
is the material's natural height less \dbltextfloatsep; it then subtracts
\ht\@currbox + \dbltextfloatsep -- the natural height exactly -- from
\@ColhT, \vsize and \@colroom, and ends with \@floatplacement, which
recomputes \@toproom, \@botRooM and \@fpmin from that reduced \@ColhT.
\@combinedblfloats (21019) stacks the box, \vskip\dbltextfloatsep and the
two-column box in one \vbox to\textheight, so the columns start the same
natural height down that \@ColhT lost. Both columns of the page are
shortened, because \@outputdblcol reaches \@outputpage (\global\@ColhT
\textheight) only after the second one. Read off pdflatex's own \showoutput:
\vbox(686.56499) = \vbox(108.18784) + 12 - 12 + 20 + \hbox(558.37715).

So floatpage::paginate takes short_cols/short, Placer::set_colht drops
\@ColhT for those columns and restores \textheight afterwards, and a float's
graphics -- display-list items the placer had already put in page
coordinates, unlike its caption lines -- take the same shift as the column
they belong to. \@topnewpage's cap (\ht\@currbox > \textheight) and its
"Optional argument of \twocolumn too tall" case are reported, not guessed at.

\@makecol does not have two shapes, so floatpage no longer has two either:
every column is packed \vbox to\@ColhT through pagebuild::make_column, not
only a column carrying footnotes. That is what makes a \flushbottom column
(\if@twocolumn \sloppy\flushbottom\fi) stretch its glue instead of standing
at natural size; under \raggedbottom the \@textbottom fil keeps the natural
positions, so single-column documents are unchanged. make_column in turn
contributes \skip\footins, the \footnoterule and the notes only
\ifvoid\footins\else: without notes the \vskip-\@outputbox@depth lands right
after the body, so the body's last depth is outside \@ColhT. Those two were
worth 3.726bp and 0.485bp of drift per paragraph on the new fixtures.

fixtures/twocolumn-title (TeX Live 2025 on this Linux host, like
fixtures/float-notes): the title alone 852/852 words, with a [t] float on
page 1 957/957, with a float too large for the shortened column 1075/1075 --
all within 0.007bp, page counts exact. 04-title-figure-star is REPORTED, not
gated, until the next commit: figure*/table* still reach the placer as
single-column floats.

flashtex-render vs each fixture's committed reference.pdf, page-1 median dy
of matched words (control built in the same target directory, from
cc3232b): article-twocolumn +37.057bp -> +4.257bp, page 2 -241.570 ->
+0.010; conf-paper -118.696bp -> -0.000 (0 of 79 lines over 0.1pt), page 2
-246.718 -> -0.001. conf-paper's 2.25pt overfull_vbox on page 1 is gone, and
so are plain-article's and thesis-chapter's; article-twocolumn's
unsupported_block warning is gone. No other corpus fixture changes status,
page count or diagnostics.

Gates: amsmath 59/59, tabular 106/106, float-notes 10/10, footnotes 35/39
(unchanged), HW1 and HW2 3 pages each via flashtex-render with no error and
no overfull, render-pipeline suite green.

Implementation-Agent: engine-engineer (Claude Opus 5), linux-primary
Commit-Executor: engine-engineer (Claude Opus 5), direct git under the
  observed-Cursor-limit fallback

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
conf-paper was a page short of pdflatex and the named cause was its
figure*: floats.rs mapped `figure*` to a plain FloatKind::Figure, so
\linewidth inside it resolved to \columnwidth (243.911pt) where pdflatex
uses \textwidth (505.89pt), and the float was then placed in a column.
Widening the box alone would have put a 505pt box in a 243pt column; the
width and the placement are the same mechanism, and it is the one
\@topnewpage already uses -- the page's spanning top area.

\@float is \@dbflt \if@twocolumn (latex.ltx 17419). \@xdblfloat (17555)
sets \hsize\textwidth \linewidth\textwidth, defaults the placement to [tp]
rather than [tbp], and leaves the box depth at 1sp. That depth is the whole
dispatch: \@testwrongwidth (21187) compares \dp\@currbox with \f@depth,
which is \z@ everywhere except inside \@dblfloatplacement, so a full-width
float is refused by \@addtocurcol, \@addtonextcol and \@startcolumn's
\@tryfcolumn, and only \@addtodblcol (21280) takes it.

That routine runs from \@startdblcolumn, after \@outputpage restored
\global\@ColhT\textheight -- so it is once per page, never the page the
float was written on, and its \@dbltoproom is \dbltopfraction of the full
text height with \@textmin the rest. Each accepted box costs \@ColhT its
height plus \dbltextfloatsep (the first) or \dblfloatsep, which is exactly
the stack \@combinedblfloats (21019) builds above the columns, so the
existing short_cols/short shift generalises to it unchanged. \dblfigrule is
\relax in the kernel (21579). \@startdblcolumn tries \@tryfcolumn first,
with \@fpmin \dblfloatpagefraction\textheight, and \@doclearpage's
\if@twocolumn\if@firstcolumn branch flushes what is left the same way: a
full-width float page takes every column slot of its page, and a
half-finished page is closed with \@emptycol first.

The box itself is built in a second Context over a \textwidth stylesheet
and adopted, the route multicol already takes for a column's own \hsize --
Context::style is a shared reference and every block builder measures from
it. LengthEnv grows a line_width beside text_width so \textwidth keeps
meaning the whole block while \linewidth/\columnwidth/\hsize follow where
the key is read; in a two-column document style.text_width_pt is
\columnwidth, so the two were conflated before.

conf-paper now sets 4 pages like pdflatex, with the figure* on a full-width
float page of its own: page 1 median dy -0.000bp (0 of 79 lines over
0.1pt), page 3 -0.000, page 4 24/25 words matched at -0.069bp. Corpus
page-count match against the references 19/22 -> 20/22 (the two remaining
misses, thesis-chapter and twelvept-plain, are untouched by this).
04-title-figure-star is now gated: 1072/1072 words and its image rectangle
within 0.007bp. Not modelled: nothing here changes a one-column document,
where the star does nothing at all.

Gates: amsmath 59/59, tabular 106/106, float-notes 10/10, floats 10/10,
float-body 11/11, footnotes 35/39 (unchanged), page-frame 11/11,
twocolumn-title 4/4, HW1 and HW2 3 pages each via flashtex-render with no
error and no overfull, render-pipeline suite green. No corpus fixture
regresses; plain-article and thesis-chapter each lose an overfull_vbox.

Implementation-Agent: engine-engineer (Claude Opus 5), linux-primary
Commit-Executor: engine-engineer (Claude Opus 5), direct git under the
  observed-Cursor-limit fallback

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
… model

The previous commit's "not modelled" note was stale the moment it was
written: `\@startdblcolumn`'s `\@tryfcolumn` *is* implemented, so a `[p]`
full-width float does get a double float page. The case that really is not
modelled is narrower -- a page that takes a `\@dbltoplist` box and whose
first column `\@startcolumn` then fills with a single-column float page.
LaTeX still combines the spanning boxes when that page ships; here the
spanning area is attached to the next ordinary column. It needs a deferred
`[p]` float and a deferred `figure*` at the same page boundary, which no
fixture reaches, and guessing at it would be worse than saying so.

Comment only; no behaviour change.

Implementation-Agent: engine-engineer (Claude Opus 5), linux-primary
Commit-Executor: engine-engineer (Claude Opus 5), direct git under the
  observed-Cursor-limit fallback

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar merged commit e3fa43e into main Sep 14, 2026
9 of 20 checks passed
@GoKubar
GoKubar deleted the agent/engine-twocolumn/topnewpage branch September 16, 2026 04:17
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
…sh-tex#746 follow-up)

What changed:
- columns::ColumnMode::top_material finds the optional argument of a
  \twocolumn that IS the document's first material (the only place
  \@topnewpage can run: it opens with \@nodocument), matching the ] the
  way TeX matches a delimited parameter -- at brace level zero.
- adapter::split_top_material cuts that material out of the block stream,
  character by character so the [ and ] glued to the words go with them,
  and carries it on Doc::top_material. It refuses, leaving flash-tex#746's
  behaviour and its report in place, when the material cannot be cut
  exactly (page-level material, another document, a non-paragraph block
  across a bracket).
- typeset::top_material_box sets it in \@topnewpage's box: a sub-Context
  at \textwidth (Context::box_blocks is already \@parboxrestore), then
  natural_box for the \vbox height TeX gives a list that ends in glue --
  the last line's depth counts, which is the \vskip -\dbltextfloatsep.
  It feeds the existing top_title plumbing, so the page-1 shortening,
  the shift and the float interaction are flash-tex#382's, unchanged.
- style: \raggedbottom/\flushbottom and \sloppy follow the class OPTION,
  not \if@twocolumn. article.cls 631-640 runs them once, as the last
  thing \documentclass does; the \twocolumn command runs long afterwards.

What was run:
    cargo test --lib
    test result: ok. 176 passed; 0 failed; 1 ignored; 0 measured
    cargo test --test twocolumn_banner
    test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured
    cargo test --test twocolumn_command --test twocolumn_title_oracle \
               --test maketitle_empty_author --test page_frame
    test result: ok. 7 passed; 0 failed
    test result: ok. 1 passed; 0 failed
    test result: ok. 1 passed; 0 failed
    test result: ok. 1 passed; 0 failed

Oracle (/Library/TeX/texbin/pdflatex, pdfTeX 3.141592653-2.6-1.40.29,
glyph origins via PyMuPDF), 33 probes at 10/11/12 pt: every glyph of
every page within 0.194 bp of pdflatex (worst case a \Large banner at
12 pt; all others within 0.086 bp).

Next step: PR, then the remaining \@topnewpage gaps (a sectioning
command in the argument, \@dbltopnum's deferral of later full-width
floats).

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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