A Brief Introduction to TeX


TeX (rhymes with "wreck") refers to a suite of programs for producing high-quality typeset documents. It includes the typesetting programs proper (TeX and relatives "plain TeX", "AmSTeX", and "LaTeX"), output format converters (dvips), and previewers (xdvi, ghostview).

The first set of programs take input files consisting of text interspersed with formatting commands, and produce a file suitable for driving an output device like a typesetter or laser printer. TeX itself has rather primitive controls -- you won't want to use it "bare". To help make life easier, various macro packages are available.

The first, and most common, package is known as "plain", which is the version you'll get if you simply type "tex" as a command to the shell. TeX and plain TeX are described in "The TeXbook", by D. E. Knuth. This book is volume A of the five-volume set "Computers and Typesetting".

AmSTeX is oriented towards making mathematics typesetting easier, and can be obtained by typing "amstex". A thorough description of "AmSTeX" is in the book by M. D. Spivak called "The Joy of TeX". A locally modified version of AmSTeX, called "MathTeX" is in routine use by the word processing office in the Math department.

LaTeX is a general purpose macro package, and is described in the book "LaTeX: A Document Preparation System" by by L. Lamport. This book also describes LaTeX's companion programs "BibTeX" for maintaining bibliographies and "SLiTeX" for producing slides. You can get LaTeX by typing "latex". Similarly for "bibtex" and "slitex".

LaTeX2e

To process a LaTeX (including LaTeX2e) document type "latex".

There is a LaTeX "style" called "amstex" by which LaTeX can imitate most of the AmSTeX functionality. Since LaTeX is easier to use, we recommend that people use this style rather than using AmSTeX itself.

All these programs are easiest to use if you place a ".tex" suffix on the name of your input file. If your file was called, say, "paper.tex", you could simply type "tex paper" as a command, and TeX will take care of tacking on the .tex extension; also, the output file it will create will be called "paper.dvi", and the log file (with error messages and other information) will be "paper.log". LaTeX also creates "paper.aux" with table of contents information, if any.

If you do not name a file on the command line, TeX will prompt you for the name, and write an output file called "texput.dvi", and a log file called "texput.log". When you type "tex" (or "amstex" or "latex") like this (i.e., as a command with no arguments), TeX will print a banner telling you its version number and system information. There'll be a slight pause while TeX initializes itself before the prompt character (an asterisk) comes up, so be a little patient. At that stage, use TeX's \input command to read in your file. So, you could process your paper with a dialogue like this ("%" is the shell prompt; you only type "tex" and "\input paper"):

% tex
This is TeX, C Version 2.9 (no format preloaded)

*\input paper
   .........
Output written on texput.dvi (x pages, y bytes).
Transcript written on texput.log.
%

Remember to put an endmark at the end of your document:
        Plain TeX       \bye
        LaTeX           \end{document}
        AmSTeX          \enddocument

The output file produced by TeX is in a format known as "DVI", short for "DeVice Independent". It is a low-level language which describes symbol placement in a general way. This device independence means that TeX output can be run off on various different machines, provided a proper format conversion package exists.

Just as TeX knows about files ending in ".tex", the format converters know about ".dvi"; continuing the example above, if you wanted to print the document "paper.tex" on the printer called "aclps" you would type:

tex paper
dvips -Paclps paper

All of the Math department printers speak PostScript. The "dvips" command converts a DVI file to PostScript and sends it to the printer.

See the Printing Facilities page for the locations and names of the printers at UCLA Math.

As you work with TeX, you'll soon discover that it has nuances which are not immediately obvious. Even experienced TeX users have been chagrined by what they found on the printed page. To help this, previewers are available for taking a look at your output before actually committing it to paper. (Save a tree, and save your paper quota!) In a sense, a previewer is really only another kind of format converter, but it puts its result on a bitmap screen rather than on paper. The previewer in use here is called "xdvi". To look at your paper, you would type:

tex paper
xdvi paper
If your document contains postscript figures, you may find previewing easier with:
tex paper
dvips paper -o paper.ps
ghostview paper.ps

There are some hardcopy writeups available which describe using TeX in the Math department in greater detail. They can be found in the Computer Consulting Office, MS6117. This office is also a good place to go to get your questions answered.

Related Material:

Quick Reference Guide: Using Tex [tex.ps] [tex.pdf]


Last updated: 9/25/98