Basic layout of a LaTeX document

Last revision August 3, 2004

 Table of Contents: Features of LaTeX Basic layout of a LaTeX document Required parts of a LaTeX input file Basic LaTeX topics LaTeX by example LaTeX Frequent Questions

Files consist of intermixed text and commands

Everything is completely free-format. LaTeX doesn't care how you split the input up across lines or how many blank spaces you put between things. It reads the input as a byte stream, looking for commands or blocks of text (words), separated by blanks, new-lines, tabs, or special symbols. Commands or text do not have to begin in a specific column or be on a line by themselves.

General syntax for commands is a backslash followed by an alphabetic name (no numerals or special characters) of arbitrary length, for example:

\maketitle

The backslash and following characters do not appear in the typeset output - they are interpreted by LaTeX.

Case of the name is important. Uppercase is not the same as lowercase. Almost all LaTeX commands use lower case letters only.

Some commands require arguments, such as a length value for resetting a margin or the text of a heading, for example:

Required arguments (there may be more than one, depending upon the command) are enclosed in a matching pair of left and right curly braces. The braces themselves do not appear in the typeset output.

A few commands have an optional argument. If you do not specify it, you get a default action. Optional arguments are enclosed in a matching pair of left and right square brackets, for example:

\documentstyle[11pt]{...}

Note that the square brackets only have the special meaning of optional argument delimiters when they follow a command that can have an optional argument. Elsewhere, a square bracket in the input file turns into a square bracket typeset in the output file.

A few commands do not have alphabetic names, but rather a single non-alphabetic character after the backslash, for example:

 \\ This command forces the start of a new line in the output \% This command puts a percent sign in the output (% by itself has a special meaning).

The following "reserved" symbols are interpreted as special command names or arguments and do not appear in the output. You can get them typeset in your output file with special LaTeX commands in your input file.

# \$ % & ~ _ ^ \ { }