Setting up and Using Inline Editable LaTeX in SuperMemo

Credit goes to ijgnord’s question and Alessivs’s answer in latex in 2018 in SM. Without their discussion and Alessivs’s demo I’d not have known that it’s possible to render LaTeX in SuperMemo.

This article is my step-by-step setup for rendering LaTeX in SuperMemo. Here’s the result:


A. Setup

1. Install MiKTeX

I followed this excellent guide How To Use LaTeX In SuperMemo created by Luke. Please install MiKTeX as outlined in the first half of the video. The second half is about installing and using Mathpix. You don’t necessarily have to but I recommend Mathpix. It’s great for converting math’s symbols and formulae into LaTeX, and also because I’m too lazy to type.

2. Install TTH

  1. Go to TTH download page

  2. Click Windows executable

  3. The downloaded file is Unzip it

  4. Make sure the following files and paths exist. If they don’t exist, create them:

C:\Program Files\tth_exe\
C:\Program Files\tth_exe\test.html
C:\Program Files\tth_exe\test.tex
  1. Put the unzipped file to C:\Program Files (it’s important that you put it to this location because the following script depends on this location.)

  2. Add the executable to path by:

I. Click Win key, in the Start Search, type env, and choose Edit the system environment variables

II. click on the Environment Variables button

III. Under User variables for user, click Path, then click Edit

IV. In the popup dialog, click New and add C:\Program Files\tth_exe\

V. Click OK to exit

  1. Test your TTH by opening cmd or (Git for Windows) and type tth --help. If you see **** Invalid switch or file: --help, it means it’s working.

3. Append TTH’s css rules to SuperMemo’s default stylesheet

Toolkit -> Options -> Go to “Fonts” tab -> Click “Stylesheet” button -> click “Edit” button at the bottom to open supermemo.css. Then copy tth.css and append it to supermemo.css (highly recommend backing up the original css first.)

4. Basic usage of TTH

tth -L test.tex -r

$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty}(1+x/n)^n$

-L file tells tth the base file (no extension) for LaTeX auxiliary input, enables LaTeX commands (e.g. \frac) without a \documentclass line.

-r output raw HTML (no preamble or postlude) for inclusion in other HTML.

Please see the man page for more. The most relevant part is probably 3 Usage.

B. Using TTH with the following ahk script

Download the F1_latex_to_html.ahk. In order to make this script work, you need to also download Clip.ahk (credit goes to berban) and put it into the same folder as F1_latex_to_html.ahk.

In the script, SetWorkingDir, C:\Program Files\tth_exe set the working directory C:\Program Files\tth_exe. If you didn’t put the unzipped file to C:\Program Files, you need to modify this line. Please also refer to the ahk script for more comments.

When the script F1_latex_to_html.ahk is active (you’d see the green icon in the taskbar), select the LaTeX in SuperMemo, press F1 (provided that you didn’t change the ahk trigger), you should be able to replicate the gif above.


I hope this tutorial is helpful. As a die-hard SuperMemo supporter, this is the best I can do. If you have any questions or problems, feel free to leave a comment below!