next up previous contents
Next: Common LaTeX Operations Up: LaTeX, it's not just Previous: LaTeX Preliminaries - Commands,   Contents

LaTeX Document Structure

Now that you know some basics, lets move on to the structure of a LaTeX document. When you program in C++, Python, or Java, you usually structure source files in a certain way. Same holds for LaTeX. Here is the format of a LaTeX document.

% -- Begin LaTeX document.
% Begin document preamble.
% End document preamble.
% -- Your text and LaTeX commands go here.
% -- End LaTeX document.

A LaTeX document begins with the document class command. This command specifies the class of your
document, and consequently, what commands and environments are supported and how LaTeX formats the
document. LaTeX document classes include article, report, and book, to name a few. Think of the document
class as defining the type of writing you are doing as well as its appearance. For example, if you are going
to write an article, use the article class; a book, use the book class.

Here are the most common LaTeX document classes. 

\item letter - for writing letters
\item article - for writing short reports, papers, and documentation
\item report - for larger writing tasks such as large reports having
  several chapters, or a theses
\item book - for writing books
\item slides - for preparing slides

The options parameter is used to change the settings for a document class. For example, most classes slides, accepts the typeface size options 10pt, 11pt, 12pt - 10pt is the default. Another option is the paper
size, which includes a4paper, a5paper, b5paper, letterpaper, legalpaper, executivepaper - letter is the default.
You can also specify the documents page orientation. For example, landscape tells LaTeX to display the document in landscape mode.

Here are some example of common document classes.

\documentclass[12pt,landscape] {article}

You add extra functionally and commands through packages. Many packages come with LaTeX such as color, graphicx, and makeidx. In addition, you can add packages written by others, or even write your own for specific writing needs. Following the package command, you can define other commands that alter the formatting of your document.

The section of your document from document class to the begin document command is called the Document Preamble. The document preamble contains statements, packages, and other commands that set values and change the appearance of your document. LaTeX documents end with the end document command. Any text after this command is ignored.

The begin document command signals the beginning of your actual writing. Between the begin and end document commands is where you add your text and various LaTeX commands. What commands you can use is determined by the document class and the packages you include.

Before concluding this discussion, let's look at one more thing - the environment command. The environment command enables you to control the formatting and appearance of your document's content. For example, imagine you need to create a list of text, add an abstract, or display a table. For these cases, LaTeX provides environments that make it easy to accomplish these goals. You can even define your own environments, or redefine existing envoronments, with the new environment command.

next up previous contents
Next: Common LaTeX Operations Up: LaTeX, it's not just Previous: LaTeX Preliminaries - Commands,   Contents
Kevin O'Malley 2004-03-05