How can I include graphs within Anki flashcards?

I am attempting to make a set of Anki flashcards for a Calculus class but cannot figure out how to add graphs.

Is there a method to include a visual representation of functions within Anki? For example, if I want to show the student what g(x)=(x-3)^2/3 + 2 looks like; how can I do so? Can I use LaTeX?

If LaTeX and/or MathJax have suitable ways to display your graphs, you can use either – Math & Symbols - Anki Manual . You can also attach images of graphs generated on some other site/platform.

To clarify, MathJax can be used to render math formulas, but it is not capable of plotting graphs based on those formulas. The simplest way you can do the latter is to use your preferred plotting software, then take a screenshot and paste it into Anki.

You can do a lot with just LaTeX. See Unsupported browser for example.

Neat, I wasn’t aware that was a possibility. Have you successfully been able to do that inside Anki?

I haven’t used LaTeX myself, but since Anki allows including packages, I don’t see why it wouldn’t work.

EDIT: I finally made it work. The main things to do are:

  1. Make sure “Install missing packages on the fly” is set to “Always”, not to “Ask me first” (as the manual says!).
  2. Enable “Create scalable images with dvisvgm” from manage note types → options.
  3. Enable “Generate LaTeX images” from the preferences.
  4. Read the manual for more details.

It generates instantly too! Actually no, it takes a few seconds the first time.

fixing the inverted colors in night mode

Add the following to the styling

.nightMode .latex_image .latex { filter: invert(0%); }

then surround the latex code with <div class="latex_image"> and </div>, or put that in the card template to avoid adding it each time.

Credits. I modified it to be optional (only latex inside a latex_image class is inverted), since I still want white formulas.

Outdated

Edit: I tried it and it shows this error:

hidden

Edited with the error in latest updates.

Error executing dvipng.
Generated file: C:\Users\MATH31~1\AppData\Local\Temp\anki_temp\tmp.tex<U+2069>

This is pdfTeX, Version 3.141592653-2.6-1.40.27 (MiKTeX 25.4) (preloaded format=latex.fmt)
 restricted \write18 enabled.
entering extended mode
(tmp.tex
LaTeX2e <2025-06-01> patch level 1
L3 programming layer <2025-07-19>

(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/base\arti
cle.cls
Document Class: article 2025/01/22 v1.4n Standard LaTeX document class

(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/base\size
12.clo))
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/base\inpu
tenc.sty)
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsfonts\
amssymb.sty
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsfonts\
amsfonts.sty))
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsmath\a
msmath.sty
For additional information on amsmath, use the `?' option.

(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsmath\a
mstext.sty
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsmath\a
msgen.sty))
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsmath\a
msbsy.sty)
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsmath\a
msopn.sty))
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/l3backend
\l3backend-dvips.def)
No file tmp.aux.

(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsfonts\
umsa.fd)
(C:\Users\Math3141592Computer\AppData\Local\Programs\MiKTeX\tex/latex/amsfonts\
umsb.fd)
[1] (tmp.aux) )
Output written on tmp.dvi (1 page, 572 bytes).
Transcript written on tmp.log.
This is dvipng 1.16 Copyright 2002-2015, 2019 Jan-Ake Larsson

Sorry, but dvipng did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

  C:\Users\Math3141592Computer\AppData\Local\MiKTeX\miktex\log\dvipng.log

It successfully generated a tex file in \anki_temp and it works in TeXstudio.

Edit 2: it seems like LaTeX doesn’t work at all on Anki. I tried one of the examples in the manual on a basic note and it shows me basically the same error message. (I have enabled generate LaTeX images in the preferences and added the code to a field not inside the template). I even tried to run it in safe mode, but still the same. I didn’t enable install missing packages. Now, the example in the manual renders but the one provided by Overleaf doesn’t.

Debug info
Anki 25.07.1 (a83a6b59) (ao)
Python 3.13.5 Qt 6.8.1 PyQt 6.8.0
Platform: Windows-10-10.0.19045-SP0

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
AnkiConnect ['2055492159', 2025-02-26T01:57, 'None', mod]
Disconnected Review-Log Cleaner ['1067771610', 2025-06-10T16:28, 'None', '']
Local Audio Server for Yomichan ['1045800357', 2023-06-19T06:57, 'None', '']
The KING of Button Add-ons ['374005964', 2025-01-28T01:26, 'None', mod]

===IDs of active AnkiWeb add-ons===
1045800357 1067771610 2055492159 374005964

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Advanced Copy Fields ['1898445115', 2024-01-08T20:01, 'v0.4.01', '']
No Distractions Full Screen Fixed by Shige ['1370336700', 2024-08-26T08:08, 'None', mod]

Edit 3: I updated Anki to ⁨25.07.5 (7172b2d2)⁊ and all the LaTeX packages in MiKTeX including miktex-dvipng-bin-x64-2.9. Still not working.

dvipng.log
2025-08-04 13:40:15,199+0300 INFO  dvipng - this process (1668) started by pythonw in directory C:\Users\MATH31~1\AppData\Local\Temp\anki_temp with command line: dvipng -bg Transparent -D 200 -T tight tmp.dvi -o tmp.png
2025-08-04 13:40:15,199+0300 INFO  dvipng - running on Windows 10.0.19045
2025-08-04 13:40:15,206+0300 FATAL dvipng.core - GUI framework cannot be initialized.
2025-08-04 13:40:15,207+0300 FATAL dvipng.core - Data: 
2025-08-04 13:40:15,207+0300 FATAL dvipng.core - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp:126
2025-08-04 13:40:15,207+0300 FATAL dvipng - GUI framework cannot be initialized.
2025-08-04 13:40:15,207+0300 FATAL dvipng - Info: 
2025-08-04 13:40:15,207+0300 FATAL dvipng - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp
2025-08-04 13:40:15,207+0300 FATAL dvipng - Line: 126
2025-08-04 13:40:15,212+0300 INFO  dvipng - this process (1668) finishes with exit code 1