22.B: Next Creating LaTeX Documents  22: Up LaTeX  22: Prev LaTeX  Contents Contents

Basic

§ 22.A: Printing a LaTeX File


While it may seem odd to start by learning how to print a LaTeX file before learning how to create one, there is a method to our madness. Once you know how to convert your LaTeX files to postscript form, you can view your new creations on your computer terminal.

LaTeX files consist of a series of commands which instruct the compiler to take certain actions when typesetting your file. The first step towards printing a LaTeX file is to convert your file to a more machine-friendly form. This is done with the command latex (no surprise there).

Look at the practice file practice.tex (more is good for this). Notice that the file has the extension tex indicating it is a TeX or LaTeX file. Now use the latex command to compile the file

LaTeXshould respond with:

This verbose yet cryptic response tells you that LaTeX has run successfully and has created the file practice.dvi (among others).

To view the typeset version of your file, you can preview the "device independent" or .dvi file with the X-Window previewer xdvi:

Since a .dvi file is device independent, a device like a printer cannot process it. Accordingly, you need to convert it to a postscript form so a postscript printer can print it. This is easy:

You should receive a remarkably short and clear response:

In other words, you have just created the postscript version of your file practice.ps.

It is also possible to view a postscript file in an X Window:

To print your file, use your standard postscript printer command lpr, but make sure that you send it to a postscript capable printer or printer queue:

Of course your documents will not always be easy for LaTeX to compile. You may get error messages while running latex, or you may get output you do not like. We will create an error to give you the opportunity to see an error message. (It saves money and trees to use xdvi and ghostview and thereby avoid printing draft documents.)

Bring up practice.tex in your favorite editor and remove the closing brace after the word document in the second line, that is, change \begin{document} to

Now save your file and LaTeX it again. (Consider this a quiz.)

Unix should respond with:

The first lines should look familiar. Then LaTeX asks if you have a "Runaway argument?" Runaway argument explains the problem LaTeX is having, while the ? means it wants an answer or action from you. If you do not know what is wrong, you can request advice from LaTeX with the h command:

Unix responds with the helpful and good-natured advice

Again it asks you what it should do. Since it recommends that we forget the whole thing and go ahead, just press <return> and stumble onward. It then gives you another error (a second confusion created by the first):