parse: \genfrac, and the two triangle binary operators - #7
Merged
Conversation
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
force-pushed
the
genfrac-triangles
branch
from
August 31, 2026 12:55
c1ee3c7 to
0b512c7
Compare
This was referenced Aug 31, 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.
Three of the commands the
go-tex/enginecorpus 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:
They are not the ⊲ ⊳ of
\vartriangleleft/\vartrianglerightalready 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:An empty thickness means
\over— the font's own rule — and any other means\abovethat thickness, 0pt being no rule at all. That is how\binomitself 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, whichreadOptionalDelimhandles 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\genfracshapes render; and the rule is what separates the two families — an empty thickness draws a<rect>,0ptdoes not.