Repository navigation
Conversation
…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)
GoKubar
force-pushed
the
agent/kabir-claude/limsup-thin-space
branch
from
September 14, 2026 20:00
f4b438c to
f818952
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PR 3 of 3 (math detail, lane
nixos-math-detail). Base:agent/kabir-claude/limsup-thin-space(#462) — review #461 and #462 first;this diff is only the third commit. This is the one with the corpus win.
Mechanism
\mathellipsisand\cdotsare\mathinner{\dotp\dotp\dotp}of apunctuation atom. That is two facts about spacing, neither of which an
ordinary atom has:
\mathinneris the Inner class, so the group takes a thin space againstthe 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 atomsare rebuilt from the control word at the atom's span (
math_ellipsis_of), theidiom
fence_of/class_override_of/operator_limits_ofalready use.A correction to how this was scoped
This was handed to me as compiler-side work needing a vendor re-pin. It does
not: the glyphs were already right.
flashtex_math_layout::cm::symbol_slotmaps.to math italic"3A(
\ldotp) andU+22C5to cmsy"01(\cdotp), exactly as plain TeX's\mathcodes do. What was wrong is that the low dots never reached thattable —
Nucleus::Textgoes to the text-font run path, so they were set inec-lmr12— and that neither form had any of the four thin spaces.Those four spaces are essentially the entire error: the two periods differ by
under 0.0001 bp in width (roman
.3.2518 bp, cmmi.3.2517 bp). So thisis a pipeline-only change, it lands now, and it does not wait on
agent/kabir-claude/vendor-repin-par-leading.Oracle
TeX Live 2025 pdflatex under the harness preamble,
\showbox/\showthe\wd.pdflatex is an oracle only and is never in the product path.
\wd $\ldotp$3.26385 pt,\wd $\cdotp$3.33334 pt,\thinmuskip1.99997 pt.Regression test
crates/render-pipeline/tests/math_ellipsis.rs. Onmain:vdots_and_ddots_are_left_alonepasses on main and is a guard.Corpus
tools/visual-oracle/rank.py, 22 fixtures / 59 pages. Within 0.5 bp:Every changed page improved; none regressed on any metric. Biggest movers:
(The +194/+8 are this PR; #461 contributes −11.45 bp of total |dx| and no
bucket change, #462 none — the 22 fixtures have no
\limsup/\liminf.)What this deliberately does not do
\,. amsmath redefines\cdots,\dotsb,\dotsm,\dotscand\dotsothrough\extrap@(amsmath.sty612–628) to append a 3mu
\,when the next token is,,;,.or a\DOTSBoperator. Measured:$a\cdots ,b$minus$a,b$is 19.99987 ptwhere
$a\cdots b$minus$ab$is 17.99991 — one extra thin space. Neitherthe pinned compiler nor this change reads the following token, so that
\,is still missing. The corpus does contain such uses (
\cdots +threetimes), and those pages still improve substantially — hw2 p3's residual
max |dx|is 1.16 bp. The kernel's\ldotsis not redefined and isunaffected (
$a\ldots ,b$minus$a,b$equals$a\ldots b$minus$ab$).\vdotsand\ddots. They are not runs of math dots but\vboxconstructions over text-font periods —
\vdotsis a\vboxof three\hbox{.}at\baselineskip2.83334 over a\kern 6.0;\ddotsis anInner hbox of three
\hbox{.}shifted −7.0/−4.0/−1.0 between kerns of0.66666 and 1.33331. math-layout has no atom that builds a vbox, so they
need their own change.
vdots_and_ddots_are_left_alonepins that thischange did not reach them.
Gates
render-pipeline suite green (exit 0), amsmath 59/59, tabular 106/106, corpus
22/22 fixtures with no page-count mismatch and no producer failure, zero
font-FAILURE diagnostics. Nothing under
crates/render-pipeline/vendor/istouched.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu