Introducing LaTeX

(URL: http://www.cs.cornell.edu/Info/Misc/LaTeX-Tutorial/Introduction.html)


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}

The Edit/Format/Preview Process

Here's how you get from a blank emacs-19 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. Print with a UNIX command
    dvips filename.dvi | lpr -d filename.dvi


Use LaTeX to convert running.tex (should already be in your latex directory) into a "dvi" file and then preview the output with xdvi.

and here's the dvi output.


LaTeX Document Structure

At a minimum, a LaTeX document consists of:
\documentstyle{article}
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:
    \documentstyle
  4. Braces are used for "arguments":
    \begin{document}
  5. Brackets are used for "optional arguments":
    \documentstyle[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 \documentstyle 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 \documentstyle:
11pt - uses 11-point type rather than the default point size
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


Edit running.tex so that it now uses 12pt fonts rather than the default point size. Re-LaTeX it and see how it looks in the previewer.

and here's the dvi output.


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
Go to Departmental Home Page
If you have any questions or problems, send mail to www@cs.cornell.edu.
Last modified 17 Jan 1995 by Denise Moore (denise@cs.cornell.edu).