OSU/REU98: Introducing LaTeX


LaTeX is a document preparation system, a special version of Donald Knuth's TeX program. TeX is a sophisticated program designed to produce high-quality typesetting, especially for mathematical text. It takes a computer file, prepared according to the "rules" of TeX, and converts it to a form that may be printed on a high-quality printer, such as a laser writer, to produce a printed document of publication quality.

Probably THE reference for using LaTex is the "LaTeX User's Guide & Reference Manual" by Leslie Lamport, the author of LaTeX. Another good source for understanding beginning LaTeX is "Getting Started with LaTeX" by D. R. Wilkins. The source for this tutorial, as well as several others, can be found on any CTAN (Comprehensive TeX Achive Network) site in the help and info directories. The main US site is ftp.shsu.edu, but sunsite.unc.edu and wuarchive.wustl.edu provide mirrors.

How LaTeX Works

In typical "WYSIWYG" text processors, such as Microsoft Word or Word Perfect:

LaTeX, on the other hand, is a formatter rather than a text processor:

The Typical Input File

Here's an example of a LaTex input file. Use the icon to see the formatted document


     \documentstyle{article}
     \begin{document}
     ``Well, in OUR country,'' said Alice, still panting 
     a little, ``you'd generally get to somewhere else -- if
     you ran very fast for a long time, as 
     we've been doing.''

     ``A slow sort of country!'' said the Queen.
     ``Now, HERE, you see, it takes all the 
     running YOU can do, to keep in the same
     place.  If you want to get somewhere else,
     you must run at least twice as fast as that!''
     \end{document}

This is the old style of a Latex document (sometimes also refered to as Latex 2.09).
In the current version, Latex2e, the \documentstyle statement is replaced by the \documentclass[12pt]{article}

(There are many additional changes but this is not the time to get into this discussion)


     \documentclass{article}
     \begin{document}
     ``Well, in OUR country,'' said Alice, still panting 
     a little, ``you'd generally get to somewhere else -- if
     you ran very fast for a long time, as 
     we've been doing.''

     ``A slow sort of country!'' said the Queen.
     ``Now, HERE, you see, it takes all the 
     running YOU can do, to keep in the same
     place.  If you want to get somewhere else,
     you must run at least twice as fast as that!''
     \end{document}

The Edit/Format/Preview Process

Here's how you get from a blank emacs window to a fully formatted, previewed, then printed document.

  1. Put text and LaTeX commands in a file:
  2. Issue the latex command to format the file:
    latex filename.tex

    The result is a ".dvi" ("dvi" = device independent) file.

  3. Display the .dvi file with XWindows previewer xdvi
    xdvi filename.dvi
  4. Convert to post script
    dvips -o filename.ps filename.dvi
  5. Print with a UNIX command
    lpr -Psmith2097 filename.ps

LaTeX Document Structure

At a minimum, a LaTeX document consists of:

\documentclass[12pt]{article} ([] includes options such as 12pt)
preamble
\begin{document}
body
\end{document}

The preamble consists of the overall, document-wide LaTeX formatting commands. The body contains the text of the document and text formatting commands.

General Principles

When creating a LaTeX input file, there are a few general principles to remember:

  1. All input, both text and formatting commands is in "ASCII" text.
  2. Spaces and line breaks are not important. A blank line starts a new paragraph, however.
  3. Commands all start with backslash:
    \documentclass
  4. Braces are used for "arguments":
    \begin{document}
    They delimit the scope of a command.
  5. Brackets are used for "optional arguments":
    \documentclass[11pt]{article}
  6. Commands are case sensitive.
    \documentstyle not \DocumentStyle
  7. Some text characters must be generated by control sequences (i.e., quotes, {}, [], \, etc.).

Document Styles

The \documentclass command describes the overall format of the document. There are four basic document styles:

article - for short documents for publication
report - for longer technical documents; like articles, but has chapters
book - for large documents, such as books
letter - for writing letters (has other special which have to be set)

Optional Argument for Document Styles

There are several optional arguments to \documentclass

11pt - uses 11-point type rather than the default point size (10pt)
12pt - uses 12-point type rather than the default point size
twoside - formats output for two-sided printing
twocolumn - produces two-column output for printing

Body Structure

Document text is started by \begin{document} and ended with \end{document}. You can put pretty much anything inbetween as long as it conforms to TeX (LaTeX) rules.


Go to Fonts, Scope, and Symbols
Return to LaTeX Tutorial Home Page