How to make your own Anki deck with LaTeX
Some useful resources:
Installing the appropriate Addons
Creating a new Note Type
-
Tools -> Manage Note Types
-
Click Add
-
Choose Add:Basic
-
Type a name, e.g., “Imported”
-
Select the newly-created type and click Options
- Header
\documentclass[border=1px,preview]{standalone} \usepackage[utf8]{inputenc} \usepackage{manki} \pagestyle{empty} \setlength{\parindent}{0in} \begin{document}
- Footer
\end{document}
and also marking Create scalable…
- Header
LaTeX package manki
above is a custom package implemented as a subdirectory (with a bunch of .sty
and .tex
files) reachable through one of the paths in TEXINPUTS
.
Editing Latex build process
-
Tools -> Addons
-
Choose Edit LaTeX build process
-
Click Config
-
Erase whatever is in there, and copy-paste:
{
"pngCommands": [
[
"latex",
"-interaction=nonstopmode",
"tmp.tex"
],
[
"dvipng",
"-D",
"200",
"-T",
"tight",
"tmp.dvi",
"-o",
"tmp.png"
]
],
"svgCommands": [
[
"pdflatex",
"-interaction=nonstopmode",
"tmp.tex"
],
[
"pdf2svg",
"tmp.pdf",
"tmp-unscaled-svg"
],
[
"rsvg-convert",
"--zoom=2",
"--format=svg",
"tmp-unscaled-svg",
"-o",
"tmp.svg"
]
]
}
Import
-
File -> Import
-
Locate the .tex file and click Open
-
Click Type, and choose the appropriate one, e.g., “Imported”
- Click Deck, and choose an existing one or Add a new one
- Hierarchy can be achieved by using “::” for separating different levels, e.g. Communications Theory :: Noise in communication systems refers to a deck named “Noise in communication systems” within “Communications Theory”
- Finally, click Import
Troubleshooting
- If it’s not possible to import
.tex
files (the extension doesn’t show in the list), one can try and use the bottom-right button instead of the menu, or try and access the webpage of Latex Note Importer from the Add-Ons. - One might need to install pdf2svg
Export
-
Click the cogs icon next to the deck you want to export
-
Choose Export
-
Turn off include scheduling information
-
Click Export
- In Linux it is exported by default in folder Documents
Testing
Things to keep in mind:
- (It seems) Anki caches stuff, so when importing/exporting a deck it might be a good thing to choose Tools -> Check media -> Delete Unused Files to delete old stuff
- (It seems) AnkiDroid also caches stuff, so when testing updated versions of a deck, it’s probably a good thing to (really) close the app, and launch it back again
Original config in “LaTeX build process”
{
"pngCommands": [
[
"latex",
"-interaction=nonstopmode",
"tmp.tex"
],
[
"dvipng",
"-D",
"200",
"-T",
"tight",
"tmp.dvi",
"-o",
"tmp.png"
]
],
"svgCommands": [
[
"latex",
"-interaction=nonstopmode",
"tmp.tex"
],
[
"dvisvgm",
"--no-fonts",
"-Z",
"2",
"tmp.dvi",
"-o",
"tmp.svg"
]
]
}