# Comparing MathJax and MathML

My organisation needs to update its website, which, in particular, will host a number of blogs and wikis on mathematics-related themes. We need to use some way of rendering of LaTeX on our web pages. Given a choice of MathJax and MathML, which one would you recommend? Any other solutions?

-
@user4650: Welcome to tex.sx! Your question won't be seen by many people here so it would be best to repost it as a fresh question. However, your question belongs to Super User, as it isn't really related to TeX. – Caramdir Apr 5 '11 at 1:53
In retrospect, this question is off-topic, as neither MathJax nor MathML are directly connected to TeX. – Caramdir Apr 5 '11 at 1:54
I have read (on mathjax.org/docs/1.1/installation.html) that Firefox's same-origin policy might slow the loading of mathjax. Does anyone know how I might install mathjax locally on my windows XP machine? – user4650 Apr 5 '11 at 8:22
@user4650: Welcome to tex.sx! Your question won't be seen by many people here so it would be best to repost it as a fresh question. However, your question belongs to Super User, as it isn't really related to TeX. – Martin Scharrer Apr 5 '11 at 8:23

"It seems that to use MathML, I ("hypothetical I") need to use a Ruby program called iTeX, w"

There seem to be some very confused descriptions of MathML, which doesn't require itex or ruby or any server side configuration at all.

You cant really compare mathjax and mathml as they are different things,

mathjax is a an implementation of a client side parser for both a tex-like syntax and mathml then (which ever input syntax is used for input) it can use various rendering methods including native mathml in the browser (including IE+MathPlayer, or recent webkit builds, not just firefox) or it can use css rendering.

Currently, if you don't want to use some javascript such as mathjax (or the simpler, less ambitious asciimathml) then you do need to serve the files as well formed xhtml (not necessarily valid xhtml, despite the comment above) however this is changing, mathml parsing is built into html5 so firefox 4 (beta) for example will render mathml in an html page not just xhtml. So going forward a year or two one would expect html+mathml pages to not require any javascript or server side support at all. whereas a tex like syntax (like a wiki) will always require some additional javascript or server processing.

whether you want to use a linear tex-like syntax or the xml/html syntax of mathml is pretty much a matter of choice, it is exactly analogous to a choice of whether to use a linear wiki style markup for your web pages, or to directly code (or generate) html markup. Sometimes one is more appropriate than the other, many sites use both wiki and traditional html markup, depending on the context.

David

(co editor of mathml2 and 3, and before that co-developer of latex2e, and before that a long time association with the Mathematics department at Manchester, and still an LMS member should you want any discussion offline at any stage about mathml, I'm easy enough to find:-)

-
David you do not need an introduction! – Yiannis Lazarides Sep 3 '10 at 21:31
Sorry, you're right, I was confused in the sentence you quoted. But I did and do recognise that one can't really compare mathjax and mathml since the latter is just a format, so I was only comparing mathjax with an equivalent: the way of using mathml that was proposed by the other answer. – ShreevatsaR Sep 3 '10 at 23:35

I would recommend MathJax. MathJax has the ability to be configured to use native MathML rendering when available in a browser, and only fall back to HTML-CSS mode when native rendering is not available. This way you get the best part of both worlds. (One limitation of MathJax is that fonts tend to load slowly. However, once they are cached in the browser the display is very quick).

-
Though MathJax output is not as good as TeX's, but it is very close, and is miles ahead of the quality of current MathML implementations, so I'll pick MathJax over MathML any time of the day. – Khaled Hosny Sep 3 '10 at 8:06
Also MathJax can take direct TeX input, but if you are using MathML you will need to convert TeX input to MathML. – Khaled Hosny Sep 3 '10 at 8:07
@Khaled Hosny: That second point is spurious. Most web pages now are generated in some way and the program that generates them can easily be adapted to convert the TeX syntax to MathML. The only difference is whether you do it before sending the file to the browser or afterwards. – Loop Space Sep 3 '10 at 8:33

This question is similar to Embedding LaTeX equations into a webpage and I think that my arguments for MathML there are pretty strong. I can also now add a couple of extra things since MathOverflow uses MathJaX so I've some direct experience.

1. MathJaX is really slow, particularly when the server is in the US and I'm sitting here in Norway. You need to consider the geographical locations of your users. Yiannis says that one limitation is that the fonts take a long time to load. That's true, and if - like a good internet user - you clear your cache then they have to load again each session. And even in the same session, I find that the same page takes just as long the second time as it did the first. And even in the right geographical location, not everyone can afford fancy computers and high-speed internet connections. When I'm "on the road", I use a 6-year old iBook that creaks along running Linux off a USB-stick. Add to that the dodgy internet connection and MathJaX makes a site completely unusable.

2. MathJaX with HTML+CSS is just plain awful. It looks really nice with MathML rendering but then why not go for MathML in the first place?

I've decided to interpret the "Any other solutions" as a request for implementations. I don't think this is the place for a full list, but just to let you know that on the server side, there is MathML-capable software for all the usual things:

• Wiki: instiki is a MathML-enabled wiki system. It's what the nLab uses.
• Forum: Vanilla is a forum software that I've adapted to be MathML-enabled. It's what the nForum uses.
• Blog: Vanilla can actually be run as a blog. Also I've written a plugin for Wordpress for MathML (see here for an example), blosxom can also generate MathML, and the n-Category Cafe runs on Moveable Type.
-
"MathJaX with HTML+CSS is just plain awful." Huh? not my experience at all, what browser/OS are you using? AFAICT, MathJax's HTML+CSS is far superior to MathML's in terms of spacing and positioning, but font rendering is equally as good. – Khaled Hosny Sep 3 '10 at 12:39
@Khaled Hosny: I'm using firefox on Linux with the STIX fonts installed. When I view a page with HTML+CSS rendering then the Maths jumps out and doesn't "flow" (non-technically) with the text. MathML renders just right. However, perhaps the more important point is that categorical statements like "MathJaX output is ... miles ahead of the quality of ... MathML ..." are quite misleading. Unless there's something actually wrong, personal taste can account for quite a wide spread of what looks best. Which is where server-side MathML comes out better since it is much easier to style using ... – Loop Space Sep 3 '10 at 13:21
... stylesheets. With MathJaX, you'd have to ensure that the stylesheet was getting applied after the javascript and reapplied each time there was a rendering change (for example, in the preview at MO or math.SE). – Loop Space Sep 3 '10 at 13:22
BTW, "What about implementation?" (a late section in your other answer) should not be an afterthought. MathJax is a complete solution in Javascript to the LaTeX-in-webpages thing, with detailed installation and usage instructions. MathML is just a format. It seems that to use MathML, I ("hypothetical I") need to use a Ruby program called iTeX, which means(?) that either my server needs to run Ruby (which may be fine if I have full control of my server), or I need to use one of your extensions to Perl/PHP/Python, about which you say "Contact me for these extensions". – ShreevatsaR Sep 3 '10 at 19:15
@ShreevatsaR: You're right and wrong. I guess I should get round to writing the documentation for the extensions. The difficulty is just that I've plenty else to be doing. Incidentally, iTeX is a C++ program. It's just that the ruby bindings are the oldest and so the most known about and most integrated with other software (eg instiki). But apart from instructions, it's a stable system: the nForum has been running MathML for about half a year now. The validation issue will go away once HTML5 gets here (I'm told), but actually I think that forcing valid pages is a Good Thing. – Loop Space Sep 3 '10 at 19:27

I am involved with the MathJax project and, IMHO, David Carlisle has the best explanation on this thread (as usual).

All I can add is that MathJax is only just at 1.0 and has not received all the performance tuning it will eventually get. Of course, that is not to be interpreted as a promise that it will be faster in some specific browser or in all browsers. Just the other day, I noticed it was excruciatingly slow on my HTC Evo. A bug was swatted and now it is an order of magnitude faster, though it still has room for improvement. MathJax will also gain from the JavaScript engine speed wars currently being waged between all the browser vendors. Internet Explorer is particularly slow but IE9 promises to be much faster.

Paul

-

Peter Luschny has prepared a nice test page and started a discusson on de.c.t.t (in German).

-

A 'quick and dirty' way is to use google's chart api: http://ardoris.wordpress.com/2010/06/27/converting-inline-latex-to-images-with-javascript-and-google-chart-api/

-
This is an answer to the other question, Embedding LaTeX equations into a webpage :-) – ShreevatsaR Sep 4 '10 at 4:35

You might want to look at using SVG on the web page, with dvisgm to generate the SVG, and Google's svgweb for IE prior to version 9.

-