Skip to content

math-layout: TeX stretch/shrink on math glue and hpack-exact pack_to (display-math blocker 1 of #146) - #148

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

jay3332 merged 1 commit into
mainfrom
agent/kabir-claude/math-glue-shrink

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Part A of the two blockers left by #146 (too-wide displays, fixtures 09/10/33).

What

  • Inter-atom spacing glue carries plain.tex's muskips in full (TeX Live 2026 plain.tex 373-375, kept by LaTeX): \thinmuskip 3mu, \medmuskip 4mu plus 2mu minus 4mu, \thickmuskip 5mu plus 5mu, scaled by the style's math unit (tex.web §716).
  • BoxKind::Glue { mu, stretch: Flex, shrink: Flex }; new GlueOrder (normal/fil/fill/filll), Flex, GlueTotals, GlueSet/GlueSign, Packed.
  • Explicit glue atoms: Nucleus::Glue { mu, pt, stretch: MathFlex, shrink: MathFlex }, Atom::glue_flex, Atom::hfill/hfil. Atom::glue and MathBox::glue keep their signatures (rigid).
  • MathBox::glue_totals() (natural width plus total stretch/shrink per order of an hlist, §656) and MathBox::pack_to(width): TeX hpack(p, w, exactly) (§649-667). The highest order wins, finite shrink is capped at its total (glue set 1.0, excess in overfull), and later children move by the accumulated glue change.

Evidence

  • Oracle tests/glue_set/glue-set.log: pdfTeX 1.40.29 \showbox of 8 hboxes (natural, shrink -0.65746, stretch 0.51007, overfull -1.0, plus 1fill 53.66805fill, pt glue, text and script styles). tests/glue_set.rs reads the log and checks glue components, totals, glue set ratio (compared in sp, as TeX prints it) and glyph positions.
  • cargo test --release (math-layout): 43 passed, 0 failed.
  • Render-pipeline API compatibility: the pipeline matches BoxKind::Glue { .. } only, and font-engine does not match glue at all. Pipeline output is unchanged until C uses pack_to.

Re-pin order

A (this PR) and B (compiler equation numbering) are independent. C (render-pipeline wiring) needs both re-pinned in vendor/.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…:pack_to

Inter-atom spacing now carries plain.tex's muskips in full (plain.tex
373-375, kept by LaTeX): \thinmuskip 3mu, \medmuskip 4mu plus 2mu minus
4mu, \thickmuskip 5mu plus 5mu, scaled by the style's math unit like
tex.web 716 math_glue. Explicit glue atoms gain plus/minus components
(Atom::glue_flex with MathFlex in mu, pt or fil/fill/filll units;
Atom::hfill/hfil). BoxKind::Glue carries the resolved Flex stretch and
shrink.

MathBox::glue_totals exposes an hlist's natural width and total stretch
and shrink per order (tex.web 656); MathBox::pack_to(width) sets the glue
like hpack(p, w, exactly) (649-667): highest order wins, finite shrink is
capped at its total (glue set 1.0) with the excess reported as overfull,
and later children move by the accumulated glue change. Displays wider
than \displaywidth can now be squeezed as in tex.web 1199-1201.

Oracle: tests/glue_set/glue-set.log, pdfTeX 1.40.29 \showbox of eight
hboxes (natural, shrink, stretch, overfull, fill, pt glue, text and script
styles); tests/glue_set.rs reads it and checks glue components, totals,
glue set ratio (in sp) and glyph positions. math-layout: 43 tests pass.
Existing Atom::glue/MathBox::glue keep their signatures (rigid glue).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude math glue + numbering, 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
Clean merge. math-layout 43 tests pass; compiler unchanged.

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
Conflicts against #148: MathBox::glue_flex (SourceTag plus stretch/shrink) and the mathlist.rs imports. math-layout 54 tests pass.

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
No conflicts: #168 is an oracle and its fixtures, with no pipeline source
changes. The compiler side it needs (siunitx) came in with #159 in stage 1,
so the vendored compiler already satisfies it.

One change was needed. #168 carries a `PENDING` list of fixtures that must
*still* differ from pdfLaTeX, each naming the work it waits on, so the entry
is removed when that work lands. `39-heading.tex` waited on heading math --
"the pipeline sets a `$...$` formula in \section at the heading size but an
Inline::Math whose span starts at a command at the body size". That landed on
this branch with #151, so the fixture now matches and the test failed with
"39-heading.tex now matches: remove it from PENDING", exactly as designed.
Removed; the oracle passes.

siunitx is now 36/39 exact against the committed MacTeX references, up from
the 35/39 the PR reports. The three still pending are unrelated to siunitx
and name their own dependencies: 34-paragraph (math glue stretch in line
justification, PR #148), 37-ang-minutes (`\prime` drawn from Latin Modern
Math at 2.169pt where pdfLaTeX's cmsy7 prime is 2.306pt), 38-power-on-letter
(no upright fam0 Latin math character, so a power on a one-letter unit sits
0.78 bp high).

`cargo test --release` in render-pipeline: the same 11 known failures, no
more. Zero font diagnostics on every gate.

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 f6e1364 into main Sep 13, 2026
12 of 18 checks passed
@GoKubar
GoKubar deleted the agent/kabir-claude/math-glue-shrink 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