MathML reference

People

Qing Wang
Undergraduate Researcher

June 13, 2023

Part 0. Why there are two kinds of MathML and what is the difference?

Presentation markup captures notational structure. It encodes the notational structure of an expression in a sufficiently abstract way to facilitate rendering to various media. Thus, the same presentation markup can be rendered with relative ease on screen in either wide and narrow windows, in ASCII or graphics, in print, or it can be enunciated in a sensible way when spoken. It does this by providing information such as structured grouping of expression parts, classification of symbols, etc.

Presentation markup does not directly concern itself with the mathematical structure or meaning of an expression. In many situations, notational structure and mathematical structure are closely related, so a sophisticated processing application may be able to heuristically infer mathematical meaning from notational structure, provided sufficient context is known. However, in practice, the inference of mathematical meaning from mathematical notation must often be left to the reader.

Employing presentation tags alone may limit the ability to re-use a MathML object in another context, especially evaluation by external applications.

Content markup captures mathematical structure. It encodes mathematical structure in a sufficiently regular way in order to facilitate the assignment of mathematical meaning to an expression by application programs. Though the details of mapping from mathematical expression structure to mathematical meaning can be extremely complex, in practice, there is wide agreement about the conventional meaning of many basic mathematical constructions. Consequently, much of the meaning of a content expression is easily accessible to a processing application, independently of where or how it is displayed to the reader. In many cases, content markup could be cut from a Web browser and pasted into a mathematical software tool with the confidence that sensible values will be computed.

Since content markup is not directly concerned with how an expression is displayed, a renderer must infer how an expression should be presented to a reader. While a sufficiently sophisticated renderer and style sheet mechanism could in principle allow a user to read mathematical documents using personalized notational preferences, in practice, rendering content expressions with notational nuances may still require the intervention of some sort.

Employing content tags alone may limit the ability of the author to precisely control how an expression is rendered.

Both content and presentation tags are necessary in order to provide the full expressive capability one would expect in a mathematical markup language. Often the same mathematical notation is used to represent several completely different concepts. For example, the notation x^i may be intended (in polynomial algebra) as the i-th power of the variable x, or as the i-th component of a vector x (in tensor calculus). In other cases, the same mathematical concept may be displayed in one of the various notations. For instance, the factorial of a number might be expressed with an exclamation mark, a Gamma function, or a Pochhammer symbol.

Thus, the same notation may represent several mathematical ideas, and, conversely, the same mathematical idea often has several notations. In order to provide authors with the ability to precisely control notation while at the same time encoding meanings in a machine-readable way, both content and presentation markup are needed.

In general, if it is important to control exactly how an expression is rendered, presentation markup will generally be more satisfactory. If it is important that the meaning of an expression can be interpreted dependably and automatically, then content markup will generally be more satisfactory.



Part 1. Presentational-MathML elements


Top-level element

<math> Top-level MathML element used to write a single mathematical formula.
Attributes
display: its default value is inline
  • display = block: this element will be displayed in its own block outside the current span of text.
  • display = inline: this element will be displayed inside the current span of text.
Example The infinite sum

n = 1 + 1 n 2 is equal to the real number π 2 6

     <p>
        <math display="block"> 
            <mrow>
            <munderover>
                <mo></mo>
                <mrow>
                <mi>n</mi>
                <mo>=</mo>
                <mn>1</mn>
                </mrow>
                <mrow>
                <mo>+</mo>
                <mn></mn>
                </mrow>
            </munderover>
            <mfrac>
                <mn>1</mn>
                <msup>
                <mi>n</mi>
                <mn>2</mn>
                </msup>
            </mfrac>
            </mrow>
        </math>
        is equal to the real number
        <math display="inline">  
            <mfrac>
            <msup>
                <mi>π</mi>
                <mn>2</mn>
            </msup>
            <mn>6</mn>
            </mfrac>
        </math>
    </p>   
    

Token elements

<mi> Indicates that the content should be rendered as an identifier such as function names, variables, or symbolic constants.
Attributes
  • mi accepts global attributes.
  • For mi elements that contain a single character, the default value of the mathvariant attribute is italic. Otherwise, the mathvariant attribute is normal.
Example sin y F
<math display="block">
    <!-- Multiple characters, default mathvariant is "normal". -->
    <mi>sin</mi>
</math>

<math display="block">
    <!-- Single character, default mathvariant is "italic". -->
    <mi>y</mi>
</math>

<math display="block">
    <!-- Overriding default mathvariant. -->
    <mi mathvariant="normal">F</mi>
</math>
    
<mn> Represents a numeric literal which is normally a sequence of digits with a possible separator (a dot or a comma). It is also allowed to have arbitrary text in it which is actually a numeric quantity
Attributes mn: accepts global attributes.
Example 0 1.337 twelve XVI 2e10
<math display="block">
    <mn>0</mn>
</math>

<math display="block">
    <mn>1.337</mn>
</math>

<math display="block">
    <mn>twelve</mn>
</math>

<math display="block">
    <mn>XVI</mn>
</math>

<math display="block">
    <mn>2e10</mn>
</math>
        
<mo> Represents an operator in a broad sense. Besides operators in strict mathematical meaning, this element also includes "operators" like parentheses, separators like commas and semicolons, or "absolute value" bars.
Attributes mo: accepts global attributes.
accent: A boolean indicating whether the operator should be treated as an accent when used as an under or overscript (i.e. drawn bigger and closer to the base expression).
  • accent = True: does draw bigger and closer to the base expression.
  • accent = False: does not draw bigger and closer to the base expression.
fence: A boolean indicating whether the operator is a fence (such as parentheses).
  • fence = True: the operator is a fence.
  • fence = False: the operator is not a fence.
separator: A boolean indicating whether the operator is a separator (such as commas).
  • separator = True: the operator is a separator.
  • separator = False: the operator is not a separator.
stretchy: A boolean indicating whether the operator stretches to the size of the adjacent element.
  • stretchy = True: stretches to the size of adjacent element.
  • stretchy = False: does not stretches to the size of adjacent element.
symmetric: A boolean indicating whether a stretchy operator should be vertically symmetric around the imaginary math axis (centered fraction line).
  • symmetric = True: a stretchy operator should be vertically symmetric around the imaginary math axis.
  • symmetric = False: a stretchy operator does not have to be vertically symmetric around the imaginary math axis.
movablelimits: A boolean indicating whether attached under- and overscripts move to sub- and superscript positions when math-style is set to compact.
  • movablelimits = True: allow to perform the movement.
  • movablelimits = False: do not allow to perform the movement.
lspace: indicates the amount of space before the operator.
  • lspace = <length>: set the space to a specific thickness given the unit.
  • lspace = <percentage>: set the space relative to its parent object.
rspace: indicates the amount of space after the operator.
  • rspace = <length>: set the space to a specific thickness given the unit.
  • rspace = <percentage>: set the space relative to its parent object.
maxsize: indicates the maximum size of the operator when it is stretchy.
  • maxsize = <length>: set the size to a specific thickness given the unit.
  • maxsize = <percentage>: set the size relative to its parent object.
minsize: indicates the minimum size of the operator when it is stretchy.
  • minsize = <length>: set the size to a specific thickness given the unit.
  • minsize = <percentage>: set the size relative to its parent object.
Example 5 + 5 [ 0 ; 1 )
<math display="block">
    <mrow>
        <mn>5</mn>
        <mo>+</mo>
        <mn>5</mn>
    </mrow>
</math>

<math display="block">
    <mrow>
        <mo>[</mo> <!-- default form value: prefix -->
        <mrow>
        <mn>0</mn>
        <mo>;</mo> <!-- default form value: infix -->
        <mn>1</mn>
        </mrow>
        <mo>)</mo> <!-- default form value: postfix -->
    </mrow>
</math>
    
<ms> Represents a string literal meant to be interpreted by programming languages and computer algebra systems.
Attributes ms: accepts global attributes.
Example Hello World!
<math display="block">
    <ms>Hello World!</ms>
</math>
    
<mspace> Used to display a blank space, whose size is set by its attributes.
Attributes
depth: desired depth (below the baseline) of the space.
  • depth = <length>: set the depth to a specific thickness given the unit.
  • depth = <percentage>: set the depth relative to its parent object.
height: desired height (above the baseline) of the space.
  • height = <length>: set the height to a specific thickness given the unit.
  • height = <percentage>: set the height relative to its parent object.
width: desired width of the space.
  • width = <length>: set the width to a specific thickness given the unit.
  • width = <percentage>: set the width relative to its parent object.
Example 1 2
<math display="block">
    <mn>1</mn>
    <mspace depth="40px" height="20px" width="100px"
            style="background: lightblue;"/>
    <mn>2</mn>
</math>
    
<mtext> Used to render arbitrary text with no notational meaning, such as comments or annotations.
Attributes mtext: accepts global attributes.
Example Theorem of Pythagoras /* comment here */
<math display="block">
    <mtext>Theorem of Pythagoras</mtext>
</math>

<math display="block">
    <mtext>/* comment here */</mtext>
</math>
    

General Layout

<menclose> Renders its content inside an enclosing notation specified by the notation attribute.
Attributes menclose: accepts global attributes.
notation: layout element that encompasses expression. Multiple options.
  • notation = longdiv: enclose in long division symbol.
  • notation = actuarial: enclose in actuarial symbol.
  • notation = box: enclose in an enclosed box.
  • notation = roundedbox: enclose in a rounded box.
  • notation = circle: enclose in a circle.
  • notation = left: line to the left of the content.
  • notation = right: line to the right of the content.
  • notation = top: line to above content.
  • notation = bottom: line to bottom content.
  • notation = updiagonalstrike: - strikeout line through contents from lower left to upper right.
  • notation = downdiagonalstrike: - strikeout line through contents from upper left to lower right.
  • notation = verticalstrike: - vertical strikeout line through contents.
  • notation = horizontalstrike: - horizontal strikeout line through contents.
  • notation = madruwb: - Arabic factorial symbol.
  • notation = phasorangle: - phasor angle.
Example x + y
<math display="block">
    <menclose notation="horizontalstrike box">
        <mi>x</mi>
        <mo>+</mo>
        <mi>y</mi>
    </menclose>
</math>
    
<merror> Used to display contents as error messages. The intent of this element is to provide a standard way for programs that generate MathML from other inputs to report syntax errors.
Attributes merror: accepts global attributes.
Example Syntax error: \frac{1} 3
<math display="block">
    <mfrac>
        <merror>
        <mtext>Syntax error: \frac{1}</mtext>
        </merror>
        <mn>3</mn>
    </mfrac>
</math>
    
<mfrac> Used to display fractions and fraction-like objects such as binomial coefficients and Legendre symbols.
Attributes mfrac: accepts global attributes.
denomalign: The alignment of the denominator under the fraction (not standard, only accepted by Safari).
  • denomalign = center: (default) place the denominator on center.
  • denomalign = left: place the denominator on left.
  • denomalign = right: place the denominator on right.
numalign: The alignment of the numerator under the fraction (not standard, only accepted by Safari).
  • numalign = center: (default) place the numerator on center.
  • numalign = left: place the numerator on left.
  • numalign = right: place the numerator on right.
linethickness: indicates the thickness of the horizontal fraction line.
  • linethickness = <length>: set the line to a specific thickness given the unit.
  • linethickness = <percentage>: set the line to a size relative to its parent.
Example a + 2 3 b
<math display="block">
    <mfrac>
        <mrow>
        <mi>a</mi>
        <mo>+</mo>
        <mn>2</mn>
        </mrow>
        <mrow>
        <mn>3</mn>
        <mo></mo>
        <mi>b</mi>
        </mrow>
    </mfrac>
</math>
    
( n k )
<math display="block">
    <mrow>
        <mo>(</mo>
        <mfrac linethickness="0">
        <mi>n</mi>
        <mi>k</mi>
        </mfrac>
        <mo>)</mo>
    </mrow>
</math>
    
<mpadded> Used to add extra padding and to set the general adjustment of position and size of enclosed contents.
Attributes mpadded: accepts global attributes.
depth: desired depth (below the baseline) of the mpadded element.
  • depth = <length>: set the depth to a specific thickness given the unit.
  • depth = <percentage>: set the depth relative to its parent object.
height: desired height (above the baseline) of the mpadded element.
  • height = <length>: set the height to a specific thickness given the unit.
  • height = <percentage>: set the height relative to its parent object.
width: desired width of the mpadded element.
  • width = <length>: set the width to a specific thickness given the unit.
  • width = <percentage>: set the width relative to its parent object.
lspace: indicating the horizontal location of the positioning point of the child content with respect to the positioning point of the mpadded element.
  • lspace = <length>: set the horizontal line to a specific thickness given the unit.
  • lspace = <percentage>: set the horizontal line relative to its parent object.
voffset: indicating the vertical location of the positioning point of the child content with respect to the positioning point of the mpadded element.
  • voffset = <length>: set the vertical line to a specific thickness given the unit.
  • voffset = <percentage>: set the vertical line relative to its parent object.
Example x + y
<math display="block">
    <mpadded width="400px" height="5em" depth="4em"
            lspace="300px" voffset="-2em"
            style="background: lightblue">
        <mi>x</mi>
        <mo>+</mo>
        <mi>y</mi>
    </mpadded>
</math>
    
<mphamtom> Renders the element invisibly, but dimensions (such as height, width, and baseline position) are still kept.
Attributes mphamtom: accepts global attributes.
Example x + y + z
<math display="block">
    <mrow>
        <mi>x</mi>
        <mo>+</mo>
        <mphantom>
        <mi>y</mi>
        <mo>+</mo>
        </mphantom>
        <mi>z</mi>
    </mrow>
</math>
    
<mroot> Used to display roots with an explicit index. Two arguments are accepted, the first element is the base, and the second element is the index.
Attributes mroot: accepts global attributes.
Example x 3
<math display="block">
    <mroot>
        <mi>x</mi>
        <mn>3</mn>
    </mroot>
</math>
    
<mrow> important Used to group sub-expressions, which usually contain one or more operators with their respective operands (such as <mi> and <mn>).
Attributes mrow: accepts global attributes.
Example 1 + K 3 ( x + y )
<math display="block">
    <mfrac>
        <mrow>
            <!-- numerator content grouped in one mrow -->
            <mn>1</mn>
            <mo>+</mo>
            <mi>K</mi>
        </mrow>
        <mrow>
            <!-- denominator content grouped in one mrow -->
            <mn>3</mn>
            <mrow>
                <!-- fenced expression grouped in one mrow -->
                <mo>(</mo>
                <mrow>
                <!-- fenced content grouped in one mrow -->
                <mi>x</mi>
                <mo>+</mo>
                <mi>y</mi>
                </mrow>
                <mo>)</mo>
            </mrow>
        </mrow>
    </mfrac>
</math>
    
<msqrt> Display square root symbol (no index is displayed).
Attributes msqrt: accepts global attributes.
Example x
<math display="block">
    <msqrt>
        <mi>x</mi>
    </msqrt>
</math>
    

Script and limit elements

<mmultiscripts> Used to attach an arbitrary number of subscripts and superscripts to an expression at once, generalizing the msubsup element. Scripts can be either prescripts (placed before the expression) or postscripts (placed after it).
Attributes mmultiscripts: accepts global attributes.
subscriptshift: indicating the minimum amount to shift the baseline of the subscript down for both pre and post subscripts (not standard).
  • subscriptshift = <length>: indicate shift by length.
  • subscriptshift = <percentage>: indicate shift by percentage.
superscriptshift: indicating the minimum amount to shift the baseline of the superscript up for both pre and post subscripts (not standard).
  • superscriptshift = <length>: indicate shift by length.
  • superscriptshift = <percentage>: indicate shift by percentage.
Example 1 By default, children are sub- and super-scripts tot eh right of the base expression. You can add sub- and super-scripts to the left of the expression using the <mprescripts/> element: X d c b a
<math display="block">
    <mmultiscripts subscriptshift="1em" superscriptshift="1.5em">
        <mi>X</mi>      <!-- base expression -->
        <mi>d</mi>      <!-- postsubscript -->
        <mi>c</mi>      <!-- postsuperscript -->
        <mprescripts />
        <mi>b</mi>      <!-- presubscript -->
        <mi>a</mi>      <!-- presuperscript -->
    </mmultiscripts>
</math>
    
Example 2 You can use the <mrow> tag to not include a sub-/super-script (or just use a blank <mi> child, though that may cause problems with certain parsers). X d b
<math display="block">
    <mmultiscripts>
        <mi>X</mi>      <!-- base expression -->
        <mi>d</mi>      <!-- postsubscript -->
        <mi></mi>      <!-- postsuperscript -->
        <mprescripts />
        <mi>b</mi>      <!-- presubscript -->
        <mrow></mrow>      <!-- presuperscript -->
    </mmultiscripts>
</math>
    
Example 3 Children alternate between the sub- and super- script X a b 1 2 I c d 3 4 III
<math display="block">
    <mmultiscripts>
        <mi>X</mi>      <!-- base expression -->
        <mi>a</mi>      <!-- postsubscript -->
        <mi>b</mi>      <!-- postsuperscript -->
        <mi>1</mi>      <!-- postsubscript -->
        <mi>2</mi>      <!-- postsuperscript -->
        <mi>I</mi>      <!-- postsubscript -->
        <mprescripts />
        <mi>c</mi>      <!-- presubscript -->
        <mi>d</mi>      <!-- presuperscript -->
        <mi>3</mi>      <!-- presubscript -->
        <mi>4</mi>      <!-- presuperscript -->
        <mi>III</mi>      <!-- postsubscript -->
    </mmultiscripts>
</math>
    
<msub> Used to attach a subscript to an expression.
Attributes msub: accepts global attributes.
subscriptshift: indicating the minimum amount to shift the baseline of the subscript down for both pre and post subscripts (not standard).
  • subscriptshift = <length>: indicate shift by length.
  • subscriptshift = <percentage>: indicate shift by percentage.
Example X 1
<math display="block">
    <msub>
        <mi>X</mi>
        <mn>1</mn>
    </msub>
</math>
    
<msup> Used to attach a superscript to an expression.
Attributes msup: accepts global attributes.
superscriptshift: indicating the minimum amount to shift the baseline of the superscript up for both pre and post subscripts (not standard).
  • superscriptshift = <length>: indicate shift by length.
  • superscriptshift = <percentage>: indicate shift by percentage.
Example X 1
<math display="block">
    <msup>
        <mi>X</mi>
        <mn>1</mn>
    </msup>
</math>
    
<msubsup> Used to attach a superscript to an expression.
Attributes msubsup: accepts global attributes.
subscriptshift: indicating the minimum amount to shift the baseline of the subscript down for both pre and post subscripts (not standard).
  • subscriptshift = <length>: indicate shift by length.
  • subscriptshift = <percentage>: indicate shift by percentage.
superscriptshift: indicating the minimum amount to shift the baseline of the superscript up for both pre and post subscripts (not standard).
  • superscriptshift = <length>: indicate shift by length.
  • superscriptshift = <percentage>: indicate shift by percentage.
Example X 1 2
<math display="block">
    <msubsup>
        <mi>X</mi>
        <mn>1</mn>
        <mn>2</mn>
    </msubsup>
</math>
    
<mover> Used to attach an accent or a limit over an expression.
Attributes mover: accepts global attributes.
accent: indicating whether the over script should be treated as an accent (i.e. drawn bigger and closer to the base expression).
  • accent = True: the overscript should be treated as an accent.
  • accent = False: the overscript should not be treated as an accent.
Example x + y + z
<math display="block">
    <mover accent="true">
        <mrow>
        <mi>x</mi>
        <mo>+</mo>
        <mi>y</mi>
        <mo>+</mo>
        <mi>z</mi>
        </mrow>
        <mo>&#x23DE;<!--TOP CURLY BRACKET--></mo>
    </mover>
</math>
    
<munder> Used to attach an accent or a limit under an expression.
Attributes munder: accepts global attributes.
accentunder: indicating whether the over script should be treated as an accent (i.e. drawn bigger and closer to the base expression).
  • accentunder = True: the underscript should be treated as an accent.
  • accentunder = False: the underscript should not be treated as an accent.
Example x + y + z
<math display="block">
    <munder accentunder="true">
        <mrow>
        <mi>x</mi>
        <mo>+</mo>
        <mi>y</mi>
        <mo>+</mo>
        <mi>z</mi>
        </mrow>
        <mo>&#x23DF;<!--TOP CURLY BRACKET--></mo>
    </munder>
</math>
    
<munderover> Used to attach an accent or a limit to both under and over an expression.
Attributes munderover: accepts global attributes.
accent: indicating whether the over script should be treated as an accent (i.e. drawn bigger and closer to the base expression).
  • accent = True: the overscript should be treated as an accent.
  • accent = False: the overscript should not be treated as an accent.
accentunder: indicating whether the over script should be treated as an accent (i.e. drawn bigger and closer to the base expression).
  • accentunder = True: the underscript should be treated as an accent.
  • accentunder = False: the underscript should not be treated as an accent.
Example n = 1 +
<math display="block">
    <munderover>
        <mo></mo>
        <mrow>
        <mi>n</mi>
        <mo>=</mo>
        <mn>1</mn>
        </mrow>
        <mrow>
        <mo>+</mo>
        <mn></mn>
        </mrow>
    </munderover>
</math>
    

Tabular Math

<mtable> Allows the creation of tables or matrices. Its children are <mtr> elements (representing rows), each of them having <mtd> elements as its children (representing cells).
Attributes mtable: accepts global attributes.
width: indicating the width of the entire table.
  • width = <length>: set the width to a specific thickness (must provide unit).
  • width = <percentage>: set the width to a size relative to its parent object.
align: specify the table's vertical alignment with respect to its environment.
  • align = axis: (default) the vertical center of the table aligns on the environment's axis (typically the minus sign).
  • align = baseline: the vertical center of the table aligns with the environment's baseline.
  • align = bottom: the bottom of the table aligns with the environment's baseline.
  • align = center: same as baseline.
  • align = top: the top of the table aligns on the environment's baseline.
columnalign: specifies the horizontal alignment of the cells.
  • columnalign = left: align the column to left.
  • columnalign = center: center text in column.
  • columnalign = right: align the column to right.
columnspacing: specifies the horizontal alignment of the cells.
  • columnspacing = <length>: set the spacing to a specific thickness given the unit.
  • columnspacing = <percentage>: set the spacing to a size relative to its parent object.
rowalign: specifies the vertical alignment of the cells.
  • rowalign = baseline: (default) the vertical center of the cell aligns with the environment's baseline.
  • rowalign = axis: the vertical center of the cell aligns on the environment's axis (typically the minus sign).
  • rowalign = bottom: the bottom of the cell aligns with the environment's baseline.
  • rowalign = center: same as baseline.
  • rowalign = top: the top of the cell aligns on the environment's baseline.
rowlines: specifies row borders.
  • rowlines = none: no lines between rows.
  • rowlines = solid: solid border.
  • rowlines = dashed: dashed border.
rowspacing: specifies space between table rows.
  • rowspacing = <length>: set the spacing to a specific thickness given the unit.
  • rowspacing = <percentage>: set the spacing to a size relative to its parent object.
frame: specifies border around the entire table.
  • frame = none: no border.
  • frame = solid: solid border.
  • frame = dashed: dashed border.
framespacing: specifies additional space added between the table and frame. The first value specifies the spacing on the right and left; the second value specifies the spacing above and below.
  • framespacing = <length>: set the spacing to a specific thickness given the unit.
  • framespacing = <percentage>: set the spacing to a size relative to its parent object.
Example X = A B C D E F
<math display="block">
    <mi>X</mi>
    <mo>=</mo>
    <mtable frame="solid" rowlines="solid" align="axis 3">
        <mtr>
        <mtd><mi>A</mi></mtd>
        <mtd><mi>B</mi></mtd>
        </mtr>
        <mtr>
        <mtd><mi>C</mi></mtd>
        <mtd><mi>D</mi></mtd>
        </mtr>
        <mtr>
        <mtd><mi>E</mi></mtd>
        <mtd><mi>F</mi></mtd>
        </mtr>
    </mtable>
</math>
    
<mtr> Represents a row in a table or a matrix.
Attributes mtr: accepts global attributes.
columnalign: specifies the horizontal alignment of the cells (overrides setting in parent environment).
  • columnalign = left: align the column to left.
  • columnalign = center: center text in column.
  • columnalign = right: align the column to right.
rowalign: specifies the vertical alignment of the cells (overrides setting in parent environment).
  • rowalign = baseline: (default) the vertical center of the cell aligns with the environment's baseline.
  • rowalign = axis: the vertical center of the cell aligns on the environment's axis (typically the minus sign).
  • rowalign = bottom: the bottom of the cell aligns with the environment's baseline.
  • rowalign = center: same as baseline.
  • rowalign = top: the top of the cell aligns on the environment's baseline.
Example Check example in <mtable>
<mtd> Represents a cell in a table or a matrix.
Attributes mtd: accepts global attributes.
columnspan: use to setup a multi-column cell. A non-negative integer value that indicates on how many columns does the cell extend.
  • columnspan = num: indicates the number of columns the cell extends.
rowspan: use to setup a multi-row cell. A non-negative integer value that indicates on how many columns does the cell extend.
  • rowspan = num: indicates the number of rows the cell extends.
columnalign: specifies the horizontal alignment of the cells (overrides setting in parent environment).
  • columnalign = left: align the column to left.
  • columnalign = center: center text in column.
  • columnalign = right: align the column to right.
rowalign: specifies the vertical alignment of the cells (overrides setting in parent environment).
  • rowalign = baseline: (default) the vertical center of the cell aligns with the environment's baseline.
  • rowalign = axis: the vertical center of the cell aligns on the environment's axis (typically the minus sign).
  • rowalign = bottom: the bottom of the cell aligns with the environment's baseline.
  • rowalign = center: same as baseline.
  • rowalign = top: the top of the cell aligns on the environment's baseline.
Example Check example in <mtable>

Semantic annotations

<semantics> A tag used to define alternate formats of the expression.
  • Must be a first child in the <math> environment and must contain a MathML expression to be annotated.
  • By default, only the first child is rendered, which is supposed to be Presentation MathML.
  • Subsequent <annotation> or <annotation-xml> elements are reserved for XML formats such as OpenMath.
Attributes
encoding: the encoding of the semantic information in the annotation.
  • encoding = MathML-Content: a dedicated XML dialect to express the meaning of mathematical formulas. Typically used to store data for parsing and analysis.
  • encoding = MathML-Presentation: the presentation of the formula that most browsers render. Typically this isn't needed since the presentation version is in the semantics environment by default but it is included for certain data processing tasks.
  • encoding = image/png: annotate with a PNG image of the formula. Some browsers may choose to load the image if the equation markup throws an error.
  • encoding = <custom>: can define a custom environment to be used with data processing tasks.
src: the location of an external source for semantic information.
  • src = “some/path/formula.png”
Example x 2 + y x 2 y x^{2} + y
<math display="block">
    <semantics>
        <!-- The first child is the MathML expression rendered by default. -->
        <mrow>
        <msup>
            <mi>x</mi>
            <mn>2</mn>
        </msup>
        <mo>+</mo>
        <mi>y</mi>
        </mrow>

        <!-- Annotate with "Content MathML", a dedicated XML dialect to
            express the meaning of mathematical formulas. -->
        <annotation-xml encoding="MathML-Content">
        <apply>
            <plus />
            <apply>
            <power />
            <ci>x</ci>
            <cn type="integer">2</cn>
            </apply>
            <ci>y</ci>
        </apply>
        </annotation-xml>

        <!-- Annotate with a PNG image of the formula. -->
        <annotation encoding="image/png" src="some/path/formula.png" />

        <!-- Annotate with LaTeX, a lightweight markup language to write
            mathematical formulas. -->
        <annotation encoding="application/x-tex"> x^{2} + y </annotation>
    </semantics>
</math>    
    


Part 2. (Strict) Content-MathML elements


Just like HTML at-large, there are many different flavors of content-markup. We’ll focus on strict content-MathML typically used by parsers such as LateXML.

<cn> Used to represent integers, real numbers, and double-precision floating point numbers.
Attributes cn: accepts global attributes.
type: Defines integer format.
  • type = integer: an integer is represented by an optional sign followed by a string of one or more decimal "digits".
  • type = real: a real number is presented in radix notation.
  • type = double: used to mark up those double-precision floating point numbers that can be represented in theIEEE 754 standard format.
  • type = hexdouble: used to directly represent the 64 bits of an IEEE 754 double-precision floating point number as a 16-digit hexadecimal number.
Example
    <cn type="hexdouble">7F800000</cn>
    
<ci> Represent "mathematical variables" which have properties, but no fixed value.
Attributes ci: accepts global attributes.
type: Defines integer format.
  • type = integer: used as the argument of the type symbol to convey the type of an integer.
  • type = rational: used as the argument of the type symbol to convey the type of a rational number.
  • type = real: a real number is presented in radix notation.
  • type = complex: used as the argument of the type symbol to convey the type for a complex number.
  • type = complex-polar: used as the argument of the type symbol to convey the type of a complex number specified in terms of its modulus and argument.
  • type = complex-cartesian: used as the argument of the type symbol to convey the type of a complex number specified in terms of its real and imaginary parts.
  • type = constant: used as the argument of the type symbol to convey a type for the common constants, pi ~= 3.1415, e ~= 2.718, i = square root of -1, gamma ~= .5772, NaN, infinity (all in the nums cd), true and false (in the logic cd). Also for MathML variables declared to have type constant, as in "x=2."
  • type = function: used as the argument of the type symbol to convey the type for a function name.
  • type = vector: used as the argument of the type symbol to convey the type for a vector.
  • type = list: used as the argument of the type symbol to convey the type for a list.
  • type = set: used as the argument of the type symbol to convey the type for a set.
  • type = matrix: used as the argument of the type symbol to convey the type for a matrix (n tuple of rows, where each row is an m tuple for some m, it should be noted that each row must be the same length).
Example
<semantics>
    <ci>n</ci>
    <annotation-xml cd="mathmltypes" name="type" encoding="MathML-Content">
        <csymbol cd="mathmltypes">integer_type</csymbol>
    </annotation-xml>
</semantics>
    
<csymbol> Used to refer to a specific, mathematically-defined concept with an external definition. In the expression "x+y", the plus sign is a symbol since it has a specific, external definition, namely the addition function.
Attributes csymbol: accepts global attributes.
cd: directly referring to OpenMath CD(Content Dictionaries), an extensive, open, and active repository of mathematical definitions.
cdgroup: specifies a URL to an OpenMath CD Group file.
  • cdgroup = URI, the URI is used to look up for the name in the CD Group File.
definitionURL: reference CDs or any other source of definitions that can be identified by a URL.
  • definitionURL = URI/URL.
Example
<semantics>
    <csymbol>symbolname</csymbol>
    <annotation-xml cd="mathmltypes" name="type" encoding="MathML-Content">
        <ci>T</ci>
    </annotation-xml>
</semantics>
    
<cs> Encodes "string literals" which may be used in Content MathML expressions.
Attributes cs: accepts global attributes.
Example
<set>
    <cs>A</cs><cs>B</cs><cs>  </cs>
</set>
    
<apply> Used to build an expression tree that represents the application of a function or operator to its arguments. Roughly speaking, this means a piece of mathematics that could be surrounded by parentheses or "logical brackets" without changing its meaning.
Attributes apply: accepts global attributes.
Example The expression "(F+G)X" can be ambiguous but with the content markup, the intent is clear:
<apply><csymbol cd="arith1">times</csymbol>
    <apply><csymbol cd="arith1">plus</csymbol>
        <ci>F</ci>
        <ci>G</ci>
    </apply>
    <ci>x</ci>
</apply>
    
<bind> and <bvar> Used to represent bound variables. Informally, they can be thought of as the "dummy variables" in expressions such as integrals, sums, products, and the logical quantifiers "for all" and "there exists". Binding expressions are represented as MathML expression trees using the bind element. Its first child is a MathML expression that represents a binding operator, for example integral operator. This is followed by a non-empty list of bvar elements denoting the bound variables, and then the final child which is a general Content MathML expression, known as the body
Attributes bind: accepts global attributes. bvar: accepts global attributes.
Example
<bind><csymbol cd="quant1">forall</csymbol>
    <bvar><ci>x</ci></bvar>
    <apply><csymbol cd="relation1">eq</csymbol>
        <apply><csymbol cd="arith1">plus</csymbol><ci>x</ci><ci>y</ci></apply>
        <apply><csymbol cd="arith1">plus</csymbol><ci>y</ci><ci>x</ci></apply>
    </apply>
</bind>
    
<share> Used to conserve space in the XML encoding, MathML expression trees can make use of structure sharing.
Attributes share: accepts global attributes.
href: a URI specifying the id attribute of the root node of the expression tree.
  • href = URI of the structure.
Example Original form:
<apply><ci>f</ci>
    <apply><ci>f</ci>
        <apply><ci>f</ci>
        <ci>a</ci>
        <ci>a</ci>
        </apply>
        <apply><ci>f</ci>
        <ci>a</ci>
        <ci>a</ci>
        </apply>
    </apply>
    <apply><ci>f</ci>
        <apply><ci>f</ci>
        <ci>a</ci>
        <ci>a</ci>
        </apply>
        <apply><ci>f</ci>
        <ci>a</ci>
        <ci>a</ci>
        </apply>
    </apply>
</apply>
    
share form:
<apply><ci>f</ci>
    <apply id="t1"><ci>f</ci>
        <apply id="t11"><ci>f</ci>
        <ci>a</ci>
        <ci>a</ci>
        </apply>
        <share href="#t11"/>
    </apply>
    <share href="#t1"/>
</apply>
    
<cerror> It has no direct mathematical meaning. Errors occur as the result of some action performed on an expression tree. Errors may occur inside other objects and also inside other errors.
Attributes cerror: accepts global attributes.
Example Divide by zero error:
<cerror>
    <csymbol cd="aritherror">DivisionByZero</csymbol>
    <apply><csymbol cd="arith1">divide</csymbol><ci>x</ci><cn>0</cn></apply>
</cerror>
    
<cbytes> Represents a stream of bytes as a sequence of characters in Base64 encoding. It is mainly used for OpenMath compatibility, but may be used, as in OpenMath, to encapsulate output from a system that may be hard to encode in MathML, such as binary data relating to the internal state of a system, or image data.
Attributes cbytes: accepts global attributes.


References