MathJax Delimiters Explained
MathJax only renders text wrapped in delimiters, the markers that say where math starts and ends. Anything outside them stays plain text. Here's how the defaults work and how to change them in MathJax 2, 3 and 4.
Try inline and display math in the live preview →Default delimiters
| Type | Default in MathJax 2, 3 and 4 | Example |
|---|---|---|
| Inline math | \(...\) only |
The area is \(\pi r^2\). |
| Display math | $$...$$ and \[...\] |
$$\int_0^1 x^2\,dx = \tfrac{1}{3}$$ |
| Environments | Rendered even without delimiters | \begin{align} ... \end{align} |
Why doesn't $...$ work?
Single dollar signs are off by default in every MathJax version, because dollar signs are
common in normal text such as prices. If your content uses $x^2$, you have to turn them on.
How to enable $...$ for inline math
MathJax 3 and 4
<script>
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
}
};
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
MathJax 2
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
processEscapes: true
}
});
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js?config=TeX-AMS_CHTML"></script>
Backslashes are doubled ('\\(') because this is a JavaScript string. Keep
\(...\) in the list so existing content still works.
Showing a literal dollar sign
Once $ is a delimiter, write \$ to show a real dollar sign, for example
It costs \$5. This escaping is controlled by processEscapes:
- MathJax 3 and 4: on by default.
- MathJax 2: off by default, so add
processEscapes: trueas shown above.
Stopping MathJax in part of a page
MathJax never processes math inside <script>, <style>,
<textarea>, <pre> and <code> elements. To skip any
other element, add a class:
| Purpose | MathJax 2 | MathJax 3 and 4 |
|---|---|---|
| Skip this element | tex2jax_ignore |
mathjax_ignore |
| Process it anyway (inside an ignored element) | tex2jax_process |
mathjax_process |
<div class="mathjax_ignore">
Price range: $10 to $20 (not math)
</div>
Common problems
- Math shows as raw text. Check that the math is wrapped in delimiters your configuration enables, and that the configuration is set before the MathJax script loads.
-
Math added later doesn't render. MathJax only scans the page once on load. Call
MathJax.typesetPromise()(MathJax 3 and 4) after inserting content. See the migration guide for the MathJax 2 equivalent. -
Prices turn into math. You enabled
$...$; escape the dollars as\$or wrap the text inmathjax_ignore.