- Forward


MathML
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

About MathML
Back SMYC Forward
  • Origins:
    • Introduced in 1998
    • One of the first applications of XML
  • Versions:
    • MathML 2.0 - 2001 (revised 2003)
    • XML Entity Definitions for Characters - 2010 (revised 2014)
    • MathML 3.0 - 2010 (revised 2014)
  • Today:
    • MathML is included in HTML5
    • MathML is not included in all browsers
    • Some browsers (and some dynamic uses) require the XML namespace (xmlns="http://www.w3.org/1998/Math/MathML ")
Some History
Back SMYC Forward
  • Purpose:
    • Change the relative position of elements
  • Some Uses:
    • Subscripts and superscripts
    • Mathematical accents
    • Stacking
The Top-Level math Element
Back SMYC Forward
  • Requirements:
    • Contains one instance of MathML markup
    • Must not contain another math element
  • Attributes:
    • display can be "block" or "inline"
    • overflow can be "linebreak", "scroll", "elide" (i.e., abbreviate), "truncate", or "scale"
    • alttext provides a text alternative as a fall-back
Presentation Markup - Basics
Back SMYC Forward
  • Foundational Elements:
    • mi - an identifier
    • mo - an operator
    • mn - a number
  • Examples: Click here for a demonstration.
    • htmlexamples/mathml/basics.html
       
Presentation Markup - Sub-Expressions
Back SMYC Forward
  • Motivation:
    • Some MathML elements must contain a particular number of elements in a fixed order (e.g., a fraction contains a numerator and a denominator)
    • Hence, one must be able to create sub-expressions (i.e., "horizontal" groupings)
  • Grouping Elements:
    • mrow
    • mfenced
Presentation Markup - Sub-Expressions (cont.)
Back SMYC Forward
  • Preferred Groupings:
    • Sub-expressions should be grouped in the same way they are grouped in the mathematical interpretation (e.g., the expression \(ax + b\) should be in an <mrow> that contains an <mrow> for the sub-expression \(ax\))
  • Examples: Click here for a demonstration.
    • htmlexamples/mathml/rows.html
       
Presentation Markup - Positioning
Back SMYC Forward
  • Purpose:
    • Change the relative position of elements
  • Some Uses:
    • Subscripts and superscripts
    • Mathematical accents
    • Stacking
Presentation Markup - Positioning (cont.)
Back SMYC Forward
  • Elements:
    • msup or msub - superscript or subscript
    • msubsup - subscript and superscript
    • mover or munder - above or below
    • munderover - below and above
  • Examples: Click here for a demonstration.
    • htmlexamples/mathml/positioning.html
       
Presentation Markup - Fractions
Back SMYC Forward
  • The mfrac Element:
    • First child is the numerator
    • Second child is the denominator
  • Examples: Click here for a demonstration.
    • htmlexamples/mathml/fraction.html
       
Presentation Markup - Other Things
Back SMYC Forward
  • msqrt and mroot for radicals
  • mtable (containing mtr and mtd) for matrices and vectors
  • mlongdiv for long division (e.g., to explain division)
  • mscarries for carries, borrows, and crossouts (e.g., to explain elementary arithmetic)
Content Markup
Back SMYC Forward
  • Motivation:
    • It is difficult to infer semantics from presentation
  • Approach:
    • Use expression trees
There's Always More to Learn
Back -