Skip to content

compiler: LaTeX box commands as structured inline nodes (\mbox .. minipage, saved boxes, \settowidth) - #137

Closed
GoKubar wants to merge 3 commits into
mainfrom
agent/kabir-claude/box-commands
Closed

GoKubar wants to merge 3 commits into
mainfrom
agent/kabir-claude/box-commands

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

What

LaTeX box commands parse into structured inline nodes instead of unsupported errors:
\mbox, \makebox[w][l|c|r|s], \fbox, \framebox[w][pos], \parbox[pos][height][inner]{w}, minipage (same options),
\raisebox{lift}[h][d], \phantom/\hphantom/\vphantom, \smash, \llap/\rlap, \strut, \hss,
\newsavebox/\sbox/\savebox/lrbox/\usebox, \newlength + \settowidth/\settoheight/\settodepth,
\setlength of a \newlength, and \hspace{\len} / \hspace{.5\textwidth}.

  • New src/boxes.rs: Inline::Box(TextBox), Inline::SetLength(LengthAssignment), Inline::LengthGlue.
    Dimensions keep their decimal digits and unit (BoxDimen) so the typesetter converts them to sp exactly as scan_dimen does
    (physical units, em/ex, \width/\height/\depth/\totalheight, \textwidth-style and declared lengths).
  • src/parser/boxes.rs: every content argument goes through the ordinary paragraph parser as its own group, so spans are exact and
    math, nested boxes and style commands work inside. \parbox/minipage keep paragraphs and their alignment declaration
    (\centering etc.); outer list/alignment state is hidden as \@parboxrestore does. [2cm][r] written as one word is split correctly.
  • The Core 14 layout places box content inline (no box model there). Supported inventory regenerated
    (kernel commands 104 -> 119 of 410, environments 15 -> 16 of 30, total 194 -> 210 of 1003).

Not in this PR (other lanes): \rule, \TeX/\LaTeX, \, and friends (text builtins PR #128). minipage is implemented
generally in running text; the float-bodies lane's side-by-side subfigures inside floats should reuse Inline::Box rather than
add a second minipage path. Minipage footnotes (\@mpfootins) are not implemented: the note is set inline, as elsewhere.

Depends / follow-up

The render-pipeline half is a separate PR against main (not stacked, per the 11:14Z rule): branch
agent/kabir-claude/box-commands-pipeline. It needs vendor/compiler re-pinned to this PR's merge.

Evidence

  • cargo test (crates/compiler, after merging main 85ec30c): 374 passed, 1 failed. The failure,
    supported_latex::canonical_names_outside_the_inventory_are_diagnosed, fails identically on origin/main (verified in a clean
    checkout: \and reaches unsupported()'s debug_assert); not touched here.
  • New tests/box_commands.rs (6 tests): arguments, kinds, paragraphs/alignment, saved-box reuse, length assignments, diagnostics
    for undeclared registers, nested content.
  • With this compiler vendored into render-pipeline (scratch copy), the pipeline PR's pdflatex oracle matches 36/37 box fixtures;
    HW1/HW2 PDFs and display lists are byte-identical to main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 3 commits September 13, 2026 07:21
\mbox, \makebox, \fbox, \framebox, \parbox, minipage, \raisebox,
\phantom/\hphantom/\vphantom, \smash, \llap/\rlap, \strut, \hss,
\newsavebox/\sbox/\savebox/lrbox/\usebox and \newlength with
\settowidth/\settoheight/\settodepth parse into Inline::Box,
Inline::SetLength and Inline::LengthGlue (src/boxes.rs). Dimensions keep
their decimal digits and unit so the typesetter converts them exactly
(crates/tex-boxes); \parbox/minipage keep paragraphs and alignment. The
Core 14 layout places box content inline. Supported inventory regenerated.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude box commands, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Implementation-Agent: Claude Opus 5 (subagent kabir-claude box commands, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Implementation-Agent: Claude Opus 5 (subagent kabir-claude box commands, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>

# Conflicts:
#	crates/compiler/src/parser.rs
#	docs/user/compiler.md
GoKubar added a commit that referenced this pull request Sep 13, 2026
Conflicts: lib.rs modules (boxes + color/color_names), parser.rs modules (hyperlinks/boxes/lists + colors) and Inline enum (#137's Box/SetLength/LengthGlue + #150's ColorBox variant, then main's ReferenceForm and #150's ColorBox struct), incremental.rs span shifting (both). Integration fixes: #150's parser/colors.rs box_inlines renamed color_box_inlines (clashed with #137's); #149's theorems.rs ITALIC const gains color: None; set_length records \fboxsep/\fboxrule before #137's set_box_length claims the assignment, so \colorbox sees it (xcolor_parse fboxsep 3.0 vs 5.0).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, 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
…ession handoff)

Stage 1 partly done: #131, #137, #153 (incl. #142), #144, #147, #149, #150,
#155, #159, #163, #164 merged with conflicts and post-expansion fixes recorded
in docs/evidence/integration-2026-09-13b/merge-log.md. Remaining: #166, #169,
#148, #161, then the inventory regeneration and stages 2-4. The helper scripts
under tools/ hard-code the original worktree path.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, 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
…merges

Every stage 1 merge took main's side of the generated inventory and deferred
the regeneration to the end of the stage. Running
crates/compiler/scripts/render_supported_latex.sh picks up #131, #137, #144,
#147, #149, #150, #153, #155, #159, #163, #164, #166 and #169, so
supported_latex::generated_artifacts_are_current passes again.

The TeX Live-derived canonical denominator is deliberately untouched: this
machine has TeX Live 2025, not the MacTeX the committed file was pinned from.

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

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as abandoned (per backlog triage). Conflicting, based on 2026-09-13 main, no activity or dependents since. The structured box-command model here never landed (main treats \mbox via supported.rs passthrough, no Inline box nodes), and the \settowidth territory now has a newer open draft, #492 (BoxMeasurer). A restart should rebuild on current main; the branch agent/kabir-claude/box-commands is preserved for reference.

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