Skip to content

render-pipeline: \limsup and \liminf have a thin space inside them - #462

Merged
GoKubar merged 1 commit into
mainfrom
agent/kabir-claude/limsup-thin-space
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/kabir-claude/limsup-thin-space

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Stacked PR 2 of 3 (math detail, lane nixos-math-detail). Base:
agent/kabir-claude/math-text-italic-correction (#461) — review that first;
this diff is only the second commit.

Mechanism

\limsup and \liminf 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 and we set one word with a zero
gap. The space is re-derived from the control word at the atom's span
(operator_thin_space_split) and the operator becomes an Op atom whose
nucleus is the list lim + 3mu glue + sup.

That is also TeX's own shape, which matters: with a sub_mlist nucleus
make_op takes the else delta:=0 branch, so the Rule 13a limits get no ±δ/2
shift. Nucleus::List already yields δ = 0 in math-layout, so the structures
agree.

The part that is easy to get wrong

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 and §752 leaves it its
delta:

\setbox0=\hbox{$\limsup$}\showbox0        \setbox0=\hbox{$\liminf$}\showbox0
.\hbox(8.38399+2.33331)x36.06792          .\hbox(8.38399+0.0)x32.60657
..\kern 0.0 ..l ..i ..m                   ..\kern 0.0 ..l ..i ..m
..\kern0.05731                            ..\kern0.05731
..\glue 1.99997                           ..\glue 1.99997
..s ..u ..p                               ..i ..n ..f  ..\kern0.84708

So the gap from m to s is 2.05728 pt, not the 1.99997 pt of the glue
alone — a fix that inserted only a thin space would still be 0.057 pt short.
\wd confirms it from the other side: $\mathrm{limsup}$ is 34.01064 pt and
$\limsup$ is 36.06792, and the difference 2.05728 is exactly the correction
plus the glue. \liminf likewise closes with f's \kern0.84708, which it
gets for free from #461.

Oracle

TeX Live 2025 pdflatex under the harness preamble, \showbox / \showthe\wd.
pdflatex is an oracle only and is never in the product path.

Regression test

crates/render-pipeline/tests/math_operator_thin_space.rs. On main:

`\limsup`: `s` after the `m` of `lim`: 9.7554 bp, pdflatex 11.8050 bp (off by -2.0496)
`\liminf`: `inf`'s `i` after the `m` of `lim`: 9.7554 bp, pdflatex 11.8050 bp (off by -2.0496)

(9.7554 bp is m's own advance, i.e. no gap at all.) The third test,
mathrm_limsup_is_one_word_with_no_thin_space, passes on main and is a guard
that the split comes from the control word and not from the letters.

Corpus

No effect: the 22 fixtures contain no \limsup and no \liminf (checked
by grep, and the corpus numbers are byte-identical to #461's). This fix is
carried by the oracle and the regression test, not by the corpus — stating
that plainly rather than implying a win that is not there.

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. Pipeline-only; nothing under vendor/ is touched,
so no re-pin is needed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

@GoKubar
GoKubar changed the base branch from agent/kabir-claude/math-text-italic-correction to main September 14, 2026 19:57
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)
@GoKubar
GoKubar force-pushed the agent/kabir-claude/limsup-thin-space branch from f4b438c to f818952 Compare September 14, 2026 20:00
@GoKubar
GoKubar merged commit bb7776f into main Sep 14, 2026
21 checks passed
@GoKubar
GoKubar deleted the agent/kabir-claude/limsup-thin-space branch September 14, 2026 20:04
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