LaTex error when displaying card

Greetings,
I’m trying to use LaTex inside Anki cards. This is my first time as I was using MathJax before. As an example, I have the following on the back of a basic card:

Let SC be a stream cipher with key size k. Let K be randomly drawn from the set of all keys. The advantage of an adversary A in distinguishing SCK from a random oracle RO is defined as 
[$]Adv^{prf}_{SC}(A)=\Delta_A(SC_K ; RO)[/$].

Unfortunately, when I try to display it via the preview function of normally when studying the card, I get the following output:

Let SC be a stream cipher with key size k. Let K be randomly drawn from the set of all keys. The advantage of an adversary A in distinguishing SCK from a random oracle RO is defined as
$Adv^{prf}_{SC}(A)=\Delta_A(SC_K ; RO)$.Errore nell'eseguire <U+2068>latex<U+2069>.
File generato: <U+2068>/tmp/anki_temp/tmp.tex<U+2069>
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/Arch Linux) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(./tmp.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-04-10>
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size12.clo))
(/usr/share/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/share/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/share/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/share/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def) (./tmp.aux)
(/usr/share/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/share/texmf-dist/tex/latex/amsfonts/umsb.fd)
Overfull \hbox (4.23528pt too wide) in paragraph at lines 8--15
\OT1/cmr/m/n/12 0; Math-Jax.Hub.Config( mes-sageStyle:"none", show-Pro-cess-ing
Mes-sages:false,
! Missing $ inserted.
<inserted text> 
                $
l.20 .../mathjax/latest/MathJax.js?config=TeX-AMS_
                                                  SVG-full"></script>
! Missing $ inserted.
<inserted text> 
                $
l.21 $Adv^
          {prf}_{SC}(A)=\Delta_A(SC_K ; RO)$

Overfull \hbox (316.39453pt too wide) in paragraph at lines 15--22
\OT1/cmr/m/n/12 ']], pro-cess-Escapes:true  ); </script> <script type="text/jav
ascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-
[1] (./tmp.aux) )
(see the transcript file for additional information)
Output written on tmp.dvi (1 page, 1060 bytes).
Transcript written on tmp.log.

Here is my tmp.log:

This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/Arch Linux) (preloaded format=latex 2022.10.29)  29 OCT 2022 23:06
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**tmp.tex
(./tmp.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-04-10>
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size12.clo
File: size12.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@section=\count186
\c@subsection=\count187
\c@subsubsection=\count188
\c@paragraph=\count189
\c@subparagraph=\count190
\c@figure=\count191
\c@table=\count192
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)
(/usr/share/texmf-dist/tex/latex/base/inputenc.sty
Package: inputenc 2021/02/14 v1.3d Input encoding file
\inpenc@prehook=\toks16
\inpenc@posthook=\toks17
)
(/usr/share/texmf-dist/tex/latex/amsfonts/amssymb.sty
Package: amssymb 2013/01/14 v3.01 AMS font symbols

(/usr/share/texmf-dist/tex/latex/amsfonts/amsfonts.sty
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\@emptytoks=\toks18
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info:    Redeclaring math symbol \hbar on input line 98.
LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
(Font)                  U/euf/m/n --> U/euf/b/n on input line 106.
))
(/usr/share/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2021/10/15 v2.17l AMS math features
\@mathmargin=\skip49

For additional information on amsmath, use the `?' option.
(/usr/share/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2021/08/26 v2.01 AMS text

(/usr/share/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks19
\ex@=\dimen139
))
(/usr/share/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen140
)
(/usr/share/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 2021/08/26 v2.02 operator names
)
\inf@bad=\count193
LaTeX Info: Redefining \frac on input line 234.
\uproot@=\count194
\leftroot@=\count195
LaTeX Info: Redefining \overline on input line 399.
\classnum@=\count196
\DOTSCASE@=\count197
LaTeX Info: Redefining \ldots on input line 496.
LaTeX Info: Redefining \dots on input line 499.
LaTeX Info: Redefining \cdots on input line 620.
\Mathstrutbox@=\box50
\strutbox@=\box51
\big@size=\dimen141
LaTeX Font Info:    Redeclaring font encoding OML on input line 743.
LaTeX Font Info:    Redeclaring font encoding OMS on input line 744.
\macc@depth=\count198
\c@MaxMatrixCols=\count199
\dotsspace@=\muskip16
\c@parentequation=\count266
\dspbrk@lvl=\count267
\tag@help=\toks20
\row@=\count268
\column@=\count269
\maxfields@=\count270
\andhelp@=\toks21
\eqnshift@=\dimen142
\alignsep@=\dimen143
\tagshift@=\dimen144
\tagwidth@=\dimen145
\totwidth@=\dimen146
\lineht@=\dimen147
\@envbody=\toks22
\multlinegap=\skip50
\multlinetaggap=\skip51
\mathdisplay@stack=\toks23
LaTeX Info: Redefining \[ on input line 2938.
LaTeX Info: Redefining \] on input line 2939.
)
(/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def
File: l3backend-dvips.def 2022-04-14 L3 backend support: dvips
\l__pdf_internal_box=\box52
\g__pdf_backend_object_int=\count271
\l__pdf_backend_content_box=\box53
\l__pdf_backend_model_box=\box54
\g__pdf_backend_annotation_int=\count272
\g__pdf_backend_link_int=\count273
\g__pdf_backend_link_sf_int=\count274
) (./tmp.aux)
\openout1 = `tmp.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Trying to load font information for U+msa on input line 14.


(/usr/share/texmf-dist/tex/latex/amsfonts/umsa.fd
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
)
LaTeX Font Info:    Trying to load font information for U+msb on input line 14.


(/usr/share/texmf-dist/tex/latex/amsfonts/umsb.fd
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
)
Overfull \hbox (4.23528pt too wide) in paragraph at lines 8--15
\OT1/cmr/m/n/12 0; Math-Jax.Hub.Config( mes-sageStyle:"none", show-Pro-cess-ing
Mes-sages:false,
 []

! Missing $ inserted.
<inserted text> 
                $
l.20 .../mathjax/latest/MathJax.js?config=TeX-AMS_
                                                  SVG-full"></script>
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

! Missing $ inserted.
<inserted text> 
                $
l.21 $Adv^
          {prf}_{SC}(A)=\Delta_A(SC_K ; RO)$
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.


Overfull \hbox (316.39453pt too wide) in paragraph at lines 15--22
\OT1/cmr/m/n/12 ']], pro-cess-Escapes:true  ); </script> <script type="text/jav
ascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-
 []

[1

] (./tmp.aux) ) 
Here is how much of TeX's memory you used:
 1704 strings out of 478239
 24582 string characters out of 5850481
 313107 words of memory out of 5000000
 19979 multiletter control sequences out of 15000+600000
 473904 words of font info for 46 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 54i,5n,62p,216b,102s stack positions out of 5000i,500n,10000p,200000b,80000s

Output written on tmp.dvi (1 page, 1060 bytes).

It doesn’t seem particularly illuminating to me, it seems to just complain about missing $ for the math environment, but I’m expecting Anki to put those for me. All I can say, is that if I manually put the following code in a file (which is the code I’m expecting Anki to generate)

\documentclass{article}

\begin{document}
$Adv^{prf}_{SC}(A)=\Delta_A(SC_K ; RO)$
\end{document}

and then I compile it with xelatex test.tex, it works fine.

I’m using Anki version ⁨2.1.54 on Arch Linux, thank you for your help.

GTP

Edit: this is the tex file that Anki generates:

\documentclass[12pt]{article}
\special{papersize=3in,5in}
\usepackage[utf8]{inputenc}
\usepackage{amssymb,amsmath}
\pagestyle{empty}
\setlength{\parindent}{0in}
\begin{document}
<script type="text/x-mathjax-config">
    MathJax.Hub.processSectionDelay = 0;
    MathJax.Hub.Config({
        messageStyle:"none",
        showProcessingMessages:false,
        tex2jax:{
            inlineMath: [['$','$']],
            displayMath:[['$$','$$']],
            processEscapes:true
        }
});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_SVG-full"></script>
$Adv^{prf}_{SC}(A)=\Delta_A(SC_K ; RO)$

And this is what I get if I try to compile it manually:

$ xelatex tmp.tex 
This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022/Arch Linux) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./tmp.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-04-10>
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size12.clo))
(/usr/share/texmf-dist/tex/latex/base/inputenc.sty

Package inputenc Warning: inputenc package ignored with utf8 based engines.

) (/usr/share/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/share/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/share/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texmf-dist/tex/latex/l3backend/l3backend-xetex.def) (./tmp.aux)
(/usr/share/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/share/texmf-dist/tex/latex/amsfonts/umsb.fd)
Overfull \hbox (15.35149pt too wide) in paragraph at lines 8--15
\TU/lmr/m/n/12 = 0; MathJax.Hub.Config( messageStyle:”none”, showProcessingMess
ages:false,
! Missing $ inserted.
<inserted text> 
                $
l.20 .../mathjax/latest/MathJax.js?config=TeX-AMS_
                                                  SVG-full"></script>
? 
! Missing $ inserted.
<inserted text> 
                $
l.21 $Adv^
          {prf}_{SC}(A)=\Delta_A(SC_K ; RO)$
? 

Overfull \hbox (330.85551pt too wide) in paragraph at lines 15--22
\TU/lmr/m/n/12 ’]], processEscapes:true  ); </script> <script type=”text/javasc
ript” src=”https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-
[1] (./tmp.aux) )
Output written on tmp.pdf (1 page).
Transcript written on tmp.log.

I found the problem, I had to remove from the card’s intestation inthe settings the following that I added to support MatJax on Android:

<script type="text/x-mathjax-config">
    MathJax.Hub.processSectionDelay = 0;
    MathJax.Hub.Config({
        messageStyle:"none",
        showProcessingMessages:false,
        tex2jax:{
            inlineMath: [['$','$']],
            displayMath:[['$$','$$']],
            processEscapes:true
        }
});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_SVG-full"></script>

I have to say, it’s a bit unfortunate that the two systems can’t co-exist, but at least it works now

That code is intended to be placed in your card template, not your LaTeX header.