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?

  • 1
    @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
  • 1
    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

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 can't 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.


(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:-)

  • 12
    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
  • But which one is faster? In example if I have a lot of math formulas on my page, which one will be faster? – MrYouMath Jun 3 '18 at 10:32
  • 1
    @MrYouMath if you are using mathjax to render mathml input or tex input the speed difference is unlikely to be measurable and which is quicker will depend on the particular content. – David Carlisle Jun 3 '18 at 13:22
  • 1
    @MrYouMath if your browser supports mathml yes but if you (or your readers) are using chrome or ie then you need the same mathjax library to render the mathml – David Carlisle Jun 3 '18 at 15:34

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).

  • 4
    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
  • 1
    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.
  • 2
    "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
  • 1
    @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
  • 1
    ... 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
  • 1
    @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.



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/


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.