Newline command (\\) in Mathjax is broken in the latest versions of Anki

Hello there,
I have recently upgraded to Anki 2.1.40 (I think I had version 2.1.35 before, or even older), and apparently the newline command (\) in Mathjax does not work anymore (no errors, it simply does not produce a line break). I looked at the changelog and it seems that version 2.1.36 comes with Mathjax 3.0, which apparently does not support this command yet.

Has anybody found a workaround, or do I have to reverse back to 2.1.35 to use the command? If someone is aware of a different command that works I am willing to use it, since I don’t have that many cards to fix.

That’s a rather unfortunate omission. Perhaps you could wrap the code in displaylines? The line break(\\) is not work · Issue #2312 · mathjax/MathJax · GitHub

1 Like

Thank you! This workaround does the trick for me. Hopefully it will not be needed in future versions.

That’s indeed a pity !

For those coming from google because this topic is well referenced, you can use a search and replace with regex if you have thousands of mathjax notes :

  1. Select all notes
  2. Notes > Search and Replace (CTRL + ALT + F)
  3. Tick regex
  4. Search \\\[(.*?)\\\] and replace by \[\displaylines{$1}\]

In case you use tiny/small/normalsize/… to alter the font size, you have to put displaylines{} after the tiny/small/normalsize command so the regex gets more sophisticated : \\\[ ?\\(small|normalsize|tiny|scriptsize)\{(.*?)\} ?\\\] by \[\$1{\displaylines{$2}}\].
Please export your collection and check the regex works on a few notes before generalization (and reverse the test before generalization so you don’t get 2 nested displaylines).

1 Like