MathJax with dollar tags

AnkiMobile has MathJax support out of the box, however, it seems that \( and \[ are used as tags rather than $ and $$. I’m importing markdown-based notes to AnkiMobile (iOS) in which I use $ tags.

I wanted to ask whether it would be possible to parse content between dollar tags as math as well. I’m assuming that they are used more commonly, and think this might be a nice and simple addition to the app. Would there be any concerns related to enabling this?

From https://anki.tenderapp.com/kb/card-appearance/customizing-mathjax

Please avoid changing the standard open/close tags ( \( and \[ ), as Anki expects them to look like that.

As a possible workaround, after combining the code from the previous link with the code from https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-math-delimiters, it might work, but something might be broken, maybe something related to cloze deletions.

<script>
MathJax.Hub.Config({
  tex2jax: {
    inlineMath: [ ['$','$'], ['\\(','\\)'] ],
    displayMath: [ ['$$','$$'], ['\\[','\\]'] ],
    processEscapes: true
  }
});
MathJax.Hub.Configured();
</script>
1 Like

Thanks a lot for the pointer! I had tried something similar, following this blog post, which suggests using:

<script type="text/x-mathjax-config">
MathJax.Hub.processSectionDelay = 0;
MathJax.Hub.Config({
  messageStyle: 'none',
  showProcessingMessages: false,
  tex2jax: {
    inlineMath: [['$', '$']],
    displayMath: [['$$', '$$']],
    processEscapes: true
  }
});
</script>

This solution only works for Anki web but not for desktop or mobile app.

Turns out that following your suggestion:

<script>
MathJax.Hub.Config({
  messageStyle: 'none',
  showProcessingMessages: false,
  tex2jax: {
    inlineMath: [['$', '$']],
    displayMath: [['$$', '$$']],
    processEscapes: true
  }
});
MathJax.Hub.Configured();
</script>

makes MathJax work with dollar signs in desktop and mobile app (but not on Anki web).

I’ve played around a little but couldn’t find a unified way of configuration that works on all three easily. As a quick hack I ended up using both versions which makes it work on web, desktop and iOS app. :rocket: