Configure MathJax 3 adding packages

Hello,
I am using the built-in MathJax to render math and I was trying to add the physics package to it.
In particular I am using the Anki for Linux application version 2.1.44.
I tried to add some scripts at the beginning of the front and back template of the cards, I checked both the MathJax wiki and this forum for something similar and to adapt it especially from.:

Saw here how to add adding macros and the need of MathJax.startup.getComponents() in the script:

https://docs.mathjax.org/en/latest/options/index.html?highlight=configuring%20mathjax

I saw the commands for adding the package here:
https://docs.mathjax.org/en/latest/input/tex/extensions/physics.html

I tried a lot of possible combination with the commands from those sources ( they are suggested from the Anki wiki) but nothing so far did it, this is the code I am stuck now with:

<script>
MathJax.config.tex.packages = {'[+]': ['physics'] };
MathJax.loader.load = ['[tex]/physics'] ;
MathJax.startup.getComponents();
</script>

which doesn’t render the commands in the physics package correctly.
eg. for the curl command :

Undefined control sequence \curl
00000

What could be the problem?

There may be a way to set it up with javascript, but it would be easier to use \require{physics} in a card template. The link you provided says:

Alternatively, use \require{physics} in a TeX expression to load it dynamically from within the math on the page, if the require package is loaded.

Try putting the following at the beginning of the front template.

\( \require{physics} \)

If you don’t use {{FrontSide}} in the back template, put the above code in the back template as well, otherwise I think it probably won’t work on AnkiDroid.

2 Likes

Thank you so much, that did it.
I’m feeling so dumb ahaha.

1 Like