Can live preview of MathJax be tunred off in the card editor?

I use Anki to rember lots of math euqations. It works well. However it, when Anki 2.1.50, the MathJax the editor of Anki has live preview of them, and now it’s quit inconvenience for me to edit cloze in an equation.
For example, suppose I have on equation:
\[F = {{c1:: \frac{a}{b} }} = \frac{ac}{bc} }}\]
and I want to change it to:
\[F = \frac{a}{b} = {{c1:: \frac{ac}{bc} }}\]
In the previos version I can easily use the cloze buttons to do this, while in the new version them are not available in the editor of equation.
Ps. I have found one post in the forum. However, we need the same feature for different purposes, which is the reason I posed the new one.

Would supporting the cloze button while inside the MathJax editor also solve your problem?

1 Like

I think so. It will be very helpful if the buttons are avaliable inside the MathJax editor. Thanks for your reply.

I also frequently use Mathjax formulae in my cards and have had a different but related issue. I have setup a large number of macros in the card template like so:

\(
\require{physics}
\def \N {\mathbb{N}}
\def \Z {\mathbb{Z}}
\def \Q {\mathbb{Q}}
\def \R {\mathbb{R}}
\def \quotient#1#2{^{\textstyle #1}\big/_{\textstyle #2}}
...
\)
{{Front}}

all of which don’t work with the live previews as the mathjax code in the template isn’t run when creating the preview. Does anyone know of a fix/workaround? Perhaps an alternate way of defining macros?

Thanks in advance

1 Like

There is no way to support this right now. Maybe there will be one in the future.

Just updated to 2.1.54 from 2.1.49.

I’d like to say that I face the same problem as j35.

If possible, it would be nice if in new updates the Mathjax code in the template is loaded into the preview, so we can use macros.

Thank you.

I’ve had a lot of problems with the new live preview for MathJax. It would be great to have an option to disable it. You can see in these screenshots how the live editor mangles the output:

In this screenshot, the “\reals” macro that I define in my template is missing and there is an extra pair of square brackets around “lim inf”:
image
In this screen shot, the presence of " " (which was added automatically by Anki at some point) causes an error, where as the actual flashcard is rendered correctly:
image

All in all, it makes editing cards a LOT harder to the point where I often write my flashcards in a text editor and then copy them over.

I don’t really see what in the screenshots you posted is wrong (besides your mathjax code), but if you don’t want a WYSIWYG editor, you can always use the HTML editor.

there’s also other issues with the live preview.

A notable one is that, if you’re outside the editing mode for an equation, a single backspace will remove the whole equation. That’s slightly annoying but bearable, but what’s much worse is that ctrl-z immediately after having removed an equation in this way doesn’t restore the equation. This can easily lead to loss of information. I ended up deleting by mistake a couple of long equations while trying to make simple edits to them.

Another annoying feature is that if you’re editing an equation, then alt-tab to focus on another window, and then alt-tab back to anki (imagine copying an equation from some pdf and going back and forth between pdf and anki), you have to manually click back into the equation to resume editing.

1 Like

If you want to make suggestions on how to improve the live preview, please open a new thread. If these are, instead, arguments in favor of turning off the live-preview by default, please consider using the HMTL editor instead.

I mean, it’s both. You are right that I should probably open a new thread for this, and I will. But also, I see these things as an argument for allowing to turn off the live preview (or can this already be done? I don’t see the option). Using the HTML is not a solution, because that loses you other features, such as the ctrl-m+m to add mathjax or the ctrl-shift-c to add cloze deletions.

The advantage of having both the HTML editor and the “visual” editor side-by-side is that you can use the one that fits better what you are writing, and swap out for the other when you need the other (it’s just a Tab or Shift-Tab away).

1 Like

@BlackBeans, there are three problems with the live previews in my screenshots:

  • The “\reals” macro that I define using the script at the bottom of this comment—and which works properly when the cards are displayed everywhere else—is not rendered correctly in the live preview.
  • There is an extra set of square brackets around “lim inf”. These brackets appear whenever there is a cloze deletion in a MathJax expression.
  • The text highlighted in yellow is rendered correctly on cards but in the live preview the presence of " " causes an error.

Overall, the live preview feels half-baked and it seems unreasonable to force users to use it or the HTML editor when both are vastly worse than the old editor.

<script>
MathJax.config.tex.macros =  {
      reals: '{\\mathbb R}',
    };
MathJax.startup.getComponents();
</script>

You’re asking us to jump through hoops to approximate the editing experience that we used to have. :expressionless:
“Just use a Tab or SHIFT-Tab” sounds like it’s not too bad, but doing it dozens of times and getting your bearings each time you switch is a significant extra burden that frankly is not worth the benefits of the live preview feature to me.

2 Likes

I agree with MathJax live preview, but are you really saying the old HTML “editor” (which was just a text area without any pretty-printing, just condensed HTML) was better than the CodeMirror live editor we got now? :smiley:

Edit: After reading that sentence of yours again, I understood you just meant having to edit MathJax in the HTML editor is worse than how it was before. Then you can ignore my comment ^^

Haha, yes, your edit is correct. I meant that using the new HTML editor to edit MathJax is harder than using the old standard note editor.

Added to Provide opt-out of MathJax live preview · Issue #1942 · ankitects/anki · GitHub

3 Likes

Thanks so much for this! I just tested out your commit and it feels much better making and editing cards with MathJax rendering disabled. I can see the utility of embedded rendering, but having the option to disable it is really useful for me, especially since my cards tend to be extremely LaTeX-dense and I use a lot of custom commands. (I prefer to have a separate live preview open instead.) The wording in your GitHub issue seems to suggest this is a temporary workaround, but I hope this toggle stays in future releases!

4 Likes