MathTheme sets defaults for the formulas below it — Math, MathSpan and
the formulas of MathText. Read the nearest one with MathTheme.of(context);
MathThemeData.copyWith returns a copy with fields replaced.
Field
What it sets
color
Formula colour. Wins over the text style’s colour, so set it per light and dark theme.
errorColor
Colour of parse errors drawn in place.
placeholderColor
Colour of placeholders for unfinished input.
selectionColor
Selection highlight. Defaults to the ambient DefaultSelectionStyle.
classColors
Colours for parts marked \htmlClass{name}{…}, by class name.
classStyles
Full styles per class name (MathClassStyle: colour, background, bold, scale). A colour here wins over classColors.
font
The math font. Defaults to the bundled Latin Modern Math.
fallbackFonts
Fonts tried, in order, for symbols the math font lacks.
debugOverlay
Draws every item’s box, the baseline, italic corrections and break points.
Mark parts with \htmlClass{name}{…} (or \class{name}{…}) and style them by
name. MathClassStyle.scale changes the part’s size relative to the formula,
and is applied at layout, so the formula makes room for it.
For fonts — the math font, symbol fallbacks and the text fonts — see
Styling and fonts.
How formulas look below a MathTheme: the colour (set it per light
and dark theme), the error and placeholder colours, the selection
colour, colours per \htmlClass / \class name, the math font, and a
layout debug overlay.
Constructor
Description
MathThemeData({…})
Creates theme data; null fields fall back to the text style and the widgets’ defaults.
MathThemeData: more
constMathThemeData({
this.color,
this.errorColor,
this.placeholderColor,
this.selectionColor,
this.classColors =const {},
this.classStyles =const {},
this.font,
this.fallbackFonts =const [],
this.debugOverlay =false,
})
Field
Type
Default
Description
color
Color?
Colour of formulas (default: the text style’s colour).
errorColor
Color?
Colour of parse errors drawn in place.
placeholderColor
Color?
Colour of placeholders (unfinished input, empty editor slots).
Colours for parts marked \htmlClass{name}{…} (or \class{name}{…}), by class name — for example a “step” colour in a worked solution. Like KaTeX, \htmlClass needs ParseOptions(trust: true) (or a trust callback allowing it).
classStyles
Map<String, MathClassStyle>
const {}
Full styles (colour, background, bold, size) per class name; a colour here wins over classColors.
font
MathFont?
The math font (default: the bundled Latin Modern Math).
fallbackFonts
List<MathFont>
const []
Fonts for symbols the math font lacks, tried in order (see MathFont.symbols).
debugOverlay
bool
false
Draw every item’s box, the baseline, italic corrections and break points, for debugging layout.
Member
Type
Description
resolvedClassStyles
Map<String, MathClassStyle>
classStyles with classColors folded in.
copyWith({…})
MathThemeData
A copy with the given fields replaced.
apply(LayoutOptions options)
LayoutOptions
options with this theme’s error and placeholder colours and class sizes.