Skip to content

engine: assignments and stretch carry no maths - #173

Merged
tannevaled merged 1 commit into
mainfrom
math-skips-and-setlength
Aug 31, 2026
Merged

engine: assignments and stretch carry no maths#173
tannevaled merged 1 commit into
mainfrom
math-skips-and-setlength

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Three families reached the maths layer as unknown commands, and an unknown command costs the whole formula.

what it is source
\setlength{\len}{dim} an assignment, two arguments \def\setlength#1#2{#1 #2\relax} latex.ltx:7347
\hfil \hfill \hss \hfilneg (and the v-forms) \hskip with a fixed glue, so no argument primitive("hfil",hskip,fil_code), fil_glue = 0pt plus 1fil — tex.web:20547, §3318
\leftskip \parskip \baselineskip glue parameters: assignments reading a <glue> tex.web §224

The maths layer cannot stretch, so what \hfill contributes inside a formula is nothing — and the glue parameters take TeX's optional equals, which scanMathGlue now accepts (\leftskip=0pt as well as \leftskip 0pt).

Measured — 200 arXiv papers, 200 beamer talks

11 documents change and 3 repaginate for +1290 glyphs; the page error against the 157 tectonic renders falls 656 → 655. beamer gains 17 glyphs on one talk.

Test

mathskips_test.go: eight shapes — \hfill, \hss, \vfil, \setlength, \addtolength, \leftskip=0pt, \leftskip 0pt, \parskip\medskipamount — must each leave the maths layer with nothing to drop. All eight fail on main.

Three families reached the maths layer as unknown commands, and an unknown command
costs the WHOLE formula:

  - \setlength{\len}{dim} is \def\setlength#1#2{#1 #2\relax} (latex.ltx:7347), an
    assignment with two arguments — \addtolength beside it (:7348);
  - \hfil and its kin are \hskip with a fixed glue:
    primitive("hfil",hskip,fil_code) with fil_glue = 0pt plus 1fil (tex.web:20547,
    §3318), so they take no argument at all. The maths layer cannot stretch, so what
    they contribute here is nothing;
  - \leftskip and the other glue PARAMETERS are assignments that read a <glue>
    (tex.web §224), with TeX's optional equals before it, which scanMathGlue now
    accepts.

Measured over 200 arXiv papers and 200 beamer talks: 11 documents change and 3
repaginate for +1290 glyphs; the page error against the 157 tectonic renders falls
656 -> 655. beamer gains 17 glyphs on one talk.
@tannevaled
tannevaled merged commit 1f096b2 into main Aug 31, 2026
18 checks passed
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