Math 300: Basic LaTeX (back to Math 300 notes)

LaTeX is a markup language. The "tags" of the markup language are identified by starting with a backslash ( \ ), i.e. every LaTeX command or variable starts with a backslash. As with other markup languages, every LaTeX document has a preamble section and a body section. Unlike most other markup languages with which we are familiar, there are many commands in LaTeX that do not require, or even possess, closing tags.

In any computer language, it is common to make one's first application a so-called "Hello, world!" program. Such a document in LaTeX follows.

\documentclass{article}
% Any text following a percentage sign is ignored - a comment
\begin{document}
Hello, world!

This is a second paragraph.
\end{document}

The structure of a basic LaTeX document is evident. The file must begin by declaring the class of the document - the "article" class here. Other possibilities include "book", "thesis", and "letter". Following that are preamble commands, which pertain only to formatting and new command structures. The body of the document begins with the "\begin{document} statement. Any text that is not preceded by a backslash actually appears on the formatted page.

Note that the blank line in the body of the document makes a new paragraph. It is very important to watch blank lines - starting a new paragraph can generate errors if it is done e.g. in the middle of an equation.

Note also that there are several special characters that cannot be used in an ordinary way. They include \, _ ^, {, }, &, #, ~, %, and $. If you actually want one of these characters to appear in your document, you must enter them as \backslash, \_, \^, \{, \}, \&, \#, \~, \% and \$, respectively. Some of these characters are only valid in math mode, or require some extra tricks to manage.