Generating MathML
Mathematica 5.0 includes several functions for generating MathML from the boxes and expressions used internally by Mathematica to represent equations. You can enter an equation in a notebook using palettes, menus, or keyboard shortcuts and then convert it into MathML using one of these conversion functions. All the MathML conversion functions are located in the XML`MathML` context.
You can use BoxesToMathML to generate MathML from a box structure. By default, this generates presentation markup only.
In[3]:=
Out[3]=
Alternatively, you can use ExpressionToMathML to convert a typeset equation in a notebook into MathML. By default, this generates combined markup with both the presentation markup and content markup for the equation enclosed in a semantics element.
In[4]:=
Out[4]=
The annotationxml element is used to provide additional information of a type specified by its encoding attribute. Here, the encoding attribute has the value "MathMLContent" indicating that the annotationxml element contains content MathML.
You can use the option "Formats" to generate either presentation MathML or content MathML only. You can also set the option "Annotations" {} to suppress the header information. For more details, see MathML Conversion Options.
In[5]:=
Out[5]=
It is important to note that ExpressionToMathML evaluates its first argument before converting it to MathML. Hence, if you supply an expression that can be simplified on evaluation, you may get unexpected results. For example, suppose you want to generate the presentation markup for the following definite integral.
In[6]:=
Out[6]=
Since the integral evaluates to give the result 1, the following command generates the MathML representation of 1 instead of the integral.
In[7]:=
Out[7]=
To get the MathML representation of the integral, you must force the integral to remain unevaluated by wrapping the Unevaluated function around it.
In[8]:=
Out[8]=
Setting Options
These are all the functions that generate MathML as output.

ExpressionToSymbolicMathML
These functions all accept the following options.
Using these options, you can control various features of the generated MathML, such as including an XML declaration or DTD declaration, generating presentation markup, content markup, or both, and using an explicit namespace declaration and namespace prefix.
You can specify the options explicitly each time you evaluate one of the MathML functions. Alternatively, you can use the SetOptions command to change the default values of the options for a particular function. The option values you set are then used for all subsequent evaluations of that function.
For example, evaluating the following command ensures that the output for all subsequent evaluations of ExpressionToMathML will by default generate presentation MathML only and omit the header information in the output.
In[9]:=
Out[9]=
