Introduction

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

Some simple examples of presentation markup were discussed under Presentation and content. We saw there that presentation markup consists of approximately 30 elements and 50 attributes that describe the visual structure of mathematical notation. Most presentation elements can be divided into two categories: token elements and layout schemata. Token elements represent the smallest building blocks of mathematical notation; that is, numbers, operators, and identifiers used to denote names of variables and functions. There are also separate token elements for representing text, blank space, strings, and character glyphs. The following table summarizes the different types of token elements.

Table: Types of token elements.

Element Role
mn Number
mo Operator, fence, separator, or accent
mi Identifier
mtext Text
mspace Blank space
ms String
mglyph Character glyph

Numbers, operators, and identifiers are each represented by a different token element (mn, mo, and mi, respectively) because each of these types of items has slightly different notational conventions. For example, numbers are usually rendered in an upright font, whereas variables are usually rendered in an italic font. Further, the space left around operators is different from that left around numbers or variables.

Token elements are the only presentation elements that can directly contain character data. They can contain any sequence of zero or more Unicode characters as well as entity references. Token elements can include whitespace, but any whitespace in the content is trimmed from the ends, as explained under Presentation and content. In general, token elements cannot contain other elements. However, there are two exceptions. The mglyph element, used for representing nonstandard characters, and the malignmark element, used for aligning parts of an expression, can appear inside token elements.

Layout schemata specify templates for constructing expressions out of smaller parts. The following table summarizes the different types of layout schemata.

Table: Types of layout schemata.

Element Role
mrow Horizontal row
mfrac Fraction
msqrt Square root
mroot Root
mstyle Apply style
mspace Blank space
mphantom Make content invisible
mfenced Add fences around content
menclose Enclose content in a stretchy symbol
merror Error messages
msub Add subscript to a base
msup Add superscript to a base
msubsup Add subscript-superscript pair to a base
munder Add underscript to a base
mover Add overscript to a base
munderover Add underscript-overscript pair to a base
mmultiscripts Add multiple prescripts and postscripts to a base
mtable Table or matrix
mtr Row of a table
mlabeledtr Labeled row of a table
mtd Cell in a table
maligngroup Alignment group
malignmark Alignment marker

Layout schemata can contain only other elements as content; they cannot contain character data except for whitespace, which they ignore. The rules for rendering layout schemata are more complex than those for token elements since layout schemata specify how to construct a two-dimensional notational structure out of smaller subexpressions. MathML suggests rules for rendering each type of layout schemata but these rules are only suggestions, not requirements. In general, each processing application can choose its own rendering rules for different MathML elements as long as the rules are consistent with the basic conventions of mathematical typesetting.

In addition to token elements and layout schemata, there are a few other elements that do not belong to either category. These include the elements none and prescripts (which are empty elements used inside other layout schemata) and the maction element (which is used to add interactivity to MathML equations).

Note:
Note that in this and all subsequent chapters of the book, the math element is omitted from all examples for the sake of brevity. However, this element is implied by the context; that is, each instance of MathML markup should be thought of as being enclosed in an outer math element.

Number of arguments

MathML specifies constraints on the number of child elements that certain layout schemata are allowed to contain. Child elements subject to such constraints are called arguments. Some arguments may also have a special meaning based on their position within the parent element. For example, an msub element must have exactly two arguments, the first of which is interpreted as the base and the second as the subscript attached to that base.

The MathML DTD does not specify either the number of arguments a given element has or their interpretation. The restrictions placed on arguments is an example of the additional rules specified by MathML that go beyond the basic syntax of XML.

The following table lists the number of arguments for each presentation element as well as any special meaning attached to the argument based on its position.

Table: Arguments for each presentation element.

Element Number of Arguments Argument Role
mrow 0 or more 
mfrac 2 numerator denominator
msqrt 1*  
mroot 2 base root
mstyle 1*  
merror 1*  
mpadded 1*  
mphantom 1*  
mfenced 0 or more  
menclose *  
msub 2 base subscript
msup 2 base superscript
msubsup 3 base subscript superscript
munder 2 base underscript
mover 2 base overscript
munderover 3 base underscript overscript
mmultiscripts 1 or more base (underscript overscript)*
[<mprescripts/> (underscript overscript)*]
mtable 0 or more 0 or more mtr or mlabeledtr elements
mtr 0 or more 0 or more mtd elements
mlabeledtr 2 A label and 0 or more mtd elements
mtd 1*  
maction 1 or more Depends on the actiontype attribute

The elements in the table above whose required number of arguments is listed as 1* have a special property. They are always interpreted as having a single argument even if they are written with a different number of arguments. In other words, if any of these elements occurs with either zero arguments or more than one argument, the contents of the element are interpreted as being enclosed in an mrow element. Such an mrow element is called an inferred mrow since its presence is inferred from the context. The elements that place an inferred mrow around their arguments are: msqrt, mstyle, merror, mpadded, mphantom, menclose, and mtd.

The advantage of this behavior is that you can omit a large number of mrow elements that would otherwise be necessary. This allows MathML expressions to be written more compactly. For example, the msqrt element below has 2 arguments:

<msqrt>
  <mo>-</mo>
  <mn>1</mn>
</msqrt>

Hence, the above expression is automatically interpreted as:

<msqrt>
  <mrow>
    <mo>-</mo>
    <mn>1</mn>
  </mrow>
</msqrt>

   

<< back next >>

 

 

 


 

Copyright © CHARLES RIVER MEDIA, INC., Massachusetts (USA) 2003
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "The MathML Handbook" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.


CHARLES RIVER MEDIA, INC., 20 Downer Avenue, Suite 3, Hingham, Massachusetts 02043, United States of America