This page contains some information about the LaTeX document preparation system. LaTeX can produce high quality typeset documents and is especially good for mathematics.
LaTeX documents are typed in a text editor, not a word processor. The input file contains special "markup" commands. The input file is then processed to produce a DVI (device independent) file. The DVI file, in turn, can be printed or viewed on-screen with appropriate programs. The DVI can also be transformed into PDF or PostScript. It is also possible to transform a LaTeX file into HTML for direct viewing on the Web (although the results are not especially pretty).
The picture is the LaTeX lion from Leslie Lamport's LaTeX User's Guide and Reference Manual. LaTeX was created by Leslie Lamport on the foundation of Donald Knuth's TeX typesetting system.
Here is a 12-page document that was written in LaTeX to serve as a short introduction to some of LaTeX's features:
There is also a short template input file that you can as a starting point for your own documents:
For a very brief overview, you can look at some slides from a short presentation about LaTeX. The presentation has been exported to HTML format for viewing on the web:
The paper and presentation tell you how to create a LaTeX input file, but they don't tell you how to process the input file to produce the actual document. That will depend on what type of computer you are using. First, you have to make sure that the LaTeX system is installed on your computer. LaTeX is built on a more basic system called TeX, so you often see references to TeX instead of to LaTeX. Usually if you have TeX, you also have LaTeX, but it is possible that you might have to do some extra installation on top of TeX. Fortunately, free versions of TeX/LaTeX are available for every type of computer. You should be aware that TeX is a very large system that can take up 100 megabytes or more on your hard drive.
LaTeX is already installed on the Linux computers in the computer science computer lab. The system installed there is called "tetex," which is a free TeX for Linux/UNIX that is also the basis for many free versions of TeX on other systems. If you install your own copy of Linux, you will probably find tetex on your installation CD's.
To use LaTeX in Linux, create the LaTeX input file with any text editor. Give the file a name that ends in ".tex". I'll assume that the file name is mypaper.tex. To process the input file into a dvi file, use the command:
If this succeeds [see section on LaTeX errors below], you will get a DVI file named mypaper.dvi. Use the command
To preview the document. The kdvi viewer has a print command in its menu that you can use to print the document. You can also print it from the command line with
If you would like to have a PDF version of your paper, use the command
If all you want is the PDF file, you can use the command
instead of latex mypaper.tex. This converts a LaTeX input file directly to PDF. Note that Adobe's PDF viewer program, Acrobat Reader, is called acroread on Linux, so you can use the following command to view a PDF file:
And, finally, you can convert your LaTeX to non-too-bad-quality HTML with the command: latex2html mypaper.tex
A note on spellchecking: The linux editor kedit has a built-in spell checker. There is a command-line spell checker named ispell that can be used with a command such as ispell mypaper.tex. This program has the advantage of being aware of LaTeX commands, and the interface isn't so bad once you get used to it. With the nedit editor, you can use the Spell command in the Shell menu to run ispell on your document (but when run in this way, it loses its awareness of LaTeX commands, and will point out most of them as possible spelling errors).
(By the way: Information about using your Linux account on the cslab machines can be found at http://math.hws.edu/eck/about_linux/.
There are several versions of TeX for Macintosh, including the $30 shareware version OzTeX and a completely free version for MacOS X only named TeXShop. These TeX systems come with an integrated text editor and menu commands for processing your document. Of course, if you are smart enough to be a Mac user, you already know that Mac programs don't require a lot of instructions...
There is a pretty good free version of TeX for Windows called MikTeX. It does not come with an integrated text editor, so you have to prepare your input file with a separate text editor (such as Notepad, if you don't have anything else). You can download it from the Web site (be sure to do the "small" installation, which already has more stuff than you will ever need). Note that you have to run the installation wizard twice--once to download all the "packages" that you need for the installation, and once to do the actual installation. After downloading the installation wizard, put it into a new directory, since it will dump a lot of packages into the same directory. When you run the installer, you should be able to accept all the defaults.
Once you have installed MikTeX, you will probably want to add the MikTeX program directory to your PATH environment variable. If you used the defaults in the installer, the directory will be C:\texmf\miktex\bin. Adding this to your path will let you use the following commands in a command window:
latex filename.tex -- process a TeX input file to produce a dvi file yap filename.dvi -- view the dvi file on-screen dvipdfm filename.dvi -- convert a DVI file to PDF for viewing or printing pdflatex filename.tex -- convert a LaTeX input file directly to PDF format
(The technique for adding a directory to the PATH is different on different versions of Windows, so I won't give instructions for doing it. If you don't do it, you can still use the full path name of the commands, such as C:\texmf\miktex\bin\latex.)
I've saved LaTeX's worst feature for last. When you process a LaTeX input file, it might turn out that there are syntax errors in the file. Except in simple cases, LaTeX's error messages can be pretty much incomprehensible. Here's what to do when an error occurs.
When LaTeX finds an error, it will pause, print an error message, and wait for some guidance from you. LaTeX will tell you the line number in the input file where the error occurred. Take note of it -- you will want to go back to that line in the input file to fix the error.
If you simply press return at the error prompt, LaTeX will try to continue in spite of the error. It's often best just to keep hitting return until LaTeX gets to the end of the file. (The alternative is to try to fix the error interactively.) Then, looking at the output will often give a better idea of what the error was.
If you want to give up processing the input file, just enter x at the error prompt. You can still look at the output that LaTeX has already produced.