LaTeX Introduction - snowpuppy/augreality GitHub Wiki

#What is LaTeX? In spite of what you may think, it is not camel case rubber. It's a document markup language (like HTML) which is designed to separate content from formatting (like HTML+CSS). Here's a very simple example of a LaTeX document:

\documentclass[12pt,a4paper]{article}
\title{Binary Space Partitions for 3D maps}
\author{John Carmack}
\date{July 1993}
\begin{document}
   \maketitle
   \section{Intro}
   BSPs are cool.
   \textbf{So is bold text.}
   \textsl{So is slanted text.}
\end{document}

It's a fairly straightforward tag system, with the syntax \command[optional, parameters]{required, parameters}. From this file and a separate stylesheet, you can generate an actual readable document, usually as a PDF.

#Tools You'll need a LaTeX parser in order to export your documents to something readable. TeX Live(runs pretty much anywhere) and MiKTeX(Windows only) are the common choices. You can either use a standard text editor or one of several editors available that provide handy features like syntax highlighting and output previews. There's even an Eclipse plugin if you like that sort of thing. Once you get the tools installed, we can move on to looking at some common tags.

#Some Common Tags The first thing you'll probably want to set in any LaTeX document is the \documentclass{tag}. The example above used article, as in an academic journal article, but there are of course others:

  • report: probably what we want to use
  • book: for writing books
  • slides: if we want to do presentations with LaTeX

For displaying code, the verbatim tag is useful. LaTeX generally ignores whitespace, but this tag preserves formatting as it is in the file.

\begin{verbatim}
for(i=0; i<42; i++) {
    printf("%d\n", i);
}
\end{verbatim}

LaTeX lacks a lot of features like embedded images and color text, so there's a way to add extensions. All the common LaTeX packages include a large set of these. In a document, they're used with \usepackage{packagename}. One common example is graphicx, which lets you embed images. It's used as \includegraphics{imagename}, which will look for either imagename.png, imagename.jpg, or imagename.pdf.

Here's a cribsheet of some more common tags.