Description
I have a note template with MathJax macros defined on the first card. I have generally found that this is fine for getting the macros to be available on all the other cards of the template… and sometimes it is (or it will load specific macros but not all or properly). However, I have some interesting behaviour.
Steps to Reproduce
- (I did this in a brand new profile)
- Create a note template with multiple cards (e.g.
Basic (and reversed) copy) - Add a card to some deck with
\[\dd{f}{x}\on the front and\[\dd{f}{x} = f'(x)\]on the back. - Hit
Browseand make sure you are viewingNotes - On the card you created in (2), select
Cardsand check you are viewing card type 1. - Set the front template of card type 1 to
<script>
MathJax.config.tex["macros"] = {
dd: ["\\frac{ {\\mathrm{d}}#1}{ {\\mathrm{d}}#2}", 2]
};
if (typeof is_already_run == "undefined") {
is_already_run = true;
MathJax.startup.getComponents();
}
</script>
{{Front}}
- Hit save and re-view
Cards. It should render fine for both front and back previews in both card type 1 and card type 2. - Close
Cardsand switch the browser to viewCards. OpenCard 2of the note with itsCardsbutton. - Things are broken:
- on card type 2, both front and back preview show red for undefined MathJax functions
- switching to card type 1, only the mid-bar of the fraction is rendered
- back to card type 2, only the mid-bar
- close
Cardsand openCard 2’sPreview, shows undefined MathJax - close browser and study the new cards,
Card 1renders fine (grade itGood) andCard 2renders fine (do NOT grade it) - go back to
Decksand study again,Card 2render with red undefined MathJax (grade itAgain) andCard 1only renders the fraction’s mid-bar
Screenshots of a more complex example:
Same setup: macros defined on card type 1, starting with viewing card type 2.
Card type 2 back preview:
Card type 1 back preview:
Card type 2 back preview:
Anki Version
- Version 23.12.1 (1a1d4d54)
- Python 3.9.15 Qt 6.5.3 PyQt 6.5.3



