Skip to content

render-pipeline: \twocolumn is a command, so two-column mode is state (#743) - #746

Merged
d-q222 merged 6 commits into
mainfrom
agent/daniel-parent/twocolumn-command
Sep 17, 2026
Merged

d-q222 merged 6 commits into
mainfrom
agent/daniel-parent/twocolumn-command

Conversation

@d-q222

@d-q222 d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

What

Stacked on #738 (agent/daniel-parent/trivlist-pkgs), which is stacked on #728 → #722 → #712. Closes the structural half of #743: \twocolumn and \onecolumn are commands, so two-column mode is state the document sets, not a property of \documentclass. The \twocolumn[<material>] full-width banner and a per-page frame are the stacked follow-up.

The class option was read directly in nine places, and none of them could have been patched into covering the command. Listed before anything was changed:

site what it read now
class-geometry/src/geometry.rs:1142-1144, lib.rs:192-194 options.twocolumn → LayoutFlags unchanged: this is where the flag starts
class-geometry/src/class.rs:354, 392, 412, 459 o.twocolumn → \parindent, \textwidth, \marginparsep, \leftmargini unchanged, and that is the fix: the option is read by size1<n>.clo while the class loads; the commands run long afterwards and change none of them
class-geometry/src/frame.rs:74-75 flags.twocolumn → the column list factored into frame::columns, so the list can be rebuilt when the flag changes
render-pipeline/src/abstractenv.rs:185 (branch, and end_is_endtrivlist through it) g.options.twocolumn style.columns.at(document, offset) — asked per abstract
render-pipeline/src/adapter.rs:5089 (gap_has_trivlist_end) the hoisted boolean above asked at the \end{abstract} it actually found
render-pipeline/src/style.rs:309, 311 doc.flags.twocolumn → \raggedbottom, \sloppy unchanged: flags now follows the command
render-pipeline/src/floats.rs:716 frame.columns.len() > 1 unchanged: derived, so it follows
render-pipeline/src/typeset.rs:7794 (n_columns, the \twocolumn[\@maketitle] branch) g.frame.columns.len() unchanged: derived, so it follows
render-pipeline/src/toc.rs:367 (twocolumn_class) a raw source re-scan of \documentclass[...] left alone — it asks a genuinely class-scoped question (report/book \tableofcontents wraps the list in \onecolumn \if@twocolumn), and it is one of three ad-hoc re-implementations of adapter::class_options; merging those is its own cleanup
render-pipeline/src/typeset/multicol.rs:252 a third raw source re-scan of the same option same
compiler/src/parser.rs:4353 option_list.contains("twocolumn") for multicol's warning unchanged: that warning really is about the option

Where the state lives. ResolvedDocument.flags is already the \if@... set and is already mutated by \usepackage[twocolumn]{geometry} (geometry.rs:719-726), so it is the existing mechanism, not a parallel one: ResolvedDocument::set_twocolumn sets \if@twocolumn, \col@number and \columnwidth and stops there. For positions, the new render-pipeline::columns reuses the shape the pipeline already uses for the body commands the compiler discards (adapter::body_commands → ChromeEvent): scan the source, keep the byte offsets, fold them in document order. Stylesheet::columns carries it, and abstractenv::branch / end_is_endtrivlist take (document, offset).

The observable behaviours were measured, not guessed (/Library/TeX/texbin/pdflatex, pdfTeX 3.141592653-2.6-1.40.29, glyph origins via PyMuPDF):

  • The command does not do what the option does. \twocolumn in a 10pt article keeps \textwidth at 345pt — the text block still starts at x = 133.768 bp where the option gives 72.0 — and keeps \parindent at 15pt where the option gives 1em (9.963 bp). Its columns are at 133.768 and 310.605 bp, a step of 176.837 bp = \columnwidth + \columnsep of the one-column \textwidth. Reusing the option's path would have been wrong by 61.768 bp horizontally.
  • Both commands start a new page, because both open with \clearpage — including in a two-column document, where \newpage only ends the column. All four combinations measured; the \newpage control still ends the column. So they join PAGE_BREAKS and, unlike \newpage, clear_page_blocks.
  • \twocolumn[<material>] sets its argument at the full \textwidth above the columns and the columns start below it (10pt: banner baseline 149.658, columns from 243.155 on the new page). Deferred, and reported.

What is deliberately not done, and is reported rather than approximated. The page frame is still one frame for the whole document, so a switch after the first material sets every \if@twocolumn test and its own page break but cannot change the column count of the pages (twocolumn_mid_document); and \twocolumn[<material>]'s box is not built, so the material is set in the column with its brackets (twocolumn_top_material). A switch that changes nothing says nothing.

The compiler knows the commands now too, in the preamble and the body, emitting the same Block::PageBreak as \clearpage. That cannot reach this PR's own output — flashtex-cli and render-pipeline both build against the pinned render-pipeline/vendor/compiler, which still reports them as unknown — so the pipeline supersedes that diagnostic the way it already supersedes abstract's. The compiler change is the right home for it and lands whenever vendor/ is re-pinned.

Why

#743 said the fix could not be a list: abstractenv::end_is_endtrivlist keyed on class options, so no amount of adding \twocolumn to tables would have reached it. It was right, and the audit found the option read directly in nine places rather than one. The split that made the fix small was already in the codebase and unused: ClassOptions (what \documentclass asked for, which fixed the dimensions) versus LayoutFlags (the \if@ flags, which the document may change). Putting the commands into LayoutFlags alone is what makes the measured 61.768 bp horizontal difference between the command and the option come out right for free.

Overlap check

Test results

cargo test --test twocolumn_command
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.31s

Oracle, the issue's own repro (\twocolumn, an abstract, a \trivlist beside it) at 10/11/12 pt, engine vs pdflatex, in bp:

boundary 10 pt 11 pt 12 pt
\end{abstract}\begin{itemize} before 21.918 25.504 27.397
after 19.925 22.516 24.409
pdflatex 19.925 22.516 24.409
\end{abstract}\begin{lstlisting} before 23.910 28.493 32.379
after 17.932 19.527 20.424
pdflatex 17.932 19.527 20.424

(The second row is the issue's 5.977 / 8.966 / 11.955 bp: read as one-column, the abstract is a \small quotation whose \endlist adds \small's \topsep + \partopsep — 6/9/12 pt — that the two-column branch never has.) Every baseline of both documents at all three sizes is now within 0.0006 bp of pdflatex; the one remaining ** in the sweep is the lstlisting body's x, 0.9-1.07 bp, which is identical under the class option on the base and is listings' own declared gap, not this change.

Full crate --no-fail-fast on the branch and on the base (54bfdd98, #738's head) built identically, with the individual test <name> ... <result> lines diffed rather than the totals:

501 result lines on base, 513 on branch
only in base:   (none)
only in branch: the 12 new tests (6 columns:: unit tests, 6 twocolumn_command)
18 FAILED lines on base, 18 on branch — the same 13 test names, all
   pre-existing, all panicking at adapter.rs:1308 (the stale vendor/compiler
   pin). They disappear under --release because debug_assert is compiled out,
   so a green release run is not evidence about them.

(The diff was taken at 71f195c; the_abstract_to_lstlisting_boundary_follows_the_command_too was added in 0896139 afterwards and is a 13th new passing test, additive.)

HW1/HW2 and the real-world corpus: every fixture under fixtures/real-world/ rendered with the base binary and the branch binary and the glyph origins diffed — 80 296 glyph lines over 20 renderable fixtures plus HW1's 3 285, 0 differences. conf-paper and article-twocolumn (the two [twocolumn] class-option fixtures) are byte-identical, which is the control that says the option path did not move. HW2 ships only a reference PDF, so there is nothing to render.

crates/class-geometry: cargo test --no-fail-fast — all suites ok, 0 failed

Not done

  • \twocolumn[<material>]'s full-width \@topnewpage box, the stacked follow-up. Measured here so the next PR has its numbers (10pt: banner at 133.768/149.658 across the full 345pt \textwidth, columns from 243.155). Today the material is set in the first column with its brackets, as it was before, now under twocolumn_top_material instead of an "unknown command" error.
  • A per-page frame, so a switch after the first material changes the column count of the pages it opens. The page break and every \if@twocolumn test are already right there; only the frame is not. Reported as twocolumn_mid_document.
  • \twocolumn inside an \input file is not scanned — the same limitation adapter::body_commands has.
  • The three ad-hoc re-implementations of \documentclass[...] option parsing (adapter::class_options, toc::twocolumn_class, multicol::scan) were found and left alone; merging them is a cleanup, not this fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

What changed:
`\end{<list>}` is `\@endparenv`'s `\addvspace\@topsepadd` and the
`\begin{<list>}` beside it is `\@trivlist`'s `\addvspace\@topsep`. Both are
`\addvspace`, so they keep the larger natural skip; the pipeline summed them.
`\@endparenv` also leaves TeX in vertical mode, so the second `\begin` is read
in vertical mode and takes `\partopsep` with no blank line in between; the
pipeline read it as horizontal mode and dropped `\partopsep`.

At 10pt that made a list/list boundary 10pt + 8pt = 18pt where pdflatex puts
max(10pt, 10pt) = 10pt. Every list after the first sat 8pt low and the error
grew 6pt at each further boundary (4 adjacent lists: +7.971, +13.948,
+19.925 bp).

The environment never mattered: `itemize`, `enumerate` and `description` are
all `\list` with `\@listI`'s skips, and `list_seps_from` does not branch on the
name for vertical spacing. #706 saw only `itemize` match because `itemize` came
first in its fixture.

New `tests/adjacent_list_skips.rs` pins the adjacency coverage #705's oracle
left out: all six orderings of the three environments, all nine ordered pairs,
four of a kind and a mixed chain of four, plus the `\topsep`-only vs
`\topsep`+`\partopsep` pair that separates the two lengths.

What was run:
  cargo test -p render-pipeline --test adjacent_list_skips
    test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  same test on unfixed origin/main (dbe3cac), to show it catches the bug:
    test result: FAILED. 1 passed; 3 failed; 0 ignored; 0 measured
    ied: bravo: 164.653 bp, pdflatex 156.682 bp (+7.970)
  28-document pdflatex sweep (MacTeX 2026, PyMuPDF glyph origins), engine vs
  pdflatex: worst |dy| = 0.0001 bp, worst |dx| = 0.0379 bp, all within 0.5 bp.

Next step:
Full `cargo test -p render-pipeline` diffed against origin/main for regressions.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…two (#712 follow-up)

What changed:
#712 fixed the list-to-list boundary. Neither half of that fix was about
lists: `\@endparenv` is what every `\endtrivlist` ends with, and article.cls
builds `center`/`flushleft`/`flushright` as `\trivlist \centering \item\relax`,
`quote`/`quotation`/`verse` as `\list{}{...}\item\relax`, and amsthm builds a
theorem as a `\trivlist`. Measured against pdflatex, three boundaries were off:

  * `\end{<list>}` then `\begin{center|quote|quotation|verse|<theorem>}` summed
    the list's closing `\@topsepadd` onto the environment's opening `\@topsep`:
    10pt + 8pt = 18pt where pdflatex puts max(10, 10) = 10pt, +7.971 bp;
  * `\end{<theorem>}` then any `\trivlist` environment, and every pair the
    pipeline reads as one `ParaStyle` run (`center`/`center`, `quote`/`verse`,
    ...), was read in horizontal mode and dropped `\partopsep`: -1.992 bp;
  * both accumulated. Six `center`s drifted -1.992/-3.985/-5.978/-7.970/-9.963
    bp; alternating `center`/`itemize` drifted +5.978/+3.985/+9.963/+7.970 bp.

`gap_has_trivlist_end` extends #712's "the previous `\end` left vertical mode"
test from the four `LIST_ENVS` to every `\trivlist`-derived environment, and
feeds both the list `\begin`'s `list_vmode` and the styled `\begin`'s
`EnvOpen::vmode`. In `typeset`, the environment's own opening `\addvspace`
now resolves against the `\lastskip` that `addvspace_before` already raised,
instead of being added on top of it -- `\@xaddvskip` keeps the larger skip
whole, so its flex comes with it and the other's does not.

An amsthm theorem is the one case that legitimately steps by `\topsep` alone:
`\@thm` assigns `\@topsep`/`\@topsepadd` from `\thm@preskip`/`\thm@postskip`,
so it never takes `\partopsep`. Two adjacent theorems stay 19.925 bp apart and
that is pinned, so this fix does not sweep them up.

Pipeline-only, as #706/#712 were: nothing under vendor/ changed, no re-pin.

What was run:
  cargo test --test vmode_boundary_skips
    test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  the same test on the unfixed base (6763a09, #712 head):
    test result: FAILED. 2 passed; 4 failed; 0 ignored; 0 measured
    thm -> itemize (adjacent): bravo: 154.690 bp, pdflatex 156.682 bp (-1.993)
    itemize -> center: bravo: 164.653 bp, pdflatex 156.682 bp (+7.970)
    center -> center: bravo: 154.690 bp, pdflatex 156.682 bp (-1.993)
    ["center" x6]: bravo: 154.690 bp, pdflatex 156.682 bp (-1.993)
  cargo test --no-fail-fast, this branch:  479 passed; 13 failed
  cargo test --no-fail-fast, base 6763a09: 473 passed; 13 failed
    same 13 names both sides (frame_env, letter_class_geometry x5, uline x2,
    underline_sout x3, xcolor_oracle x2); +6 passed is this commit's new test.
    0 new failures. hw2_sets_three_pages_with_the_reference_breaks ... ok
  pdflatex oracle: MacTeX 2026 pdfTeX 1.40, 10pt T1 Latin Modern, PyMuPDF
    glyph origins; 101 probe documents (pairs both directions with and without
    a blank line, six-deep chains, solo/paragraph/blank-line controls).

Next step:
None; the boundary is measured in both directions and the chains are flat.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…722 follow-up)

What changed:
#722 closed the \trivlist boundary for center/flushleft/flushright/quote/
quotation/verse and every \newtheorem, and left two gaps open on purpose:
`verbatim` and `abstract` are \trivlist-derived too but were never measured,
so they were deliberately not added to TRIVLIST_ENVS; and only the 10 pt base
size was swept. Both are now measured, over 918 probe documents against
pdflatex at 10/11/12 pt. Three of the four things a "they're all trivlists"
guess would have predicted were already right; the two real bugs differ:

  * verbatim diverged only where the pipeline reads the pair as one
    ParaStyle run. \@verbatim is `\trivlist \item\relax ...` and
    \endverbatim is \endtrivlist, so \end{verbatim} leaves vertical mode and
    the next \begin takes \partopsep: verbatim/verbatim and
    verbatim/flushleft were short by exactly that, -1.992 bp at 10 pt and
    -2.989 bp at 11 and 12 pt, accumulating to -9.963 bp over six
    verbatims. verbatim against center/quote/quotation/verse/flushright, a
    theorem or any list was already right in both directions.
  * abstract diverged on both sides, for two different reasons.
    \end{abstract} is \endquotation -> \endlist -> \endtrivlist, and what
    followed it was short by one \partopsep (-1.992/-2.989/-0.996 bp). The
    other direction is not a TRIVLIST_ENVS problem: the pipeline inserts the
    \small \abstractname head as a block in front of the body the compiler
    produced, and the boundary skip the compiler had hung on that body
    stayed there and fired a second time below the head, so
    \end{itemize}\begin{abstract} was +5.305/+5.729/+6.273 bp long.
    \end{center}\begin{abstract} was already right, because a center's
    closing skip rides on its own env_close rather than on the next block.

TRIVLIST_ENVS gains verbatim, verbatim* and abstract; `take_lead` moves the
abstract body's leading skip to the head that now occupies its position.

No boundary diverged only at 11 pt or 12 pt, so the size sweep found no third
bug -- but it did find one boundary that is not size-invariant at all, which a
10 pt-only sweep would have pinned as a single rule:
\end{abstract}\begin{thm} is \topsep-only at 10 pt and 11 pt but 26.401 bp at
12 pt, because the abstract's \@topsepadd was fixed inside \small (6/9/12 pt)
while a theorem opens with \thm@preskip = \normalsize's \topsep (8/9/10 pt)
and no \partopsep, and which \addvspace wins changes with the class option.
That is pinned as its own constant.

Pipeline-only, as #706/#712/#722 were: nothing under vendor/ changed, no
re-pin.

What was run:
  cargo test --test vmode_boundary_skips
    test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  cargo test --test abstract_env
    test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  cargo test --no-fail-fast, this branch:  480 passed; 13 failed (107 suites)
  cargo test --no-fail-fast, base 237b95f: 479 passed; 13 failed (107 suites)
    diffing every `test <name> ... <result>` line between the two runs gives
    exactly one line, the added
    an_abstract_shares_one_addvspace_with_the_environment_on_either_side ...
    ok. Same 13 failures both sides (every_line_is_where_pdflatex_put_it,
    letter_class_geometry x3, the_raggedleft_group_closes_no_trivlist,
    shared_colorbox_path_draws_border_with_content_inside, uline x2,
    sout/underline x4, xcolor_fixtures_match_pdflatex) -- the known
    adapter.rs:1308 vendor/compiler pin. 0 new failures.
    hw2_sets_three_pages_with_the_reference_breaks ... ok on both.
  pdflatex oracle: MacTeX 2026 pdfTeX 1.40, T1 Latin Modern, PyMuPDF glyph
    origins; 918 probe documents at the 10pt/11pt/12pt article base sizes
    (every ordered pair of 9 shapes x 12 partners, with and without a blank
    line, six-deep chains, solo/paragraph/blank-line controls), plus nine
    twocolumn probes.

Next step:
Two measured divergences are left and deliberately not fixed here, both
documented at the top of tests/vmode_boundary_skips.rs: a \begin{abstract} on
the line directly after body text is not recognised at all (the compiler does
not break the paragraph there, so it needs a vendor/ change and a re-pin),
and the twocolumn branch sets an abstract body after a list 3.985/4.483/4.981
bp low -- base and branch print byte-identical baselines for all nine
twocolumn probes, so that one is untouched by this commit.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ow-up)

What changed:

#728 left four things explicitly unmeasured. All four are measured now, over
1482 further probe documents against pdflatex, and nothing was added to
TRIVLIST_ENVS for looking like a \trivlist.

* `lstlisting` (listings) diverged twice and is *not* a \trivlist: `\lst@Init`
  opens no list. What it has is a `\par` and a `\vspace` at each end, and both
  were read as nothing. `\end{lstlisting}\begin{<trivlist>}` dropped
  `\partopsep` (-1.993/-2.989/-2.989 bp at 10/11/12 pt) because
  `\lst@DeInit`'s `\par` leaves vertical mode as `\@endparenv`'s does — a new
  `VMODE_END_ENVS`, deliberately kept apart from TRIVLIST_ENVS, since
  `\end{lstlisting}\begin{thm}` was right all along.
  `\end{<list>}\begin{lstlisting}` lost the whole closing `\@topsepadd`
  (-9.963/-11.955/-12.951) because `listings` zeroed the block's
  `addvspace_before` along with the `flushleft` lowering, although
  `\lst@Init`'s skip is a `\vspace` that adds to it rather than competing.
  The same after `flushleft` and `verbatim`, where the pair reads as one
  `ParaStyle` run and the closing skip is never materialised at all.

* `Verbatim` (fancyvrb) and `alltt` are unimplemented and are left alone. The
  engine says so itself ("packages fancyvrb are recognised but not
  implemented"); measured, six `alltt` blocks land on one baseline (-21.917
  bp by the second, -109.589 by the sixth at 10 pt). There is no \trivlist
  there to give a boundary skip to, so no test pins a number for them.

* `report` and `book` measure exactly like `article` over the whole 8x8
  boundary matrix at all three sizes, `lstlisting` included; `\@listI` does
  not differ by class. `book` differs only in its first baseline. The two
  class exceptions are outside a boundary and already declared: book.cls has
  no `abstract`, and `report`'s default `titlepage` branch sets one on a page
  of its own (head 317.407 bp, body 339.325, following material on the next
  page), which `abstractenv::Branch::TitlePage` does not set.

* No boundary in this scope is size-dependent, and not by luck: both listings
  skips are `\vspace`s, so nothing competes for a class option to flip.
  Forcing `belowskip` to 4, 9 and 20 pt still measures a plain sum at all
  three sizes.

The two-column `abstract` #728 filed is fixed rather than filed again. It was
one line of #728's own argument: `\if@twocolumn`'s head is a `Block::Heading`,
which has no `addvspace_before`, so `take_lead` fell out of its `let else` and
left the list's `\@topsepadd` below the head to fire there (+3.985/+4.483/
+4.981 bp). `\@startsection`'s negative before-skip has already spent it above
the head — pdflatex puts the head the same distance below an `itemize`, a
`center`, a `verbatim`, a theorem and a plain paragraph — so it is dropped,
with a real `\section*{Abstract}` in the same position as the control.

The same sweep caught a regression #728 introduced: `abstract` went into
TRIVLIST_ENVS unconditionally, but article.cls 386 closes the environment with
`\if@twocolumn\else\endquotation\fi`, so a two-column `\end{abstract}` expands
to nothing. Every two-column `\end{abstract}\begin{<trivlist>}` was one
`\partopsep` long (1.992/2.989/2.988 bp) against #722, which was right.
Whether that `\end` is an `\endtrivlist` is now a class-option question
(`abstractenv::end_is_endtrivlist`), not a name lookup.

What was run:

  cargo test --test vmode_boundary_skips
  test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 8.55s

  full crate --no-fail-fast, branch and base (a12ec1d) built identically,
  `test <name> ... <result>` lines diffed rather than totals:
  497 lines on base, 501 on branch; 0 lines changed, 4 added, all ok:
    test a_lstlisting_boundary_is_the_neighbour_skip_plus_listings_own|ok
    test a_two_column_abstract_is_a_section_head_and_its_end_is_not_a_trivlist|ok
    test report_and_book_share_the_class_boundary_skips|ok
    test the_listings_skips_add_and_never_compete|ok
  13 failures on both, all panicking at adapter.rs:1308 (stale vendor/compiler pin).

  every glyph of all 22 renderable fixtures under fixtures/real-world/
  (HW1 and HW2 included), base vs branch: 15567 lines, 0 differences.
  listings-manual is the 23rd and panics at adapter.rs:1308 on both.

  probe sweeps against /Library/TeX/texbin/pdflatex with PyMuPDF glyph
  origins, 0.5 bp gate: 531 package documents, 891 class documents, 60
  two-column documents; every remaining divergence involves only `alltt`
  or `Verbatim`, or `report`'s titlepage `abstract`.

Next step:

  File report's `titlepage` abstract (204.560/205.624/209.875 bp plus a lost
  page break) and the `alltt`/`fancyvrb` gap as their own issues; neither is a
  boundary skip.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…#743)

What changed:
- flashtex_render_pipeline::columns: two-column mode as the class option
  plus every \twocolumn/\onecolumn the source runs, by byte offset. Every
  \if@twocolumn question is now asked at a position instead of read once
  off \documentclass.
- class-geometry: ResolvedDocument::set_twocolumn sets \if@twocolumn,
  \col@number and \columnwidth and nothing else -- measured, that is the
  whole difference between the command and the class option, which also
  doubles \textwidth and changes \parindent, \marginparsep, \leftmargini.
- abstractenv::branch / end_is_endtrivlist take (document, offset): which
  branch an abstract takes, and whether its \end is an \endtrivlist, are
  questions about the mode where it stands.
- Both commands open with \clearpage: they break the page (PAGE_BREAKS)
  and end the page rather than the column (clear_page_blocks).
- compiler: \twocolumn/\onecolumn are known commands in the preamble and
  the body, emitting the same Block::PageBreak as \clearpage. The pinned
  vendor/compiler still reports them as unknown, so the pipeline
  supersedes that diagnostic the way it supersedes abstract's.
- Not implemented and reported, not guessed: a switch after the first
  material cannot change the page frame's column count, and
  \twocolumn[<material>]'s full-width \@topnewpage box.

What was run:
  cargo test --test twocolumn_command
  test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.25s

  Oracle (/Library/TeX/texbin/pdflatex, pdfTeX 3.141592653-2.6-1.40.29,
  PyMuPDF glyph origins, 0.5 bp gate). GH#743's repro at 10/11/12 pt:
  \end{abstract} boundary 21.918/25.504/27.397 -> 19.925/22.516/24.409
  where pdflatex gives 19.926/22.516/24.409. lstlisting boundaries in the
  same document: every baseline within 0.0004 bp of pdflatex.

Next step: \twocolumn[<material>] as a full-width \@topnewpage box, and a
per-page frame so a mid-document switch changes the column count.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
… number

What changed:
- twocolumn_command: the boundary GH#743 measured as 5.977/8.966/11.955 bp
  long is \end{abstract}\begin{lstlisting} in a \twocolumn document, not a
  lstlisting-to-list one. Read as one-column, the abstract is a \small
  quotation whose \endlist adds \small's \topsep + \partopsep (6/9/12 pt)
  that the two-column branch never has. Pinned at all three sizes.

What was run:
  cargo test --test twocolumn_command
  test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.31s

Next step: the full-crate --no-fail-fast line diff against #738's head.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

@d-q222 d-q222 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent verification round 4 — VERIFIED, with one body correction

Reviewed at head 08961391; stack base 54bfdd98 (#738's head), which is what every
before/after below is measured against. Separate worktrees, separate
CARGO_TARGET_DIR (target-vr4-746, target-vr4-746base), CARGO_BUILD_JOBS=4.
Oracle: /Library/TeX/texbin/pdflatex. Nothing on the branch was modified.


1. The claim I attacked hardest: the option path did not move — it did not

Rather than re-count glyph lines, I rendered the whole v2 display list for every
fixture with both binaries and compared it byte for byte. That is strictly stronger
than diffing glyph origins: it also covers item kinds, spans, page boxes and
diagnostics.

$ cargo build --release --bin flashtex-render     # in each worktree
$ cd fixtures/real-world/article-twocolumn && flashtex-render --tex main.tex --v2 …
1315046 article-twocolumn.base.json     1315046 article-twocolumn.branch.json
3145475 conf-paper.base.json            3145475 conf-paper.branch.json

article-twocolumn: IDENTICAL
conf-paper:        IDENTICAL

Then the rest of the corpus, same method:

=== corpus: identical=20 differs=0 skipped=2 ===        (skipped: hw1, hw2 — no main.tex)
$ cd fixtures/real-world/hw1 && flashtex-render --tex HW1.tex --v2 …
hw1: IDENTICAL (1151584 bytes)

21 documents, zero differing bytes, including both [twocolumn] class-option
fixtures. The control holds: the class-option path is untouched. (I did not
re-count the 80 296 / 3 285 glyph-line totals — a byte-identical display list makes
the count moot.)


2. The four "deliberately unchanged" sites — measured against pdflatex, all four genuine

The PR leaves class-geometry/src/class.rs:354, 392, 412, 459 reading o.twocolumn
and says that is the fix, because size1<n>.clo runs at class-load time and the
command runs long afterwards. I did not spot-check one — I measured all four, in
pdfTeX directly, with \makeatletter and \typeout:

$ pdflatex "\makeatletter\input{opt.tex}"     % \documentclass[10pt,twocolumn]{article}
PROBE textwidth=469.0pt parindent=10.00002pt marginparsep=10.0pt leftmargini=20.00004pt

$ pdflatex "\makeatletter\input{cmd.tex}"     % \documentclass[10pt]{article} + \twocolumn
PROBE textwidth=345.0pt parindent=15.0pt     marginparsep=11.0pt leftmargini=25.00003pt
site quantity class option \twocolumn command differ?
class.rs:392 \textwidth 469.0pt 345.0pt yes
class.rs:354 \parindent 10.00002pt (1em) 15.0pt yes
class.rs:412 \marginparsep 10.0pt 11.0pt yes
class.rs:459 \leftmargini 20.00004pt (2em) 25.00003pt (2.5em) yes

Not one of the four is "just missed": every one of them is a quantity size10.clo
froze at class-load time and that \twocolumn provably does not touch. Routing the
command through the option's path would have been wrong in all four.

The horizontal claim checks out to the last digit too:

$ pdflatex …                                  % class option
PROBE2 oddside=0.0pt  colsep=10.0pt           -> text starts at 1in = 72.000 bp
$ pdflatex …                                  % \twocolumn command
PROBE2 oddside=62.0pt colsep=10.0pt           -> 72.27 + 62.0 = 134.27pt = 133.768 bp

133.768 − 72.000 = 61.768 bp, exactly the figure the PR gives for how wrong
reusing the option's path would have been.

And the page-break claim, measured rather than reasoned:

% A \twocolumn B \onecolumn C
Output written on pages.pdf (3 pages, 11417 bytes).
% \twocolumn ... x\newpage y\twocolumn z
Output written on cmd2.pdf (2 pages, 10785 bytes).

Both commands do open a new page; \newpage inside two-column does not. Correct.


3. The site audit — the table is right, the prose is wrong

I re-ran the audit independently on the base (54bfdd98), listing every place the
class option twocolumn is read, directly or by re-scanning \documentclass[…]:

$ git grep -n twocolumn crates/render-pipeline/src crates/class-geometry/src crates/compiler/src \
    | grep -E 'options\.twocolumn|o\.twocolumn|"twocolumn"|twocolumn_class|contains\("twocolumn'
crates/class-geometry/src/geometry.rs:1144      twocolumn: class.twocolumn,
crates/class-geometry/src/lib.rs:194            twocolumn: options.twocolumn,
crates/class-geometry/src/class.rs:354          let parindent = if o.twocolumn {
crates/class-geometry/src/class.rs:392          let textwidth = if o.twocolumn {
crates/class-geometry/src/class.rs:412          let marginparsep = if o.twocolumn {
crates/class-geometry/src/class.rs:459          let leftmargini = fm.em.scaled(if o.twocolumn { "2" } else { "2.5" })
crates/render-pipeline/src/abstractenv.rs:185   if g.options.twocolumn {
crates/render-pipeline/src/toc.rs:367           pub fn twocolumn_class(source: &str) -> bool {
crates/render-pipeline/src/typeset/multicol.rs:252   … .any(|o| o.trim() == "twocolumn")
crates/compiler/src/parser.rs:4353              if option_list.contains(&"twocolumn") {

That is ten distinct sites, and it matches the PR's own table row for row
(row 1 covers two sites, row 2 covers four). But the body's prose says nine,
twice:

"The class option was read directly in nine places, and none of them could have
been patched into covering the command."
"…the audit found the option read directly in nine places rather than one."

The table is correct and the prose is not. Worth fixing in the body — the audit is
the PR's central argument and an off-by-one in its headline number is the kind of
thing that makes a reader distrust the table underneath it. Body edit only; no code
change.


4. The tests are real regression tests

On the branch:

$ cargo test --release --test twocolumn_command
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

$ cargo test --release --lib columns
test columns::tests::comments_and_longer_names_are_not_switches ... ok
test columns::tests::a_command_after_material_is_positional_and_reported ... ok
test columns::tests::a_switch_that_changes_nothing_is_not_reported ... ok
test columns::tests::a_preamble_command_is_the_documents_column_state ... ok
test columns::tests::a_command_before_any_material_is_too ... ok
test columns::tests::onecolumn_undoes_the_class_option ... ok
test result: ok. 7 passed; 0 failed; 164 filtered out      (6 columns:: + 1 unrelated mathgrid)

Then I copied tests/twocolumn_command.rs unmodified onto the base worktree and
ran it there — a test that passes on its own base proves nothing:

$ cargo test --release --test twocolumn_command          # on 54bfdd98
test the_optional_argument_is_declared_not_implemented ... FAILED
test both_commands_start_a_new_page_wherever_they_stand ... FAILED
test a_switch_after_material_is_reported_and_one_before_it_is_not ... FAILED
test the_abstract_to_lstlisting_boundary_follows_the_command_too ... FAILED
test the_command_keeps_the_one_column_textwidth_and_parindent ... FAILED
test the_twocolumn_command_sets_the_abstract_and_its_boundary ... FAILED
test the_lstlisting_boundaries_follow_the_command_too ... ok
test result: FAILED. 1 passed; 6 failed; 0 ignored; 0 measured; 0 filtered out

Six of seven fail without the change. Genuine.


Findings

  1. PR body, "What" section — "nine places" should be "ten". The table beneath it
    already enumerates ten sites (§3); the prose contradicts it. Body edit.

  2. crates/render-pipeline/tests/twocolumn_command.rs —
    the_lstlisting_boundaries_follow_the_command_too passes on the base (§4).
    It is
    the one test in the file that does not discriminate this change, so it is
    documenting #738's behaviour rather than guarding this one. Harmless, but it
    should not be counted among this PR's regression tests. Its sibling
    the_abstract_to_lstlisting_boundary_follows_the_command_too (added in 08961391)
    does fail on the base and is the real guard for the issue's own number.

Neither is blocking. Every measured claim — 61.768 bp, the \clearpage page break,
the four frozen size10.clo quantities, and above all "the option path did not move"
— reproduced independently, the last of them byte-for-byte across 21 documents.
VERIFIED.

— independently verified by daniel-parent's review lane

@d-q222
d-q222 merged commit 0896139 into main Sep 17, 2026
21 of 22 checks passed
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