Up: Table of Contents | REC-MathML-19980407

# 3. Presentation Markup

- 3.4 Script and Limit Schemata
  - 3.4.1 <msub> -- attach a subscript to a base
  - 3.4.2 <msup> -- attach a superscript to a base
  - 3.4.3 <msubsup> -- attach a subscript-superscript pair to a base
  - 3.4.4 <munder> -- attach an underscript to a base
  - 3.4.5 <mover> -- attach an overscript to a base
  - 3.4.6 <munderover> -- attach an underscript-overscript pair to a base
  - 3.4.7 <mmultiscripts> -- attach prescripts and tensor indices to a base

## 3.4 Script and Limit Schemata

The elements described in this section position one or more scripts around a base. Attaching various kinds of scripts and embellishments to symbols is a very common notational device in mathematics. For purely visual layout, a single general-purpose element could suffice for positioning scripts and embellishments in any of the traditional script locations around a given base. However, in order to capture the abstract structure of common notation better, MathML provides several more specialized scripting elements.

In addition to sub/superscript elements, MathML has over/underscript elements which place scripts above and below the base. These elements can be used to place limits on large operators, or for placing accents and lines above or below the base. The rules for rendering accents differ from those for overscripts and underscripts, and this difference can be controlled with the accent and accentunder attributes, as described in the appropriate sections below.

Rendering of scripts is affected by the scriptlevel and displaystyle attributes, which are part of the environment inherited by the rendering process of every MathML expression, and are described under <mstyle> (Section 3.3.4). These attributes cannot be given explicitly on a scripting element, but can be specified on the start tag of a surrounding <mstyle> element if desired.

MathML also provides an element for attachment of tensor indices. Tensor indices are distinct from ordinary subscripts and superscripts in that they must align in vertical columns. Tensor indices can also occur in prescript positions.

Because presentation elements should be used to describe the abstract notational structure of expressions, it is important that the base expression in all "scripting" elements (i.e. the first argument expression) should be the entire expression that is being scripted, not just the rightmost character. For example, should be written as:

>     <msup>
>        <mrow>
>           <mo> ( </mo>
>           <mrow>
>              <mi> x </mi>
>              <mo> + </mo>
>              <mi> y </mi>
>           </mrow>
>           <mo> ) </mo>
>        </mrow>
>        <mn> 2 </mn>
>     </msup>

### 3.4.1 <msub> -- attach a subscript to a base

#### Description:

The syntax for the <msub> element is

> <msub> base subscript</msub>

#### Attributes of <msub>:

| Name | values | default
| subscriptshift | number v-unit | automatic (typical unit is ex)

The subscriptshift attribute specifies the minimum amount to shift the baseline of subscript down.

v-unit represents a unit of vertical length (see Section 2.3.3).

The <msub> element increments scriptlevel by 1, and sets displaystyle to "false", within subscript, but leaves both attributes unchanged within base. (These attributes are inherited by every element through its rendering environment, but can be set explicitly only on <mstyle>; see Section 3.3.4.)

### 3.4.2 <msup> -- attach a superscript to a base

#### Description:

The syntax for the <msup> element is

> <msup> base superscript </msup>

#### Attributes of <msup>:

| Name | values | default
| superscriptshift | number v-unit | automatic (typical unit is ex)

The superscriptshift attribute specifies the minimum amount to shift the baseline of superscript up.

v-unit represents a unit of vertical length (see Section 2.3.3).

The <msup> element increments scriptlevel by 1, and sets displaystyle to "false", within superscript, but leaves both attributes unchanged within base. (These attributes are inherited by every element through its rendering environment, but can be set explicitly only on <mstyle>; see Section 3.3.4.)

### 3.4.3 <msubsup> -- attach a subscript-superscript pair to a base

#### Description:

The <msubsup> element is used so that the subscript and superscript are both tight against the base, i.e. vertically aligned as in the second case shown here:

The syntax for the <msubsup> element is

> <msubsup>base subscript superscript</msubsup>

#### Attributes of <msubsup>:

| Name | values | default
| subscriptshift | number v-unit | automatic (typical unit is ex)
| superscriptshift | number v-unit | automatic (typical unit is ex)

The subscriptshift attribute specifies the minimum amount to shift the baseline of subscript down. The superscriptshift attribute specifies the minimum amount to shift the baseline of superscript up.

v-unit represents a unit of vertical length (see Section 2.3.3).

The <msubsup> element increments scriptlevel by 1, and sets displaystyle to "false", within subscript and superscript, but leaves both attributes unchanged within base. (These attributes are inherited by every element through its rendering environment, but can be set explicitly only on <mstyle>; see Section 3.3.4.)

#### Examples of <msubsup>:

The <msubsup> is most commonly used for adding sub/superscript pairs to identifiers as illustrated above. However, another important use is placing limits on certain large operators whose limits are traditionally displayed in the script positions even when rendered in display style. The most common of these is the integral. For example,

would be represented as

>     <mrow>
>        <msubsup>
>           <mo> &int; </mo>
>           <mn> 0 </mn>
>           <mn> 1 </mn>
>        </msubsup>
>        <mrow>
>           <msup>
>              <mi> &ExponentialE; </mi>
>              <mi> x </mi>
>           </msup>
>           <mo> &InvisibleTimes; </mo>
>           <mrow>
>              <mo> &DifferentialD; </mo>
>              <mi> x </mi>
>           </mrow>
>        </mrow>
>     </mrow>

### 3.4.4 <munder> -- attach an underscript to a base

#### Description:

The syntax for the <munder> element is

> <munder> base underscript </munder>

#### Attributes of <munder>:

| Name | values | default
| accentunder | true | false | automatic

The accentunder attribute controls whether underscript is drawn as an "accent" or as a limit. The main difference between an accent and a limit is that the limit is reduced in size whereas an accent is the same size as the base. A second difference is that the accent is drawn closer to the base.

The default value of accentunder is false, unless underscript is an <mo> element or an embellished operator (see Section 3.2.4). If underscript is an <mo> element, the value of its accent attribute is used as the default value of accentunder. If underscript is an embellished operator, the accent attribute of the <mo> element at its core is used as the default value. As with all attributes, an explicitly given value overrides the default.

Here is an example (accent vs underscript):
The MathML representation for this example is shown below.

If the base is an operator with movablelimits="true" (or an embellished operator whose <mo> element core has movablelimits="true"), and displaystyle="false", then underscript is drawn in a subscript position. In this case, the accentunder attribute is ignored. This is often used for limits on symbols such as &sum;.

Within underscript, <munder> always sets displaystyle to "false", but increments scriptlevel by 1 only when accentunder is "false". Within base, it always leaves both attributes unchanged. (These attributes are inherited by every element through its rendering environment, but can be set explicitly only on <mstyle>; see Section 3.3.4.)

#### Examples of <munder>:

The MathML representation for the example shown above is:

>     <mrow>
>        <munder accentunder="true">
>           <mrow>
>              <mi> x </mi>
>              <mo> + </mo>
>              <mi> y </mi>
>              <mo> + </mo>
>              <mi> z </mi>
>           </mrow>
>           <mo> &UnderBrace; </mo>
>        </munder>
>        <mtext> &nbsp;&nbsp;vs&nbsp;&nbsp; </mtext>
>        <munder accentunder="false">
>           <mrow>
>              <mi> x </mi>
>              <mo> + </mo>
>              <mi> y </mi>
>              <mo> + </mo>
>              <mi> z </mi>
>           </mrow>
>           <mo> &UnderBrace; </mo>
>        </munder>
>     </mrow>

### 3.4.5 <mover> -- attach an overscript to a base

#### Description:

The syntax for the <mover> element is

> <mover> base overscript </mover>

#### Attributes of <mover>:

| Name | values | default
| accent | true | false | automatic

The accent attribute controls whether overscript is drawn as an "accent" (diacritical mark) or as a limit. The main difference between an accent and a limit is that the limit is reduced in size whereas an accent is the same size as the base. A second difference is that the accent is drawn closer to the base. This is shown below (accent vs limit):

These differences also apply to "mathematical accents" such as bars over expressions:

The MathML representation for each of these examples is shown below.

The default value of accent is false, unless overscript is an <mo> element or an embellished operator (see Section 3.2.4). If overscript is an <mo> element, the value of its accent attribute is used as the default value of accent for <mover>. If overscript is an embellished operator, the accent attribute of the <mo> element at its core is used as the default value.

If the base is an operator with movablelimits="true" (or an embellished operator whose <mo> element core has movablelimits="true"), and displaystyle="false", then overscript is drawn in a superscript position. In this case, the accent attribute is ignored. This is often used for limits on symbols such as &sum;.

Within overscript, <mover> always sets displaystyle to "false", but increments scriptlevel by 1 only when accent is "false". Within base, it always leaves both attributes unchanged. (These attributes are inherited by every element through its rendering environment, but can be set explicitly only on <mstyle>; see Section 3.3.4.)

#### Examples of <mover>:

The MathML representation for the examples shown above is:

>     <mrow>
>        <mover accent="true">
>           <mi> x </mi>
>           <mo> &hat; </mo>
>        </mover>
>        <mtext> &nbsp;&nbsp;vs&nbsp;&nbsp; </mtext>
>        <mover accent="false">
>           <mi> x </mi>
>           <mo> &hat; </mo>
>        </mover>
>     </mrow>

>     <mrow>
>        <mover accent="true">
>           <mrow>
>              <mi> x </mi>
>              <mo> + </mo>
>              <mi> y </mi>
>              <mo> + </mo>
>              <mi> z </mi>
>           </mrow>
>           <mo> &OverBar; </mo>
>        </mover>
>        <mtext> &nbsp;&nbsp;vs&nbsp;&nbsp; </mtext>
>        <mover accent="false">
>           <mrow>
>              <mi> x </mi>
>              <mo> + </mo>
>              <mi> y </mi>
>              <mo> + </mo>
>              <mi> z </mi>
>           </mrow>
>           <mo> &OverBar; </mo>
>        </mover>
>     </mrow>

### 3.4.6 <munderover> -- attach an underscript-overscript pair to a base

#### Description:

The syntax for the <munderover> element is

> <munderover> base underscript overscript </munderover>

#### Attributes of <munderover>:

| Name | values | default
| accent | true | false | automatic
| accentunder | true | false | automatic

The <munderover> element is used so that the underscript and overscript are vertically spaced equally in relation to the base and so that they follow the slant of the base as in the second expression shown below:

The MathML representation for this example is shown below.

The difference in the vertical spacing is too small to be noticed on a low resolution display at a normal font size, but is noticeable on a higher resolution device such as a printer and when using large font sizes. In addition to the visual differences, attaching both the underscript and overscript to the same base more accurately reflects the semantics of the expression.

The accent and accentunder attributes have the same effect as the attributes with the same names on <mover> (Section 3.4.5) and <munder> (Section 3.4.4), respectively. Their default values are also computed in the same manner as described for those elements, with the default value of accent depending on overscript and the default value of accentunder depending on underscript.

If the base is an operator with movablelimits="true" (or an embellished operator whose <mo> element core has movablelimits="true"), and displaystyle="false", then underscript and overscript are drawn in a subscript and superscript position, respectively. In this case, the accent and accentunder attributes are ignored. This is often used for limits on symbols such as &sum;.

Within underscript, <munderover> always sets displaystyle to "false", but increments scriptlevel by 1 only when accentunder is "false". Within overscript, <munderover> always sets displaystyle to "false", but increments scriptlevel by 1 only when accent is "false". Within base, it always leaves both attributes unchanged. (These attributes are inherited by every element through its rendering environment, but can be set explicitly only on <mstyle>; see Section 3.3.4.)

#### Example of <munderover>:

The MathML representation for the example shown above with the left expression made using separate <munder> and <mover> elements, and the right one using an <munderover> element, is:

>     <mrow>
>        <mover>
>           <munder>
>              <mo> &int; </mo>
>              <mn> 0 </mn>
>           </munder>
>           <mi> &infinity; </mi>
>        </mover>
>        <mtext> &nbsp;&nbsp;vs&nbsp;&nbsp; </mtext>
>        <munderover>
>           <mo> &int; </mo>
>           <mn> 0 </mn>
>           <mi> &infinity; </mi>
>        </munderover>
>     </mrow>

### 3.4.7 <mmultiscripts> -- attach prescripts and tensor indices to a base

#### Description:

The syntax for the <mmultiscripts> element is

> <mmultiscripts>
> base
> ( subscript superscript ) *
> [ <mprescripts/> ( presubscript presuperscript ) * ]
> </mmultiscripts>

Presubscripts and tensor notations are represented by a single element, <mmultiscripts>. This element allows the representation of any number of vertically-aligned pairs of subscripts and superscripts, attached to one base expression. It supports both postscripts (to the right of the base in visual notation) and prescripts (to the left of the base in visual notation). Missing scripts can be represented by the empty element <none/>.

The prescripts are optional, and when present are given after the postscripts, because prescripts are relatively rare compared to tensor notation.

The argument sequence consists of the base followed by zero or more pairs of vertically-aligned subscripts and superscripts (in that order) that represent all of the postscripts. This list is optionally followed by an empty element <mprescripts/> and a list of zero or more pairs of vertically-aligned presubscripts and presuperscripts that represent all of the prescripts. The pair lists for postscripts and prescripts are given in a left-to-right order. If no subscript or superscript should be rendered in a given position, then the empty element <none/> should be used in that position.

The base, subscripts, superscripts, the optional separator element <mprescripts/>, the presubscripts, and the presuperscripts, are all direct subexpressions of the <mmultiscripts> element, i.e. they are all at the same level of the expression tree. Whether a script argument is a subscript or a superscript, or whether it is a presubscript or a presuperscript is determined by whether it occurs in an even-numbered or odd-numbered argument position, respectively, ignoring the empty element <mprescripts/> itself when determining the position. The first argument, the base, is considered to be in position 1. The total number of arguments must be odd, if <mprescripts/> is not given, or even, if it is.

The empty elements <mprescripts/> and <none/> are only allowed as direct subexpressions of <mmultiscripts>.

#### Attributes of <mmultiscripts>:

Same as attributes of <msubsup>.

The <mmultiscripts> element increments scriptlevel by 1, and sets displaystyle to "false", within each of its arguments except base, but leaves both attributes unchanged within base. (These attributes are inherited by every element through its rendering environment, but can be set explicitly only on <mstyle>; see Section 3.3.4.)

#### Examples of <mmultiscripts>:

Two examples of the use of <mmultiscripts> are:

>     <mrow>
>        <mmultiscripts>
>           <mi> F </mi>
>           <mn> 1 </mn>
>           <none/>
>           <mprescripts/>
>           <mn> 0 </mn>
>           <none/>
>        </mmultiscripts>
>        <mo> &ApplyFunction; </mo>
>        <mrow>
>           <mo> ( </mo>
>           <mrow>
>              <mo> ; </mo>
>              <mi> a </mi>
>              <mo> ; </mo>
>              <mi> z </mi>
>           </mrow>
>           <mo> ) </mo>
>        </mrow>
>     </mrow>

(where k and l are different indices)

>     <mmultiscripts>
>        <mi> R </mi>
>        <mi> i </mi>
>        <none/>
>        <none/>
>        <mi> j </mi>
>        <mi> k </mi>
>        <none/>
>        <mi> l </mi>
>        <none/>
>     </mmultiscripts>

Next: Presentation Markup -- Tables and Matrices
Up: Table of Contents