I am trying to add a few custom macros to MathJax, for all my card types. I don’t want to copy-paste the entire configuration into every card template, because that would make it tedious to add/remove/edit macros. Instead, I created a script file called _mathjax.js
, which I include into all my card templates with <script src="_mathjax.js"></script>
.
The _mathjax.js
file looks something like this:
MathJax.config.tex['macros'] = {
R: '{\\mathbb {R}}',
};
if (typeof window.isAlreadyRun == 'undefined') {
window.isAlreadyRun = true;
MathJax.startup.getComponents();
}
This seems to work fine on desktop Anki, but for some reason not on AnkiMobile.
On AnkiMobile, if I try previewing a flashcard where I imported _mathjax.js
, then at first the macro doesn’t work, and after flipping the card, the macro starts working, but the rest of the expression disappears.
If I try inlining the script into the card template, then it does work. But I was trying to avoid doing this :)
Here’s the source of this flashcard, if it helps:
Let <anki-mathjax>x\in\R</anki-mathjax>.
Am I doing something wrong? Is there some way to make this work?
I am using:
- Anki 24.06.3 on desktop
- AnkiMobile 24.11 on an iPhone 12 Mini, iOS 16.7.1
- also experiencing the same issue on an iPad Air M2, iPad OS 18.1.1