Skip to content

render-pipeline: \ldots and \cdots are three Punct dots inside a \mathinner - #467

Merged
GoKubar merged 5 commits into
mainfrom
agent/kabir-claude/math-ellipsis
Sep 14, 2026
Merged

GoKubar merged 5 commits into
mainfrom
agent/kabir-claude/math-ellipsis

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Reopens #463, which GitHub auto-closed when I merged its base (#462) with --delete-branch — my mistake, and the third time that pattern has bitten this repo today. No content is lost: this is the same branch, merged up to current main, re-tested.

$a\ldots b$ and $a\cdots b$ were set as upright roman periods with no internal spacing. Both families are \mathinner{\dotp\dotp\dotp} of a punctuation atom (plain.tex 360–361), which is two separate spacing facts an ordinary atom does not have: Punct against Punct is a thin space, so the three dots sit 3mu apart; and \mathinner is the Inner class, so the group takes a thin space against the Ord on each side.

This is not compiler-side and needs no vendor re-pin — contrary to the brief it was given. cm::symbol_slot already maps . to math-italic "3A (\ldotp) and U+22C5 to cmsy "01 (\cdotp) exactly as plain TeX's \mathcodes do. The low dots simply never reached that table, because Nucleus::Text goes down the text-font path. The two periods differ by under 0.0001 bp; the four thin spaces are essentially the whole error.

Measured with \showbox rather than from the PDF, because pdfTeX rounds kerns to 1/1000 em — 0.012 bp at 12 pt, a fifth of the effect being measured.

One correction to the brief's numbers: $a\cdots b$ is 13.95 bp, not 13.27 (inner box 13.99997 pt = 3 × \cdotp 3.33334 + 2 × 3mu). The \ldots figure of 13.75 was right.

\vdots/\ddots are deliberately untouched — they are \vbox constructions over text-font periods, which math-layout has no atom for, and a test pins that they were not changed. amsmath's \extrap@ (which appends a thin space before , ; . or a \DOTSB operator) is also not modelled; the corpus does hit it three times.

Gates on this merge with main: render-pipeline 358 passed / 0 failed, compiler 635 passed / 0 failed. Corpus contribution when measured on its original base: dx 87.63% → 88.87%, both 72.28% → 73.53%, total |dx| 38497.75 → 34978.92 bp, with thesis-chapter p3 max |dx| 426.27 → 3.61. No page count changed.

…ction

tex.web §752 leaves the last `math_char` of a run its `delta`; §753's
`make_ord` demotes only a character whose *next* noad is a math char of the
same family, so the `m` of `l i m` keeps its correction and pdfTeX's `\lim`
box is `l i m \kern0.05731` -- 16.3773 pt against the 16.31999 pt of
`\text{lim}`, whose `\hbox` has none.

`shape_run` computed that correction and then discarded it for every run
without a math-alphabet font key, so `\lim`, `\mathrm{...}` and `\bmod` were
set at bare advances. The gate was the font; it should be the construct.
Which `Nucleus::Text` atoms are whole runs of math characters is re-read from
the control word at the atom's span (`math_text_keeps_italic`), the idiom
`fence_of` / `class_override_of` / `operator_limits_of` already use.

It is a whitelist rather than a blacklist because a third case looks exactly
like a whole run and must behave like an `\hbox`: the compiler emits a
multi-character siunitx unit as one `Nucleus::Text` per character, so
`\unit{\katal}` arrives as three runs where TeX has one `\mathrm{kat}`.
Correcting each of those adds a correction *inside* a word -- measured, it
moved `12-unit-derived-c.tex` by 1.255 bp.

Oracle: TeX Live 2025 pdflatex under the harness preamble, read with
`\showbox` rather than from the PDF, because pdfTeX rounds a kern to 1/1000 em
in the content stream (0.012 bp at 12 pt) -- a fifth of the effect measured
here. pdflatex is an oracle only and is never in the product path.

Corpus (tools/visual-oracle/rank.py, 22 fixtures / 59 pages): total |dx| over
15120 aligned words 38497.75 -> 38486.30 bp, on inline-math p1/p2 and
twelvept-plain p2, every page toward the oracle and none away. No word crosses
the 0.5 bp bucket, because the correction is about 0.057 bp.

Gates: render-pipeline suite green, amsmath 59/59, tabular 106/106, corpus
22/22 fixtures with no page-count mismatch, zero font-FAILURE diagnostics.

Implementation-Agent: Claude Opus 5 (lane nixos-math-detail, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
They are the only two of the kernel's thirty-odd log-like functions whose
definition is not a single word (latex.ltx 15528-15529):

    \DeclareRobustCommand\limsup{\mathop{\operator@font lim\,sup}}
    \DeclareRobustCommand\liminf{\mathop{\operator@font lim\,inf}}

The compiler has no glue inside a named operator and emits one
`Nucleus::Text("limsup")`, so the `\,` is lost. It is re-derived from the
control word at the atom's span (`operator_thin_space_split`) and the operator
becomes `lim` + 3mu + `sup`, as an Op atom whose nucleus is that list -- which
is also what TeX has, so `make_op`'s delta stays 0 and the Rule 13a limits are
not shifted.

Splitting the word also earns `lim` its own italic correction: its `m` is now
followed by glue rather than by a math character of the same family, so §753's
`make_ord` never demotes it to a `math_text_char`. pdfTeX's box is
`l i m \kern0.05731 \glue 1.99997 s u p`, so the gap from `m` to `s` is
2.05728 pt -- a fix that inserted only the thin space would still be 0.057 pt
short. `\liminf` likewise closes with `f`'s `\kern0.84708`.

Oracle: TeX Live 2025 pdflatex under the harness preamble, `\showbox`.
pdflatex is an oracle only and is never in the product path.

No corpus effect: the 22 fixtures contain no `\limsup` or `\liminf`. The fix
is carried by the oracle numbers and the new regression test, which fails on
main by exactly -2.0496 bp.

Gates: render-pipeline suite green, amsmath 59/59, tabular 106/106, corpus
22/22 fixtures with no page-count mismatch, zero font-FAILURE diagnostics.

Implementation-Agent: Claude Opus 5 (lane nixos-math-detail, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
… Punct dots

`\mathellipsis` and `\cdots` are `\mathinner{\dotp\dotp\dotp}` of a
*punctuation* atom, which is two facts about spacing that an ordinary atom
does not have: Punct against Punct is a thin space, so the three dots sit 3mu
apart, and the Inner class takes a thin space against the Ord on each side.

The compiler flattens both to three bare characters -- `Nucleus::Text("...")`
for the low dots, `Nucleus::Symbol("...")` for the centred ones -- so the atoms
are rebuilt from the control word at the atom's span (`math_ellipsis_of`), the
idiom `fence_of` / `class_override_of` / `operator_limits_of` already use.

The glyphs were already right: `flashtex_math_layout::cm::symbol_slot` maps
`.` to math italic "3A (`\ldotp`) and U+22C5 to cmsy "01 (`\cdotp`) exactly as
plain TeX's `\mathcode`s do. What was wrong is that the low dots never reached
that table -- `Nucleus::Text` goes to the text-font run path, so they were set
in ec-lmr12 -- and that neither form had any of the four thin spaces. Those
four are essentially the whole error: the two periods differ by under
0.0001 bp in width.

Oracle: TeX Live 2025 pdflatex under the harness preamble, `\showbox` and
`\showthe\wd`. `$a\ldots b$` is `a | thin 1.99997 | hbox 13.7915 | thin
1.99997 | b`. pdflatex is an oracle only and is never in the product path.

Corpus (tools/visual-oracle/rank.py, 22 fixtures / 59 pages): within 0.5 bp,
dx 87.63% -> 88.87% (+194 words), dy 77.52% -> 77.55%, both 72.28% -> 73.53%;
aligned 15120 -> 15128; total |dx| 38497.75 -> 34978.92 bp. thesis-chapter p3
(dx_max 426.27 -> 3.61) and hw2 p3 (5.51 -> 1.16) gain the most, with
conf-paper p2, twelvept-plain p1/p2, inline-math p1, hw2 p2, math-sheet p2 and
enumitem-worksheet p1 also improving. No page regressed on any metric.

Not modelled: amsmath redefines `\cdots`/`\dotsb`/`\dotsm`/`\dotsc`/`\dotso`
through `\extrap@` (amsmath.sty 612-628) to append a 3mu `\,` when the next
token is `,`, `;`, `.` or a `\DOTSB` operator -- measured, `$a\cdots ,b$` is
one thin space wider than this produces. Neither the pinned compiler nor this
change reads the following token. The kernel's `\ldots` is not redefined and is
unaffected. `\vdots` and `\ddots` are deliberately left alone: they are `\vbox`
constructions over *text*-font periods, not runs of math dots, and math-layout
has no atom that builds a vbox; a regression test pins that they are untouched.

Gates: render-pipeline suite green, amsmath 59/59, tabular 106/106, corpus
22/22 fixtures with no page-count mismatch, zero font-FAILURE diagnostics.

Implementation-Agent: Claude Opus 5 (lane nixos-math-detail, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
# Conflicts:
#	crates/render-pipeline/src/typeset.rs
@GoKubar
GoKubar merged commit e2066db into main Sep 14, 2026
19 of 21 checks passed
@GoKubar
GoKubar deleted the agent/kabir-claude/math-ellipsis branch September 16, 2026 04:17
d-q222 added a commit that referenced this pull request Sep 17, 2026
…ot a glyph

What changed:
The LaTeX kernel gives neither command a character. Both are boxes built out
of `\hbox{.}` of the *text* font (`fontmath.ltx` 404-409, identical to
`plain.tex` 934-937):

    \vdots {\vbox{\baselineskip4\p@ \lineskiplimit\z@
                  \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
    \ddots {\mathinner{\mkern1mu\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern2mu
                       \raise4\p@\hbox{.}\mkern2mu\raise\p@\hbox{.}\mkern1mu}}

Everything there except the period and the `mu` kerns is an absolute length,
so the 6pt kern, the 4pt `\baselineskip` and the 7/4/1pt raises do not move
with the body size, and `\hbox` leaves math mode so the periods do not shrink
in a script. Both boxes come out 14pt plus the period's height tall with no
depth -- 15.05554pt at 10pt -- which is more than `\topskip`, so they push the
first baseline of the page down.

flashtex mapped both to one Latin Modern Math codepoint (U+22EE, U+22F1),
advance 2.18pt and 6.13pt, ink box 5.06pt too short (issue #717).

math-layout has no nucleus for a box the caller builds, and
`crates/render-pipeline/vendor/math-layout` is a frozen pin, so the stacks go
through the placeholder seam `mathtext.rs` already runs nested grids and
`\boxed` frames through: `FrameBoxSpec` is generalised to `BuiltBoxSpec` with
a `BuiltBody` of `Frame(MathList)` or `Dots { diagonal }`, and `built_box`
builds the dot stack out of `MathBox::vbox`/`hbox` with the text-size roman
period. `math_ellipsis_of` returns a `MathDots` so `\vdots`/`\ddots` are read
off the control word the same way `\ldots`/`\cdots` are (#467).

Measured against pdfTeX 3.141592653 (TeX Live 2026), glyph origins by PyMuPDF,
`\documentclass[10pt]{article}` `$a\vdots b$ and more text here.`, TeX pt:

                        before     after    pdflatex
    first baseline     135.2700  140.3256   140.3253
    \vdots `b` origin  156.7359  157.3336   157.3355
    \ddots `b` origin  160.6859  169.5557   169.5555

i.e. the first baseline was 5.0364 bp out and `\ddots` 8.8365 bp wide of
pdflatex; the largest residual now is 0.0019 bp. The three periods of each
stack now land within 0.0006 bp of pdflatex in both axes.

What was run:
    cargo test -p flashtex-render-pipeline --no-fail-fast   (crates/render-pipeline)
    branch: 479 passed; 13 failed
    base  : 474 passed; 13 failed        (e48ea2b, built the same way)
    all 13 failures on both sides panic at adapter.rs:1308 (the vendor/compiler
    pin, fixed by #696); 0 new failures, 5 new tests.

Next step:
None; `\vdots`/`\ddots` stay out of `math_symbol_line_height.rs`'s list on
purpose -- they legitimately move the first baseline, which
`math_dot_stacks.rs` pins separately.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222 added a commit that referenced this pull request Sep 17, 2026
…ot a glyph

What changed:
The LaTeX kernel gives neither command a character. Both are boxes built out
of `\hbox{.}` of the *text* font (`fontmath.ltx` 404-409, identical to
`plain.tex` 934-937):

    \vdots {\vbox{\baselineskip4\p@ \lineskiplimit\z@
                  \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
    \ddots {\mathinner{\mkern1mu\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern2mu
                       \raise4\p@\hbox{.}\mkern2mu\raise\p@\hbox{.}\mkern1mu}}

Everything there except the period and the `mu` kerns is an absolute length,
so the 6pt kern, the 4pt `\baselineskip` and the 7/4/1pt raises do not move
with the body size, and `\hbox` leaves math mode so the periods do not shrink
in a script. Both boxes come out 14pt plus the period's height tall with no
depth -- 15.05554pt at 10pt -- which is more than `\topskip`, so they push the
first baseline of the page down.

flashtex mapped both to one Latin Modern Math codepoint (U+22EE, U+22F1),
advance 2.18pt and 6.13pt, ink box 5.06pt too short (issue #717).

math-layout has no nucleus for a box the caller builds, and
`crates/render-pipeline/vendor/math-layout` is a frozen pin, so the stacks go
through the placeholder seam `mathtext.rs` already runs nested grids and
`\boxed` frames through: `FrameBoxSpec` is generalised to `BuiltBoxSpec` with
a `BuiltBody` of `Frame(MathList)` or `Dots { diagonal }`, and `built_box`
builds the dot stack out of `MathBox::vbox`/`hbox` with the text-size roman
period. `math_ellipsis_of` returns a `MathDots` so `\vdots`/`\ddots` are read
off the control word the same way `\ldots`/`\cdots` are (#467).

Measured against pdfTeX 3.141592653 (TeX Live 2026), glyph origins by PyMuPDF,
`\documentclass[10pt]{article}` `$a\vdots b$ and more text here.`, TeX pt:

                        before     after    pdflatex
    first baseline     135.2700  140.3256   140.3253
    \vdots `b` origin  156.7359  157.3336   157.3355
    \ddots `b` origin  160.6859  169.5557   169.5555

i.e. the first baseline was 5.0364 bp out and `\ddots` 8.8365 bp wide of
pdflatex; the largest residual now is 0.0019 bp. The three periods of each
stack now land within 0.0006 bp of pdflatex in both axes.

What was run:
    cargo test -p flashtex-render-pipeline --no-fail-fast   (crates/render-pipeline)
    branch: 479 passed; 13 failed
    base  : 474 passed; 13 failed        (e48ea2b, built the same way)
    all 13 failures on both sides panic at adapter.rs:1308 (the vendor/compiler
    pin, fixed by #696); 0 new failures, 5 new tests.

Next step:
None; `\vdots`/`\ddots` stay out of `math_symbol_line_height.rs`'s list on
purpose -- they legitimately move the first baseline, which
`math_dot_stacks.rs` pins separately.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222 added a commit that referenced this pull request Sep 17, 2026
…ot a glyph

What changed:
The LaTeX kernel gives neither command a character. Both are boxes built out
of `\hbox{.}` of the *text* font (`fontmath.ltx` 404-409, identical to
`plain.tex` 934-937):

    \vdots {\vbox{\baselineskip4\p@ \lineskiplimit\z@
                  \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
    \ddots {\mathinner{\mkern1mu\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern2mu
                       \raise4\p@\hbox{.}\mkern2mu\raise\p@\hbox{.}\mkern1mu}}

Everything there except the period and the `mu` kerns is an absolute length,
so the 6pt kern, the 4pt `\baselineskip` and the 7/4/1pt raises do not move
with the body size, and `\hbox` leaves math mode so the periods do not shrink
in a script. Both boxes come out 14pt plus the period's height tall with no
depth -- 15.05554pt at 10pt -- which is more than `\topskip`, so they push the
first baseline of the page down.

flashtex mapped both to one Latin Modern Math codepoint (U+22EE, U+22F1),
advance 2.18pt and 6.13pt, ink box 5.06pt too short (issue #717).

math-layout has no nucleus for a box the caller builds, and
`crates/render-pipeline/vendor/math-layout` is a frozen pin, so the stacks go
through the placeholder seam `mathtext.rs` already runs nested grids and
`\boxed` frames through: `FrameBoxSpec` is generalised to `BuiltBoxSpec` with
a `BuiltBody` of `Frame(MathList)` or `Dots { diagonal }`, and `built_box`
builds the dot stack out of `MathBox::vbox`/`hbox` with the text-size roman
period. `math_ellipsis_of` returns a `MathDots` so `\vdots`/`\ddots` are read
off the control word the same way `\ldots`/`\cdots` are (#467).

Measured against pdfTeX 3.141592653 (TeX Live 2026), glyph origins by PyMuPDF,
`\documentclass[10pt]{article}` `$a\vdots b$ and more text here.`, TeX pt:

                        before     after    pdflatex
    first baseline     135.2700  140.3256   140.3253
    \vdots `b` origin  156.7359  157.3336   157.3355
    \ddots `b` origin  160.6859  169.5557   169.5555

i.e. the first baseline was 5.0364 bp out and `\ddots` 8.8365 bp wide of
pdflatex; the largest residual now is 0.0019 bp. The three periods of each
stack now land within 0.0006 bp of pdflatex in both axes.

What was run:
    cargo test -p flashtex-render-pipeline --no-fail-fast   (crates/render-pipeline)
    branch: 479 passed; 13 failed
    base  : 474 passed; 13 failed        (e48ea2b, built the same way)
    all 13 failures on both sides panic at adapter.rs:1308 (the vendor/compiler
    pin, fixed by #696); 0 new failures, 5 new tests.

Next step:
None; `\vdots`/`\ddots` stay out of `math_symbol_line_height.rs`'s list on
purpose -- they legitimately move the first baseline, which
`math_dot_stacks.rs` pins separately.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
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