Home >> Reference Materials >> Running LaTeX
  Login

How to run LaTeX



David Sherrill

Fri Jan 26 11:00:04 EST 1996

What Is LaTeX?
LaTeX is a text formatting program. It is not a word processor. The document is prepared using any standard text editor, such as vi or emacs. LaTeX formatting commands are embedded in the document to specify italics, boldface, centering, quotations, etc. LaTeX is particularly good at formatting complex mathematical equations, and it has a substantial library of special characters (Greek letters, mathematical symbols, etc.). This article will not explain LaTeX commands or syntax; please refer to the LaTeX manual or some of my sample files.
There are a number of reasons why you might want to use LaTeX. A few of them are listed below:

  1. LaTeX is the universal document language for UNIX. Be assured that if you want to convert your document into Postscript, HTML, or whatever possible format, it can be done if you start with LaTeX files.
  2. LaTeX is just ASCII text with embedded control codes. This means that it is a trivial matter to transfer files among any type of computer or operating system. By contrast, there are quite a few possible Mac binary formats, leading to much confusion. This also means that, if your word processor doesn't exist 10 years from now, you won't have to worry about not being able to get to your document. With LaTeX you can always retrieve your text (even if LaTeX itself disappears in 10 years) because it's just ASCII! In the very worst case, you would have to remove all formatting information, but the raw text will never become unreadable.
  3. The American Physical Society is currently accepting documents in LaTeX format. They use a special ``style'' file called REVTeX.
  4. LaTeX is free! If multiple authors are working on a paper, they all must have the same software. They can all buy copies of Microsoft Word, or they can just download LaTeX for free.
  5. Equations look very nice in LaTeX, much better than you get with any word processor, and they are fairly easy to write.
  6. With most word processors, if you don't like how something is formatted, there's nothing you can do to fix it beyond a certain point. With LaTeX you can almost always fix something exactly how you want it (although it may not necessarily be easy to figure out how).
  7. Reformatting your papers to produce a different format (for example, to put them into a thesis) is really an easy excercise. Style files define the format, and you just re-run LaTeX with the appropriate styles loaded.
  8. Bibliographies and cross-references to tables, figures, and equations are all automated. LaTeX automatically numbers equations and figures and tables for you, and referring to them through the text is done generically, so that if you insert an equation (or citation or figure or table) somewhere, you don't have to renumber all the equation references---it's automatic! Also, reformatting the bibliography (from JACS to JCP format, for instance) is fully automated and specified by a single keyword.

Which LaTeX?
Sometime in 1995, we at CCQC converted to LaTeX . I have not yet converted all my sample documents, but they should still work; the new LaTeX invokes a compatibility mode to process the old documents. All LaTeX files should begin with documentclass instead of the older documentstyle. If you have problems running the new LaTeX , it may be because you're running the wrong binary, or because the old environmental variables $TEXFONTS and $XDVIFONTS should no longer be used.

How Do You Run LaTeX?
After you have created a LaTeX file (which must end with a .tex suffix), you are ready to run LaTeX. To run LaTeX, type
latex filename.tex
and LaTeX will format your file, assuming it conforms to the required syntax. Remember that the last line of your document needs to be
\end{document}
or else LaTeX will hang up and wait for more input. If this happens, use control-D to abort.

The information LaTeX prints as it does the formatting is rather confusing and generally unhelpful. If an error occurs, it is usually best to type exit. This causes LaTeX will quit and call up your default editor (e.g. vi). The cursor will automatically go to the line that caused the error. Typing quit will quit LaTeX without calling up the editor.
If everything goes well, LaTeX will output a file with the same name as the input file, but with a .dvi extension (for ``device-independent'' format). LaTeX also produces some temporary files with .log and .aux extensions. The .log file may be of some use in tracking down errors. There is no reason to keep these files after you've printed out the document. You can examine the .dvi file by typing
xdvi filename.dvi
This will bring up a previewer screen. The mouse buttons cause magnification windows of different sizes to appear. There are icons to click for paging forward or backward in the document, or you can use the keys n and p. Use q to quit the xdvi previewer.
To print out the document, you must convert the .dvi file to a Postscript file. This is accomplished using either of the programs dvips or dvi2ps. For certain cases involving graphics (via xfig), dvips seems to work better. There is generally no reason to store the Postscript file on disk; in most cases it is best to pipe the output of dvi2ps directly to the Postscript printer. This is accomplished by
dvi2ps filename.dvi | lpr -Php3
The program dvips automatically sends its output to the printer. If you need dvips to output to a file, use the -o flag, as in
dvips -pp 1-5 -o filename.ps filename.dvi
This example also shows how to print only pages 1-5, using the -pp flag.

Where To Get Help
The book of all knowledge for LaTeX is Leslie Lamport's LaTeX: A Document Preparation System, Addison-Wesley, 1986. Unfortunately, this book isn't always easy to read, and the index is badly organized. Other, more readable, books are also available. The best of the rest is The LaTeX Companion, by Michel Goossens, Frank Mittelbach, and Alexander Samarin (Addison-Wesley, 1994). This book contains lots of information and examples which are not in Lamport's book. However, it is meant as a companion, and not as a replacement for Lamport's book, so you may want to buy both books.

There are some helpful documents in /usr/local/tex/inputs/latex and in /usr/local/tex/doc. Several example files reside in ~sherrill/Text/Samples.
Events Calendar (Next 7 Days)
Southeastern Theoretical Chemistry Association
Professor David Dixon
Date:16 May 2008
Location:The University of Alabama
<< May 2008 >>
S
M
T
W
T
F
S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31