Generating Content MathML

SnuggleTeX can attempt to convert input LaTeX to Content MathML by first creating Enhanced Presentation MathML and then processing that. In many ways, this part of the process is relatively simple since most of the semantic structure has already been inferred (though might not necessarily make any sense).

The following tables demonstrate the types of inputs that we support.

Supported Operators

LaTeX operator Application Content MathML element Live Example
+ unary or n-ary <plus/> x+1
- unary or binary <minus/> -a-b
Any multiplication n-ary <times/> A\times 3x
Any division binary <divide/> 1/2/{3\div 4}
\vee n-ary <or/> A\vee B
\wedge n-ary <and/> A\wedge B
\cup n-ary <union/> A\cup B
\cap n-ary <intersect/> A\cap B
\setminus binary <setdiff/> A\setminus B\setminus C
\lnot unary (prefix) <not/> \lnot \lnot A
! unary (postfix) <factorial/> x!!
Any mix of relation operators binary, applied in adjacent pairs See below 1\leq x < y


  • Operators may be left “unapplied”, e.g. a raw input of + would result in <plus/> with no enclosing <apply/>.+
  • Failures will be registered if an operator is used in an inappropriate context.

Supported Relation Operators

LaTeX operator Content MathML element Live Example
= <eq/> x=1
\not= <neq/> x\not=a
< <lt/> a<b
\not< <not>...<lt/>...</not> a\not<b
> <gt/> a>b
\not> <not>...<gt/>...</not> a\not>b
\leq <leq/> x\leq 1
\not\leq <not>...<leq/>...</not> x\not\leq 1
\geq <geq/> x\geq 1
\not\geq <not>...<geq/>...</not> x\not\geq 1
\equiv <equivalent/> a\equiv b
\not\equiv <not>...<equivalent/>...</not> a\not\equiv b
\approx <approx/> x\approx 1
\not\approx <not>...<approx/>...</not> x\not\approx 1
\mid <factorof/> a\mid b
\not\mid <not>...<factorof/>...</not> a\not\mid b
\in <in/> a\in A
\not\in <notin/> a\not\in A


  • Relation operators will be paired up earlier in the up-conversion process. Where there are two or more relations together, each pairing becomes an operand of an enclosing logical and when converting to Content MathML. So a LaTeX input like 1<x\leq 2 will result in the same output as (1<x) \land (x \leq 2).
  • Note that this pairing is still done for inputs like a=b=c, even though they could have been converted to an n-ary application of the <eq/> operator.

Supported Pre-defined Functions

LaTeX function Arity Invertible Content MathML element Live Example
\sin unary Yes <sin/> or <arcsin/> \sin x
\cos unary Yes <cos/> or <arccos/> \cos^{-1} 0
\tan unary Yes <tan/> or <arctan/> \tan\tan^{-1}x
\sec unary Yes <csc/> or <arcsec/> \sec 0
\cot unary Yes <cot/> or <arccot/> \cot x
\sinh unary Yes <sinh/> or <arcsinh/> \sinh x
\cosh unary Yes <cosh/> or <arccosh/> \cosh x
\tanh unary Yes <tanh/> or <arctanh/> \tanh x
\sech unary Yes <sech/> or <arcsech/> \sech^{-1}x
\csch unary Yes <csch/> or <arccsch/> \csch x
\coth unary Yes <coth/> or <arccoth/> \coth x
\arcsin unary No <arcsin/> \arcsin x
\arccos unary No <arccos/> \arccos x
\arctan unary No <arctan/> \arctan x
\arcsec unary No <arcsec/> \arcsec x
\arccsc unary No <arccsc/> \arccsc x
\arccot unary No <arccot/> \arccot x
\arcsinh unary No <arcsinh/> \arcsinh x
\arccosh unary No <arccosh/> \arccosh x
\arctanh unary No <arctanh/> \arctanh x
\arcsech unary No <arcsech/> \arcsech x
\arccsch unary No <arccsch/> \arccsch x
\arccoth unary No <arccoth/> \arccoth x
\ln unary No <ln/> \ln x
\log unary No <log/> \log x
\exp unary No <exp/> \exp x
\det unary No <determinant/> \det A
\gcd n-ary No <gcd/> \gcd(x,y)
\lcm n-ary No <lcm/> \lcm(x,y)
\max n-ary No <max/> \max(1,2,3)
\min n-ary No <min/> \min A
\Re n-ary No <real/> \Re z
\Im n-ary No <imaginary/> \Im(1+3i)


  • For all functions, constructs like \cos^3 x is interpreted as “cosine x raised to the power of 3”. This behaviour is used for any power that is a number greater than or equal to 1.\cos^2x+\sin^2x = 1
  • For functions listed as Invertible in the table above, the up-conversion process interprets constructs like \sin^{-1} x as the “inverse sin of x” and would result in <apply><arcsin/><ci>x</ci></apply>. A failure will be noted if constructs like these are used on functions which do not support this.\sin^{-1}0 = 0
  • For the log function, an input like \log_a x is interpreted as “logarithm to base a of x”.\log_{10}100 = 2

Supported Fixed Symbols

LaTeX symbol Content MathML interpretation Live Example
\emptyset <emptyset/> A=\emptyset
\infty <infinity/> x<\infty

Configurable Symbols

Some input symbols are not given pre-defined meanings and instead may be configured, either via the custom \assumeSymbol macro provided as part of the snuggletex-upconversion module, or via the Java API.

The following table shows examples of what is available:

LaTeX input Content MathML interpretation Live Example
\assumeSymbol{e}{exponentialNumber} $e$ <exponentiale/> e
\assumeSymbol{e}{exponentialNumber} $e^x$ Application of <exp/> function e
\assumeSymbol{i}{imaginaryNumber} $i$ <imaginaryi/> i
\assumeSymbol{\pi}{constantPi} $\pi$ <pi/> \pi
\assumeSymbol{\gamma}{eulerGamma} $\gamma$ <eulergamma/> \gamma
\assumeSymbol{f}{function} $f(x)$ Application of a function called f, rather than a product f(x)+a(x)


Interpretation of Brackets

SnuggleTeX inteprets brackets of various types according to the following default rules:

LaTeX input Default Content MathML intepretation Live Example
(x) Round brackets treated as grouping only (x)
(x,y) Round fence treated as <vector/> (x,y)
[x,y] Square fence treated as <list/> [x,y]
\{x,y\} Curly fence treated as <set/> \{x,y\}

From SnuggleTeX 1.2.0 onwards, this behaviour can be changed using the \setUpConversionOption command. Here are some examples:

Live Example Notes
\setUpConversionOption{roundBracketHandling}{list} $(x)$ Creates a list
\setUpConversionOption{roundFenceHandling}{set} $(1,2)$ Creates a set
\setUpConversionOption{squareFenceHandling}{vector} $[x]$ Creates a vector
\setUpConversionOption{curlyFenceHandling}{error} $[x]$ Treated as an error
\setUpConversionOption{squareFenceHandling}{grouping} $a[x]$ Treated as a grouping only

Other Supported Constructs