Skip to content

parse: \genfrac, and the two triangle binary operators - #7

Merged
tannevaled merged 1 commit into
mainfrom
genfrac-triangles
Aug 31, 2026
Merged

parse: \genfrac, and the two triangle binary operators#7
tannevaled merged 1 commit into
mainfrom
genfrac-triangles

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Three of the commands the go-tex/engine corpus reports as dropped formulas live here, not in the engine.

\triangleleft and \triangleright — 98 dropped formulas

Missing from the symbol table. They are binary operators at U+25C1 and U+25B7:

\UnicodeMathSymbol{"025B7"}{\triangleright}{\mathbin}{(large) right triangle, open}
\UnicodeMathSymbol{"025C1"}{\triangleleft }{\mathbin}{(large) left triangle, open}
                                          % unicode-math-table.tex:694/704
\DeclareMathSymbol{\triangleleft}{\mathbin}{letters}{"2F}   % fontmath.ltx:264-265

They are not the ⊲ ⊳ of \vartriangleleft/\vartriangleright already in the table, which amssymb makes relations: the two pairs differ in glyph and in spacing.

\genfrac — 88 dropped formulas

\genfrac{left}{right}{thickness}{style}{num}{den}, amsmath's generalised fraction:

\edef\@tempb{\@nx\@genfrac\@mathstyle{#4}%
  \csname @@\ifx @#3@over\else above\fi
  \ifx\@tempa\@empty \else withdelims\fi\endcsname}   % amsmath.sty:245-250

An empty thickness means \over — the font's own rule — and any other means \above that thickness, 0pt being no rule at all. That is how \binom itself is defined: \genfrac()\z@{} (amsmath.sty:240). The style argument is TeX's digit — 0 display, 1 text, 2 script, 3 scriptscript — and empty keeps the style in force.

Both real uses in the corpus are the delimited no-rule form: a q-binomial written \genfrac[]{0pt}{}{n}{k} and \genfrac{\{}{\}}{0pt}{}. Note the delimiters arrive unbraced there, as TeX takes single tokens for arguments, which readOptionalDelim handles alongside {} for "no delimiter on this side".

Documented reduction: a non-zero explicit thickness draws the font's rule rather than that exact width — fraction() takes its thickness from the font's MATH table.

Test

genfrac_test.go: both triangles render as operators; the five \genfrac shapes render; and the rule is what separates the two families — an empty thickness draws a <rect>, 0pt does not.

Three of the commands the go-tex/engine corpus reports as dropped formulas live
here, not in the engine.

\triangleleft and \triangleright were missing. They are BINARY operators at U+25C1
and U+25B7 — unicode-math-table.tex:704/694, and fontmath.ltx:264-265 declares both
\mathbin — and they are not the ⊲ ⊳ of \vartriangleleft/right already in the table,
which amssymb makes relations: the two pairs differ in glyph and in spacing. 98
dropped formulas over the arXiv corpus.

\genfrac{left}{right}{thickness}{style}{num}{den} is amsmath's generalised
fraction (amsmath.sty:245-250):

	\edef\@tempb{\@nx\@genfrac\@mathstyle{#4}%
	  \csname @@\ifx @#3@over\else above\fi
	  \ifx\@tempa\@empty \else withdelims\fi\endcsname}

so an EMPTY thickness means \over — the font's own rule — and any other means
\above that thickness, 0pt being no rule at all. That is how \binom itself is
defined: \genfrac()\z@{} (amsmath.sty:240). The style argument is TeX's digit: 0
display, 1 text, 2 script, 3 scriptscript, empty keeping the style in force. Both
real uses in the corpus are the delimited no-rule form — a q-binomial written
\genfrac[]{0pt}{}{n}{k} and \genfrac{\{}{\}}{0pt}{} — and 88 formulas were dropped
for it. The delimiters arrive UNBRACED there, as TeX takes single tokens for
arguments, which readOptionalDelim handles beside {} for "no delimiter this side".

\z@ needs its own note: this parser has no catcodes, so amsmath's own spelling of
zero arrives as \z and @, and read as \z alone it would draw a rule where the
binomial wants none. The @ that follows a control word is absorbed with it.

Documented reduction: a non-zero explicit thickness draws the font's rule rather
than that exact width, since fraction() takes its thickness from the font's MATH
table.
@tannevaled
tannevaled merged commit de01b51 into main Aug 31, 2026
11 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