JupyterLab MathJax 3
raw JSON → 4.3.0 verified Fri May 01 auth: no python
A JupyterLab extension that renders LaTeX math using MathJax version 3. Provides improved performance and modern rendering compared to the default MathJax 2 renderer. Current version 4.3.0 (requires Python >=3.6) with a history of breaking changes across major releases (v2->v3, v3->v4).
pip install jupyterlab-mathjax3 Common errors
error ModuleNotFoundError: No module named 'jupyterlab_mathjax3' ↓
cause Package not installed or installed in wrong environment.
fix
Run 'pip install jupyterlab-mathjax3' in the same environment as JupyterLab.
error Extension failed to load: @jupyterlab/mathjax3-extension: Could not find required module 'mathjax3' ↓
cause Outdated version of the extension or JupyterLab version mismatch.
fix
Upgrade both jupyterlab and jupyterlab-mathjax3: 'pip install -U jupyterlab jupyterlab-mathjax3'
Warnings
breaking In v4, the settings schema changed. The 'renderer' setting is now a string instead of an object. Old settings may cause errors if not updated. ↓
fix Update user settings to use 'renderer': 'MathJax 3' (string) instead of the previous object format.
deprecated Python 3.6 and 3.7 are no longer supported. Upgrade to Python 3.8+ if you encounter import errors. ↓
fix Use Python 3.8 or later. Python 3.6 support was dropped in v4.
gotcha Common mistake: Users try to import 'jupyterlab_mathjax3' in notebooks to programmatically configure it. The extension works via JupyterLab settings, not Python imports. Importing the module does not enable the renderer. ↓
fix Configure MathJax 3 via JupyterLab settings (see quickstart). Do not rely on Python imports for activation.
Imports
- MathJax3Extension
from jupyterlab_mathjax3 import MathJax3Extension
Quickstart
# Create a JupyterLab settings file to enable MathJax 3
import json
import os
settings = {
"renderer": "MathJax 3",
"latex": {
"inlineMath": [["$", "$"], ["\\(", "\\)"]],
"displayMath": [["$$", "$$"], ["\\[", "\\]"]]
}
}
os.makedirs(os.path.expanduser("~/.jupyter/lab/user-settings/@jupyterlab/mathjax3-extension/"), exist_ok=True)
with open(os.path.expanduser("~/.jupyter/lab/user-settings/@jupyterlab/mathjax3-extension/plugin.jupyterlab-settings"), 'w') as f:
json.dump(settings, f)
print("MathJax 3 configured as renderer")