Skip to content

tex-boxes (KC-107) - #93

Merged
jay3332 merged 4 commits into
mainfrom
agent/kabir-claude/tex-boxes-r2
Sep 13, 2026
Merged

jay3332 merged 4 commits into
mainfrom
agent/kabir-claude/tex-boxes-r2

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Supersedes #92. This PR resumes KC-107 (TeX boxes, rules, kerns, glue setting, and the LaTeX box commands). It only changes crates/tex-boxes/**.

Oracle: pdfTeX 1.40.29, TeX Live 2026

  • The pdflatex oracle log has no TeX errors. The 19 Missing } errors had two causes, both now fixed:
    • nested <<N*…>> repeats were not expanded;
    • \wd0\space let \space terminate the register number, so the DIM fields ran together.
  • axisheight has been regenerated and is 163840sp.
  • cargo test passes all 151/151 fixtures on each of:
    • dims, exact to the sp;
    • \badness;
    • \showbox text;
    • diagnostics.
  • Positions match exactly on 92/92 fixtures.
  • Unit tests: 4/4.

Findings

  • Glue ratio is a double. Storing glue_set as f32 breaks g_long_stretch, g_long_odd and g_long_vertical. With f64 all positions match.
  • LaTeX 2021-06+ para hooks. The standard \everypar restarts each paragraph with \noindent, with \parskip set to 0 (or -\parskip under minipage). That puts a second \glue(\parskip) in the vertical list. This is modeled in BoxEngine::latex_para_hooks and fixed all 12 parbox/minipage \showbox diffs.
  • .3\baselineskip gives 235932sp, via round_decimals 19661. The old unit test expected the wrong value.
  • A LaTeX warning's leading newline depends on pdfTeX's terminal column (print_nl). This is modeled with term_offset.

CONTRACT.md

  • Adoption path for render-pipeline and compiler: a CharMetrics implementation over TFM data, nodes as the layout IR, and ship_out positions in sp.
  • KC-101: a main_control mapping onto BoxEngine, plus a recommendation on register and save-stack ownership.
  • KC-102: the LineBreaker hook and margin kerns. The expansion hook is still a stub and its wiring is listed as work.
  • KC-106: the PageBuilder hook, and a plan to remove the scaled/node/pack code duplicated in page-builder.

Believed, not oracle-checked

  • chars and ligatures (no fonts in the fixtures);
  • \vadjust migration;
  • \vcenter in real math;
  • multi-line paragraphs (the default breaker handles a single line only).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 4 commits September 13, 2026 02:23
New crate crates/tex-boxes: scaled arithmetic and units (tex.web 99-109,
453-458), node model, badness/hpack/vpackage with exact over/underfull
report text (108, 644-678), show_box/short_display (173-198), shipout
positions with cur_g/cur_glue rounding and leaders (619-637), a primitive
box engine (nest, save stack, box contexts, vtop, lastbox, unpackage,
vcenter, single-line paragraph hook), and the latex.ltx box layer
(makebox/framebox/fbox/raisebox/parbox/minipage/rule/hspace/vspace/
phantom/smash/laps/savebox/settodim/lrbox). Oracle generator, 151
fixtures and generated expected.txt; DSL-driven oracle test not yet run.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-107, 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
- generate.py: expand nested <<N*...>> repeats innermost-first, keep a
  space after \wd0 so DIM fields don't fuse, drop the \voidb@x error,
  emit no DIAG lines for an empty transcript. pdflatex log now has no
  TeX errors; axisheight regenerated (163840sp).
- DSL: nested repeats, simple {..} groups inside box bodies.
- engine: LaTeX 2021-06+ standard \everypar (indent box saved, empty
  \par, \noindent restart with \parskip 0 / -\parskip under minipage)
  which produces pdfTeX's doubled \parskip glue; term_offset for
  write_out's print_nl.
- scaled: .3\baselineskip = 235932sp (round_decimals 19661).

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

write_out's print_nl breaks the line when the terminal is mid-line. In the
oracle run that holds exactly when the previous fixture shipped a page
(position pass); \showbox's error() ends with print_ln. Oracle now passes
all 151 fixtures (dims, badness, showbox, diagnostics) and 92/92 positions.

Glue ratio: storing glue_set as f32 breaks g_long_stretch, g_long_odd and
g_long_vertical positions; f64 matches, so pdfTeX 1.40.29 uses double.

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

Documents oracle coverage (151 fixtures exact; 92 positions), the glue
ratio (double) and LaTeX para-hook findings, adoption for render-pipeline /
compiler, and plug-in points for KC-101 tex-expansion (main-control
mapping, register ownership), KC-102 microtype (LineBreaker, margin kerns;
expansion hook is a stub) and KC-106 page-builder (PageBuilder, module
de-duplication).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude KC-107 r2, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
@GoKubar
GoKubar marked this pull request as ready for review September 13, 2026 07:31
@jay3332
jay3332 merged commit 3b2703a into main Sep 13, 2026
14 of 18 checks passed
@jay3332

jay3332 commented Sep 13, 2026

Copy link
Copy Markdown
Member

Merged to main via integration/2026-09-13c (Commander orchestrator-jaysen-claude); hermetic library, tests green.

@GoKubar
GoKubar deleted the agent/kabir-claude/tex-boxes-r2 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