Physics package bindings do not work for MathJax3
eeopd opened this issue · 5 comments
Hi all, I'm having troubles with the physics latex package that is included in MathJax 3.
To reproduce, just run
jupyter labextension install @jupyterlab/mathjax3-extension
jupyter labextension disable @jupyterlab/mathjax2-extension
Then create a notebook, try to execute a markdown cell with a physics command in it, e.g.
$$ \dv{y}{x} $$
This makes the command red, indicating some sort of error.
Secondly, importing the physics package explicitly does not work either: $$\require{physics}$$
gives a red error too, but this should not be necessary as this extension seems to be configured to load all extensions anyway. The physics commands do work on the live demo on the MathJax site (after importing the package).
Do you have any idea where the problems lies? Or where I could look to fix it or get more debugging information?
I just checked, and indeed the \require
command doesn't seem to work. I'm not sure exactly why, but perhaps has to do with us loading the tex extension manually instead of doing something with the loading system of mathjax?
The AllPackages thing we import seems to be this, which does not include require or physics: https://github.com/mathjax/MathJax-src/blob/6ba6cca458080ec2a73c60f8b19db6491985f92b/ts/input/tex/AllPackages.ts#L78
Before I ran out of time looking at this, I tried editing AllPackages to include 'require', but that didn't seem to make \require
available.
I was able to get physics to work by cloning MathJax-src and adding physics to AllPackages within that project. And then updating the dependencies in the package.json to point at the local directory. I haven't tried adding require yet.
According to mathjax/MathJax-src#553:
the physics package redefines lots of standard macros (like \sin, \cos, etc.), and so is not included in the AllPackages variable, since that is frequently used to turn on all the extensions.
But it is added in the MathJax.loader.preLoad.
I was able to enable physics
by changing
to
packages: AllPackages.concat('physics')
and rebuilding as described in your readme, But this is more of a hack. It would be great to have a support for a mathjax user config so that one could do
window.MathJax = {
loader: {load: ['[tex]/physics']},
tex: {packages: {'[+]': ['physics']}}
};
like described in mathjax
documentation
Alternatively maybe just internally add require
to loader
and packages
so that $$\require{physics}$$
would work.
Unfortunately, I know nothing about TypeScript and I can't do it myself. This is just as a friendly user request.