Mathjax Configuration via Cards Template Not Working

I am on Anki version 2.1.43. I tried it on Anki 2.1.40, it does not work either. I tried it on an older version of Anki and everything worked. What doesn’t work:

  1. When I paste any script relating to Mathjax configuration into my Front or Back templates, nothing happens.

Example: (script to let me use $ instead of \( and \).)

Front or Back:

<script>
  MathJax.Hub.Config({
tex2jax: {
    inlineMath: [['$','$'], ['\\(','\\)']],
    processEnvironments: true
},
  });
  MathJax.Hub.Configured();
</script>
  1. Also, I cannot style Mathjax font via Style Template+ Front or Back template.

Example would be:
Styling:

.field_1 .MathJax_CHTML {
font-size: 250% !important;
color: red;

}

Front:

<div class="field_1">{{Front}}</div>

Maybe you read the section Customizing MathJax on the Anki FAQ page, but this article seems to be for older versions of Anki, not for recent versions. The version of MathJax that ships with Anki used to be 2.x, but has been updated to 3.x in recent versions, including AnkiDroid and AnkiMobile. See the following thread on how to customize MathJax 3.x with Javascript.

However, I would strongly recommend that you do NOT change the standard MathJax delimiters( \( ... \), \[ ... \] ), as described in the FAQ above.

As for changing the font size and color only for the MathJax block within a specific class, I think you can do it using CSS as you did in version 2.x. But, the HTML tags and classes used by MathJax are different between 3.x and 2.x. You can use Google Chrome to inspect the webview of the card screen so you can see what tags and classes MathJax uses.

Writing Anki Add-ons

  • You can now debug the webviews using an external Chrome instance, by setting the env var QTWEBENGINE_REMOTE_DEBUGGING to 8080 prior to starting Anki, then surfing to localhost:8080 in Chrome.

(Sorry for my poor English. I hope that makes sense.)

2 Likes

Thank you for your reply. I tried inspecting the webview but I literally don’t know what to look for. Is there anyone who could help me, or has anyone already extracted the new Mathjax HTML tags and classes?