Installing and using MathML

Hal Abelson

MathML is an extensive system for displaying mathematics on the Web. This page is a quick guide to installing and using it. I've written this guide for members of the MIT Intelligent Book Project, but it should be generally useful as well.

This page includes instructions for installing MathML with Mozilla on GNU/Linux or Windows, and with Internet Explorer on Windows.


Browser tests

To check if your browser can render MathML, try viewing this simple test page. The page includes both flavors of MathML:

There are also W3C test pages: for Presentation MathML and for Content MathML as well as an extensive test suite.

In order to view MathML you need:

  1. A browser that supports MathML. Mozilla has MathML support built in. Internet Explorer requires you to download and install and plug-in.
  2. Math fonts installed on your system.

Installing MathML on GNU/Linux for use with Mozilla

Mozilla comes with built-in MathML support, so all you need to do is to install the fonts. I've put together a font package for use by people in the Intelligent Book project. To use this:

  1. If you are in the Intelligent Book project, copy the directory /project/intelligent-book/mathml/math-fonts into the X fonts directory on your machine, which is I'll assume is named /usr/lib/X11/fonts:
    cp -r /project/intelligent-book/mathml/math-fonts /usr/lib/X11/fonts
    You'll probably need root privileges on your machine to do this. This creates a math-fonts directory with two subdirectories called cmtex-pfb and mathematica-pcf.

    If you are not in the Intelligent Book project, you can't access the fonts package I put together. Read the instructions below on how to create the fonts package for GNU/Linux. Then create the package, move it to your X fonts directory, and continue with the instructions here.

  2. Test that the fonts work by temporarily adding the new fonts to your X fonts. Execute:
    xset fp+ /usr/lib/X11/fonts/math-fonts/cmtex-pfb
    xset fp+ /usr/lib/X11/fonts/math-fonts/mathematica-pcf
    xset fp rehash
    Now close Mozilla if it was open, relaunch it, and try the test pages above. If this doesn't work, check that the fonts are really in the directories, and that the directories really were added to your path, which you can do with:
    xset -q
    Good luck.

  3. Now add the fonts permanently, so you won't need to do this every time you log in. You need to edit the file /etc/X11/XF86Config-4. (At least, this is where it is on Debian.) Find the lines in the fonts section that look like
    	FontPath	some directory
    and add the lines
    	FontPath	"/usr/lib/X11/fonts/math-fonts/cmtex-pfb"
    	FontPath	"/usr/lib/X11/fonts/math-fonts/mathematica-pcf"
    Now reboot your machine (or restart the X server some other way). When everything comes back, you should open Mozilla and be able to view the test pages. Congratulations.

    Note: Be very careful editing the XF86Config-4 file. If you blow it, you may not be able to start X. If you do mess up like this, say a penance and find a wizard.

Installing MathML on Windows for use with Mozilla

Just as on GNU/Linux, Mozilla on Windows comes with built-in MathML support, so all you need to do is to install the fonts. There are two sets of fonts to install.

  1. Go to the Fonts for MathML-enabled Mozilla page, and download and install the Bako Ma TeX CM fonts (top of the right-hand column on the page): Download the folder, unzip it, and copy the contents to the Windows/fonts folder.
  2. From the same Fonts for MathML-enabled Mozilla page, follow the link to the Mathematica 4.1 fonts for windows. When you get to the Mathematica page, download the TrueType 4.1 fonts. Make sure to get the 4.1 fonts and not the 4.2 fonts. Uzip the folder and copy the contents to the Windows/fonts folder.
Restart Mozilla and test things with the browser tests above. Congratulations (hopefully).

Installing MathML on Windows for use with Internet Explorer

IE does not have native MathML support, so you'll need to download and install a plug-in, in addition to installing the fonts. Begin by installing the fonts, as described in the previous section for Mozilla on Windows. In fact, you might take this opportunity to switch to Mozilla as your browser rather than IE. Among other advantages, Mozilla lets you shut off those annoying pop-up windows. But if you are determined to use IE, then you must also ...

Download and install the MathPlayer Plug-in. When I download this, I get a file whose name ends in ".exe.asp". I had to change the name to remove the ".asp", before I click on the installer and run it.

Now try the browser tests. Hopefully, these will work.

Serving MathML pages from the web server

Here are some brief notes on serving MathML. Here's a complete MathML file, that you can play with, and also point your browser to here,
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/styles/mathml.xsl"?>
<html xmlns="">

<title>Simple MathML Example</title>

Here is some presentation MathML --

<math xmlns="">


Here is some content MathML --
<math xmlns="">
This discussion says nothing at all about reasonable ways to author MathML. There are several tools for doing so. For the Intelligent Book, we'll use a program that translates Scheme expressions to MathML.

How to create the fonts package for GNU/Linux

This is for people not in the Intelligent Book project who would like to get the math fonts package. You're probably wondering why, if I could put this package in our directory, I couldn't just also dump a copy on the web server. The reason is that the Mathematica fonts, which are part of the package, are licensed in a way that does not permit wide-scale redistribution.

This is a perfect illustration of why restrictive licenses on digital information impede innovation -- you have to go to the trouble of rebuilding the package yourself, rather than being able to take advantage of the work I've already done. So curse, send a donation to the FSF, and build the package as follows:

  1. Starting at the Fonts for MathML-enabled Mozilla page, download the Tex CM type1 fonts from AMS, and also the Linux Mathematica 4.1 Type 1 PCF fonts. Each up these should produce a gzipped tar file. Uncompress and untar the files. You should end up with two directories, PCF and cmpsfont.

  2. The cmpsfont directory has a subdirectory called pfb. Change (cd) into that directory and run the command
    What this is doing is creating a fonts.dir file that indexes the fonts in that directory.

  3. Create a new directory named math-fonts somewhere (e.g., in an appropriate temporary place) and move cmpsfont/pfb into that directory, renaming it to cmtex-pfb:
    mv cmpsfont/pfb directory-where-math-fonts-is/math-fonts/cmtex-pfb

  4. Now go into the PCF directory and run type1inst. Then move the PCF directory into math-fonts, renaming it to mathematica-pcf.
    mv PCF directory-where-math-fonts-is/math-fonts/mathematica-pcf

  5. math-fonts is the fonts package. Scan it to make sure it looks OK and that the permissions are set correctly. Use the package as described above to complete the installation of fonts for GNU/Linux.


Thanks to Daniel Jamous of MIT Information Systems for help with installing the GNU/Linux fonts.

Last modified: Mon, 14 Jul 2003 09:47:31 -0400