Latex issues on Windows with MiKtex

Been having issues with generating my images. The only error I can find in the debug that gets spit out is the following.

! LaTeX Error: Command \Zbar already defined.
Or name \end… illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.

l.177 …command{\Zbar}{\ensuremath{\overline{Z}}}
% sample mean (Z) (uncomm…

I can post more of the log if its helpful.

It’s a bit hard to help without the actual latex code, but I’d say you have something like \newcommand{\Zbar}{\ensuremath{\overline{Z}}}, while \Zbar already being defined. In that case, you need to use \renewcommand instead of \newcommand. Or, alternatively, you could use the good old \def

1 Like

The error happens with a lot of the latex code across many decks. This is one that created the error

[latex] \textbf{Complete Preferences}\

$\pref$ is \textbf{complete} if \blue{{{c1::$\forall x,y\in X$ either $x\pref y$ or $y\pref x$.}}}\

Note that completeness $\implies$ \blue{{{c1::\textbf{reflexivity}: $x \pref x$}}}

The error message seems to happen within pdftex? The latex log says the following:

2022-06-15 12:28:29,112-0700 INFO latex - this process (14092) started by anki in directory C:\Users\toobs\AppData\Local\Temp\anki_temp with command line: latex -interaction=nonstopmode tmp.tex
2022-06-15 12:28:29,115-0700 INFO latex - this is MiKTeX-PDFTEX 4.10.0 (1.40.24) (MiKTeX 22.3)
2022-06-15 12:28:29,117-0700 INFO latex - allowing known shell commands
2022-06-15 12:28:30,110-0700 INFO latex - this process (14092) finishes with exit code 1

And what Anki error display starts with is

This is pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX 22.3) (preloaded format=latex.fmt)
restricted \write18 enabled.
entering extended mode

Line break in LaTeX have two backslashes \\, not a single one \. I’m not sure how well Anki behaves when you have triple braces, but maybe spacing them out with a space will help \blue{ {{c1::$\forall x,y\in X$ either $x\pref y$ or $y\pref x$.}} }. Also note that LaTeX might behave weirdly with cloze deletions because Anki will replace them with HTML formatted content, which will cause some issues. I would recommend trying MathJax instead, as it has better integration with Anki, and because you don’t seem to be using LaTeX markup features that are unfeasible in HTML. For instance, that card could be transformed like

<h3>Complete Preferences</h3>
\(\pref\) is <b>complete</b> if <span style="color: blue;">{{c1::\(\forall x,y\in X, x\pref y\lor y\pref x\)}}</span><br>
Note that completeness ⇒ <span style="color: blue;">{{c2::<b>reflexivity</b>: \(x\pref x\)}}</span>