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.
To check if your browser can render MathML, try viewing this simple test page. The page includes both flavors of MathML:
In order to view MathML you need:
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:
/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/fontsYou'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.
xset fp+ /usr/lib/X11/fonts/math-fonts/cmtex-pfb xset fp+ /usr/lib/X11/fonts/math-fonts/mathematica-pcf xset fp rehashNow 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 -qGood luck.
/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 directoryand 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.
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.
Windows/fonts
folder.
Windows/fonts
folder.
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.
foo.xml
, not foo.html
.)
This implies that any HTML on your pages must be well-formed
XML (i.e., it must be XHML, rather than just XML). For
example, all tags must be balanced -- none of those hanging,
unbalanced <p> tags and the like.
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="/styles/mathml.xsl"?> <html xmlns="http://www.w3.org/1999/xhtml"> ... Your stuff here ... </html>The style sheet referred to in the first line --
/styles/mathml.xsl
is already on Swissnet. If
you wish to serve MathML from a different server (or test it
offline) you need to install appropriate style sheets. You'll
need four of them, which you can snarf from W3C: mathml.xsl,
pmathml.xsl,
ctop.xsl and
pmathmlcss.xsl.
Place these in a directory on your server and make the
xsl-stylesheet for MathML pages you serve point to the
mathml.xsl
file. For more information, see the
W3C note:Putting
mathematics on the Web with MathML
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.<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="/styles/mathml.xsl"?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Simple MathML Example</title> </head> <body> Here is some presentation MathML -- <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>x</mi><mo>+</mo><mn>3</mn><mo>+</mo><mi>y</mi> </math> <p/> Here is some content MathML -- <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <fn><ci>f</ci></fn> <ci>x</ci> </apply> </math>
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:
PCF
and cmpsfont
.
cmpsfont
directory has a subdirectory called
pfb
. Change (cd
) into that directory
and run the command
type1instWhat this is doing is creating a fonts.dir file that indexes the fonts in that directory.
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
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
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.