# MathJax: equations on the web

When I started reading the MathJax homepage, I wondered why I would ever want to switch to it from the tried and true jsMath, which I’ve used for years to get good looking equations in my web page. Then I saw that Davide Cervone, the creator of jsMath, is one of the MathJax designers, and decided this is a project worth watching.

MathJax continues the jsMath tradition of accepting TeX/LaTeX notation to generate the equations, and intends to extend that to cover MathML as well. The MathJax preview page has many examples. Here’s the MathJax code for showing the binomial distribution on a line of its own:

$P(E) = {n \choose k} p^k (1-p)^{ n-k}$


The result (apart from a difference in fonts; see below) looks like this:

$P(E) = {n \choose k} p^k (1-p)^{ n-k}$

That code should be familiar to anyone who’s used LaTeX. It is, in addition, the same way you’d generate the equation if you were writing an HTML page using jsMath and the tex2math plugin.

It’s also how I generated the equation for this post. I don’t use the tex2math plugin, but I modified Michel Fortin’s PHP Markdown Extra to take input like that and create the equivalent in “classic” jsMath:

<div class="math">P(E)   = {n \choose k} p^k (1-p)^{ n-k}</div>


MathJax will have the ability to use fonts likely to already be on the user’s computer and to download fonts as needed via webfonts. This will be a big improvement over jsMath, which really prefers that the user have the TeX font set already installed.

Update 12/17/09
Looking at the MathJax preview page again, I see that it is using the TeX fonts (i.e, Computer Modern), at least on systems which, like mine, have them installed. I wonder if it uses @font-face to bring those fonts to systems that don’t. The fonts are free, so I can’t imagine there being a licensing problem with them.

Since there isn’t a MathJax download link, it appears that the authors don’t consider it ready for prime time just yet. But with talented programmers and some significant sponsors behind it, MathJax has a good chance to become the standard way people write equations for the web.