## Chromatic Homotopy II or how I learned to stop worrying and love LaTeXing in Real Time February 25, 2010

Posted by Chris Schommer-Pries in blog triumphalism, Latex, liveblogging.
Tags:

I am currently taking course notes for Jacob Lurie’s class on Chromatic Stable Homotopy in real time in Latex. This is not the first time I have taken course notes live and in tex, and when people see it happening they often ask me about it.

I wanted to write an update about Jacob Lurie’s class on Chromatic Stable Homotopy and mention some of exciting and beautiful things happening in that course, but as I started writing this post I found that it was morphing into a sort advice post on how to LaTeX in real time. Since there is obvious appeal, I’ve decided to run with it and collect all the advice, tips, and tricks on how to LaTeX in real time that I’ve gathered from the wild.

Before I started live-TeXing, I was very skeptical. I thought there was no way that I would be able to latex a document in real time. Totally Impossible. Fortunately I was wrong. And even more fortunately I had the pleasure of taking a couple of courses alongside Anton Geraschenko. I saw him take his notes in latex. In Real Time. And I benefited from having his notes available just days after the lecture finished (and more often just a few minutes after). I saw that it was possible and that it was useful.

One of the things that Anton said that got me to try taking notes in LaTeX was that you actually have more time when you latex than when you take notes on paper. What!!?? More time? That can’t possibly be true.

Yes. It’s true. You have more time. It is simple really. Think about how much time it takes you to write out letters with a pen on a piece of paper. Now think about the same thing on a keyboard. You just push a key. It’s much faster to push a key. You gain a couple milliseconds. After writing a few words or sentences, you gain actual seconds. I often find while LaTeXing that I can write down what the speaker is saying (jokes and whatnot), even when the speaker doesn’t write it down themselves. I’ve never been able to do this taking notes with pen and paper.

Another big advantage is the finished product. First it looks great. There is no denying that. This shouldn’t be underestimated. It means my notes are something that I am proud of that I am happy to share with people (this is not always the case for sloppy partial hand written notes). I also find it great to have my notes of talks and lectures on my computer in an electronic form. This means that I can share my notes without the risk of loss or destruction. This also means they are searchable. “Wait. This sounds familiar. Wasn’t there a talk by so-and-so, whose name I forgot, about this subject a couple years back :: searches computer :: why yes, and here are my notes!”. Need I say more?

There are some disadvantages, of course. The biggest being the lack of ability to draw pictures. One solution that I’ve used and liked was to bring a digital camera to lecture and take snap shots. Then I can later include them into my latex file. That’s my favorite solution, but I’d like to hear what others have tried. Anyway, here are some things I’ve learned that have made my live-TeXing a happy reality.

## Tips and Tricks:

The golden rule of LaTeXing in Real Time is: Plan Ahead.

Basically all the tips I have are different manifestations of this same basic principle.

### Skip the Scenic Route, Take a Shortcut

For me the most important thing I need to LaTeX in real time (besides a computer) is a good collection of latex macros. One of the beautiful things about latex, as opposed to any old word processor, is that you can pre-program your own commands. With sufficient planning ahead, this can really speed up real time note taking.

There are several kinds of macros that I find myself using frequently.

Alphabets. It is very helpful to have shortcuts for useful fonts. Most people probably do this already, at least to some extent. Why waste time time typing out \mathbb{R} over and over when a short command like \R is so much faster? But which letters will you need? You can try to guess in advance, but what if the speaker uses a different letter? Also which fonts? What if out of the blue the speaker starts talking about moduli stacks and you need to write: $\mathcal{M}$
(this happened yesterday). You could write out the whole thing out: \mathcal{M}
But you can save your self a lot of time by having a shortcut for this too ( I like \cM).

What I do is I go through the entire alphabet and pre-load shortcuts for all of these fonts for every letter. That way whenever I want to write

$\mathfrak{g} \to \mathsf{A} \to \mathbb{R} \to \mathcal{M}$

I just need to write “\g \to \sA \to \R \to \cM”. I include these alphabet shortcuts in all documents that I am planing to live-TeX. That way I consistently have these shortcuts at my fingertips and I get used to using them.

Context Specific Macros In addition to alphabets I also keep a variety of other command shortcuts that I think I might need. This varies from subject to subject, and since I don’t always know what I will need I like to keep a pretty long list just in case. These range over all sorts of things. Many of them are math operator commands. I might include something like
 \DeclareMathOperator{\colim}{colim}
so that I have a “\colim” math operator to match “\lim” (btw, does anyone know how to get it to place math text under it correctly in an enquation environment? I want it to behave exactly like \lim). I try to do this for all the commands I think I might use. So for example in a topology course I will try to include commands like \holim, \hocolim, \map, \tot, etc. and in a class on algebraic geometry I will include things like \spec, \proj, \spf, and \hom.

I also add to this list as I go along. I found in the begining of Jacob’s class that I was constantly writing “\C \P^n” for projective space, so I added a command to my preamble so that now I just have to write “\CP^n”. This is a minor improvement, but if later I decide that I don’t like how the projective spaces look I can change them uniformly.

Another thing which falls under this category are the names of categories. These come up so often I keep a separate list in my preamble just for categories. This way I can also make sure that they consistently look the same. I like to use the \mathsf font for category names.

Complicated Commands/Formatting These are things that I would put in the preamble of an ordinary Latex document, and fall into two camps. The first includes all the environments that I think I will want. Things like theorems, lemmas, corollaries, proofs, claims, remarks, etc.. These are the usual sort of fare for a latex document. Other things that I include are more complicated commands. Some of which I’ve written which take a certain numbers of arguments (I don’t seem to have an example handy), and some which are just plain useful. For example whenever I need to draw a simplicial complex I always get stuck with the triple and quadruple arrows. So I wrote the following command,
\DeclareMathOperator{\righttriplearrows} {{\; \tikz{ \foreach \y in {0, 0.1, 0.2} { \draw [-stealth] (0, \y) -- +(0.5, 0);}} \; }} 
which allows my to just write “\righttriplearrows” in a math equation. I also include a few more permutations of this, since I might want four arrows or I might want left arrows.

Usually what happens is that I’m taking notes and then BAM! I need a command that I don’t have. I loose. But later I go write it and add it to my preamble so that next time I have it ready. I win. This way I amass a pretty nice collection of commands. Another win. It also means that it is important to comment well about what your commands are doing and how they are supposed to work.

### Hot, Hot, Hot, Hot Keys!

Having a good collection of macros at your disposal is probably the most important thing you can do to prepare for live-TeXing, but it is not the only thing. There are an number of other time savers which I find myself using all the time.

One of them, which I learned from Anton, is that it is important to learn how latex parses things. This can save you a lot of time. One of the easiest is the fractions command. Suppose that I want to write out the expression:

$\frac 1 2 \sin x$

I could do this by hand using curly-braces “\frac{1}{2} \sin x”. But it is four-characters faster to write
\frac 1 2 \sin x
Not only that, but the four characters are curly braces and so by not writing them you avoid some elaborate (i.e. slow) shift-key keyboard gymnastics.

A similar thing is to learn about standard keyboard shortcuts. You want to use your mouse as little as possible because it is slow and wastes time. There are keyboard short cuts for switching between apps ( command-tab on a Mac) and between windows in an open app (command- on a Mac). Memorize these.

There are also often some built in commands which allow you to highlight things quickly. This is useful in conjunction with what I am about to describe below, and is important because you might be tempted to use a mouse to highlight things. Resist the temptation. I use a Mac so I know Mac keyboard commands. The ones I use the most are the shift-arrow commands and the shift-command-arrow commands. These let me highlight text at the cursor and highlight an entire line of text, respectively. (If you have a Mac, try ’em out!)

Why would I want to highlight text? The answer it that I might want to write my own Hot-key Macros. This is the second most useful thing to have for Live-TeXing, after having a good collection of LaTeX macros. Many Latex editors allow you to write your own program macros and to link these up to keyboard short cuts/hot keys.

I use TeXShop, so let me explain what I mean for that program. One of the great things about this program is that it has the “macro editor” (in the Macro menu). This allows you to write macros which you can use to manipulate text. It also has a bunch of built in macros. Even better, it lets you assign these to certain hot-key combinations. So for example suppose that I want to start a new equation. This is one of the standard Marcos, so I just assign it a hot key (ctrl-command-K, in this case). Now when I am LaTeXing in real time and I want to start an equation I just type this hot-key sequence and this text automatically appears:
 \begin{equation*}

 

\end{equation*} 
As you see, I decide to link the hot key to the unnumbered equation, but could have done whatever I want. The default Macro in TexShop just adds this text, but I like to do something more fancy. Sometimes I start writing math text inline before I know that I want it to be a nicely formated equation. So I’ve altered the default Macro so that if there is some highlighted text then this gets put inside the equation environment.

For example I could type
 \spf R[[t]] \to S 
Then type command-shift-leftarrow to highlight it and then ctrl-command-K and I get
 \begin{equation*} \spf R[[t]] \to S \end{equation*} 
This helps speed up the Live-TeXing process. There is a similar default command that takes some highlighted text and puts it into a begin/end environment. I set this to a hot-key. That way I just type out “lemma” highlight it with a key-board short cut (shift-command-arrow), press another hot-key sequence (ctrl-command-B) and I get the code,
 \begin{lemma} \end{lemma} 
with the cursor conveniently placed inside. I just continue writing.

The real power of this comes from the fact that you can write your own commands. For example I wrote a macro which is similar to the previous ones but it spits out the text:
 \begin{center} \begin{tikzpicture} \node (LT) at (0, 1.5) {}; \node (LB) at (0, 0) {$$}; \node (RT) at (2, 1.5) {$$}; \node (RB) at (2, 0) {$$}; \draw [->] (LT) -- node [left] {$$} (LB); \draw [right hook->] (LT) -- node [above] {$$} (RT); \draw [->] (RT) -- node [right] {$$} (RB); \draw [->] (LB) -- node [below] {} (RB); %\node at (0.5, 1) {$\ulcorner$}; %\node at (1.5, 0.5) {$\lrcorner$}; \end{tikzpicture} \end{center} 
What does this do? It uses TikZ to make a square-shaped commutative diagram and puts my cursor right at the correct spot. I just go down the line, adding the text for the four corners of the diagram. I make a couple of quick tweaks and presto! I have a commutative diagram that I have made in latex in Real Time. I’m sure you can imagine countless other possibilities.

Finally, I want to mention something that helps me but is not essential: organize your files. This is more important in a large document like the lecture notes for an entire semester’s worth of classes (or a thesis for those unfortunate souls who are graduating this Spring). Each time you compile a large document it takes time. As the document gets longer, the compilation gets slower. If you organize your document well you can “turn off” parts of you document while you take notes to speed up the compiling process.

I usually have a single master document which then includes separate files where I have the notes. Then I just comment out the part which includes the old notes and un-comment them back after I’m done Live-TeXing. I also keep a large separate preamble file which has all of the commands I mentioned above.

So that’s it. These are my best tips and tricks. I’d love to hear about anyone else’s experiences and tips or suggestions, problems they’ve run into and solutions. Also to get people started, I’ve decided to make my LaTeX files public. They are available at my lecture note website.

1. Sam Lichtenstein - February 25, 2010

Regarding text under colim, I think the right thing to do is (in your macro definition) wrap the operator in a \mathop{ } environment. (So you might have a two-stage macro definition; first define the operator, say, as \DeclareMathOperator{\mycolim}{colim} and then
make a macro \newcommand{\colim}{\mathop{\mycolim}}

In fact, I think one can iterate mathop’s to get multiple lines of text underneath displayed sums, limits, etc., which can look nicer when summing over complicated index sets, or example. But I sort of doubt this is the “right” way to do that; does anyone know if there’s a better way?

2. Maia - February 25, 2010

Some nice tips… one tiny thing I noticed, for \frac, (and others), you don’t even need the spaces, ie. \frac12 gets you the same as \frac 1 2.

3. Yossi Farjoun - February 25, 2010

“btw, does anyone know how to get it to place math text under it correctly in an enquation environment? I want it to behave exactly like \lim”

use the stared version of DeclareMathOperator.

Yossi

4. Theo - February 25, 2010

This is a great post.

A few comments. First, I think that to get \colim to behave just like \lim, you use \DeclareMathOperator* instead of \DeclareMathOperator

Second, if you’re really trying to save keystrokes, \frac12 gives the same result as \frac 1 2. I often write things like \frac1{a+b}, or whatever, if that’s what I need. Similarly, \C \P^n is the same as \C\P^n. I agree that \CP^n is better, though: you don’t have to keep going up and down on the shift key as much.

Third, hot key macros sound awesome. Somehow I never knew about them, but now I’m going to implement all of them.

As for keeping documents organized, I like to have individual TeX documents for each day of the class, and each one just imports my preamble for the class. I generally always have the preamble in the recent-files menu, and so if I ever need a new math operator, I can add it pretty quickly (I keep my DeclareMathOperator list alphabetized so that I can see whether I’ve declared the operator before). Actually, what I do is I have a document called “today.tex”, which lives in my recent-files menu. As I sit down to start to type, before ever clicking “LaTeX” I command-shift-s and type today’s date in the file name. today.tex then stays as it is: minimal, with the preamble, etc., pre-loaded.

Finally, I like to post my notes essentially immediately (it’s not like I’m going to take any time to edit them soon anyway). So then the trick is to write a simple script that I can issue form the command line. My script does the following. I have a master TeX document that inputs the preamble and each day’s notes and has the instructions for the title, table of contents, etc. The script pdfLaTeXs this document, runs BibTeX and makeindex, pdfLaTeXs a few more times, uploads the pdf to math.berkeley.edu, tars the entire folder, and uploads that too. Now that Evans has reliable internet in the ground floor, this whole process takes under 60 seconds, and so the files post before I’ve even left the room.

5. Robin Houston - February 25, 2010

Since you’re using a Mac, it’s worth mentioning that the TextMate text editor has both excellent LaTeX support and a really nice “snippets” system that’s perfect for defining the sort of shortcuts you’re talking about here.

Snippets can be activated by hot key combinations, but the really cool thing is the “tab trigger”. For example, I’ve got it so that typing pf and then pressing tab will insert

\begin{proof}

\end{proof}

leaving the cursor between the tags. You can have multiple hot-spots within a snippet, and press tab to jump between them, which would work really well for your square-shaped commutative diagram example.

It would work really well for what you’re doing, I think.

6. Daniel - February 25, 2010

Hi Chris,

(1) To compile just some parts of the document you can use the command \includeonly`; you make a master file and call individual files from within — works like a charm: http://en.wikibooks.org/wiki/TeX/includeonly

(2) I know you said you use TeXshop… but, IMHO (and YMMV in this case), i think that the combination of Emacs + AucTeX is much more robust. To do this in the Mac you’ll need the following,

(2a) Aquamacs (it already comes bundled with AucTeX), http://aquamacs.org/

(2b) AucTeX, http://www.gnu.org/software/auctex/

(2c) TeXLive: the MacTeX distribution of TeXlive is the recommended one: http://www.tug.org/mactex/2009/

And, once we’re at it…

(3) LaTeX-make: http://www.ctan.org/tex-archive/support/latex-make/

I’m sure this has the potential to really speed up your current setup. ;-)

7. Chris Schommer-Pries - February 25, 2010

Thanks for the advice on DeclareMathOperator* and on the \mathop. Both seem to do the trick nicely. The first seems like the right thing to put in my preamble, but the \mathop command is going to be useful for those complicated limits and sums. Somehow I never learned that command.

8. skewline - February 25, 2010

I think it helps if you have an idea what letters/symbols are going to come up. I haven’t heard a talk with \CP in the last decade and maybe longer, but I see \mathfrak with capital letters all the time (e.g., the M comes in handy for the stack of prestable curves)..
I learned some live-TeXing from Stefano (here and here) but I never got fast at it.

I am also not motivated enough: I usually can (hand)write down what the speaker says but doesn’t write, and most people find the output readable.

9. Chris Schommer-Pries - February 25, 2010


I found one software that allow you to redefine this, and if you bought it (which I didn’t, it is about 10 bucks) you can safe it as a Language/Keyboard layout type “latex”, and you can switch from the “English(US)” layout to “latex” when you type, and everything is customized, — just as when you switch to a french keyboard in your system, “QWERTY” on your keyboard becomes “AZERTY”.

24. Sam Lichtenstein - February 28, 2010

I’m really curious what people think about Andrew Stacey’s and Mike Hall’s differing philosophies about .tex files. Recently I substituted as the live-tex’er for one lecture of a seminar (the person who usually live-tex’ed was away), and I had a lot of trouble even getting the universal notes file to compile on my machine. (I think this was more a font/packages issue than a macro issue, though.) So I just made a new file with the notes for that day, using my standard header file and macros. Later I had to re-integrate those notes into the main file, which meant removing or changing all the macros, which was a real pain! (Surely someone capable of writing a shell script could have done this with one magical line of perl or something, but that sort of thing is beyond me.)

Anyhow, this experience made me buy into the idea that macros should be used sparingly if there is any chance that another human being will have to read your latex “code” at some point. On the other hand, Andrew Stacey’s point about doing things to the opposite extreme, in a fully “object oriented” way, has a certain ring of philosophical truth about it. It just strikes me as impractical. Does anyone have an opinion one way or the other as to which philosophy is superior. (What about for collaborating with 1 or 2 coauthors on an actual paper, versus for rapidly live-texing lecture notes? Are the considerations different in this case?)

25. Chris Schommer-Pries - February 28, 2010

I’m torn on the issue. On the one hand I think that the object oriented approach is a better philosophical approach to document production. It makes the document more consistent and easier to update and maintain. I also think that if it is done well, it can make the source file much more readable to outsiders.

On the other hand, I once had a similar experience to comment #23. My job was to gather and collect abstracts for an Olberwolfach report. I was fairly inexperienced at the time, and if I did it over again I would have provided people with a template and required that they don’t define any new macros. Instead I just got the files with each persons random macros in it. I had a long and difficult experience trying to merge these into something that would actually compile. So I am sympathetic to Mike Hall’s point of view.

I think for live-TeXing it is justifiable to do whatever makes it easier for the author. For me that means lots of macros and hot-key commands.

26. Mike Hall - March 2, 2010

@Sam Lichenstein

There’s an option for abbreviation expansion that makes the case of the expansion “match” the case of the abbreviation, which I think is what you’re running into. Unfortunately I don’t remember what the variable is that you would need to change. In this case it seems like the easiest workaround would be to make the abbreviation “\gal” (lowercase ‘g’).

27. Andrew Stacey - March 2, 2010

Curiously, I’ve just read a section of the Camel book which touches on this. I quote: “We’ve all fallen into the trap of using cut-and-paste when we should have chosen to define a higher-level abstraction, if only just a loop or subroutine.” and onwards.

The point is that hacking something together is fine if you only need to do it once. As soon as you start needing to use it again, it’s best to abstract it.

I think that Chris has got it about right except for the final sentence in his second paragraph: to me, the experience described there supports my view, not Mike’s!

I’m not a raving OO hardliner. I tend to go with whatever makes my life easiest. I tend to make my tex files OO-like now because I find that that works best. But I can see that for live-tex’ing, speed is of the essence and other considerations come into play. But when you have the time, it’s worth doing it elegantly because, in the end, that will save you time.

Incidentally, TeX is quite happy with scoping so all those redefinitions of macros can be avoided quite simply. Consider two files, master.tex and slave.tex.

master.tex is:

\documentclass{article}

\def\hello{hello}

\begin{document}

\hello
\input{slave}
\hello

\end{document}

slave.tex is:

\def\hello{greetings}
\hello

Result:

hello greetings greetings

Now put braces around the input line. Result:

hello greetings hello

Simple!

(Okay, so long as no-one used \gdef …)

28. Chris Aldrich - March 16, 2010

Here’s one to throw everyone for a nice curve… and to potentially add some additional richness and speed things up considerably for the TeX newbies.

For the last year and a half, I’ve been using the Pulse pen from Livescribe.com. It’s a brilliant product, particularly for advanced level mathematics lectures and discussions. It simultaneously records everything written down using an infrared “camera” and special (inexpensive) paper as well as everything that was said with an audio recorder! It links the two together in real-time so that one can go back and “rewatch” past lectures for review or to add in additional written notes after the fact. You can actually watch the notes being “rewritten” out in real time as you hear exactly what was being said as they were originally being written. A relatively inexpensive $175 gets you a 4GB pen, a few ink refills, a starter notebook, a sync cradle, a pair of stereo headphones/microphones, and the continuously improving software to go with it. In the last couple of months, it’s been so popular in my Galois Theory class, that now at least 4 others have purchased them. The accompanying software and online site allows sharing lecture notes with others (via email, blog, facebook, etc.), as well as exporting the handwritten file almost immediately as a .pdf file or exporting the audio of the lecture as .ACC, .MP4, and other popular audio files. More relevant to the thread above, there’s a$29 plug-in for this software that does handwriting to type conversion, so that after a quick processing, I’ve got a typewritten version of my notes which I can cut and paste into my TeX editor (I prefer WinEdt) tweak for a few minutes and voila… perfectly typeset lecture notes, and often without the need for as many/any custom macros or definitions.

It also solves the issues of drawing diagrams into notes and gives the added benefit of having an audio recording of the lecture for later consultation. Even with poor handwriting, the software has a search function built into it as well so one can quickly find things even in 100’s of pages of notes and then immediately both see/hear what was originally said.

The livescribe.com website has some excellent short videos showing the features of the pen in action. I couldn’t recommend it more highly, particularly for math students.

Incidentally the pen also has an open SDK for developers to dig into the guts for their own further customization. It’s also not too difficult to strip out the flash movie files their website creates natively and convert them into videopodcasting format for later viewing/sharing as well.

29. Chris Schommer-Pries - March 17, 2010

Do you have to get the speaker to wear a microphone? I’m skeptical about how well it could record audio, but I don’t really have much experience with these things…

30. Chris Aldrich - March 17, 2010

@Chris, No the lecturer doesn’t even have to know you’re taping it. There’s a great microphone built into the pen itself that does really well in most all lecture settings from small rooms to large lecture halls. If you’re sitting in the back of a 400 person lecture hall, I’d recommend plugging the headphones into the pen and using the two mics built into the earbuds (you don’t need to have the headphones in your ears while recording) and set the recording quality to the highest setting (of three). I’ve yet to meet a lecture situation that I haven’t been able to get great results with. They’re even good with getting quietly asked questions by the audience.

Additionally the pen has some fairly advanced signal processing built into it as during playback, you can listen to the audio at 2x, 4x, 8x + speeds and the audio is resampled so the speaker talks faster but doesn’t sound like Mickey Mouse.

31. My adventure in live TeXing and some notes « Climbing Mount Bourbaki - July 7, 2010

[…] is pretty and computer files don’t (usually) vanish.  I recommend it to others, as well as this post of Chris […]

32. Recovery of a technical post | M and D blog - July 29, 2010

[…] have not used $LaTeX$ in this way, but someone else has. The linked article has a treasure trove of good advice on how to make your creation of LaTeX […]

33. Stuart Ambler - October 15, 2011

Chris, Mike, Andrew, thanks. I used to write software before coming to math grad school. Having one’s own private language, “o-o” or not, seems like something to be avoided if possible, though I’m impressed with people who are able to TeX live. Even without that, when I first saw how people used LaTex, it struck me as a write-only language. At one point I thought I’d use my adviser’s include file(s) for my thesis, which I thought could help with compatibility, but it was easier to write my own, though I’ve tried to keep it small. The problem, I think, is that LaTeX doesn’t understand math; it’s all about typesetting. I’ve been tempted to help remedy that, but it surely would be another career. Perhaps if Andrew’s specific idea of a more meaningful language for mathematicians to use gained adherents, or if people got together to define something we could all agree on? … Now back to my thesis.

Sorry comments are closed for this entry