MathJax alternate renderer issues in notebook rendering

In a fresh install from conda-forge (jupyterlab 3.1.14 and its deps, in an isolated conda environment), I’m getting MathJax [Math Processing Error]s when I try to use MathJax renderers SVG or Common HTML. Html-CSS is ok. A minimal reproduction for me is simply create a new notebook with a single markdown cell containing $x$, and right-click and use the menus to change renderers.

I see this in both lab and classic notebook, and I get it in both firefox and chrome (mac, big sur). The specific errors look like:

Error: a.FONTDATA is undefined

file: http://localhost:8888/static/components/MathJax/jax/output/SVG/jax.js?V=2.7.9
line: 19

Debugging tips: use 'unpacked/MathJax.js', inspect 'MathJax.Hub.lastError' in the browser console

Can anyone provide any suggestions for what is going on or how to resolve this? I’ve had no luck googling this, except that lots of results come up from the time back in the day when jupyter came with a stripped down version of MathJax that simply did not provide all the renderers, and similar symptoms occurred. (Definitely caused me much grief back then too!) But I thought this was changed a long time ago.

Edit: additional question, should I just post this as an issue, and if so, in what repository? (notebook?)

Bump – anyone have any ideas about this, or even where to start looking or where else to ask?


conda create --yes -c conda-forge -p /tmp/mathjax-issue python=3.8 jupyterlab notebook
conda activate /tmp/mathjax-issue
jupyter notebook --debug

After changing render to SVG in context menu, front-end shows [Math Processing Error] and server logs show that some expected MathJax sources are not found (404):

[W 13:34:27.543 NotebookApp] 404 GET /static/components/MathJax/jax/output/SVG/fonts/TeX/fontdata.js?V=2.7.9 (::1) 2.110000ms referer=http://localhost:8888/notebooks/Untitled2.ipynb?kernel_name=python3

Noting version 2.7.9 in the log message above, we can place the expected MathJax resources the location that Jupyter is looking:

curl -L${MATHJAX_VERSION}.tar.gz > /tmp/MathJax-/${MATHJAX_VERSION}.tar.gz
tar -xzf /tmp/MathJax-/${MATHJAX_VERSION}.tar.gz
cp -r MathJax-${MATHJAX_VERSION}/jax $(python -c "import notebook, os.path; print(os.path.dirname(notebook.__file__))")/static/components/MathJax/jax

Refresh browser (no need to restart Jupyter server).

Font renders as expected (with renderer still set to “SVG”) and server logs confirm success (200):

[D 13:52:15.081 NotebookApp] 200 GET /static/components/MathJax/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js?V=2.7.9 (::1) 3.300000ms

Thanks @danielballan !!

I should mention that I also opened an issue here, with some more details, but nothing this close to a workaround: MathJax alternate renderers fail with error `Error: a.FONTDATA is undefined` · Issue #11306 · jupyterlab/jupyterlab · GitHub

1 Like

Very quick followup: this workaround does work for me, but looking into why it works reveals that the problem is that Jupyter is trying to use the TeX font, which Jupyter purposefully does not ship. (Installing a full MathJax package puts that font in place.) It should, I’m pretty sure, be able to work with these renderers using the STIX-Web font, but this isn’t happening for some reason. I’m also pretty sure that this did work around the time of include SVG mathjax output · jupyter/notebook@b0772dd · GitHub. So it’s possible some default has shifted out from under Jupyter since then, but I haven’t been able to isolate it. I’ll keep chipping away at this as time permits…

(Side-note: in 2021 the CommonHTML renderer should really be the default, not HTML-CSS. I wonder if there is some technical reason not to do this though?)