Inline equations $...$ do not render with mathjax3
See original GitHub issueDescription
I managed to use mkdocs&mkdocs-material for documentation. When trying to insert some chemical equations , I used to document with pymdownx.arithmatex and the default mathjax2.7 js. It was great and worked well as expected.
However, to render equations with TeX packages like mhchem, chemfig, I would add an extra js for mathjax, and there are only mathjax3 instructions available.
Therefore, in my mkdocs.yaml file,
- 'javascripts\mathjax.js'
- 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
# - 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'
# - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'
After that, the problem occurs. The euqation donot render correctly.
Expected behavior
Inline equations
$\ce{CH2CH=CH2CH3 + CH3CH=CHCH3 ->[Cat] CH2=CHCH3 + CH3CH=CHCH2CH3}$
Block equations
$$ \ce{CH2CH=CH2CH3 + CH3CH=CHCH3 ->[Cat] CH2=CHCH3 + CH3CH=CHCH2CH3} $$
both identified and rendered
\ceis the macro added for chemical writing.
Actual behavior
Only Block equations rendered, and leave inline equations without $
\ce{CH2CH=CH2CH3 + CH3CH=CHCH3 ->[Cat] CH2=CHCH3 + CH3CH=CHCH2CH3}
Steps to reproduce the bug
-
With mathjax3 js, My inline equations would not render, just leave
$\Delta$as\Delta, while block equations with chem features render correctly. -
mathjax3 js Tried different js, ‘https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js’ and ‘https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js’. Just as Step 1.
-
With mathjax2.7 js, My inline equations render correctly, content with chem features unable to render.
-
I notice that the
?config=TeX-MML-AM_CHTMLis the difference between originalpymdownx.arithmatexinstruction. Without the config, mathjax2.7 would not render inline equations . However, mathjax3 do not support such config.
Package versions
- Python:
3.8.0 - MkDocs:
1.1 - Material:
4.6.3.
Project configuration
Follow the instruction on mathjax website and change the 2.7 config to 3.0 with officail tool
mathjax.js content
window.MathJax = {
TeX: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [ ['$$', '$$'], ["\\[","\\]"] ],
processEscapes: true,
processEnvironments: true,
digits: /^(?:[0-9]+(?:\{,\}[0-9]{3})*(?:\.[0-9]*)?|\.[0-9]+)/,
tags: 'none',
tagSide: "right",
tagIndent: ".8em",
multlineWidth: '85%',
equationNumbers: {
autoNumber: "AMS",
},
unicode: {
fonts: "STIXGeneral,'Arial Unicode MS'"
},
autoload: expandable({
mhchem: ['ce', 'pu']
}
},
displayAlign: "left",
showProcessingMessages: false,
messageStyle: "none"
};
The contents of your mkdocs.yml
nav:
theme:
name: 'material'
plugins:
- search
extra_javascript:
- 'javascripts\mathjax.js'
- 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
# - 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'
# - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'
markdown_extensions:
- toc:
permalink: "¶"
- markdown.extensions.admonition:
- pymdownx.arithmatex
- pymdownx.details
- pymdownx.superfences
- pymdownx.mark:
smart_mark: false
System information
- OS: windows7
- Browser: Firefox/Chrome
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (8 by maintainers)

Top Related StackOverflow Question
If none of that helps, you can create an issue of at
pymdown-extensions. As 3 is finally official, I will most likely migratepymdown-extensiondocuments over to using it and will document changes, if any are required.I am using
$...$in the Arithmatex docs with MathJax 3 and it works just fine. Please create an issue and post how you are configuring things as this is most likely a user error.