MathJax and MathML in my Drupal site

Submitted by Nicola Rainiero on 2012-09-13 (last updated on 2018-11-25)

When I was planning my site, one of many problems I had, was insertion of mathematical equations in my articles, but I found very soon in MathJax a useful solution. Some time after I discovered another method: MathML, even a recommendation of the W3C math working group! Here there are some personal considerations on them: about usability and convenience in my Drupal experience.

MathJax^

I like LaTeX and when I discovered MathJax, a cross-browser JavaScript library released as open-source, that displays mathematical equations in web browsers, using LaTeX math, I was nicely surprised. Besides it exists the homonym module in Drupal.

Drupal configuration

Once installed and activated the module (see below), you can configure it pointing your browser here: http://my_site/admin/config/content/mathjax. There are few choices in this menu as you can see in the next screen.

In my opinion it should allow the user to enable/disable more easily. I have tried to enable MathJax by a boolean field in Content type but doesn't work! So if I must display equations in a particular content node, I add it in the MathJax configuration menu.

Summary sheet on MathJax

• here Drupal's module ;
• here browser's compatibility list.
• Pros:
• if you know LaTeX you can use it immediately, for inline maths it is sufficient insert the equations inside $\$...\ and for display maths $...$;
• the quality is very good.
• Cons:
• you have to install an extra module that load a JavaScript library;
• you have to choose where enable it (all pages or selected pages);
• I suggest you to test your formulas in a good LaTeX editor, above all if you don't use LaTeX every day (like me!);
• make attention when you insert the $\$ $charset, because enable it in your articles. In order to avoid this, use these charsets:$ \

MathML^

While I was testing editor WYSIWYG Amaya, I have found in its menus some simple items to insert mathematic equations in html page, using MaThML. This is an application of XML for describing mathematical notations and capturing both its structure and content. It aims at integrating mathematical formulae into World Wide Web pages and other documents[1]. I have published only one article with MathML till now, but I don't like it!

Summary sheet on MathML

• here browser's compatibility list
• Pros:
• it is a recommendation of the W3C math working group;
• MathML deals not only with the presentation but also the meaning of formula components (the latter part of MathML is known as “Content MathML”)[1].
• Cons:
• you need a good editor to type your formulas in this language, because it doesn't appear easy and immediate to learn;
• in Drupal you have to choice PHP Code in text format, because the WYSIWYG, in my case TinyMCE, doesn't interpret it;
• some graphical errors and pagination.

Comparison using an example^

 MathJax MathML $w = \sqrt{{4 \cdot (\gamma_p - \gamma_w) \cdot D} \over {3 \cdot \rho_w \cdot C_D}}$    w   =                        4                  (                    γ           p                                      γ           w                  )                  D                       3                             ρ           w                                      C           D                         [/itex]  $w = \sqrt{{4 \cdot (\gamma_p - \gamma_w) \cdot D} \over {3 \cdot \rho_w \cdot C_D}}$ $w=\sqrt{\frac{4•\left({\gamma }_{p}-{\gamma }_{w}\right)•D}{3•{\rho }_{w}•{C}_{D}}}$

Related Content:

Nicola Rainiero

A civil geotechnical engineer with the ambition to facilitate own work with free software for a knowledge and collective sharing. Also, I deal with green energy and in particular shallow geothermal energy. I have always been involved in web design and 3D modelling.