next up previous
Next: About this document ... Up: Quantum Chemistry Lecture Notes

How to Run LATEX

C. David Sherrill
School of Chemistry and Biochemistry
Georgia Institute of Technology

Revised November 2000

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. 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.

Setting Up
Some LATEX documents require special processing files (style files for journals, databases for bibliographies, etc.). You can make sure the program finds all these special files by setting the environmental variables TEXINPUTS (basic LATEX stuff), BIBINPUTS (bibliography databases), and BSTINPUTS (bibliography style files). Our current default setup is as follows (appropriate for a .cshrc or .tcshrc file):
  setenv TEXHOME /home/users/sherrill
  setenv TEXINPUTS ../:./:$TEXHOME/TeX//:/usr/local/latex2html/texinputs/:
  setenv BIBINPUTS ../:./:$TEXHOME/Text/dsdb/:$TEXHOME/TeX//:/usr/local/latex2html/texinputs/:
  setenv BSTINPUTS ../:./:$TEXHOME/Text/dsdb/:$TEXHOME/TeX//:/usr/local/latex2html/texinputs/:

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
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 vi. The cursor will automatically go to the line that caused the error. Typing quit will quit LATEX without calling up vi.

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 dvips directly to a Postscript printer. Assuming your Postscript printer is set as the default printer, this is accomplished by

dvips filename.dvi

Bibliographies with BibTeX
One extremely useful feature of LATEX is the BibTeX system for automating bibliographies. The procedure BibTeX uses to create bibliographies is fairly complex, but it isn't too hard to use. The basic idea is this: citations are created using the cite command, as in
When this occurs in the text, it automatically creates a citation (usually denoted by a number in brackets or a superscript) and a corresponding entry in the list of references. BibTeX is the program which looks through the given database(s) (files with a .bib suffix) to find the reference and place it in a local bibliography file (with a .bbl suffix). To use BibTeX, you need two lines in the .tex file such as:
This will format the bibliography in the AIP (American Institute of Physics) style and use the databases jrncodes, mainbib-ds, c2h2, and refs. All of these databases have the suffix .bib.

The procedure for using BibTeX is as follows: (1) Run LATEX once; (2) Run BibTeX once (e.g., bibtex filebasename) -- do not include a suffix here; (3) Run LATEX again to have it pick up the bibliography info; (4) Run LATEX once again to make sure the references are all in the right order and all filled in properly.

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.

Some documentation usually comes with the TeX package, you might look around for it. Several example files reside in  sherrill/Text/Samples.

next up previous
Next: About this document ... Up: Quantum Chemistry Lecture Notes
C. David Sherrill