MathML

The educational technology and digital learning wiki
Jump to navigation Jump to search

Definition

  • MathML is about encoding the structure of mathematical expressions so that they can be displayed, manipulated and shared over the World Wide Web. A carefully encoded MathML expression can be evaluated in a computer algebra system, rendered in a Web browser, edited in your word processor, and printed on your laser printer.

The language

Hand-editing MathML is quite difficult. There are 30 MathML presentation elements (e.g. fractions), with about 50 attributes and around 100 elemens for content markup (e.g. operations such as + and functions). These elements are for encoding mathematical notation. Most elements represent templates or patterns for laying out subexpressions.

Integration with XHTML

If your browser supports XHTML and MathML (e.g. Firefox) all you have to do is to make sure that MathML elements are prefixed with the right namespace.

MathML as extra vocabulary in XHTML

<?xml version="1.0" encoding="iso-8859-1"?>
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml">
 <xhtml:body>
   <xhtml:h1>A Compound Document</xhtml:h1>
   <xhtml:p>A simple formula using MathML in XHTML.</xhtml:p>
   <mathml:math xmlns:mathml="http://www.w3.org/1998/Math/MathML">
     <mathml:mrow>
       <mathml:msqrt>
         <mathml:mn>49</mathml:mn>
       </mathml:msqrt>
       <mathml:mo>=</mathml:mo>
       <mathml:mn>7</mathml:mn>
     </mathml:mrow>
   </mathml:math>
 </xhtml:body>
</xhtml:html>

http://tecfa.unige.ch/guides/xml/examples/mathml/xhtml_mathml.xml

Or if you prefer:

<?xml version="1.0" encoding="iso-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml">
 <body>
   <h1>A Compound Document</h1>
   <p>A simple formula using MathML in XHTML.</p>
   <math xmlns="http://www.w3.org/1998/Math/MathML">
     <mrow>
       <msqrt>
         <mn>49</mn>
       </msqrt>
       <mo>=</mo>
       <mn>7</mn>
     </mrow>
   </math>
 </body>
</html>

http://tecfa.unige.ch/guides/xml/examples/mathml/xhtml_mathml_2.xml

MathML validated by a combined XHTML/MathML DTD

If your browser supports XHTML and MathML (e.g. Firefox) a simpleexample would look like this:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" 
         "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:math="http://www.w3.org/1998/Math/MathML"
      xmlns:xlink="http://www.w3.org/1999/xlink">
<head> <title>XTHML with MATHML</title> </head>
<body>
 <p> 
   <b>Corollary 2</b> [Contractive Sequence Theorem] <em>If
   <math xmlns='http://www.w3.org/1998/Math/MathML'><mo>(</mo><msub><mi>x</mi> <mi>n</mi></msub><mo>)</mo></math> is a sequence, 
    for which there is a number 
    <math xmlns='http://www.w3.org/1998/Math/MathML'>
          <mi>C</mi><mi><</mi><mn>1</mn></math>
     such that 
     <math xmlns='http://www.w3.org/1998/Math/MathML'>
       <mo>|</mo><msub><mi>x</mi> <mrow><mi>n</mi><mo>+</mo><mn>2</mn></mrow></msub>
       <mo>-</mo>
       <msub><mi>x</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msub>
       <mo>|</mo><mo>≤</mo><mi>C</mi><mo>⋅</mo><mo>|</mo>
       <msub><mi>x</mi> <mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msub>
       <mo>-</mo>
       <msub><mi>x</mi> <mi>n</mi></msub><mo>|</mo></math>, 
     then <math xmlns='http://www.w3.org/1998/Math/MathML'><mo>(</mo><msub><mi>x</mi> <mi>n</mi></msub><mo>)</mo>
    </math>   
    converges;</em></p>
</body>
</html>

Click here to see if your browser can handle it.

You also can make this work by installing a hack

Links

Standards

Software

Indexes
Commercial editors
Plugins

Tutorials

  • Robert Miner and Jeff Schaeffer, A Gentle Introduction to MathML, HTML
  • Putting mathematics on the Web with MathML, a W3C Page, HTML