You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is an example of a cloze card containing a latex formula
Formula: {{c1:: $f(x) = \frac{1}{\sqrt{x}}$}}
Unfortunately, the two curly braces after sqrt{x conflict with Anki's cloze syntax which also expects two }}. A simple solution would be to add a space between the two curly braces at runtime, right before creating the card in Anki, as shown below.
Formula: {{c1:: $f(x) = \frac{1}{\sqrt{x} }$}}
The text was updated successfully, but these errors were encountered:
I think this issue has nothing to do with this plugin. Seems like a bug with Anki's Cloze syntax and its inter-op with math formating. Or am i misunderstanding something ?
@ShootingKing-AM addressing this here is sensible imo.
Anki mentions in their documentation, that double curlies cause issues when they aren't meant to end a cloze when inside a math expression that is contained within a cloze.
Cloze deletions are terminated with }}, which can conflict with a }} appearing in your LaTeX. To prevent LaTeX from being interpreted as a closing cloze marker, you can put a space between any double closing braces that do not indicate the end of the cloze - anki documentation https://docs.ankiweb.net/math.html#cloze-conflicts
So I could do something like this in anki: \(z^2 = {{c1:: x^2 + y^2}}\) and it would create a cloze inside the math. Here, a double closing curly brace is intended to be placed and it works fine.
However, when we do something like this: {{c1::\(\frac{\frac{1}{2}}{3}\)}} the documentation advises users to create it like this {{c1::\(\frac{\frac{1}{2} }{3}\)}} to avoid issues with ending the cloze prematurely and therefore breaking the math.
I've run in this issue quite frequently and manually adjusting my notes to avoid it is sometimes a bit of a pain as it is only during the review of the notes that the issue becomes apparent and having to frequently stop doing my anki reps just to fix up the notes is a pain.
On top of that the fix is rather simple. Add a space in front of every double curly that isn't part of a cloze inside a math block. We have the cloze regex directly from the anki source code so implementing this shouldn't be an issue. https://github.com/ankitects/anki/blob/29f9f0dca7799cf270eb41c51a9db0c3ad9fa47d/ts/editable/mathjax.ts#L85
Here is an example of a cloze card containing a latex formula
Unfortunately, the two curly braces after
sqrt{x
conflict with Anki's cloze syntax which also expects two}}
. A simple solution would be to add a space between the two curly braces at runtime, right before creating the card in Anki, as shown below.The text was updated successfully, but these errors were encountered: