LaTeX

Technical Typesetting in LaTeX

Donald Knuth developed TeX (pronounced “tech”, with the “ch” as in the Scottish “loch”) in the 1970s to enable mathematicians, computer scientists, and scientists to produce beautiful documents that include equations. LaTeX is a popular extension to TeX that provides a higher-level user interface, allowing authors to focus more on the content of the document and less on formatting nitty gritty. TeX and LaTeX are free and there are implementations you can download to run TeX/LaTeX on essentially all computing platforms.

Besides the clean output, an advantage of LaTeX is the seamless way you incorporate mathematics in the text, without leaving your editor. Here are two examples:

In the second one, we have defined a new command (\pdd) to reduce the amount of typing necessary to produce a second partial derivative. It takes two arguments: the variable being differentiated and the quantity varying. This ability to define your own commands gives LaTeX great power and flexibility.

Getting TeX

The first step is to identify a system that already has TeX installed, or to download and install it yourself. Fortunately, TeX is open source and free, as are many utilities to support creating and editing TeX documents. You typically need administrator access of the computer if you want to install TeX. I recommend using the latest TexLive installation, which you can find at www.tug.org/texlive/.

If you are installing on a Macintosh, I strongly recommend the www.tug.org/mactex/ distribution, which packages TeXLive for Mac OS X. It includes a couple of helpful editing environments, including TeXShop and TeXWorks, and a small app LaTeXiT that you can use to create equations for presentations.

On Ubuntu (and other Linux flavors), you can use the package manager to install LaTeX via sudo apt-get install texlive, but I don’t recommend this route: the package manager is years behind and you’re better off downloading and installing straight from source.

On Windows, MikTeX is the most popular free implementation of TeX. Try TeXnicCenter for editing and compiling TeX documents. Both are free.

If you are used to word processing with a WYSIWYG editor like Microsoft Word, you may expect that an application like TeXShop is all you’ll need to install. This won’t work, because programs like TeXShop call an installed (La)TeX distribution (such as TeXLive), so be sure that you install the whole thing.

Testing Your Distribution

To test your TeX distribution, create a small textfile with the following content:

Save it with the name test.tex in a directory you know. If you are using an integrated environment, try typesetting the document (there should be an obvious menu command). If you’re comfortable with the command line, head to the appropriate directory and type

pdflatex test.tex

You should get a message indicating success and the creation of test.pdf, which you can open in a PDF viewer (if the IDE doesn't open it automatically). If that works, you’re ready to start using/learning TeX.

Resources

There are tons of very fine resources for learning LaTeX. Initially, the learning curve can be quite steep; lean on a friend who already knows! Also consider checking out some of these:

If you would like to use LaTeX to prepare a presentation (as in, you are looking for a TeX alternative to PowerPoint), I recommend looking into the beamer package, which is installed automatically by recent versions of TeXLive.

Gotchas

To type single and double quotation marks, use the back-quote key (`) for left marks, and the regular apostrophe (') for right marks. Use two of each (`` and '') for double quotation marks.

Use a tilde (~) to type a non-breaking space, especially to prevent a number from being separated from its unit: 3~mm . Better yet, take a look at the siunitx package.

Use \emph{some text} to emphasize a portion of text. It will be set in italics.

To set an equation inline with the text, surround the equation with single dollar signs or escaped parentheses: $ E=mc^{2} $ or \( E = mc^{2} \). I think the dollar sign form is more common, but the escaped parentheses form is probably superior because the start and stop characters are distinct, which makes searching for equations to modify easier with grep.

A Sample Paper

\documentclass[11pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{fourier} % choices here include times, palatino, newcent, bookman, among others
\date{2 September 2010} % if you comment this line out, LaTeX will print today's date
\author{Your Name} % No, I mean *your* name!
\title{Type Your Title Here} % Make the title interesting, please.
\begin{document}
\maketitle % this causes the title, author, and date to be printed at the top of the first page
% Start writing your paper here
As a walk through the forest was taking place on the part of Mary,
part owner of a little lamb possessed of a snow-white fleece and
a character confused about her storybook identity, a jump on the part
of a wolf said to be \emph{big} and \textbf{bad} took place, resulting
in fright occurring to Mary. The exclamation, ``Holy crud monkey!'' was
uttered.\footnote{Her exclamation was recorded by said wolf's
personal dictation device, available at amazon.com.}
With an opening like that, surely the rest of this essay is destined
for great things. Note that the blank line breaks the paragraph. When
you want to put in some math in line, just type a dollar sign and get
on with it: $ E = mc^2 $. If you want it to be set off as its own
unnumbered equation, then you can either use
\[
a^2 + b^2 = c^2
\]
or
\begin{equation*}
a^2 + b^2 = c^2
\end{equation*}
I recommend the latter, because it's a bit easier to switch to a
numbered equation, which would look like this:
\begin{equation}
a^2 + b^2 = c^2
\label{eq:PythagoreanTheorem}
\end{equation}
Later, if you want to refer to this equation, you just type something
like, ``As seen in Eq.~(\ref{eq:PythagoreanTheorem}), the alphabet has
more uses than in just spelling words.'' Note that the tilde means a
non-breaking space.
\end{document}

If you run this document through pdflatex, here’s what you should get: test.pdf.