Home

Daniel I. Scully

A Beginner's Guide to MathML

Vectors and Matrices

The markup for vectors and matrices is almost identical to the markup for HTML tables.

The outer most element is <mtable>. It contains only <mtr> row elements, which in turn contains <mtd> data elements. These <mtd> contain the elements of the matrix:

  1. <mfenced>
  2. <mtable>
  3. <mtr>
  4. <mtd> <mn>1</mn> </mtd>
  5. <mtd> <mn>5</mn> </mtd>
  6. <mtd> <mn>3</mn> </mtd>
  7. </mtr>
  8. <mtr>
  9. <mtd> <mn>8</mn> </mtd>
  10. <mtd> <mn>2</mn> </mtd>
  11. <mtd> <mn>6</mn> </mtd>
  12. </mtr>
  13. <mtr>
  14. <mtd> <mn>7</mn> </mtd>
  15. <mtd> <mn>9</mn> </mtd>
  16. <mtd> <mn>0</mn> </mtd>
  17. </mtr>
  18. </mtable>
  19. </mfenced>
1 5 3 8 2 6 7 9 0

Note that in MathML 1 the <mtd> elements are not required and you may see examples without them. However this will no longer be the case in MathML 2, so to future proof your equations it is best to always include them.

A vector is simply a matrix with one element in each row:

  1. <mfenced>
  2. <mtable>
  3. <mtr>
  4. <mtd> <mn>1</mn> </mtd>
  5. </mtr>
  6. <mtr>
  7. <mtd> <mn>8</mn> </mtd>
  8. </mtr>
  9. <mtr>
  10. <mtd> <mn>7</mn> </mtd>
  11. </mtr>
  12. </mtable>
  13. </mfenced>
1 8 7