# Anki - LaTeX, Math Font Size, & DeclareMathSizes

I use the Anki flashcard program and render math equations using LaTeX within the program.

The problem is that the font sizes are generally too big, unless the equation is really long, in which case the equation automatically sizes down in order to fit the screen.

This is the default LaTeX header in Anki:

\documentclass[12pt]{article}
\special{papersize=3in,5in}
\usepackage{amssymb,amsmath}
\pagestyle{empty}
\setlength{\parindent}{0in}
\begin{document}

And this is the default footer:

\end{document}

To call LaTeX within Anki when creating a flashcard, you use $and$, which I assume refer to the header and footer respectively. (I'm neither an Anki nor a LaTeX expert.)

Anyway, I've tried inserting the following right before \begin{document}:

\DeclareMathSizes{2}{2}{2}{2}

Yes, I realize this is supposed to make the text really tiny, but more importantly, nothing changes. My equations are still too big (or too small, if the equation is really long).

-
welcome to tex.sx. For those of use (most of us I'd guess) without that program could you post the generated latex document including an equation so we can see what markup it is generating and then can suggest a preamble to control the fonts. – David Carlisle Apr 12 '13 at 21:32
Maybe a simple change to the header is enough. Something like \documentclass[10pt]{article} should change all font sizes. – Alexander Apr 12 '13 at 22:01
BTW: What is Anki? Never heard of it ... – Kurt Apr 12 '13 at 22:05
@Kurt, thanks for the welcome and the information. Anki is a spaced-repetition flashcard program: ankisrs.net – MMS Apr 12 '13 at 22:44
@David, thanks for the welcome. Anki generates an image from the LaTeX input and attaches the image to the flashcard. Not being an Anki expert (nor a big tech expert in general), I don't know how to dig into its source code to see what "markup" it is generating. – MMS Apr 12 '13 at 22:46

Tools -> Manage Note Types... -> Options; in the last line of the Header field after \begin{document} just type

\tiny

And your LaTeX will be made smaller. Because previously rendered latex is cached as image files, you may have to delete those files before the change is apparent. On my Mac the files are in ~/Anki/User 1/collection.media/latex-*.png

For me this makes my [$$][/$$] equations the same size as the surrounding Anki font.

I hope this helps!

UPDATE: On Linux, the media directory seems to be located in ~/Documents/Anki/User 1/collection.media/

-
On Windows, it's %USERPROFILE%\Documents\Anki\User 1\collection.media\ – Sydius Apr 28 '15 at 7:54
In my case, I could not enter the \tiny on a new line. It had to immediately follow \begin{document}. – Gudmundur Jan 30 at 1:32
That is, you can't press Enter and expect it to work, but it's okay for too long a line to overlap onto the next line. It seems this isn't designed for newlines. – Gudmundur Jan 30 at 1:37

I have been struggling with this as well. My solution was to use the LaTeX environment for my entire question and answer. I surround my text with $and$ and use Latex commands to format the card. This keeps my sizes consistent between text and math, and allows me to use other packages (such as making nice looking tables, compared to the Anki tables!)

For example, my Basic and Reverse cards have this in the preamble:

\documentclass[12pt]{article}
\special{papersize=3in,5in}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{libertine-type1}
\usepackage{biolinum-type1}
\usepackage{libertineMono-type1}
\usepackage[libertine]{newtxmath}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{amssymb,amsmath}
\usepackage{booktabs}
\usepackage{color}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{wasysym}
\pagestyle{empty}
\setlength{\parindent}{0in}
\newcommand{\noun}[1]{\textsc{#1}}
\definecolor{blue}{RGB}{0,130,255}
\begin{document}

This gives me nice tables, math symbols, small caps and default to sans-serif font for graphical display devices.

An example card,

Front: $What is \textbf{finiteness?}$

Back: $A set A is said to be finite \emph{if and only if} \left|A\right|=\mathbb{N} (natural number.) A set that is not finite is said to be infinite.$

Granted, if the displayed card is resized, then the longer card back will also be resized to fit a smaller window. However, I think this can be fixed by changing the papersize in the preamble. I strictly use my laptop and tablet, so I do not have any issues. It may crop up on smaller devices like a phone though.

-