jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.65k stars 4.91k forks source link

custom.js mathjax macros not working on file open #3715

Open waynemystir opened 6 years ago

waynemystir commented 6 years ago

I have added custom.js to ~./jupyter/custom. And here's the beginning of the mathjax config section of my custom.js file:

MathJax.Hub.Config({ "tex2jax": { inlineMath: [ ["$","$"], ["(",")"] ], displayMath: [ ["$$","$$"], ["[","]"] ], processEscapes: true, }, "displayAlign": "center", "extensions": ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js","TeX/color.js","TeX/cancel.js"], "TeX": { Macros: { wes: "\blacksquare", qes: "\frac{1}{8}", qd: "\quad", dq: "\quad\quad", norm: ["{\lvert#1\rvert}", 1],

When I open a notebook that uses these macros, the notebook doesn't appear to recognize these macros:

screen shot 2018-06-25 at 1 56 49 pm

But when I refresh the page, the macros are usually recognized and presented as expected. Is there something I can do to get Notebook to recognize the Mathjax macros when a file is opened?

sindzicat commented 5 years ago

The same problem.

Custom.js must be loaded before mathjax.js. Unfortunately mathjax.js loads first...

http://docs.mathjax.org/en/latest/configuration.html#using-in-line-configuration-options

Just open any notebook in jupyter notebook, press ctrl+U and look at source HTML code. Early mathjax was at the end of <body>. Now it's on <head>. :cry:

Sorry, but I don't know what's such difficult to place mathjax at the end of <body>?

sindzicat commented 5 years ago

Hm... I found that mathjax.js is loaded with option ,Safe&delayStartupUntil=configured.

According this we should run MathJax.Hub.Configured(); after our settings. But this still doesn't works for me...

sindzicat commented 5 years ago

To be honest, now I don't understand anything.

I found here:

If you do not execute this function, MathJax will not process any of the math on the page.

That means MathJax.Hub.Configured() must run. I found it in notebook/static/notebook/js/mathjaxutils.js (code)

Then I found that mathjaxutils.js is loaded by main.min.js. That is MathJax.Hub.Configured() is called after custom.js. I even doesn't need for MathJax.Hub.Configured() in custom.js. But my Mathjax settings still doesn't works...

sindzicat commented 5 years ago

Maybe, Mathjax settings from mathjaxutils.js override user Mathjax settings from custom.js?