Skip to content

render-pipeline: multicol multicols/multicols* as multicol.sty (oracle 23/25 exact) - #160

Merged
jay3332 merged 1 commit into
mainfrom
agent/kabir-claude/multicol
Sep 13, 2026
Merged

jay3332 merged 1 commit into
mainfrom
agent/kabir-claude/multicol

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

multicol: multicols / multicols* in the render pipeline

New module crates/render-pipeline/src/typeset/multicol.rs (non-vendored) sets multicol.sty 2025/10/21 v2.0b exactly, transcribed with line citations: TeX's page builder (§§980–1028, fire_up returning material after the best break), \vsplit (vert_break, prune_page_top), \vbox to glue setting and badness, and multicol's output routines:

  • \mult@@cols / \enough@room{\premulticols} (\addpenalty, \newpage when \pagegoal-\pagetotal is short), preface at full width, \addvspace\multicolsep, the \prevdepth grid kern, \prepare@multicols (partial page saved by \eject, \@colroom, \set@mult@vsize, \hsize = (\linewidth+\columnsep)/n − \columnsep in sp, \tolerance 9999, \pretolerance -1, \emergencystretch 4pt·n)
  • \multi@column@out (full pages, \raggedcolumns \vfilmaxdepth, leftover back to the contributions), \speci@ls (\columnbreak[n] via \colbreak@box, end penalty −10006)
  • \balance@columns (start height from (ht+dp)/n on the \baselineskip grid, 1pt steps, columnbadness/finalcolumnbadness, natural-height retry, \multicolundershoot, \maxbalancingoverflow, unbalance, minrows)
  • \page@sofar / \LR@column@boxes (columns in \hss gaps, \columnseprule centred, depth ≥ dp of p), \endmulticols with \enough@room\postmulticols, multicols*
  • \setlength of \columnsep, \columnseprule, \multicolsep, \premulticols, \postmulticols; \setcounter of unbalance, columnbadness, finalcolumnbadness, minrows, collectmore

The environment is found in the source and blanked before the compiler parses (same byte length, \begin/\end → \par), exactly like floats::mask, so this PR does not need the compiler PR or a vendor re-pin. Only documents containing multicols take the new path.

Hooks in typeset.rs are three lines (outer_doc at the top of build_with_floats, paginate in the pagination expression, shift before page_chrome), plus the Context field and two lines in lib.rs.

Diagnostics (code multicol): May not work with the twocolumn option, Using 'n' columns doesn't seem a good idea…, Too many columns, Floats and marginpars not allowed inside 'multicols' environment!, \columnbreak outside multicols, nested multicols. Not implemented, with a diagnostic and main's layout kept: multicols in a two-column document, documents with floats or footnotes (\mult@footnotetext/\init@mult@footins are not modelled), nested (boxed) multicols, \columnseprulecolor, RL columns.

Oracle (pdflatex MacTeX 2026 is the oracle only; cargo never runs TeX)

tools/multicol-oracle/generate.py writes 25 fixtures and fixtures/multicol/expected/*.txt (words and rules from pdflatex's content streams, reusing the page-frame reader). tests/multicol_oracle.rs gates words at 0.5bp, rules at 0.1bp, page count and multicol warnings.

23/25 fixtures exact (12335/12672 words overall), gated: 2/3/4 columns, uneven content, multicols*, \columnbreak (vertical and inline), preface, multi-page (2 and 3 columns), \columnseprule, \raggedcolumns, display inside, heading before/inside, two environments on one page, \premulticols forcing a new page, \columnsep, \multicolsep, 12pt, short content, multicols after a page of text.

Not gated: 11-itemize-inside (43/182: the list's \topsep/\partopsep reach the page builder without stretch, so the balanced column spreads glue 0.8bp differently; list-structure lane), 14-twocolumn-document (not implemented, warning emitted).

Gates

  • cargo test --release in crates/render-pipeline: all green (incl. 3 new unit tests and the oracle test).
  • HW1, HW2 and all 9 fixtures/real-world documents: v2 display list and diagnostics byte-identical to origin/main c40d2a6c (none uses multicol).

Companion: compiler-only PR (multicols parsing, \columnbreak/\raggedcolumns arms, package inventory) — independent of this one.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…(oracle 23/25 exact)

typeset/multicol.rs runs TeX's page builder, \vsplit and \vbox to with
multicol's output routines: \enough@room, the partial page, \set@mult@vsize,
\multi@column@out, \speci@ls (\columnbreak), \balance@columns and
\page@sofar with \columnseprule; multicols* and \raggedcolumns. The
environment markup is blanked before parsing (like floats::mask), so no
compiler change or vendor re-pin is needed. Documents without multicols keep
pagebuild: HW1, HW2 and the real-world corpus are byte-identical.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude multicol, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
5 conflicts (typeset.rs 4, lib.rs 1), plus the usual catching-up where #160
branched before several of this lane's changes.

- `Context`: #160's `multicol: multicol::State` field and initialiser join
  this branch's; in lib.rs `multicol::attach` is added to this branch's
  Context setup, which reads the original (unmasked) sources for float
  bodies and also installs the maths colours and graphics environment.

- `build_with_floats`: git had aligned #160's copy of the signature against
  this branch's `stretched_left`/`Flow`/`layout_blocks`, so the conflict
  looked like two functions claiming one body. Kept this branch's block and
  injected #160's `multicol::outer_doc` early return into the one real
  `build_with_floats` instead.

- Pagination: #160's `multicol::paginate` branch runs before the float
  branches; `images` stays mutable, which the float path needs.

`multicol.rs` predates three later changes and did not compile against them:

- `Block::Paragraph` gained `addvspace_flex` (#156) and `shape` (the list
  shape work). `split_paragraph` now carries both across the split -- the
  first half keeps the original's leading glue and shape, the second starts
  mid-paragraph with no leading glue but the same shape.
- `Doc` gained `default_color`, `math_colors` and `page_color` (#150/#158).
  The synthesised outer and per-column documents inherit the outer
  document's colour state rather than defaulting it, so a `multicols` body
  inside `\color` keeps its colour.
- `rec_span` did not cover `BoxRec::ColorBox`/`Graphic`/`Transform`/`Rules`.
  They are listed explicitly rather than wildcarded, so the next variant is
  caught here too instead of silently losing its span (which is what feeds
  the column-break search).

Gates (zero font diagnostics on every run): multicol_oracle passes,
theorem_oracle passes, amsmath 59/59, tabular 59/59, display-placement
33/36, real-world 10/10 recovered with every page count still equal to its
committed reference. `cargo test --release` in render-pipeline: the same 11
known failures, no more.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
…#167 #168), and why #162 needs a lane

Records this session in the merge log: the oracle-harness bug that was
falsifying gate numbers for every lane, the parallel silent-skip in
`cargo test`, the four stage-3 merges with the techniques each needed, and
the measured reason #162 is a reconstruction rather than a merge.

Also records the control that separates pre-existing failures from this
session's work: eight of the eleven render-pipeline failures reproduce on
unmerged origin/main in this worktree, and the other three have no baseline
on a non-MacTeX host. page_frame_oracle, which the previous session's list
did not mention, is measured here as pre-existing.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@jay3332
jay3332 merged commit db453da into main Sep 13, 2026
12 of 18 checks passed
@GoKubar
GoKubar deleted the agent/kabir-claude/multicol branch September 13, 2026 18:12
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.

2 participants