Bala's Blog

MathJax

October 15 2017
94 words, ~1 min. read
javascript,  maths,  chemistry,  tex 

MathJax is a cross-browser JavaScript library for maths which can be used to display maths formulas and equations beautifully in all browsers. In addition to maths, it can also be used for chemical equations and formulas with the help of TeX extensions.

Usage

  1. Include the following JavaScript,
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML"></script>
  1. Configure MathJax extensions, as appropriate; for example, to include mhchem extension,
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({ TeX: { extensions: ["mhchem.js"] }});
</script>

Examples

  1. Equation for Pythagorean Theorem: \(a^2 + b^2 = c^2\)
  2. Algebra formula: \((a+b)^2=a^2+b^2+2ab\)
  3. Chemical equation for water formation: \(\ce{2H_2 + O_2 -> 2H_2O}\)