Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Physics package bindings do not work for MathJax3 #229

Open
eeopd opened this issue Sep 17, 2020 · 5 comments
Open

Physics package bindings do not work for MathJax3 #229

eeopd opened this issue Sep 17, 2020 · 5 comments

Comments

@eeopd
Copy link

eeopd commented Sep 17, 2020

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?

@jasongrout
Copy link
Contributor

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.

@jlrpnbbngtn
Copy link

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.

@randolf-scholz
Copy link

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.

@pordyna
Copy link

pordyna commented Feb 8, 2022

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.

@bsdz
Copy link
Contributor

bsdz commented Aug 15, 2022

I created a PR (#282) to add support for the requires extension. Now we can selectively load the physics package when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants