Taking Technical Notes in LaTeX
Last summer, I had to figure out how to take notes for technical classes electronically before I started school. I tried Evernote, Google Docs, Markdown, and even Microsoft Word with Google Drive, but nothing worked well enough to make the effort worth it. The features I was looking for were:
Taking notes in mathematical notation easily and quickly
Minimal hassle to lay out notes how I want them
Synchronizing across multiple computers
Creating and including figures in notes
I couldn't find anything to satisfy even the first requirement, let alone all four at once. For a while, I was seriously considering just scanning my hand-taken notes to back them up.
Luckily, it was about this time that I discovered LaTeX. When I started learning, everything clicked wonderfully. I loved how easy it was to take notes in mathematical notation, and having the engine do all the typesetting and formatting for me meant that I only had to worry about the content of my notes.
After using LaTeX for transcribing hand-taken notes after class (and some live-TeXing during slower classes), I've developed an efficient and practical workflow for note-taking. In this post, I'll share some of the habits and practices I've adopted that have helped me tremendously.
To see examples of the tips I'm going to share, you can check out the files in the GitHub repo for my class notes, which actually leads to my first point:
I use Git for my notes right now, and I used to use Mercurial. It's absolutely crucial to use some kind of version control for your notes to have a backup on a remote repo (Bitbucket, GitHub, whatever), a history of changes that you can revert if needed, and an easy way to transfer your notes from computer to computer.
Another advantage of using version control is that you can use a branching workflow. When I start a new topic, I create a new branch for the class that the notes are for and merge back into master when I'm finished proofreading. This way, the master branch only ever holds notes that I've finished and can print. For example, here's a portion of the network graph for my notes:
It looks a lot crazier than it actually is because the Git repo was converted from an Hg repo, but it illustrates the general idea that I start a new branch from the latest commit on master for each set of notes I start.
You'll also want to adjust your version control's ignore file (.gitignore, .hgignore, etc.) to exclude compiled PDF's and log files. I've got the following entries in my .gitignore:
This means that all I track with Git are .tex source files and whatever images and other assets I embed into my notes.
TeX users are usually pretty religious about their templates and preambles (see this). For note-taking, you won't need a massive template and preamble, but as you start working, you'll probably find yourself using some packages and commands pretty frequently. Pull those out into a template, and start new notes by copying that template to save yourself the trouble of re-typing your preamble every time.
Here's my template file, which grew pretty organically after 2 semesters of note-taking:
\documentclass[11pt]{article} \usepackage{amsmath, amssymb, amsthm} \usepackage[retainorgcmds]{IEEEtrantools} \usepackage[pdftex]{graphicx} \usepackage{tikz} \usepackage{circuitikz} \usetikzlibrary{intersections} \usepackage{fancyhdr} %Listings stuff \usepackage{listings} \usepackage{lstautogobble} \usepackage{color} \definecolor{gray}{rgb}{0.5,0.5,0.5} \lstset{ basicstyle={\small\ttfamily}, tabsize=3, numbers=left, numbersep=5pt, numberstyle=\tiny\color{gray}, stepnumber=2, breaklines=true, boxpos=t } %Format stuff \pagestyle{fancy} \headheight 35pt %Header info \chead{\Large \textbf{Title}} \lhead{} \rhead{} \begin{document} \section{} % \begin{center} % \begin{tikzpicture} % [scale=3,line cap=round, % %Styles % axes/.style=, % important line/.style={very thick}, % information text/.style={rounded corners,fill=red!10,inner sep=1ex}, % dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1} % ] % % %Colors % \colorlet{anglecolor}{green!50!black} %angle arcs/lines % % %The graphic % \end{tikzpicture} % \end{center} % \begin{figure}[htb] % \centering % \includegraphics[width=0.8\textwidth]{filename.eps} % \caption{Caption.} % \label{fig:figure} % \end{figure} % \def\enotesize{\normalsize} % \theendnotes \end{document}
The packages I include in my preamble are:
amsmath, amssymb, amsthm: For math symbols and notation.
IEEEtrantools: This package has the IEEEeqnarray environment, which is absolutely crucial for proofs and long series of equations.
graphicx: For embedding images and figures in documents, like scans from a textbook.
TikZ: For creating vector graphics with code. More on this later.
listings, lstautogobble: For formatting code. lstautogobble makes tabs in listings blocks relative to the first line so you can preserve the formatting of your TeX source files.
I've also got some commented code at the bottom of the template for things that I use somewhat frequently but can't be bothered to remember every time - my TikZ template for figures, and some boilerplate code for embedding figures and images with graphicx.
TikZ is great for relatively simple figures because it generates vector graphics that scale perfectly and the figure is defined in code that you can track changes to with version control. You can do some pretty complex stuff with TikZ (see here), but if you're just working on notes, it's probably best to keep things simple.
For example, here's a figure I created in TikZ to illustrate Dijkstra's algorithm, and the code for it:
\begin{tikzpicture} [scale=1.5,line cap=round, %Styles main node/.style={circle,fill=blue!20,draw} ] %The graphic \filldraw[dashed,fill=orange!20] (0, 0) circle (1.2cm); \node[circle,fill=green!20,draw] (s) at (0, 0) {$s$}; \node[main node] (1) at (0, 1) {$1$}; \node[main node] (2) at (2, 2) {$2$}; \node[main node] (3) at (1, 1) {$3$}; \node[main node] (4) at (-.5, -.5) {$4$}; \node[main node] (5) at (0, 2) {$5$}; \path[thick,->] (s) edge (1) edge (4) edge (3); \path[thick,->] (1) edge (5); \path[thick,->] (3) edge (2); \end{tikzpicture}
For the small stuff, I like to use TikZ because I can get a better figure in less time than composing something in Photoshop or Illustrator, and the way TikZ figures are defined in code means that I can make very precise, measured changes that would be a pain to do in a WSIWYG editor.
For more complex figures that would take too long to create with TikZ, I'll usually just scan a figure from my textbook and include it in the document with graphicx.
That's a high-level description of how I use LaTeX for note-taking at school. If you're taking STEM classes and want to learn or already know how to use LaTeX, I'd highly recommend transcribing your handwritten notes. You'll become more familiar with the material from repetition, get some practice with TeX, and end up with beautifully formatted notes that you'll actually be able to read and understand when you're cramming at the end of a semester.