mattst88's MathML tutorial chapter #2

MathML Tutorials: 1 2

Chapter 2: Over, Under, and Around

So you've now see how to form basic mathematical expressions. Now let's learn how to do the stuff a <p> tag won't let you do.

We first start off with the <msup> tag. This tag allows you to put a superscript on an identifier or a number.

x 2
<math xmlns="http://www.w3.org/1998/Math/MathML">
 <msup>
  <mi>x</mi>
  <mn>2</mn>
 </msup>
</math>

The next related tag is <msub>. It allows you to put subscripts on identifiers.

v i
<math xmlns="http://www.w3.org/1998/Math/MathML">
 <msub>
  <mi>v</mi>
  <mi>i</mi>
 </msub>
</math>

Let's say you needed to write the equation for the average acceleration. To denote 'average' we put a horizontal line across the 'a' representing acceleration. MathML has that covered also with the <mover> tag.

a
<math xmlns="http://www.w3.org/1998/Math/MathML">
 <mover>
  <mi>a</mi>
  <mo>&OverBar;</mo>
 </mover>
</math>

The same goes for under with the <munder> tag.

x
<math xmlns="http://www.w3.org/1998/Math/MathML">
 <munder>
  <mi>x</mi>
  <mo>&UnderBrace;</mo>
 </munder>
</math>

At this point you might ask: what if I need a superscript and a subscript? If you did, you'd be interested in the <msubsup> tag. Just remember that the subscript comes first in the markup followed my the superscript. Hence the 'subsup' part of the tag.

v i 2
<math xmlns="http://www.w3.org/1998/Math/MathML">
 <msubsup>
  <mi>v</mi>
  <mi>i</mi>
  <mn>2</mn>
 </msub>
</math>

The exact same thing holds true for the <munderover> tag. I bet you can't figure out what order things go in for this one. At this point, I don't need to show an example.

You've done great! You should be able to do many things with MathML now. For further reading, see

Top