Skip to content
Talk to an engineerRequest access

Parse tree

Every node class parseLatex produces, the values the nodes carry (atom types, styles, lengths, colours), and how to walk the tree.

parseLatex returns a ParseResult whose root is a RowNode: the formula as a tree of MathNodes. The tree is syntactic. It records what was written (a fraction, a font change, a delimiter) and leaves every size and position to layout. Nodes are immutable, and each carries the span of source it came from.

dump() prints a tree as a compact s-expression, without spans:

final result = parseLatex(r'\frac{a}{b} + x^2');
print(result.dump());
// (row (frac num:(row braced (sym text="a" atom="ord"))
// den:(row braced (sym text="b" atom="ord")))
// (sym text="+" atom="bin")
// (scripts base:(sym text="x" atom="ord") sup:(sym text="2" atom="ord")))

(The output is on one line; it is wrapped here.)

children gives a node’s non-null children and slots its named child slots, so a recursive walk needs no per-class code:

int fractions(MathNode node) =>
(node is FracNode ? 1 : 0) +
node.children.fold(0, (n, child) => n + fractions(child));
fractions(parseLatex(r'\frac{a}{b} + x^2').root); // 1

MathNode is sealed, so a switch can match node classes with patterns:

for (final node in result.root.nodes) {
switch (node) {
case FracNode(:final numerator, :final denominator):
print('fraction ${numerator.dump()} over ${denominator.dump()}');
case SymbolNode(:final text, :final atom):
print('symbol $text ($atom)');
default:
print(node.kind);
}
}

ParseResult.idOf(node) gives a node a stable id that survives streaming and reparsing, and ParseResult.nodeById(id) finds it again; the display list carries the same ids, which is how a tap on the layout is traced back to a node.

The kind column is the name dump() prints for the node.

Class kind Description
RowNode row An ordered list of nodes: the body of a group, an argument, a formula.
SymbolNode sym One math-mode symbol: a letter, digit, operator or delimiter character.
TextNode text A run of text-mode characters, shaped as one unit.
SpaceNode space Explicit horizontal space.
RuleNode rule A filled rectangle: \rule[shift]{width}{height}.
VerbNode verb Verbatim text from \verb.
GraphicsNode graphics An image from \includegraphics (trusted input only).
FracNode frac A fraction or binomial.
ScriptsNode scripts A base with subscript and/or superscript, and optionally prescripts.
SqrtNode sqrt A radical: \sqrt[index]{body}.
OpNode op A large operator: a symbol (\sum) or a name (\lim, \operatorname).
LeftRightNode leftright \left … \middle … \right.
MiddleNode middle \middle delimiter inside a LeftRightNode.
DelimSizeNode delimsize A delimiter of fixed size: \big(, \Biggr].
AccentNode accent An accent over or under a base: \hat, \widetilde, \overrightarrow, \utilde, and text accents.
LineNode overline, underline \overline / \underline.
BraceNode brace \overbrace / \underbrace and similar stretchy braces. A label is a script on the enclosing ScriptsNode.
OverUnderNode overunder \overset, \underset, \stackrel: a base with material stacked above and/or below at script size.
ExtArrowNode xarrow An extensible arrow with labels: \xrightarrow[below]{above}.
EncloseNode enclose A box around, through or behind content: \boxed, \fbox, \colorbox, \fcolorbox, \cancel, \bcancel, \xcancel, \sout, \cancelto, \angl, \phase, \longdiv, \textcircled.
PhantomNode phantom \phantom, \hphantom, \vphantom: invisible content that keeps some of its size.
SmashNode smash \smash: content whose height and/or depth count as zero.
LapNode lap \llap, \rlap, \clap and their \math… forms: zero-width content overlapping its neighbours.
ReflectNode reflect graphicx’s \reflectbox (its argument is text, as a box’s) and \mathreflectbox (math): content mirrored left to right.
RaiseNode raise \raisebox, \raise, \lower.
VCenterNode vcenter \vcenter: content centred on the math axis.
StyleNode style \displaystyle and friends: the rest of the group in another style.
SizeNode size \tiny … \Huge: the rest of the group at another size.
FontNode font A font change: \mathbb{…}, \textbf{…}, \bf, \boldsymbol, \emph.
ColorNode color A colour change: \textcolor{c}{…} or \color{c} (rest of group).
TextGroupNode textgroup Text mode: \text{…}, \mbox{…}, \hbox{…}. The body holds TextNode runs and math islands ($…$).
ClassNode class Forces an atom class: \mathbin{…}, \mathrel{…}, \mathord{…}, \mathopen, \mathclose, \mathpunct, \mathinner.
MathChoiceNode mathchoice \mathchoice{D}{T}{S}{SS}: content chosen by the current style.
ArrayNode array A tabular structure: arrays, matrices, aligned equations, cases, CD.
MultiColumnNode multicolumn \multicolumn{n}{spec}{body}: a cell spanning count columns.
MultiRowNode multirow multirow’s \multirow[vpos]{rows}{width}[vmove]{text}: text set across several rows of a table, centred on them by default.
CellColorNode cellcolor \cellcolor / \rowcolor inside an array cell: a background fill.
CdArrowNode cdarrow An arrow cell in a CD diagram: @>a>b>, @VVV, @=, @..
TagNode tag \tag{…} / \tag*{…}.
RefNode ref \ref{name} / \eqref{name}; resolved against a document at layout.
LinkNode link \href{url}{…} and \url{…}.
HtmlNode html \htmlClass, \htmlId, \htmlStyle, \htmlData, \class: a hook the renderer maps to theme classes, ids or semantic tags.
LineBreakNode newline \\ or \newline outside an environment: start a new line.
BreakNode break A break opportunity or prohibition: \allowbreak, \nobreak, \penalty, \linebreak, \nolinebreak.
ErrorNode error Input that could not be understood. The rest of the formula renders; this node shows raw in the error style.
IncompleteNode incomplete A placeholder for input that has not arrived yet: a missing argument at the end of input, or a half-typed command (\fra).
DiagramNode tikzcd tikz-cd’s tikzcd environment: a grid of objects and the arrows between them.
ProofTreeNode prooftree bussproofs’ prooftree environment: inference rules stacked into a tree, the conclusion at the bottom.

A node of the math syntax tree.

More about MathNode

Nodes are immutable and carry the span of source they came from. The tree is syntactic: it records what was written (a fraction, a font change, a delimiter) and leaves every size and position to layout.

Field Type Default Description
span SourceSpan Where in the normalized source this node came from.
Member Type Description
kind String Short name used by dump.
props Map<String, Object?> Scalar attributes, for dump and tooling.
slots List<(String, MathNode?)> Named child slots, in source order. Absent children are null.
children Iterable<MathNode> The non-null children.
dump() String A compact, deterministic s-expression of the subtree, for tests and debugging. Spans are omitted.

How limits are placed on a large operator.

Value Description
auto The operator’s default: above/below in display style for \sum-like operators, beside for \int-like ones.
limits \limits: always above and below.
noLimits \nolimits: always beside.
displayLimits \displaylimits: above/below in display style only.

An ordered list of nodes: the body of a group, an argument, a formula.

Constructor Description
RowNode(span, nodes, {braced = false, incomplete = false}) Creates a row.
Field Type Default Description
nodes List<MathNode> required The row’s nodes.
braced bool false Written as {…}; in TeX a braced group becomes a single ord atom.
incomplete bool false The closing brace was missing at the end of input.

One math-mode symbol: a letter, digit, operator or delimiter character.

Constructor Description
SymbolNode(span, text, atom, {command, variant = false}) Creates a symbol.
Field Type Default Description
text String required The Unicode text (one grapheme cluster).
atom AtomType required Its TeX atom class.
command String? The command that produced it (\alpha), or null for a literal.
variant bool false Use the font’s variant glyph (e.g. \varnothing, italic \varGamma).

A run of text-mode characters, shaped as one unit.

Constructor Description
TextNode(span, text) Creates a text run.
Field Type Default Description
text String required The text, including interior spaces.

Kind of SpaceNode.

Value Description
fixed A fixed width.
interword A normal inter-word space (\ , \space), width from the font.
nonBreaking A non-breaking inter-word space (~, \nobreakspace).

Explicit horizontal space.

Constructor Description
SpaceNode(span, {width, spaceKind = SpaceKind.fixed, command}) Creates a space.
Field Type Default Description
width Dimension? Width for SpaceKind.fixed; null otherwise.
spaceKind SpaceKind SpaceKind.fixed Kind of space.
command String? The command, e.g. \quad.

A filled rectangle: \rule[shift]{width}{height}.

Constructor Description
RuleNode(span, width, height, {shift}) Creates a rule.
Field Type Default Description
width Dimension required Width.
height Dimension required Height.
shift Dimension? Raise above the baseline.

Verbatim text from \verb.

Constructor Description
VerbNode(span, text, {starred = false}) Creates verbatim text.
Field Type Default Description
text String required The verbatim content.
starred bool false \verb* (spaces shown as ␣).

An image from \includegraphics (trusted input only).

Constructor Description
GraphicsNode(span, source, {width, height, totalHeight, alt}) Creates an image.
Field Type Default Description
source String required Image URL.
width Dimension? Requested width.
height Dimension? Requested height above the baseline.
totalHeight Dimension? Requested height plus depth.
alt String? Alternative text.

A fraction or binomial.

Constructor Description
FracNode(span, numerator, denominator, {…}) Creates a fraction.
FracNode: more
const FracNode(
super.span,
this.numerator,
this.denominator, {
this.hasBar = true,
this.barThickness,
this.leftDelim,
this.rightDelim,
this.style,
this.continued = false,
this.numeratorAlign,
this.command,
})
Field Type Default Description
numerator MathNode required Top part.
denominator MathNode required Bottom part.
hasBar bool true Whether a bar is drawn.
barThickness Dimension? Bar thickness; null means the font’s default.
leftDelim String? Left delimiter (( for \binom), or null.
rightDelim String? Right delimiter, or null.
style MathStyle? Forced style (\dfrac → display, \tfrac → text), or null.
continued bool false \cfrac: continued-fraction spacing.
numeratorAlign String? \cfrac[l]/[r] numerator alignment: l, r, or null (centre).
command String? The command, e.g. \frac, \over.

A base with subscript and/or superscript, and optionally prescripts.

Constructor Description
ScriptsNode(span, {base, sub, sup, preSub, preSup}) Creates a scripted node.
Field Type Default Description
base MathNode? The base; null for scripts with nothing before them (^2).
sub MathNode? Subscript.
sup MathNode? Superscript.
preSub MathNode? Pre-subscript (\sideset, \prescript).
preSup MathNode? Pre-superscript.

A radical: \sqrt[index]{body}.

Constructor Description
SqrtNode(span, body, {index}) Creates a radical.
Field Type Default Description
body MathNode required Radicand.
index MathNode? Root index, or null.

A large operator: a symbol (\sum) or a name (\lim, \operatorname).

Constructor Description
OpNode(span, body, {…}) Creates an operator.
OpNode: more
const OpNode(
super.span,
this.body, {
required this.isSymbol,
required this.limitsByDefault,
this.limits = LimitsMode.auto,
this.command,
this.smashLimits,
})
Field Type Default Description
body MathNode required The operator: a SymbolNode for symbols, a row for names.
isSymbol bool required Whether body is a single large symbol.
limitsByDefault bool required Whether limits go above/below in display style by default.
limits LimitsMode LimitsMode.auto Explicit \limits / \nolimits / \displaylimits.
command String? The command, e.g. \sum.
smashLimits String? mathtools’ \smashoperator: which sides’ limits take no width (lr, l, r), or null.
Member Type Description
withLimits(LimitsMode mode, SourceSpan span) OpNode A copy with a different limits mode.
withSmashedLimits(String sides) OpNode A copy whose limits overhang on sides (\smashoperator).

\left … \middle … \right.

Constructor Description
LeftRightNode(span, left, right, body, {incomplete = false}) Creates a delimited group.
Field Type Default Description
left String required Left delimiter (. for none).
right String required Right delimiter (. for none).
body RowNode required Content, possibly containing MiddleNodes.
incomplete bool false \right was missing at the end of input.

\middle delimiter inside a LeftRightNode.

Constructor Description
MiddleNode(span, delim) Creates a middle delimiter.
Field Type Default Description
delim String required The delimiter.

A delimiter of fixed size: \big(, \Biggr].

Constructor Description
DelimSizeNode(span, delim, size, atom) Creates a sized delimiter.
Field Type Default Description
delim String required The delimiter.
size int required 1 (\big) to 4 (\Bigg).
atom AtomType required Atom class: open (l), close (r), rel (m) or ord (plain).

An accent over or under a base: \hat, \widetilde, \overrightarrow, \utilde, and text accents.

Constructor Description
AccentNode(span, base, accent, {…}) Creates an accent.
AccentNode: more
const AccentNode(
super.span,
this.base,
this.accent, {
this.stretchy = false,
this.under = false,
this.command,
this.skew = 0,
})
Field Type Default Description
base MathNode required The accented node.
accent String required The accent: a spacing Unicode character (^, ˜, →) or, for stretchy shapes without one, a name (overgroup).
stretchy bool false Stretches to the base width.
under bool false Drawn below the base.
command String? The command.
skew double 0 \skew{n}…: the accent moved right by this many mu.

\overline / \underline.

Constructor Description
LineNode(span, body, {required over}) Creates an over- or underline.
Field Type Default Description
body MathNode required The content.
over bool required Over (true) or under (false).

\overbrace / \underbrace and similar stretchy braces. A label is a script on the enclosing ScriptsNode.

Constructor Description
BraceNode(span, body, brace, {required over}) Creates a horizontal brace.
Field Type Default Description
body MathNode required The content.
brace String required The brace character (⏞, ⏟, ⏠, ⏡).
over bool required Above (true) or below (false).

\overset, \underset, \stackrel: a base with material stacked above and/or below at script size.

Constructor Description
OverUnderNode(span, base, {over, under, atom}) Creates a stacked node.
Field Type Default Description
base MathNode required The base.
over MathNode? Above.
under MathNode? Below.
atom AtomType? Atom class of the result; null means the base’s class.

An extensible arrow with labels: \xrightarrow[below]{above}.

Constructor Description
ExtArrowNode(span, command, {above, below}) Creates an extensible arrow.
Field Type Default Description
command String required The command, which names the arrow shape.
above MathNode? Label above.
below MathNode? Label below.

A box around, through or behind content: \boxed, \fbox, \colorbox, \fcolorbox, \cancel, \bcancel, \xcancel, \sout, \cancelto, \angl, \phase, \longdiv, \textcircled.

Constructor Description
EncloseNode(span, body, notations, {…}) Creates an enclosure.
EncloseNode: more
const EncloseNode(
super.span,
this.body,
this.notations, {
this.background,
this.borderColor,
this.target,
this.command,
this.padding,
this.ruleWidth,
})
Field Type Default Description
body MathNode required The content.
padding Dimension? Space between the frame and the content (\fboxsep), when set.
ruleWidth Dimension? The frame’s thickness (\fboxrule), when set.
notations Set<String> required MathML-style notations: box, updiagonalstrike, downdiagonalstrike, horizontalstrike, updiagonalarrow, actuarial, phasorangle, longdiv, circle, roundedbox.
background LatexColor? Fill colour.
borderColor LatexColor? Border colour.
target MathNode? \cancelto target value.
command String? The command.

\phantom, \hphantom, \vphantom: invisible content that keeps some of its size.

Constructor Description
PhantomNode(span, body, {keepWidth = true, keepHeight = true}) Creates a phantom.
Field Type Default Description
body MathNode required The invisible content.
keepWidth bool true Keeps the content’s width (false for \vphantom).
keepHeight bool true Keeps the content’s height and depth (false for \hphantom).

\smash: content whose height and/or depth count as zero.

Constructor Description
SmashNode(span, body, {height = true, depth = true}) Creates a smash.
Field Type Default Description
body MathNode required The content.
height bool true Zero the height (\smash and \smash[t]).
depth bool true Zero the depth (\smash and \smash[b]).

\llap, \rlap, \clap and their \math… forms: zero-width content overlapping its neighbours.

Constructor Description
LapNode(span, body, side, {command}) Creates a lap.
Field Type Default Description
command String? The command, e.g. \mathllap.
body MathNode required The content.
side String required left, right or center.

graphicx’s \reflectbox (its argument is text, as a box’s) and \mathreflectbox (math): content mirrored left to right.

Constructor Description
ReflectNode(span, body, {command = r'\reflectbox'}) Creates a reflected box.
Field Type Default Description
command String r'\reflectbox' The command, \reflectbox or \mathreflectbox.
body MathNode required The content.

\raisebox, \raise, \lower.

Constructor Description
RaiseNode(span, body, shift, {…}) Creates a raised box.
RaiseNode: more
const RaiseNode(
super.span,
this.body,
this.shift, {
this.byHeight = 0,
this.byDepth = 0,
this.byWidth = 0,
})
Field Type Default Description
body MathNode required The content.
shift Dimension required Upward shift (negative lowers).
byHeight double 0 Added to shift: multiples of the content’s height, depth and width (\raisebox{-0.5\height}).
byDepth double 0 Added to shift: multiples of the content’s height, depth and width (\raisebox{-0.5\height}).
byWidth double 0 Added to shift: multiples of the content’s height, depth and width (\raisebox{-0.5\height}).

\vcenter: content centred on the math axis.

Constructor Description
VCenterNode(span, body) Creates a centred box.
Field Type Default Description
body MathNode required The content.

\displaystyle and friends: the rest of the group in another style.

Constructor Description
StyleNode(span, style, body, {cramped = false, inheritStyle = false}) Creates a style change.
Field Type Default Description
style MathStyle required The new style.
body RowNode required Affected content.
cramped bool false mathtools’ \cramped: the cramped form of the style (superscripts lower, as in a denominator).
inheritStyle bool false Keep the surrounding style (style is not used): \cramped{…} without a style.

\tiny … \Huge: the rest of the group at another size.

Constructor Description
SizeNode(span, size, body) Creates a size change.
Field Type Default Description
size int required 1 (\tiny) … 6 (\normalsize) … 11 (\Huge).
body RowNode required Affected content.

A font change: \mathbb{…}, \textbf{…}, \bf, \boldsymbol, \emph.

Constructor Description
FontNode(span, font, body) Creates a font change.
Field Type Default Description
font String required The font command without backslash: mathbb, mathcal, mathscr, mathfrak, mathsf, mathtt, mathit, mathrm, mathbf, mathnormal, boldsymbol, pmb, textrm, textsf, texttt, textbf, textmd, textit, textup, textsc, textnormal, emph.
body MathNode required Affected content.

A colour change: \textcolor{c}{…} or \color{c} (rest of group).

Constructor Description
ColorNode(span, color, body) Creates a colour change.
Field Type Default Description
color LatexColor required The colour.
body MathNode required Affected content.

Text mode: \text{…}, \mbox{…}, \hbox{…}. The body holds TextNode runs and math islands ($…$).

Constructor Description
TextGroupNode(span, body, {command}) Creates a text-mode group.
Field Type Default Description
body RowNode required The content.
command String? The command.

Forces an atom class: \mathbin{…}, \mathrel{…}, \mathord{…}, \mathopen, \mathclose, \mathpunct, \mathinner.

Constructor Description
ClassNode(span, atom, body) Creates a class override.
Field Type Default Description
atom AtomType required The forced class.
body MathNode required The content.

\mathchoice{D}{T}{S}{SS}: content chosen by the current style.

Constructor Description
MathChoiceNode(span, display, text, script, scriptScript) Creates a style-dependent choice.
Field Type Default Description
display MathNode required Display style content.
text MathNode required Text style content.
script MathNode required Script style content.
scriptScript MathNode required Scriptscript style content.

The layout family of an ArrayNode.

Value Description
array array, darray, subarray: explicit column spec.
matrix matrix family and smallmatrix.
cases cases family: left column math, right column often text.
aligned aligned, align, alignat, split, eqnarray: alternating right/left aligned columns.
gathered gathered, gather: centred rows.
equation equation: one centred row.
multline multline: first row left, last right, middle centred.
cd CD: commutative diagram.
substack \substack: centred rows at script size.

A column separator line style.

Value Description
solid Solid line.
dashed Dashed line.

One entry of an array column specification.

A content column: l, c or r, or a paragraph column p{w}, m{w}, b{w} whose text-mode cells break into lines width wide (aligned to the row at their top, middle or bottom line).

Constructor Description
AlignColumn(align, {width, before, after}) Creates a column.
Field Type Default Description
align String required l, c, r, or p, m, b for paragraph columns.
width Dimension? The line width of a paragraph column; null for l, c, r.
before String? The array package’s >{…}: TeX put at the start of each cell.
after String? The array package’s <{…}: TeX put at the end of each cell.
Member Type Description
isParagraph bool Whether this is a paragraph column (p, m, b).
lineAlign String How a paragraph column’s lines sit: c after >{\centering}, r after >{\raggedleft}, l after >{\raggedright}, else j (justified, as TeX sets paragraphs).
isMathColumn bool Whether >{$} and <{$} make the cells math.
withCode({String? before, String? after}) AlignColumn This column with before and after set.

A vertical rule between columns: | or :.

Constructor Description
SeparatorColumn(style) Creates a separator.
Field Type Default Description
style LineStyle required Line style.

@{…}: material replacing the inter-column space.

Constructor Description
SpacerColumn(content) Creates a spacer.
Field Type Default Description
content RowNode required The material.

A horizontal rule between rows.

Constructor Description
HLine(style, {…}) Creates a rule. fromColumn/toColumn limit a \cline (1-based, inclusive); null means full width.
HLine: more
const HLine(
this.style, {
this.fromColumn,
this.toColumn,
this.thickness = 1,
this.spaceAbove = 0,
this.spaceBelow = 0,
this.command,
})
Field Type Default Description
style LineStyle required Line style.
thickness double 1 Thickness as a multiple of the default rule width (booktabs rules are heavier or lighter); 0 draws nothing (\addlinespace).
spaceAbove double 0 Space above and below the rule, in em (booktabs pads its rules).
spaceBelow double 0 Space above and below the rule, in em (booktabs pads its rules).
command String? The command that made it when it is not \hline, \hdashline or \cline (\toprule, \midrule, \bottomrule, \cmidrule, \addlinespace), for writing it back.
fromColumn int? First column for \cline.
toColumn int? Last column for \cline.

One row of an ArrayNode.

Constructor Description
ArrayRow(cells, {…}) Creates a row.
ArrayRow: more
const ArrayRow(
this.cells, {
this.gap,
this.linesAbove = const [],
this.tag,
this.label,
this.numbered = false,
})
Field Type Default Description
cells List<MathNode> required The cells.
gap Dimension? Extra space after this row (\\[1em]).
linesAbove List<HLine> const [] Rules drawn above this row.
tag TagNode? \tag for this row.
label String? \label for this row.
numbered bool false Whether this row gets an automatic equation number.

A tabular structure: arrays, matrices, aligned equations, cases, CD.

Constructor Description
ArrayNode(span, environment, arrayKind, rows, {…}) Creates an array.
ArrayNode: more
const ArrayNode(
super.span,
this.environment,
this.arrayKind,
this.rows, {
this.columns = const [],
this.linesBelow = const [],
this.leftDelim,
this.rightDelim,
this.style,
this.arrayStretch,
this.incomplete = false,
this.container,
this.position,
this.columnSep,
this.jot,
})
Field Type Default Description
environment String required Environment name (pmatrix, align*) or command (\substack, plain TeX’s \matrix).
arrayKind ArrayKind required Layout family.
rows List<ArrayRow> required Rows.
columns List<ColumnSpec> const [] Column specification for array-like environments. For starred matrices (pmatrix*[r]) a single entry applies to every column. Empty when the environment’s default applies.
linesBelow List<HLine> const [] Rules below the last row.
leftDelim String? Surrounding left delimiter (( for pmatrix, { for cases).
rightDelim String? Surrounding right delimiter.
style MathStyle? Forced style (smallmatrix → script, dcases → display).
arrayStretch double? Row-height factor from \def\arraystretch{…}, or null.
incomplete bool false \end was missing at the end of input.
container String? An environment around this one that only wraps it (subequations, fleqn): this environment keeps its numbers, and toLatex writes the wrapper back.
position String? Vertical position (\begin{aligned}[t], \begin{array}[b]): t puts the first row’s baseline on the surrounding baseline, b the last row’s; null centres the array on the math axis.
columnSep Dimension? The space on each side of a column (\arraycolsep, \tabcolsep), when set; null uses the environment’s default.
jot Dimension? Extra space between the rows of alignments (\jot), when set.
Member Type Description
withPosition(String? position) ArrayNode This array with the given position (null keeps the current one).

\multicolumn{n}{spec}{body}: a cell spanning count columns.

Constructor Description
MultiColumnNode(span, count, columns, body) Creates a spanning cell.
Field Type Default Description
count int required Number of columns spanned.
columns List<ColumnSpec> required Column specification for the spanning cell.
body MathNode required Cell content.

multirow’s \multirow[vpos]{rows}{width}[vmove]{text}: text set across several rows of a table, centred on them by default.

Constructor Description
MultiRowNode(span, count, body, {position, width, move}) Creates a cell spanning count rows (negative: the rows above).
Field Type Default Description
count int required Rows spanned, counting this one; negative counts go upward.
body MathNode required The text.
position String? t, b or null (centred): which spanned row’s baseline the text takes.
width Dimension? A paragraph width the text wraps to; null for its natural width (*).
move Dimension? Raised by this much (multirow’s vmove).

\cellcolor / \rowcolor inside an array cell: a background fill.

Constructor Description
CellColorNode(span, color, {wholeRow = false}) Creates a cell or row fill.
Field Type Default Description
color LatexColor required Fill colour.
wholeRow bool false \rowcolor: the fill covers the whole row.

An arrow cell in a CD diagram: @>a>b>, @VVV, @=, @..

Constructor Description
CdArrowNode(span, direction, {first, second}) Creates a CD arrow.
Field Type Default Description
direction String required right, left, up, down, equals (horizontal =), vequals (vertical |), or none (@.).
first MathNode? Label above (horizontal) or left (vertical).
second MathNode? Label below (horizontal) or right (vertical).

\tag{…} / \tag*{…}.

Constructor Description
TagNode(span, body, {starred = false, left = false}) Creates a tag.
Field Type Default Description
body RowNode required The tag text (text mode).
starred bool false \tag*: no parentheses.
left bool false plain TeX’s \leqno: the number goes at the left margin.

\ref{name} / \eqref{name}; resolved against a document at layout.

Constructor Description
RefNode(span, name, {parenthesized = false}) Creates a reference.
Field Type Default Description
name String required The label referred to.
parenthesized bool false \eqref: shown in parentheses.

\href{url}{…} and \url{…}.

Constructor Description
LinkNode(span, url, body) Creates a link.
Field Type Default Description
url String required Target URL.
body MathNode required Link content.

\htmlClass, \htmlId, \htmlStyle, \htmlData, \class: a hook the renderer maps to theme classes, ids or semantic tags.

Constructor Description
HtmlNode(span, attribute, value, body) Creates a hook.
Field Type Default Description
attribute String required class, id, style or data.
value String required The attribute value.
body MathNode required Wrapped content.

\\ or \newline outside an environment: start a new line.

Constructor Description
LineBreakNode(span, {gap, command}) Creates a line break.
Field Type Default Description
gap Dimension? Extra vertical space (\\[2pt]).
command String? \newline, or null for \\ (in an array cell \\ ends the row, \newline breaks the line inside it).

A break opportunity or prohibition: \allowbreak, \nobreak, \penalty, \linebreak, \nolinebreak.

Constructor Description
BreakNode(span, penalty, {command}) Creates a break control. penalty follows TeX: ≤ −10000 forces a break, ≥ 10000 forbids one.
Field Type Default Description
penalty int required TeX penalty.
command String? The command.

Input that could not be understood. The rest of the formula renders; this node shows raw in the error style.

Constructor Description
ErrorNode(span, code, message, raw) Creates an error node.
Field Type Default Description
code String required Diagnostic code.
message String required Human-readable message.
raw String required The offending source text.

A placeholder for input that has not arrived yet: a missing argument at the end of input, or a half-typed command (\fra).

Constructor Description
IncompleteNode(span, {partial = ''}) Creates a placeholder.
Field Type Default Description
partial String '' What was typed so far (\fra), empty for a missing argument.

An arrow tip of a DiagramArrow, at its start or end.

Value Description
none No tip.
arrow An arrowhead pointing away from the arrow (->, the start of <-).
twoHeads Two arrowheads (two heads, ->>).
bar A bar across the line (the start of mapsto, |->).
hook A hook (hook), curling to the arrow’s left.
hookOpposite A hook curling to the arrow’s right (hook').
tail An arrowhead pointing along the arrow (tail, >->).
harpoon A one-sided arrowhead on the arrow’s left (harpoon).
harpoonOpposite A one-sided arrowhead on the arrow’s right (harpoon').

How the line of a DiagramArrow is drawn.

Value Description
solid A solid line.
dashed A dashed line (dashed).
dotted A dotted line (dotted).

Where a DiagramLabel sits relative to its arrow.

Value Description
auto Beside the arrow, on its left (on its right when swapped), as TikZ’s auto places labels.
description On the arrow, which is broken around it (description).
center Centred on the arrow, which is not broken (marking, and every label of a phantom arrow).
above Above the point (above).
below Below the point (below).
left Left of the point (left).
right Right of the point (right).

A label on a DiagramArrow: "f", "f"', "f" near start.

Constructor Description
DiagramLabel(body, {…}) Creates a label.
DiagramLabel: more
const DiagramLabel(
this.body, {
this.options = const [],
this.swap = false,
this.position = 0.5,
this.placement = DiagramLabelPlacement.auto,
this.color,
})
Field Type Default Description
body MathNode required The label, laid out as math (in script style).
options List<String> const [] The options after the closing quote, as written (' for a swap), for writing the label back.
swap bool false On the arrow’s right instead of its left (', swap).
position double 0.5 Where along the arrow, from 0 (start) to 1 (end): near start is 0.25, near end 0.75.
placement DiagramLabelPlacement DiagramLabelPlacement.auto How it is placed.
color LatexColor? Its colour, or null for the arrow’s.

An arrow of a DiagramNode: tikz-cd’s \arrow[options] (or \ar).

Constructor Description
DiagramArrow(span, {…}) Creates an arrow.
DiagramArrow: more
const DiagramArrow(
this.span, {
required this.row,
required this.column,
required this.fromRow,
required this.fromColumn,
required this.toRow,
required this.toColumn,
this.direction = '',
this.labels = const [],
this.options = const [],
this.head = DiagramTip.arrow,
this.tail = DiagramTip.none,
this.doubleLine = false,
this.line = DiagramLine.solid,
this.drawn = true,
this.bend = 0,
this.shift,
this.crossingOver = false,
this.color,
})
Field Type Default Description
span SourceSpan required The \arrow command and its arguments.
row int required The cell the arrow was written in (0-based).
column int required The cell the arrow was written in (0-based).
fromRow int required The cell it starts from: its own cell unless from= says otherwise.
fromColumn int required The cell it starts from: its own cell unless from= says otherwise.
toRow int required The cell it ends at.
toColumn int required The cell it ends at.
direction String '' The direction as written (r, dr, rr), or empty when to= gives the target.
labels List<DiagramLabel> const [] Labels, in order.
options List<String> const [] The other options, as written and in order (hook, bend left=20, dashed): written back by toLatex; layout reads the fields below.
head DiagramTip DiagramTip.arrow The tip at the end.
tail DiagramTip DiagramTip.none The tip at the start.
doubleLine bool false Drawn as a double line (Rightarrow, equal).
line DiagramLine DiagramLine.solid Solid, dashed or dotted.
drawn bool true False for phantom and draw=none: only the labels show.
bend double 0 bend left (positive) or bend right (negative), in degrees.
shift Dimension? shift left (positive) or shift right (negative), or null.
crossingOver bool false crossing over: arrows drawn before this one are broken where it crosses them.
color LatexColor? The arrow’s colour, or null for the diagram’s.
Member Type Description
rowOffset int Rows down from fromRow to toRow.
columnOffset int Columns right from fromColumn to toColumn.
symbol String The Unicode arrow closest to this one (→, ⇒, ↘, ↦, ↪), for text outputs; empty for a phantom arrow.

tikz-cd’s tikzcd environment: a grid of objects and the arrows between them.

Constructor Description
DiagramNode(span, rows, {…}) Creates a diagram.
DiagramNode: more
const DiagramNode(
super.span,
this.rows, {
this.arrows = const [],
this.options = const [],
this.rowSep,
this.columnSep,
this.rowSepBetweenOrigins = false,
this.columnSepBetweenOrigins = false,
this.incomplete = false,
})
Field Type Default Description
rows List<List<MathNode>> required The cells, row by row.
arrows List<DiagramArrow> const [] The arrows, in the order they were written.
options List<String> const [] The environment’s options as written (row sep=large), for writing them back.
rowSep Dimension? Space between rows (row sep), or null for tikz-cd’s normal.
columnSep Dimension? Space between columns (column sep), or null for normal.
rowSepBetweenOrigins bool false rowSep is the distance between row baselines, not between rows (row sep={2em,between origins}).
columnSepBetweenOrigins bool false columnSep is the distance between column centres.
incomplete bool false \end{tikzcd} was missing at the end of input.
Member Type Description
columnCount int Number of columns: the longest row.

How the line of a ProofStep is drawn.

Value Description
single One line (\singleLine).
double Two lines (\doubleLine).
none No line (\noLine).

One inference of a ProofTreeNode (an axiom when it has no premises): \AxiomC{…}, \UnaryInfC{…}, \BinaryInfC{…}…

Constructor Description
ProofStep(span, command, conclusion, {…}) Creates an inference.
ProofStep: more
const ProofStep(
this.span,
this.command,
this.conclusion, {
this.premises = const [],
this.beforeCenter,
this.leftLabel,
this.rightLabel,
this.rule = ProofRule.single,
this.ruleStyle = DiagramLine.solid,
})
Field Type Default Description
span SourceSpan required The command and its argument.
command String required The command as written (\AxiomC, \UIC, \BinaryInf).
conclusion MathNode required What is inferred: text (with math in $…$) for the C forms; for the $…$ forms, the math after \fCenter (all of it when there is no \fCenter).
beforeCenter MathNode? The $…$ forms: the math before \fCenter, or null. Premises and conclusion line up on their \fCenters.
premises List<ProofStep> const [] The premises, left to right (none for an axiom).
leftLabel MathNode? \LeftLabel{…} (text).
rightLabel MathNode? \RightLabel{…} (text).
rule ProofRule ProofRule.single Single, double or no line.
ruleStyle DiagramLine DiagramLine.solid Solid, dashed or dotted line.
Member Type Description
isAxiom bool Whether this is an axiom (\AxiomC, \Axiom): a formula with no line.
isMath bool Whether the formula is math (the $…$ forms), not text.

bussproofs’ prooftree environment: inference rules stacked into a tree, the conclusion at the bottom.

Constructor Description
ProofTreeNode(span, roots, {rootAtTop = false, incomplete = false}) Creates a proof tree.
Field Type Default Description
roots List<ProofStep> required The finished trees; one in a well-formed proof.
rootAtTop bool false \rootAtTop: the tree grows downwards.
incomplete bool false \end{prooftree} was missing at the end of input.
Member Type Description
steps Iterable<ProofStep> Every step, premises before their conclusion (the order written).

The enums and small value classes the nodes carry.

TeX’s math atom classes (TeXbook ch. 17), which decide spacing.

Value Description
ord Ordinary: letters, digits, most symbols.
op Large operator: \sum, \int, \lim.
bin Binary operation: +, \times.
rel Relation: =, <, \to.
open Opening delimiter: (, \langle.
close Closing delimiter: ), \rangle.
punct Punctuation: ,, ;.
inner Inner: fractions and \left…\right groups.

The four TeX math styles.

Value Description
display \displaystyle.
text \textstyle.
script \scriptstyle.
scriptScript \scriptscriptstyle.

A unit of length.

Value Description
pt TeX point, 1/72.27 in.
mm Millimetre.
cm Centimetre.
inch Inch.
bp Big (PostScript) point, 1/72 in.
pc Pica, 12 pt.
dd Didot point.
cc Cicero, 12 dd.
nd New Didot point.
nc New cicero, 12 nd.
sp Scaled point, 1/65536 pt.
px Pixel (KaTeX extension); same size as bp.
em Width of an M in the current font: the font size.
ex x-height of the current font.
mu Math unit, 1/18 em of the math font (only in math mode).
Member Type Description
texName String The TeX spelling.
static parse(String name) LengthUnit? Parses a TeX unit name.
isAbsolute bool Whether the unit is absolute (convertible to points without a font).
points double Points per unit for absolute units.

A length such as -1.5em.

Constructor Description
Dimension(value, unit) Creates a length.
Field Type Default Description
value double required The number.
unit LengthUnit required The unit.
Member Type Description
static zero = Dimension(0, LengthUnit.pt) Zero points.
operator -() Dimension This length with the value negated.
toString() String As TeX reads it: plain decimal digits, never an exponent (1e+20) or a wrapped-around integer, whatever the value’s size.

A colour, 8 bits per channel with alpha.

Constructor Description
LatexColor(argb) Creates a colour from a 32-bit 0xAARRGGBB value.
LatexColor.fromARGB(int a, int r, int g, int b) Creates a colour from components.
Field Type Default Description
argb int required The colour as 0xAARRGGBB.
Member Type Description
alpha int Alpha, 0–255.
red int Red, 0–255.
green int Green, 0–255.
blue int Blue, 0–255.