Wednesday, June 18, 2025

Writing math equation in web using mathjax and latex

Add the mathjax javascript library to the head or body of the html

<script async="" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" type="text/javascript">
</script>

To declare math equation use identifier 
\ (...\) for inline or 
\ [...\] for display

Note: no space between \ ( and \ [  

Example to write 1/2 

in latex: frac{1}{2}

in mathjax html (e.q. blogspot): \ ( \ frac{1}{2}\) 

Note: no space between characters above

result 

\(\frac{1}{2}\)

 

If you copy paste from word application with math equation support, the code may become messy, e.q word equation will result in many additional custom html tag.