Can't make chemfig in latex work with Anki

Hello everyone,
I’ve been trying to make draw chemical structures in Anki through latex using the chemfig package. I have edited my latex build process through the Edit Latex Build Process add-on. I have edited my Latex config for anki exactly according to a comment under the reddit post “How to get anki working with TikZ package? - For dummies”

When I ran the program I received an error,

Error executing ⁨/usr/bin/pdflatex⁩.
Generated file: ⁨/tmp/anki_temp/tmp.tex⁩
Have you installed latex and dvipng/dvisvgm?

I found it odd as I have already installed texlive googled about it and found a post on Apple stackexchange called "Anki + Latex not working : I have installed BasicTex + dvipng - Ask Different", which states that I have to add the full path to the latex, dvipng and all the other files, which I have done now. I changed the header of all of my note types according to the aforementioned reddit post as well.

My latex config in anki looks like this now

{
    "pngCommands": [
        [
            "/usr/bin/latex",
            "-interaction=nonstopmode",
            "tmp.tex"
        ],
        [
            "/usr/bin/dvipng",
            "-D",
            "200",
            "-T",
            "tight",
            "tmp.dvi",
            "-o",
            "tmp.png"
        ]
    ],
    "svgCommands": [
        [
            "/usr/bin/pdflatex",
            "-interaction=nonstopmode",
            "tmp.tex"
        ],
        [
            "/usr/bin/pdf2svg",
            "tmp.pdf",
            "tmp-unscaled-svg"
        ],
        [
            "/usr/bin/rsvg-convert",
            "--zoom=2",
            "--format=svg",
            "tmp-unscaled-svg",
            "-o",
            "tmp.svg"
        ]
    ]
}

When I try and add latex to a card ( e.g. - [latex]\chemfig{A ~ B}[\latex], which does compile in latex) I still get the same error. I have also confirmed the existence of all required files but it still doesn’t work.

I have tried to fix this issue for days now to no avail. Please help me.

I am running Anki 2.1.54 on Ubuntu 22.04.1 LTS. I have installed Anki-ppd through the Ubuntu Software store through - Snap (Snap Store). Anki installed through sudo apt install anki doesn’t work for me as I cannot access the prefrences section due to some error.

I thank you in advance.

1 Like

https://docs.ankiweb.net/platform/linux/distro-packages.html

1 Like

IT WORKS! Thanks man. Now I just feel dumb, really should have read the Anki manual more thoroughly.
Anyways, thank you very much again Dae, Love ya.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.