Repository navigation
render-pipeline: a run of math characters keeps its last italic correction - #461
Merged
Merged
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)
This was referenced Sep 14, 2026
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 1 of 3 (math detail, lane
nixos-math-detail). Base:main.Next:
\limsup/\liminfthin space, then math\ldots/\cdots.Mechanism
tex.web §752 leaves the last
math_charof a run itsdelta. §753'smake_orddemotes a character to amath_text_char— which loses thecorrection as "dubious" — only when the next noad is a math char of the
same family. In
l i mthat is true oflandiand false ofm, somkeeps its correction:
shape_runalready computed that value and then threw it away:keyis the math-alphabet font key, so the correction survived only for\mathbf/\mathsf-style runs. The gate is the construct, not the font:\limand\mathrm{lim}are set in the same face as\text{lim}and stillmeasure 16.3773 pt against its 16.31999 pt.
Which
Nucleus::Textatoms are whole runs of math characters is now re-readfrom the control word at the atom's span (
math_text_keeps_italic), the sameidiom
fence_of/class_override_of/operator_limits_ofalready use.math-layoutneeded no change:make_textalready appendslast_italicas akern and already returns δ = 0 for a
Nucleus::Textnucleus — which is whatmake_opdoes for asub_mlist, so the Rule 13a limits are correctly notshifted by δ/2. Verified against the oracle: both limit boxes of
$\lim\limits^{|}_{|}$have identical glue and no shift.Why a whitelist and not a blacklist
The first version of this read the control word to exclude
\textand\tag. That is wrong, and the suite caught it. A third kind ofNucleus::Textlooks exactly like a whole run and must behave like an\hbox: the compiler emits a multi-character siunitx unit as oneNucleus::Textper character (siunitx.rsupright: "One character is oneupright run; several are a boxed group of one-character runs"), so
\unit{\katal}arrives as three runsk,a,twhere TeX has a single\mathrm{kat}. Correcting each of them puts an italic correction inside aword — precisely what §752's
math_text_charrule exists to prevent.Measured:
12-unit-derived-c.texmoved 1.255 bp under the exclusionversion (
siunitx_fixtures_match_pdflatexfailed); it passes under thewhitelist.
\mathrm{kat}and\mathrm{k}\mathrm{a}\mathrm{t}arebyte-identical in pdfTeX, which is the same fact from the other side.
Known under-application: a
\operatorname{...}body, whose runs are builtfrom individual characters and so carry no control word at their span.
Oracle
TeX Live 2025 pdflatex under the harness preamble (
12pt,T1,lmodern,margin=1in,\parindent=0pt), read with\showbox, not from the PDF:pdfTeX rounds a kern to 1/1000 em when it writes the content stream (0.012 bp
at 12 pt), a fifth of the effect being measured. pdflatex is an oracle only
and is never in the product path.
\mathrm{...}\text{...}limm)ff)detthas none)Regression test
crates/render-pipeline/tests/math_text_italic_correction.rs. Onmain:The fourth test (
\bmod) passes on main and is a guard:dhas no correction,and the
\kern0.32639in that box isec-lmr12's own(LABEL C o)(KRN C d R 0.0272)lig/kern pair, not an italic correction.Corpus
tools/visual-oracle/rank.py, 22 fixtures / 59 pages, 15120 aligned words.Within 0.5 bp: unchanged (dx 87.63%, dy 77.52%, both 72.28%) — the
correction is ~0.057 bp, far below that bucket. Total |dx| 38497.75 →
38486.30 bp, on inline-math p1 (−9.256), twelvept-plain p2 (−1.300) and
inline-math p2 (−0.891); every page toward the oracle, none away.
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; this is pipeline-only and needs no re-pin.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu