Monthly Archives: June 2011

Formatting and math style in LaTeX

LaTeX gives almost infinite control over formatting, and it is possible to spend hours making small adjustments to a document, forcing every character and every pixel to be in an optimal location.

A much easier solution is to trust LaTeX to format documents. Though it might not look exactly as you might envision, LaTeX’s standard document classes do a surprisingly good job at formatting. Of course, some manual adjustments might still be in order; you might want to change the default indent size (e.g. with \parindent=0in), force some space between paragraph breaks (e.g. with \parskip=5px), or change the margins (e.g. with the geometry package or using \usepackage{fullpage}). The general structure of a document, however, is best left up to LaTeX’s default styles.

LaTeX can fairly easily create a title heading. Here is an example:

\title{All of Mathematics}
\author{C.F. Gauss}
      This paper explains all of mathematics, in alphabetical order.

The final \maketitle command tells LaTeX to display the title, author, email, date, and abstract information in the style defined by your documentclass.

LaTeX can also handle section headings and section numbering. To start a new section, simply say \section{My new section}. Similarly, you can define new subsections and subsubsections with \subsection{My subsection} and \subsubsection{A subsubsection}. These sections (and subsections and subsubsections) are automatically numbered sequentially. (To disable automatic numbering in LaTeX, add an asterisk, i.e. \section*{Unnumbered section}.)

LaTeX is also often used with mathematical expressions, for which there are also some stylistic points to keep in mind. Firstly, it is a good idea to use displayed equations. These can be used for long or complicated expressions to make them easier to read. When surrounded by text, they also serve to break up long paragraphs into more manageable chunks. Even simple equations can be displayed to make them stand out, such as

\displaystyle  e^{i\pi}+1=0.

Something to keep in mind is that all punctuation following a displayed equation should be placed in math mode, immediately following the equation.

Make it a habit to use math mode for all mathematical symbols, regardless of length. For example, it looks ugly to say “Consider a function f with f'(x) = x+5“; instead, say “Consider a function f with f'(x) = x+5“. Doing this allows you to clearly differentiate between math symbols and text, and also eliminates confusion resulting from math mode letters looking different from text mode letters.

LaTeX also provides a number of math operators for easy formatting. For example, log x looks ugly, while \log x looks much better. It is easy to define new operators as well. For example, if you want to use “disc” to denote a discriminant, then you can use \def\disc{\operatorname{disc}} or \DeclareMathOperator{\disc}{disc} to define the \disc operator. This allows you to type \disc K to get \mathrm{disc}\, K.

You can also use expanding delimiters in large math expressions. For example, compare

\displaystyle  P(\frac1x) \qquad P\left(\frac1x\right).

The symbol on the right is achieved by writing $P\left(\frac{1}{x}\right)$. All other delimiters expand as well, via commands like \left[, \left\{, \left|.

For clarity, inline fractions in text can be typeset horizontally. That is, in a typical font size, the fraction 79/128 is easier to read than the fraction \frac{79}{128}. Of course, there are plenty of cases when you want to write fractions vertically, such as when they are part of a larger expression (e.g. \frac12 + \frac13 = \frac56).

Long equations can be broken up. It’s no good when an equation is too long and runs off the page, and it’s ugly to see an equation reach into the margin. Instead, break the equation up at binary operators and equals signs, such as + or =. Long calculations can be broken up at each equals sign, such as

\displaystyle  \begin{array}{rcl}  K_m(s) &=& \frac{1}{m+1} \frac{1}{1- e^{it}} \left( \frac{1 - e^{-i(m+1)s}}{1 - e^{-is}} - e^{is} \frac{1 - e^{i(m+1)s}}{1 - e^{is}}\right) \\ &=& \frac1{m+1} \frac1{e^{is/2} (e^{-is/2} - e^{is/2})} 	\left( 		\frac{1 - e^{-i(m+1)s}}{e^{-is/2} (e^{is/2} - e^{-is/2})} 		-\frac{e^{is} (1 - e^{i(m+1)s})}{e^{is/2} (e^{-is/2} - e^{is/2})} 	\right) \\ &=& \frac1{m+1} \frac1{e^{-is/2} - e^{is/2}} 	\left( 		\frac{1 - e^{-i(m+1)s}}{e^{is/2} - e^{-is/2}} 		-\frac{1 - e^{i(m+1)s}}{e^{-is/2} - e^{is/2}} 	\right) \\ &=& \frac1{m+1} 	\left( 		\frac{ e^{i(m+1)s} + e^{-i(m+1)s} - 2 }{(e^{is/2} - e^{-is/2})^2} 	\right) \\ &=& \frac1{m+1} 		\frac{ \sin^2 (\frac{m+1}2 s) }{\sin^2 \frac s2}. \end{array}

Similarly, it is a good idea to align lists of equations at equal signs, such as

\displaystyle  \begin{array}{rcl}  \sin\theta &=& y \\ \cos\theta &=& x \\ \tan\theta &=& \frac yx \end{array}

Such an effect can be achieved using a construction like

       \sin\theta &= y \\
       \cos\theta &= x \\
       \tan\theta &= \frac yx.

Integrals need extra space. Compare:

\displaystyle  \int x^2 dx \qquad \int x^2 \, dx.

The second integral separates the dx from the integrand, making the equation more clear. This was typeset using $\int x^2 \, dx$, where the \, serves to add a bit of space.

Technical writing

It is important to remember that even though technical writing aims to communicate ideas precisely and unambiguously, such writing is still ultimately read by human beings and not computers. Readers of technical writing already have to struggle with challenging ideas, and it is up to the writers to make their writing as approachable and clear as possible.

Use words between mathematical symbols. For example, instead of “Consider {A_{mn}}, {n < m}”, use “Consider {A_{mn}} where {n < m}”. This serves to delimit mathematical expressions and avoid confusion.

Consider using words instead of symbols to express simple ideas. For example, instead of “Take {m, n \in \mathbb{Z}}”, consider using “Take integers {m} and {n}”. The goal is to avoid burying the reader in a morass of unnecessary symbols and notation.

Avoid unnecessary symbols and abbreviations. Instead of using {\therefore}, {\forall}, {\exists}, write them out in words! It is easier to read “for every {\epsilon > 0} there exists {\delta > 0} …” than “{\forall \epsilon > 0}, {\exists \delta > 0} …”

Write in complete sentences. Consider replacing each mathematical expression with some filler word, like “blah”. Is each sentence still complete? Still properly punctuated? Using mathematical symbols does not absolve the writer from the rules of grammar. If a sentence ends with a displayed math expression, use a period! For example, we can define

\displaystyle  |x| = \begin{cases} x & x \ge 0 \\ -x & x < 0. \end{cases}

Explain with words. It is often tempting to write pages of formulas and calculations and leave the reader to fend for himself while working through those computations. It is much nicer to the reader, however, to include some running commentary explaining what is being done.

Avoid walls of text. Nobody likes working through a dense argument that is one massive paragraph. Use paragraph breaks to give the reader some space to reflect on what’s been said so far. Use displayed equations to make them more readable, more visible, and simply as a way to break a paragraph into more manageable pieces.

Don’t be afraid to be redundant. It often makes things clearer to say the same thing in both words and symbols. For example, which definition of an open set is easier to read: “Every point {x \in X} has some neighborhood {B_\delta(x)} of radius {\delta > 0} around {x} such that {B_\delta(x) \subset X}” or “For all {x \in X} there exists {\delta > 0} such that {B_\delta(x) \subset X}”? They carry the same content, but in the first, the reader can focus on the concepts presented by the text, while in the other, the reader needs to translate from mathematical symbols into a more humanly parsable form.

Each theorem, lemma, corollary, definition should be self-contained. When scanning through a paper, its confusing to see

Theorem {f(x)} is a continuous but nowhere differentiable function.

Much better is to see “Let {f(x)} be as defined above in Definition 1.3. Then {f(x)} is continuous but nowhere differentiable.” Alternatively,

Theorem Let {f(x) = \sum_{n=0}^\infty a^n \cos(b^n \pi x)} where {b} is a positive odd integer, {0 < a < 1}, and {ab > 1 + \frac32 \pi}. Then {f(x)} is continuous but nowhere differentiable.

Give motivation and talk about the big picture. It is easy to blithely jump from one lemma to the next, giving clear and rigorous proofs of each lemma but losing sight of the reasoning behind those jumps. Before a chain of arguments and ideas, it helps to spend a paragraph talking about the big picture: Where is this argument leading? What’s the goal? Is there some intuitive picture or motivating example? All of this might be extremely clear for the writer, especially if he worked all of the details out on his own; for the reader, however, finding motivation and intuition often requires gaining a deep understanding of the topics under discussion. It only takes a few words to make everything much clearer.

Use clear formatting. Use section headings and appropriately space and align equations. This helps to communicate the structure of a paper. This is the subject of my next post.

For more on technical writing, see Knuth’s notes on mathematical writing.

Too much typing

I spend a lot of time typing mathematics in LaTeX. Here’s a summary of everything that I typed for my math courses this quarter:

Algebraic number theory:
Notes: 22 pages
Homework: 49 pages

Functional analysis:
Notes: 60 pages
Homework: 42 pages

Representation theory:
Notes: 42 pages
Homework: 15 pages

That’s a total of 230 pages over ten weeks. I hope my computer is not getting too tired.

I also typed papers for my writing class (PWR) in LaTeX. That comprised a total of approximately 12 double-spaced pages. This means that for every page written for my writing class, I wrote approximately 19 pages of math.

I need more work?

I spent all of spring quarter feeling somewhat overworked. It felt as if I was trying to juggle too many things: three math classes, another class that was a waste of time, SUMO events, ARML coaching, and everything else that happened over the quarter: launching rockets, finishing up SMT stuff, various miscellaneous meetings… I didn’t have time to do anything as well as I would like, and work was often deferred until it become no longer relevant.

Now that the quarter is over, I suddenly have a lot more free time. There are no more constant deadlines, and I can actually look more than a day or two into the future without recoiling in horror at mountains of work. I’m returning to a regular sleep schedule, and everything is good — except for one minor problem. I’ve become accustomed to always having lots to do, and having free time feels rather foreign.

I’m still trying to keep myself busy, of course. My summer to do list is long, longer than what could possibly be finished in one summer. But the lack of firm deadlines makes all of that seem distant, maybe even optional. The clear lesson here is that I need more work.

Surely, I’ll stop feeling this way fairly soon. By the fall, having any work at all will probably feel odious and unpleasant. But for now, I’ll continue to ponder my long to do list, procrastinate on most of it, and wonder why I have so little work.


One day, a few weeks ago, I was working on a representation theory problem set, and at some point, I curled up on a couch in order to take a nap. I dreamed that I was in a forest, holding a harpoon gun, hunting representations. The representations were little LaTeX symbols with legs, \chi_U and \rho(g) and character tables that kept running away into the bushes. I dreamed that I was walking softly through the forest, stalking my prey. I can’t recall if I ended up catching any representations, though I think I woke up from the frustration of watching those representations run away.

Another time, I started to fall asleep in an algebraic number theory class. At the time, fields were being discussed, and as I drifted into sleep, I saw a cow standing by the door at the front of the classroom. The cow appeared to be in a grassy field, and it looked very happy.

I think I should sleep more.


Sorry about not posting for the past few months. I’ve been very busy recently. With the start of the summer, I should be able to post much more frequently.

I have been a coach for the San Francisco Bay Area ARML team for the past two years. Every year, people ask me why I help with ARML, and the answer is always the same: because it’s fun.

I enjoyed my first trip to ARML in 2008, and ARML has gotten better every year. Unlike most contests, ARML is heavily team-based, and as such, it is a great way to meet interesting people. ARML tends to build a sense of community that is lacking from most math events. Over the past few years, I’ve met many students and coaches at ARML, and they are a major reason why I go back to ARML every year.

Another big part of coaching ARML are the practices that we run every spring. It’s always great to see the gathering of people with similar mathematical interests. I believe in teaching math as a way to learn and understand something more thoroughly, and I hope to do more teaching at ARML practices in future years. Doing math is often most enjoyable as a social activity, and I think that our practices fully demonstrate that feature.

Here’s a list of interesting things that happened at ARML, in no particular order:

  • Green sharpies
  • Easy button thieves
  • A disappearing sword
  • Brilliant power round solutions
  • Paper balls and paper airplanes
  • Math!