Docs
Render equations in HTML
Reference snippets for MathJax, LaTeX, and refresh scripts.
Include required scripts
Load MathJax to render TeX and LaTeX equations. Use jQuery only if you need to refresh math after a dynamic update.
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
Write equations
Inline equations live inside text. Block equations render on their own line.
\\( x = {-b \pm \sqrt{b^2-4ac} \over 2a} \\)$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$Inline: \\( ... \\)Block: $$ ... $$
Refresh equations
If you inject new math after page load, queue a MathJax render cycle.
<script>
MathJax.Hub.Queue(["Typeset", MathJax.Hub, document.getElementById("math-target")]);
</script>
Comments
Target:
/tools-docs/render-equation-html