Skip to content

Options

TemmlOptions holds the settings of a render. Pass it to RenderToString, RenderToMathMLTree, DefinePreamble, or the methods of TemmlDom. Every property is optional.

var options = new TemmlOptions
{
DisplayMode = true,
Annotate = true,
Leqno = false,
ThrowOnError = false,
ErrorColor = "#b22222",
Macros = new TemmlMacroDictionary(),
Wrap = TemmlWrap.None,
Xml = false,
ColorIsTextColor = false,
Strict = false,
Trust = false,
MaxExpand = 1000,
};
var markup = TemmlRenderer.RenderToString(tex, options);

snippet source | anchor

Property Type Default What it does
DisplayMode bool false Renders a block equation in display style instead of inline math.
Annotate bool false Adds an <annotation> element that holds the TeX source. Annotated math gets no soft line breaks.
Leqno bool false Puts \tags of display math on the left.
ThrowOnError bool false Throws ParseError instead of returning error markup.
ErrorColor string "#b22222" Color of unsupported commands and error markup.
Macros TemmlMacroDictionary? null Custom macros. \gdef writes into this dictionary.
Wrap TemmlWrap None Soft line breaks in inline math. See below.
Xml bool false Writes the MathML namespace on the <math> element, for consumers that need it.
ColorIsTextColor bool false Makes \color take an argument, like \textcolor, as old MathJax and KaTeX did.
Strict bool false Rejects conveniences that LaTeX itself does not accept.
Trust bool false Allows commands that load resources or set HTML attributes. See Security.
TrustHandler Func<TemmlTrustContext, bool>? null Decides for each such command. When set, it decides instead of Trust.
MaxSize pair of double unlimited Caps user-specified sizes: the first number in em, the second in pt.
MaxExpand int 1000 Limits macro expansions, which stops infinite macro loops.

Wrap lets a browser break long inline math. TemmlWrap.Tex allows a break after each top-level relation and binary operator. TemmlWrap.Equals allows a break before the second and each later top-level =. Display math, annotated math, and expressions with a hard break (\\ or \cr) get no soft breaks. Chromium and Firefox honor them; WebKit does not.

var options = new TemmlOptions { Wrap = TemmlWrap.Tex };
var markup = TemmlRenderer.RenderToString(@"y = a + b = c + d", options);

snippet source | anchor

var options = new TemmlOptions { Annotate = true, Xml = true };
var markup = TemmlRenderer.RenderToString(@"x^2", options);

snippet source | anchor

In display mode, \tag labels an equation. AMS environments such as equation and align number themselves with a CSS counter from the Temml stylesheet.

E = mc^2 \tag{1.1}
E=mc2(1.1)

\ref and \eqref need a post-processing pass.

MIT · Copyright 2020 Ron Kok · unofficial community port of Temml