Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any reason to favor MathML syntax over TeX in MathJax?

MathJax, opensource javascript library to render maths, support multiple syntaxes, including MathML and LaTeX. Are there any reason to favor the use of the MathML syntax for in-page equations vs the TeX syntax? It only looks to me that MathML is vastly more verbose.

like image 570
Joannes Vermorel Avatar asked Sep 25 '11 10:09

Joannes Vermorel


People also ask

What is the difference between MathJax and LaTeX?

MathJax can display mathematical notation written in LaTeX or MathML markup. Because MathJax is meant only for math display, whereas LaTeX is a document layout language, MathJax only supports the subset of LaTeX used to describe mathematical notation.

Does MathJax use LaTeX?

MathJax allows page authors to write formulas using TeX and LaTeX notation, MathML (a World Wide Web Consortium standard for representing mathematics in XML format), or AsciiMath notation.

What is LaTeX or MathML?

Mathematical Markup Language (MathML) is an XML-based language for describing mathematical notation. MathML was originally designed as a general-purpose specification for browsers, office suites, computer algebra systems, EPUB readers, LaTeX-based generators.

Is MathJax slow?

Using MathJax output (either inline SVG or HTML+CSS) is fast and can still offer excellent accessibility.


2 Answers

Well, if you actually look closely at the coding, you will find that MathJax, as well as jsMath, and other similar javascript programs, all do pretty much the same thing. They convert what is LaTeX in the source code of the webpage, as it is served by the server, into MathML on the client side. Feel free to highlight your "LaTeX" and see what the selected source code actually looks like to the browser. You will find that it is MathML (in most cases).

Unless you use a script or a hosting site that rasterizes LaTeX into a GIF or PNG image (which is another viable option), then your LaTeX is rendered as MathML-Presentation.

In the case of MathJax, however, it also gives you the option of SVG and HTML-CSS rendering. Both of which require massive amounts of client-side source code. SVG is not really practical (unfortunately it isnt even universally recognized), but it certainly is cool. HTML-CSS, though perhaps looks better, is not readable by a math parser or XML parser... it is also the MathJax default and it puts a heavier load on the client-side. So defaulting to their MathML rendering is better, in my opinion.

Thus, if I understand your question correctly, your question is actually moot. You are already dealing with MathML in both cases. The difference is, which do you find easier to write and embed into the page? Personally, I prefer writing in LaTeX, not MathML.

I have used jsMath and most recently MathJax. But I also currently do still use Codecogs.com to convert latex into GIF on the fly. (They have both a <script> and you can use direct linking <img src=> )

The fact of the matter is, you only have two options (well, four technically). You have MathML or GIF images as the primary two. What all these scripts and hosting sites do is they facilitate a conversion from LaTeX to either GIF or MathML (or the less desirable SVG or HTML-CSS). Straight LaTeX text is as difficult to read as MathML source code - you have to have some sort of rendering process.

One enormous advantage to coding your own MathML is that you have total control over the grammar and structure of the XML-based language (in case you make it available to other math programs and sites). But the other advantages are: you do not require javascript, and therefore your visitors dont have to enable javascript.

Coincidentally, ASCIIMath is a good example of a simple javascript converting LaTeX to Unicode and HTML-CSS in a very beautiful and streamlined way.

like image 113
CogitoErgoCogitoSum Avatar answered Sep 27 '22 22:09

CogitoErgoCogitoSum


If you do not need a human to write the equations, MathML is more robust. There's a clear interpretation to the mark-up, (which display mode will be used by default in all MathJax implementations?), there's a better chance for text-to-speech support for MathML. It is easy to search by XPath where your mathematical elements are, etc.

Other disadvantages of the MathJax approach are, start-up time tax, the fact it forces your browser to use Javascript.

like image 30
Elazar Leibovich Avatar answered Sep 27 '22 22:09

Elazar Leibovich