[latex][/latex] doesn't work


I would like to create Anki cards by entering mathematical formulas in the Latex environment. When I select “Latex” when creating an Anki-card, "[latex][/latex] is inserted. When I enter my content, I get the following error message: “LaTeX image generation is disabled in the preferences.” and my content is not compiled. But if I enter mathematical formulas using the command “\(” and “\)”, they are compiled correctly. I installed Texmaker and Miktex. What could be the reason that Latex isn’t working?

Best regards

Are you using version 24.06 or later? There’s a new setting in Preferences > Review – is “generate latex images” ticked?

I’m not sure what the “security risk” is that’s being addressed by this new setting – or why it is unticked by default. :person_shrugging:t4:

\( uses MathJax, which is safe and portable. Unless you have a specific reason for using LaTeX instead, MathJax is a better choice.

Thanks, that worked :slight_smile:

1 Like

I couldn’t find more about the introduction of that Prefs toggle than that pull request. I was surprised that the toggle is off by default, because it changes the behavior LaTeX users are used to.

Am I understanding correctly that some security restrictions needed to be removed – making LaTeX image generation less secure? And that’s why the toggle needs to default to “off” – so that users need to opt-in to using LaTeX in what is now a less-secure way? I’m predicting more questions about this – so I want to understand what I can.

I’ve updated the manual to mention the setting:

@Danika_Dakika we had some existing code that tried to prohibit malicious LaTeX, but it turned out not to be comprehensive. There are some legitimate use cases for the commands we were blocking, so it didn’t make much sense to continue to block them when we have this new option.

A global toggle is not without its own downsides. There’s a risk users will toggle it accidentally, or enable it, forget about it, and download shared decks months later. But given that it doesn’t seem to be practical to guard against all malicious LaTeX, or invoke LaTeX in a sandbox across all the platforms, I didn’t see many alternative options other than dropping LaTeX completely.