DanielScully.co.uk

Web Design

A Beginner's Guide to MathML

Sub-scripts & Super-scripts


Sub/Super-scripts are used in MathML not just for powers or indices, they are also used for limits.

Sub-scripts

Sub-Scripts are denoted with the <msub> tag. It accepts exactly 2 child elements, the first is the 'base', the second is the sub-script.

  1. <msub>
  2. <mi>x</mi>
  3. <mi>i</mi>
  4. </msub>
MathML rendering of an msub element

As usual, you can use grouping elements, such as <mrow>, to group multiple tags so that there are only two child elements within the <msub>.

Super-scripts

The <msup> behaves in exactly the same way as for sub-scripts.

  1. <msup>
  2. <mi>e</mi>
  3. <mrow>
  4. <mi>x</mi>
  5. <mo>+</mo>
  6. <mn>2</mn>
  7. </mrow>
  8. </msup>
MathML rendering of an msup element
Sub-script Super-script pair

For the frequently encountered case when you need both sub and super-scripts we can use the <msubsup> tag:

  1. <msubsup>
  2. <mi>x</mi>
  3. <mi>2</mi>
  4. <mn>i</mn>
  5. </msubsup>
MathML rendering of an msubsup element

Note that this is different to nesting sub/super scripts:

  1. <msup>
  2. <msub>
  3. <mi>x</mi>
  4. <mn>i</mn>
  5. </msub>
  6. <mn>2</mn>
  7. </msup>
MathML rendering of an msub nested within an msup
Integration
  1. <msubsup>
  2. <mo>&Integral;</mo>
  3. <mn>0</mn>
  4. <mn>1</mn>
  5. </msubsup>
  6. <mi>x</mi>
  7. <mrow>
  8. <mo>&DifferentialD;</mo>
  9. <mi>x</mi>
  10. </mrow>
MathML rendering of an msubsup element used to put limits on an integral
Under and Over Scripts

Exaclty like the sub and super scripts, we can place things above and below using three similar tags: <munder>, <mover> and <munderover>

  1. <munder>
  2. <mi>x</mi>
  3. <mo></mo>
  4. </munder>
  5. <mo>+</mo>
  6. <mover>
  7. <mi>y</mi>
  8. <mo>^</mo>
  9. </mover>
MathML rendering of munder and mover elements
  1. <munderover>
  2. <mi>&Sum;</mi>
  3. <mrow>
  4. <mi>x</mi>
  5. <mo>=</mo>
  6. <mn>0</mn>
  7. </mrow>
  8. <mi>n</mi>
  9. </munderover>
  10. <mrow>
  11. <mn>2</mn> <mi>x</mi>
  12. <mo>+</mo>
  13. <mn>1</mn>
  14. </mrow>
MathML rendering of an munderover element used to put limits on a summation

As you can see from this second example, this is a suitable way to write summations.