LaTeX

I use LaTeX for typesetting papers. Aside from being essentially platform independent because it is widely ported, LaTeX is "text editor independent" because it uses plain ASCII text files. This makes collaborating on a LaTeX document possible even if your co-author doesn't know LaTeX and prefers to use WordPerfect, for example. ASCII text files are also likely to remain readable for longer than any proprietary or binary format, and since new releases of LaTeX are extremely infrequent, backwards and forwards compatibility are rarely a problem.

Some things are more difficult to do in LaTeX than in a WYSIWYG word processing program, but for academics its strengths in automatically generating cross references, tables of contents, and citations, and its mathematical typesetting, more than make up for other inconveniences.

Getting Started with LaTeX

LaTeX is very powerful, but you don't need to know much to get started with it. I learned the basics of LaTeX from the short introduction found in "Essential LaTeX" and "Essential Mathematical LaTeX"; MIT has a nice intro page, and here are some useful math symbols. Note that there are now nice, free programs that will compile your latex outside of a Unix shell (the MIT article's sections on Processing/Previewing/Printing Your Document assume you are doing this all on Unix).

Classic reference books are Leslie Lamport's "LaTeX : a document preparation system" and Goossens et al.'s "The LaTeX Companion."

Bibtex

You will want to learn how to use bibtex, which makes it easy to automatically generate a bibliography for a particular paper from a master bibliograpy. If you use Google scholar, there is an option you can set to include a link to the bibtex for the papers it finds -- very handy! But please, clean up the bibtex you download. For example:

And even though a citation is not a noun, and by default I think everyone should use apalike citation style, your most flexible option is to define your own macro that changes "\mylongcite{CLR} states" to either a) "Cormen et al. [1990] states" (use \shortcite) or b) "Cormen et al. [1] states" or c) "[1] states" depending on whether i) the bibliography is apalike, ii) the bibliography uses numbers, or iii) you need to reduce the length of your NSF grant proposal by half a page.

Figures

Another essential that is not covered in many intros is how to include figures. If you use pdflatex, you can easily include a figure that is in pdf format. Add the line \usepackage{graphicx} in the preamble of your .tex file and then you can include figures in the body using e.g.:

\begin{figure*}[hbt]
\centering
\includegraphics[width=3.25in]{picture.pdf}
\caption[short TOC caption]{\em Caption to appear under the figure goes here.}
\label{ReferenceLabelHere}
\end{figure*}

The \em is entirely optional and can be omitted -- I like to make my captions italic so that the reader won't confuse them with the running text. (Note that unlike italicizing with \it, emphasizing with \em will toggle between italics and non-italics when the command is nested.) The text enclosed in square brackets [] is also optional; it's a useful feature if you have an automatically generated table of contents with a list of figures and you don't want the whole verbatim caption for the figure to appear in it, but if you won't be making a table of contents omit it.

By default, the limit of the fraction of a page that can be devoted to figures is too small. Some useful commands for the preamble:
\renewcommand{\topfraction}{0.9}% max fraction figs at top
\renewcommand{\bottomfraction}{0.9}% max fraction figs at bottom
\renewcommand{\textfraction}{0.05}% min fraction text

Here is some more advice if your figure placement misbehaves.

Comments

In addition to the built-in latex comment command %, I always define a comment command that can deal with comments spanning line breaks.

in the preamble:
\newcommand{\comment}[1]{}

usage example:
\comment{This is a comment and it won't show up in the output even if it spans more than one line of the input file or the line breaks move around.}

You can also use conditional comments, shown here being used to allow commenting out all figures (very useful for faster previewing).

in the preamble:
\usepackage{ifthen}
\newboolean{includefigs}
\setboolean{includefigs}{true}
\newcommand{\condcomment}[2]{\ifthenelse{#1}{#2}{}}

usage example:
\condcomment{\boolean{includefigs}}{
\begin{figure}
....
\end{figure}
}

LaTeX style sheets a.k.a. classes

The .tex file you write contains the body of your document and some formatting information, but most of the formatting is defined separately in a latex class file with the suffix .cls (or the suffix .sty for the older 2.09 version of latex). If you are using a common format such as "article" your latex installation will already have the style/class installed in a common directory, probably under tex/inputs. Otherwise, you will need a definition of the latex class used. Many scientific journals provide their own LaTeX document classes. Here are some useful pointers:

For a UCB thesis, see Paul Vojta's useful guide on Preparing Your Ph.D. Dissertation Using LaTeX, including links to the ucbthesis document class, sample files, etc. My students also tend to use this for their MS theses.

For ASME publications, LaTeX files can be found at http://iel.ucdavis.edu/code/ASME/ (Note that the new ASME bibliography format is not a standard bibtex format so be sure to grab the .bst file so that bibtex will know how to format the bibliography. There are some bugs in here it seems such as punctuation placement being non-American -- you can always edit the generated .bbl file as a workaround.)

The SIGGRAPH document class (with minor variations) is usually what I use for a technical paper if the conference or journal doesn't provide a LaTeX class of its own. You can download it from the Author Instructions page. Note that in general you should include the lines
\usepackage{times} %use outline Times Roman font for regular text

in the preamble of your .tex file or the pdf file will look pretty awful on the screen. For equations I also add
\usepackage{mathptm} %use an outline math font for most math text

to the .tex file.

Punctuation

Eddie Kohler has a pretty extensive page on common punctuation errors and other typesetting issues in his LaTeX Usage Notes.

Playing well with others

To export text from Microsoft Word into latex or to paste into a text box, save as a .TXT file but choose other encoding, Western European (ISO), and check "allow character substitution" (and may then need to open in notepad and paste from there).

Send comments to
Copyright © 2002-2014, Sara McMains