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

Explain Customising MathJax #324

Merged
merged 2 commits into from
Jan 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ To try it out:

\(\sqrt{x}\)

4. If you click the Cards button, you’ll see a preview of how the
4. Click the **Cards...** button. You’ll see a preview of how the
equation will appear when the card is reviewed.
\\[\sqrt{x}\\]

Anki’s MathJax support expects content in TeX format. If you’re not
familiar with TeX formatting, please see [this cheatsheet](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference).
Please note that point 2 does not apply in Anki - Anki uses `\(` and
Please note that point 1 does not apply in Anki - Anki uses `\(` and
`\)` for inline equations, and `\[` and `\]` for display equations.

If you want to use newlines in a MathJax expression, please use
Expand All @@ -42,7 +43,23 @@ equations. Please see the 'chemical equations' section and the following
sections for more information:
<https://mhchem.github.io/MathJax-mhchem/>

It is possible to [customize some settings](https://faqs.ankiweb.net/customizing-mathjax.html).
### Customize MathJax

Anki's bundled MathJax support is loaded before card content, so if you wish to customise MathJax you'll have to do so in a specific way. An example is provided here.

```javascript
<script>
MathJax.config.tex['macros'] = {
R: '{\\mathbb {R}}',
};
if (typeof is_already_run == 'undefined') {
is_already_run = true
MathJax.startup.getComponents();
}
</script>
```

Note that Anki has special logic for cloze deletions that might not work if you change the standard delimiters for MathJax equations.

## LaTeX

Expand Down