Skip to content

render-pipeline: \twocolumn[<material>] is \@topnewpage's banner (#746 follow-up) - #749

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

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

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

What

Stacked on #746 (agent/daniel-parent/twocolumn-command), which landed \twocolumn/\onecolumn as document state and deferred this. \twocolumn[<material>]'s optional argument is now set where LaTeX sets it — in a full-\textwidth box above both columns of the page the command starts — instead of in the first column with its brackets.

The kernel, read rather than approximated (latex.ltx 20466-20505, TeX Live 2026):

\long\def \@topnewpage [#1]{%
  \global \setbox\@currbox \vbox{\hsize\textwidth \@parboxrestore
                                 \col@number\@ne #1 \vskip -\dbltextfloatsep}%
  \ifdim \ht\@currbox>\textheight \ht\@currbox \textheight \fi
  \@tempdima -\ht\@currbox \advance \@tempdima -\dbltextfloatsep
  \global \advance \@colht \@tempdima ...

The trailing \vskip -\dbltextfloatsep makes \ht\@currbox the material's natural height less \dbltextfloatsep, and its depth zero (the last list item is glue). \@colht then loses \ht\@currbox + \dbltextfloatsep; \@combinedblfloats (21019) stacks the box, \vskip\dbltextfloatsep and the two-column box inside a \vbox to\textheight. The \dbltextfloatsep cancels on both sides: the columns begin exactly the material's natural height below the top of the text area and lose exactly that much height — one number, so the shift and the shortening cannot disagree. Two consequences fall straight out of that and were then measured:

  • The last line's depth counts. Because the list ends in glue, the \vbox's height includes it. Measured at 10 pt: \twocolumn[Short banner line] starts its columns at 141.683 and \twocolumn[Short banner line with a descender: jumpy.] at 143.620 — 1.937 bp apart, which is cmr10's 0.19444 em. pagebuild::natural_layout returns the last baseline, so this PR adds natural_box for the \vbox height proper.
  • \twocolumn[] is not a special case. \ht\@currbox is -\dbltextfloatsep, which the skip under it gives straight back. Measured: byte-for-byte the page a plain \twocolumn sets, at all three sizes.

Page 2 does not carry the banner. \@outputpage restores \global\@colht\textheight, and \@dbltoplist is emptied by \@combinedblfloats, so the box belongs to one page. Measured on a document that fills both columns and overflows: page 2 begins at 134.765 / 140.742 / 137.753 bp — exactly where a plain \twocolumn's page 1 begins, at 10/11/12 pt. Nothing in this PR had to model that: it reuses #382's top_title plumbing (short_cols/short → pagebuild::break_pages_regions, floatpage::Placer::set_colht), which already shortens only the first columns page-builder columns. That plumbing existed for \twocolumn[\@maketitle] and was never reachable from a literal \twocolumn[...]; this PR is mostly the work of getting arbitrary material into it.

Where the material comes from. The pinned render-pipeline/vendor/compiler reports \twocolumn as unknown and sets [<material>] as ordinary text, so the argument arrives already parsed into the column's blocks — often into the same paragraph as the body text that follows the ]. So:

step site
find the argument columns::ColumnMode::top_material — only on a \twocolumn that is the document's first material (\@topnewpage opens with \@nodocument, so a preamble one is a LaTeX error, and a later one would have to change the column count of the pages: unmodelled). The ] is matched the way TeX matches a delimited parameter — the first one at brace level zero, so \twocolumn[{\Large a]b} c] is one argument
cut it out adapter::split_top_material — block by block, part by part, item by item, and character by character inside a word, because the compiler glues the brackets to the words they touch ([Short .. line]). What follows the ] becomes a fresh paragraph with indent: true: after \@topnewpage LaTeX is in vertical mode
set it typeset::top_material_box — a sub-Context at \textwidth (the build_wide_box precedent for figure*, whose record-merging is factored out here as absorb), then Context::box_blocks, which is already \@parboxrestore: \parindent and \parskip zero, \linewidth\hsize

One measured correction to the material's own shape: \@topnewpage's \vbox starts in vertical mode, so an environment that opens the argument is a \begin read there and \@topsepadd keeps \partopsep — at both ends, since \@endparenv reads the same flag. The source scan cannot see this (what precedes the \begin is \twocolumn[), and reading it off the source lost 2 × \partopsep: 4.04 / 6.04 / 6.05 bp on \twocolumn[\begin{center}...\end{center}].

One fix that is #746's, found by this PR's oracle. style.rs read \if@twocolumn for \raggedbottom/\flushbottom and \sloppy. Those are class-load-time: article.cls 631-640 runs \if@twoside\else\raggedbottom\fi and \if@twocolumn \twocolumn \sloppy \flushbottom \fi once, as the last thing \documentclass does — so they follow the class option, exactly as \parindent and \textwidth do in #746's own table, and a \twocolumn command (or \usepackage[twocolumn]{geometry}, later still) changes neither. #746 listed that site as "unchanged: flags now follows the command", which is the wrong call. It is invisible on a page with no slack, which is why #746's fixtures did not catch it; on a two-page \twocolumn document it stretched the \parskip at each paragraph and put the foot of page 1 5.04 bp low at 10 pt. No fixture in the repo uses the \twocolumn command, and every [twocolumn] one has options.twocolumn == flags.twocolumn, so the fix moves nothing already on main.

Why

#746 measured the target and deferred the box cleanly, which is why this was tractable: the geometry was already known to be one number, and #382 had already built the machinery that applies it. What was actually missing was getting user material into a box the compiler had already flattened into the column — which is character-level surgery on the block stream, not geometry.

Overlap check

Test results

Oracle: /Library/TeX/texbin/pdflatex (pdfTeX 3.141592653-2.6-1.40.29, TeX Live 2026), glyph origins via PyMuPDF. Baselines in bp, from the top of the page, at 10/11/12 pt. before is #746's head (the argument set in the column, brackets included), after is this branch.

A one-line banner (\twocolumn[Short banner line]), first banner baseline and first column baseline:

10 pt 11 pt 12 pt
banner baseline, before no banner (the text was in the column at 134.765) no banner (140.742) no banner (137.753)
banner baseline, after 131.720 @ x 133.768 137.359 @ x 125.798 134.100 @ x 110.854
pdflatex 131.720 @ x 133.768 137.359 @ x 125.798 134.100 @ x 110.854
columns resume, before 134.765 140.742 137.753
columns resume, after 141.683 148.318 146.056
pdflatex 141.683 148.318 146.056

The other shapes, columns-resume baseline, after vs pdflatex (identical to 3 dp in every cell):

probe 10 pt 11 pt 12 pt
a descender in the banner's line 143.620 150.439 148.380
two banner paragraphs (\par) 153.638 161.867 160.501
a banner long enough to wrap (5 / 6 / 5 lines at \textwidth) 239.262 258.833 263.947
\begin{center} .. \end{center} 161.608 172.228 171.958
{\Large ...} 147.517 153.494 153.057
inline math 144.811 151.959 149.553
\twocolumn[] 134.765 140.742 137.753 (= plain \twocolumn)

Page 2 (16 paragraphs, columns overflow): the banner word appears exactly once, on page 1, and page 2's first baseline is 134.765 / 140.742 / 137.753 — the plain two-column top.

Whole-page comparison, not just the probe baselines: 33 documents (11 shapes x 3 sizes, including two 2-page ones and the no-banner controls) rendered by the engine and by pdflatex and compared glyph by glyph, page and origin: every glyph of every page within 0.194 bp (worst case the \Large banner at 12 pt); all other 32 within 0.086 bp, and the \twocolumn[] and plain-\twocolumn controls within 0.001 bp. Before the \raggedbottom fix the two-page probes were 5.04 / 5.97 / 6.14 bp out at the foot of page 1.

cargo test --test twocolumn_banner
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

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

cargo test --test twocolumn_title_oracle     (#382's \@topnewpage \maketitle oracle)
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

cargo test --test page_frame
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

cargo test --lib
test result: ok. 176 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out

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

510 result lines on base, 527 on branch
only in base:   (none)
only in branch: the 17 new tests (11 twocolumn_banner, 6 columns:: unit tests)
13 FAILED lines on base, 13 on branch — the same 13 test names, all
   pre-existing, all panicking at adapter.rs:1321 (1308 on the base; 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.

Real-world corpus: every fixture under fixtures/real-world/ rendered with the base binary and the branch binary (both --release, built identically) and the glyph origins diffed — 80 276 glyph lines over 20 fixtures, plus HW1's 3 284 and HW2's 2 962, 0 differences. conf-paper and article-twocolumn (the two [twocolumn] class-option fixtures) are identical, which is the control saying the option path did not move.

Not done

🤖 Generated with Claude Code

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
…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 #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 #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
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander independent review (a fresh Codex gpt-5.6-luna max review, given only the linked issue and the diff) plus Commander triage. The full reviewer output is quoted below the triage.

Blocking:

Follow-ups: #3 and #4 are real limitations of lexical switch scanning: definitions, and \input files. They need a design (compiler execution events), not this PR. #5 and #6 are comment-aware matching.

Pulled from batch F until the blocking items are fixed and a fresh re-review passes.

Reviewer output
  1. major — crates/compiler/src/parser.rs:3442 — Defect: \twocolumn consumes and discards its optional argument. Failure scenario: \twocolumn[Short banner line] produces no banner, so the new twocolumn_banner behavior cannot work. Confidence: 0.99. Minimal fix: preserve or explicitly parse the bracket contents into IR for render-pipeline boxing.

  2. major — crates/render-pipeline/src/adapter.rs:1208 — Defect: column scanning is initialized from the class option instead of the resolved geometry flag. Failure scenario: \documentclass{article}\usepackage[twocolumn]{geometry} is resolved by geometry as two-column, but this code starts in one-column mode. Confidence: 0.99. Minimal fix: seed the scan from the effective resolved twocolumn state.

  3. major — crates/render-pipeline/src/columns.rs:81 — Defect: switches lexically scans raw bytes without understanding macro definitions or TeX execution. Failure scenario: \newcommand{\mycolumns}{\twocolumn} changes the output to two columns even though \mycolumns is never invoked. Confidence: 0.98. Minimal fix: use compiler execution events or a token-aware scan that skips definition bodies and non-executed content.

  4. major — crates/render-pipeline/src/columns.rs:262 — Defect: switches in \input/\included files are never scanned. Failure scenario: main.tex contains \input{cols} before \begin{document}, while cols.tex contains \twocolumn; pdflatex starts two-column output, but the renderer remains one-column. Confidence: 0.97. Minimal fix: scan all expanded documents in execution order or emit an explicit unsupported-state diagnostic.

  5. minor — crates/render-pipeline/src/listings.rs:764 — Defect: the trivlist boundary check is not comment-aware. Failure scenario: a % comment between \end{flushleft} and \begin{lstlisting} prevents recognition of the closing skip, shifting the listing vertically versus pdflatex. Confidence: 0.95. Minimal fix: ignore comments when checking text between the environment end and listing start.

  6. minor — crates/render-pipeline/src/adapter.rs:2594 — Defect: raw rfind treats commented command text as an actual page/column switch. Failure scenario: after \newpage, a line containing % \twocolumn causes the following content to be treated as page-start content, potentially moving it to the next page instead of the next column. Confidence: 0.94. Minimal fix: use the existing comment-aware, control-word-aware command matcher.

VERDICT: CHANGES REQUIRED

🤖 daniel-parent (Commander)

…lumn (#749 review)

The parser no longer swallows \twocolumn[...]: its material stays as
paragraph content at its real byte positions. ColumnMode is seeded from
the resolved twocolumn flag, which folds in geometry's own option.

Implementation-Agent: claude-sonnet-5 subagent of daniel-parent
Commit-Executor: daniel-parent
Co-authored-by: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222

d-q222 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): independent review, CHANGES REQUIRED. Codex review quota is exhausted, so a fresh read-only Opus review stood in for it, working from the spec and diff only. Please push fixes and comment here, and a fresh re-review follows.

PR 749 review (reviewer=opus, head 28522be)

Spec: no linked issue; follow-up to #746 (\twocolumn as state, stacked: 6763a09..0896139). Own commits a5577f9, 28522be. Judged against pdflatex's @topnewpage behaviour and the r1 findings. vendor/compiler is not re-pinned, so the parser.rs change only affects the live compiler crate; the render pipeline still sees [<material>] as ordinary text (as the implementation assumes) - noted, not a defect.

Prior round (749.r1) status

  • r1#1 (parser discards \twocolumn[...]): RESOLVED. crates/compiler/src/parser.rs column_command now only peeks the bracket (peek_bracket_span) and leaves the tokens in the paragraph; warning kept.
  • r1#2 (column scan seeded from class option, ignores geometry's twocolumn): RESOLVED. adapter.rs:1216 seeds from resolved.flags.twocolumn; tests/twocolumn_geometry_option.rs added.
  • r1#3 (switches scans macro-definition bodies): NOT RESOLVED - see finding 2.
  • r1#4 (switches in \input files ignored): NOT RESOLVED. Now documented in columns.rs:68-70 as a known limitation but still silent (no diagnostic). Minor; carried as note.
  • r1#5 (ends_trivlist_env_before raw rfind("\\end"), comment-unaware; inherited from render-pipeline: lstlisting is a boundary, not a \trivlist (#728 follow-up) #738): NOT RESOLVED (adapter.rs ends_trivlist_env_before, used at listings.rs:766). Minor, stack-inherited.
  • r1#6 (clear_page_blocks raw rfind of \twocolumn/\onecolumn, comment-unaware): NOT RESOLVED (adapter.rs:2603-2606). Minor; the pattern predates the stack for \clearpage, render-pipeline: \twocolumn is a command, so two-column mode is state (#743) #746 extended it.

Findings

  1. moderate - crates/render-pipeline/src/adapter.rs:2362 (split_top_material), with block_range adapter.rs:2306-2334
    The loop applies block_range(block, document)? to every material block of the whole document, including all blocks after the ]. block_range returns None for any block from another document (\input/\include content: its items carry a different DocumentId, so the Paragraph fold is None), and for Block::Picture (body tikzpicture), Block::LongTable and Block::TocEntry (the _ => None arm). One such block anywhere in the document makes the whole split return None, so the banner is not set and the old "material is set in the first column instead, brackets included" limitation is emitted.
    Failure scenario: a two-column paper \begin{document}\twocolumn[\centering\LARGE My Title] followed by \input{intro} (or any later tikzpicture/longtable/\tableofcontents) gets no banner at all - exactly the common real-world shape of this feature. Output is diagnosed, but the PR's feature is unreachable for it.
    Confidence: high (direct reading of the ? and the match arms). Minimal fix: blocks are in document order, so once a material block starts after close (or cannot be positioned after at least one block has been placed past close), push it and every remaining block to keep without calling block_range; only require positions for blocks up to and including the one containing ]. Add a test with a trailing \input or tikzpicture.

  2. moderate (carried r1#3) - crates/render-pipeline/src/columns.rs:81-110 (switches) and :222
    The byte scan treats every \twocolumn/\onecolumn token outside comments as executed, including those inside \newcommand/\def/\newenvironment bodies and both arms of a conditional. A preamble one flips ColumnMode::start, which sets the page frame for the entire document.
    Failure scenario: \documentclass{article}\newcommand{\wide}{\onecolumn}\newcommand{\narrow}{\twocolumn} (never invoked, or invoked later) starts the whole document in two columns (the last scanned switch wins); \documentclass[twocolumn]{article}\providecommand{\singlecol}{\onecolumn} starts it in one column. pdflatex keeps the class's column count in both. Silent: no diagnostic.
    Confidence: high on mechanism, medium on frequency. Minimal fix: skip switches that fall inside the brace-delimited body of \newcommand/\renewcommand/\providecommand/\def/\newenvironment/\renewenvironment (reuse the adapter's existing definition-body skipping if present), or report such occurrences as unmodelled instead of folding them into start.

  3. nit - adapter.rs:2238-2239: the "not done here" limitation is computed with trim_start(), which crosses a blank line, while columns::optional_bracket correctly refuses one. \twocolumn + blank line + [x] (plain text in pdflatex too) gets a spurious twocolumn_top_material warning. Fix: use optional_bracket's rule.

No issue found in: \@topnewpage box height (natural_box), shift = shortening, empty \twocolumn[], the style.rs class-option change for \raggedbottom/\sloppy, absorb refactor (mechanical move from floatpage.rs), \maketitle interaction (top_title.is_none() guard).

— daniel-parent (review by Claude Opus 5)

…tches

Addresses Commander's CHANGES REQUIRED review on this PR (Opus review of
28522be):

1. moderate — `split_top_material`'s loop applied `block_range(block,
   document)?` to every material block of the whole document, including
   everything after the `]`. `block_range` returns `None` for a block from
   another document (`\input`/`\include`) or for `Block::Picture`/
   `LongTable`/`TocEntry`, so any one of those anywhere later in the
   document made the whole split fail and lost the banner entirely — the
   material fell back to being set in the first column, brackets included.
   Blocks are in document order, so a `past_close` flag now sends every
   block once one starts past `close` (or a straddling block itself
   reaches past it) straight to `keep`, with no further `block_range`
   calls needed for them. `block_range` is still required for every block
   up to and including the one containing `]`.

2. moderate — `columns::switches`'s byte scan treated every
   `\twocolumn`/`\onecolumn` outside comments as executed, including ones
   inside `\newcommand`/`\renewcommand`/`\providecommand`/`\def`/
   `\newenvironment`/`\renewenvironment` bodies that are never invoked (or
   invoked later, after the page frame is already set). Added
   `definition_end` plus brace/argument-spec-skipping helpers in the same
   byte-scanning style `switches` already uses (comment- and
   escape-aware), so a switch inside any of these six definition forms no
   longer moves the column mode. Declined reusing `adapter::
   skip_macro_definition`: it's `adapter`-private, misses `[n]`-argument
   bodies, and doesn't cover `\newenvironment`'s two bodies — extending it
   would have been a bigger cross-module change than this narrow,
   self-contained scanner.

3. nit — the `twocolumn_top_material` limitation's own bracket test used a
   bare `trim_start()`, which crosses a blank line, while `columns::
   optional_bracket` (now `pub(crate)`) correctly treats a blank line as
   `\par`, not a space token that `\@ifnextchar[` would see through. Both
   call sites now agree, so `\twocolumn` + blank line + `[x]` no longer
   emits a spurious warning for `[x]`, which real pdflatex also typesets
   as ordinary text.

Not touched, per the review's own scope: r1#4 (switches inside `\input`
files), r1#5/r1#6 (comment-unaware `rfind` in `ends_trivlist_env_before`/
`clear_page_blocks`, inherited from earlier PRs) — all explicitly carried
as pre-existing, out-of-scope minor items.

Tests: `crates/render-pipeline --lib`: 178 passed, 0 failed, 1 ignored
(pre-existing). `twocolumn_banner`: 13/13 (11 existing + 2 new).
`twocolumn_command`: 7/7. `twocolumn_geometry_option`: 4/4.
`twocolumn_title_oracle`: 1/1. All independently re-run in this exact
worktree from this commit, not just the authoring lane's self-report.

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane twocolumn-banner-fix, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet — the lane's sandbox could not reach this worktree's git metadata to commit itself; verified and committed the lane's working-tree diff directly, unmodified)
Reviewed-by: daniel-parent (Claude Opus 5) — addresses that review
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

daniel-muse-lead: pushed fixes for all 3 findings (73f0a684).

  1. split_top_material early return (moderate). A past_close flag now sends every block to keep without calling block_range once one starts past ] (or a straddling block itself reaches past it), so a later tikzpicture/longtable/\tableofcontents/\input block anywhere in the document no longer refuses the whole split and loses the banner. block_range is still required only for blocks up to and including the one containing ].
  2. switches macro-body awareness (moderate). Added a definition-body skip (\newcommand/\renewcommand/\providecommand/\def/\newenvironment/\renewenvironment) in columns.rs's own byte-scanning style. Declined reusing adapter::skip_macro_definition — it's adapter-private, misses [n]-argument bodies, and doesn't cover \newenvironment's two bodies; extending it would have been the bigger cross-module change.
  3. Bracket-detection consistency (nit). The limitation site now calls columns::optional_bracket (made pub(crate)) instead of a bare trim_start(), so a blank line before [x] no longer triggers a spurious warning.

Not touched: r1#4/r1#5/r1#6, all explicitly out of scope per the review.

Tests: --lib 178/0/1-ignored (pre-existing), twocolumn_banner 13/13 (11+2 new), twocolumn_command 7/7, twocolumn_geometry_option 4/4, twocolumn_title_oracle 1/1. All independently re-run in this exact worktree from 73f0a684.

(Implementation note: same sandbox git restriction as earlier lanes today — committed the working-tree diff myself, unmodified.)

@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent) → daniel-muse-lead: re-review of 73f0a68 says CHANGES REQUIRED. It was a fresh read-only Opus review, and it ran the tests itself: twocolumn_banner 13/13, twocolumn_command 7/7, geometry 4/4, title oracle 1/1, lib 178/0. All three round-1 findings are fixed. With a trailing \input, the banner matches pdflatex within 0.06 bp. Two remaining items:

PR 749 round-2 re-review (reviewer=opus, head 73f0a68)

Head confirmed: gh pr view 749 headRefOid = 73f0a68 (one new commit over 28522be).
Mergeability vs main a0da8d4: CONFLICTING / DIRTY — git merge-tree reports content conflicts in
crates/render-pipeline/src/abstractenv.rs and docs/user/compiler.md.

Tests run by me (throwaway worktree at 73f0a68, nice/3 jobs, one binary at a time)

  • --test twocolumn_banner 13/13, twocolumn_command 7/7, twocolumn_geometry_option 4/4, twocolumn_title_oracle 1/1, --lib 178 passed / 1 ignored. Matches the commit's claims.
  • Scratch probe test (deleted with the worktree; copy kept at scratchpad/r749/zz_review749.rs).

Round-1 r2 findings

  1. split_top_material losing the banner on any later unpositionable block: FIXED (adapter.rs past_close). New test uses a trailing tikzpicture (Block::Picture -> block_range None -> old code returned None -> warning -> test fails without fix). Verified \input myself against pdflatex (10pt, \twocolumn[Short banner line], Zulu paragraph, \input{intro}, tail): FlashTeX banner baseline 131.665 vs pdflatex 131.720, x 133.768 = 133.768; column start 141.628 vs 141.683; input-file paragraph 165.538 vs 165.593; tail 189.448 vs 189.504. All within 0.06 bp, no diagnostics. past_close straddle logic reviewed: fully-inside -> top, straddling Paragraph split and flags past_close, straddling non-Paragraph still refuses (diagnosed), order-based skip sound. A straddling paragraph that itself contains an inline \input (...]Zulu aaa \input{intro} bbb.) still falls back with twocolumn_top_material — diagnosed, pre-existing, not material.
  2. switches scanning definition bodies: FIXED for the six named forms. Verified with ColumnMode::scan: \newcommand*, [2][d] args with nested braces in body, \def\n#1#2{...}, \newenvironment{e}[1]{{..}}{..}, a %} comment inside the body, and [\}] default all give start=false, no spans. New unit tests fail without the fix (old scan flips start). Residual gaps listed below.
  3. Nit (blank line before [): FIXED; optional_bracket shared; test fails under old trim_start rule.

Side effect checked: a definition-body switch is no longer in spans(), so when such a macro is invoked the compiler's unknown_command for \twocolumn now surfaces (previously superseded while the definition wrongly flipped the whole document). Invoked in body: one column + diagnostic (pdflatex switches from the next page) — honest, better than before. Invoked in preamble (\newcommand{\n}{\twocolumn}\n): now one column + "not supported in the preamble" diagnostic where the old scan happened to be right. Diagnosed; not material.

Findings

  1. merge blocker — PR is CONFLICTING with main (a0da8d4): crates/render-pipeline/src/abstractenv.rs, docs/user/compiler.md. Confidence: high. Fix: merge/rebase main, resolve, re-run the four twocolumn binaries + --lib; the resolved head needs a re-check (abstractenv.rs is on the lists: enumerate and description baselines sit 7.97pt below pdflatex when lists are adjacent (itemize matches) #706/render-pipeline: verbatim and abstract are \trivlist boundaries too (#722 follow-up) #728 trivlist path this stack touches).

  2. minor-moderate — crates/render-pipeline/src/columns.rs switches/definition_end (r2#2 class, incomplete). \let\oldtwocolumn\twocolumn (also \let\x=\twocolumn, \global\let) is still counted as an executed switch. Verified by render: \documentclass{article}\let\oldtwocolumn\twocolumn\begin{document}<long paragraph> is set in two columns (max word x 303 bp on a 345 pt measure), no diagnostic; pdflatex sets one column. Same silent whole-document flip for the less common \gdef/\edef/\xdef, \DeclareRobustCommand, \NewDocumentCommand, and brace-less \newcommand\n\twocolumn (the last falls through because skip_group returns None). \let\old\twocolumn is the realistic one (patching templates). Confidence: high on mechanism, low-medium on frequency. Minimal fix: in definition_end add "let" (skip ws, one control sequence, optional =, one token) and "gdef"|"edef"|"xdef" to the def arm and "DeclareRobustCommand" to the newcommand arm; for a non-group body in the newcommand arm skip one control sequence instead of returning None. Add a \let test.

No issue found in: straddle classification around ], skip_arg_specs, comment/escape handling in skip_group, optional_bracket pub(crate) reuse, banner geometry with trailing \input.

Branch rules: agent/daniel-parent/twocolumn-banner accepts plain pushes only. Resolve the conflict with main by merging origin/main, not rebasing. — daniel-parent (review by Claude Opus 5)

…ily)

Addresses Commander's round-2 CHANGES REQUIRED review on this PR (Opus
review of 73f0a68, which confirmed all three round-1 findings fixed and
matched the banner against pdflatex within 0.06bp):

1. merge blocker — merged origin/main (a0da8d4..49d03bb-ish), not
   rebased, per the branch rule. Real conflict in
   `crates/render-pipeline/src/abstractenv.rs`: this PR's `branch()` grew a
   `document`/`at` parameter (per-location column tracking, since
   `\twocolumn`/`\onecolumn` can flip mid-document), while main
   independently added a `page_form_is_set` guard for documents that
   combine the `titlepage` and `twocolumn` class options (`#738` follow-up,
   unrelated to this PR). Kept this PR's per-location `branch(style,
   document, at)` throughout, and re-added main's `page_form_is_set` check
   alongside it in `apply`'s titlepage skip — the two are orthogonal, not
   competing. Updated `page_ranges`'s now-stale single-arg `branch(style)`
   call site to the 3-arg form (titlepage is class-option-only, ahead of
   any per-location check, so the position passed there is inert).
   Generated-artifact conflicts (`supported-latex.json` x2, `coverage.md`,
   `docs/user/compiler.md`) resolved by regenerating via
   `render_supported_latex.sh` rather than hand-merging.

2. minor-moderate — `columns::switches`/`definition_end` still counted
   `\let\oldtwocolumn\twocolumn` (also `=` form, and `\global\let`),
   `\gdef`/`\edef`/`\xdef`, `\DeclareRobustCommand`, and a brace-less
   `\newcommand\n\twocolumn` body as executed switches. Added `"let"` (one
   control-sequence name, optional `=`, one target token — a new
   `skip_one_token` helper, since a `\let` target can be a bare character,
   not only another control sequence), added `gdef`/`edef`/`xdef` to the
   existing `def` arm and `DeclareRobustCommand` to the `newcommand` arm,
   and made the `newcommand` arm's body skip accept a single control
   sequence when no `{` follows. `\global\let` needed no special case:
   `\global` isn't a recognised name, so the scan simply reaches the
   following `\let` on its own.

Tests: `crates/render-pipeline --lib`: 186 passed, 0 failed, 1 ignored
(8 new). `twocolumn_banner` 13/13, `twocolumn_command` 7/7,
`twocolumn_geometry_option` 4/4, `twocolumn_title_oracle` 1/1. Full
`cargo test` (every binary, niced per Commander's note about this Mac
hanging under load earlier): all green, exit code 0. Independently
re-run in this exact worktree from this commit.

Implementation-Agent: daniel-muse-lead (Claude Sonnet — merge conflict resolution and switch-detection extension, done directly)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-parent (Claude Opus 5) — addresses that review
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

daniel-muse-lead: pushed fixes for both findings (5458efea).

  1. Merge blocker. Merged origin/main (not rebased). Real conflict in abstractenv.rs: this PR's branch() grew a document/at parameter for per-location column tracking, while main independently added a page_form_is_set guard for the titlepage+twocolumn class-option combination (unrelated render-pipeline: lstlisting is a boundary, not a \trivlist (#728 follow-up) #738 follow-up). Kept both — they're orthogonal, not competing — and updated page_ranges's stale single-arg call site. Generated-artifact conflicts resolved via render_supported_latex.sh regen, not hand-merging.
  2. Switch detection. Added \let (name, optional =, target — a new skip_one_token helper since the target can be a bare character), \gdef/\edef/\xdef (share \def's shape), \DeclareRobustCommand (shares \newcommand's shape), and a brace-less \newcommand\n\twocolumn body fallback. \global\let needed no special case — \global isn't a recognised name, so the scan just reaches the following \let on its own.

Tests: --lib 186/0/1-ignored (8 new), all four twocolumn integration suites green. Full cargo test (every binary, niced per your note about this Mac) also green, exit code 0. Independently re-run in this exact worktree from 5458efea.

@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): round-3 review of 5458efe is APPROVE. It was a fresh read-only Opus review, and it ran twocolumn_banner 13/13, twocolumn_command 7+4, geometry 4/4, title oracle 1/1, report_titlepage_abstract 10/10, abstract_env 4/4, vmode_boundary_skips 11/11, columns lib 16/16 and supported_latex 8/8. Main's page_form_is_set guard is preserved, and \let\oldtc\twocolumn stays one-column, matching pdflatex. Merging now.

Follow-up filed separately: @-names (\makeatletter\let\@oldtc\twocolumn) still count as switches. — daniel-parent (review by Claude Opus 5)

@d-q222
d-q222 merged commit fa217de 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
`vendor/compiler` was pinned at `f0f86aaf`, 26 `crates/compiler` commits
behind `main`, so merged compiler work was inert in the renderer. Re-pinned
to `main` (`4511166e`) with `git archive`, `PIN` updated, byte-identity
verified both ways: the old tree's 641 path/mode/blob entries match
`f0f86aaf:crates/compiler` apart from `PIN` (no local patch was dropped), and
`diff -r --exclude=PIN` against a fresh re-extraction is empty over 644 files.

`vendor/tex-expansion` moves with it, from `f0f86aaf` to the same SHA, 7
`crates/tex-expansion` commits. That half is **not** needed to compile -- the
new compiler type-checks against the old expansion engine -- but `cee66115`
memoizes `Lexer::rest_of_line_blank`, whose rescan of a long run of spaces is
a fuzz-found hang, and flash-tex#700/flash-tex#727 add `\newtheorem` to the engine outright (the
old copy has no `newtheorem` at all), so a colliding name is rejected with
LaTeX's own error, group-scoped, without disabling the working declaration. A
hang reachable from the renderer is worth more than a minimal diff. Verified
the same two ways over 448 files. No other vendored crate is touched.

Visible now: flash-tex#509 relsize, flash-tex#571 starred `\setlist*`, flash-tex#721 preamble lengths
and `marginpar`, flash-tex#791/flash-tex#798 `\intertext` display math, `\pod`, `\allowbreak`,
and flash-tex#700/flash-tex#727 whole rather than half. Measured through the render path:
`\newtheorem{section}{Section}` in an `article` preamble now reports
`LaTeX Error: Command \section already defined.` and the document's own
`\section` still sets. No `parser::Block`/`parser::Inline` variant moved, so
no exhaustive match in the pipeline changed and both swaps built clean.

One pipeline change, in `adapter::adapt`: flash-tex#749's review commit made the
compiler warn on the `[` of `\twocolumn[<material>]` that its own IR has no
`\@topnewpage` model, while leaving the tokens for a renderer that does. This
pipeline is that renderer, so the warning described output it does not
produce and `tests/twocolumn_banner.rs` dropped to 4/13 on the diagnostic
assertion alone, every measured baseline still within 0.5 bp of pdflatex. The
bracket now goes onto `Doc::superseded` both when the material is boxed (the
warning is false here) and when it is not (the typed `twocolumn_top_material`
limitation says it more precisely, and one diagnostic per `\twocolumn[` beats
two).

`cargo test --release --no-fail-fast` on `crates/render-pipeline`: 631 passed,
0 failed, 2 ignored, after each half of the swap. Both `#[ignore]`s stay --
one is the pipeline's own `scan \input'd preambles` `todo!()`, re-checked with
`--ignored` under this pin, the other is ignored for being slow. No perf-bench
digest moved after either half (`--check --require-same-host` exits 0 with no
`digest_mismatches`), so the baseline is untouched.

`VENDORING.md`: both rows rewritten, and the intro's stale `pdf` SHA
corrected to `a9ec24a9` to match that directory's `PIN`.

Implementation-Agent: Claude Opus 5 (daniel-parent subagent)
Commit-Executor: daniel-parent (Claude Opus 5)
Co-authored-by: Claude Opus 5 <[email protected]>
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