next up previous contents
Next: Document Styles Up: Carrying On Previous: Carrying On

   
LATEX on UNIX

The only special problems in using LATEX caused by the UNIX operating system involve the way UNIX handles files. The first problem arises because, when a program starts to write a file, UNIX destroys the previous version of that file. Thus, if an error forces you to stop LATEX prematurely (by typing Control-C or Control-Z), then the files that LATEX was writing are incomplete, and the previous complete versions have been destroyed. You probably don't care about the output on the dvi file, but, if you are making a table of contents or using cross-referencing commands, then LATEX also writes one or more auxiliary files that it reads the next time it processes the same input file. If the auxiliary files are incomplete because LATEX was stopped before reaching the end of its input file, then the table of contents and cross-references will be incorrect the next time LATEX is run on the same input file. You will have to run LATEX a second time to get them right. If you want to avoid having to run LATEX twice after making an error--for example, if your input is very long--then you should save copies of these auxiliary files before running LATEX. An input file named myfile.tex and all the auxiliary files produced by LATEX from it are included in the UNIX file specifier myfile.*. Use the UNIX cp command to save copies of these files.

The second problem in using LATEX on UNIX involves the files that LATEX reads. The file whose name you type with UNIX's latex command is called the root file. In addition to reading the root file, LATEX also reads the files specified by \input and \include commands. With the UNIX directory system, LATEX must know not only the names of these files but also in what directories they are. It will have no problem finding the correct files if you follow two simple rules:

1.
Run LATEX from the directory containing the root file.
2.
Keep all files specified by \input and \include commands in the same directory as the root file.
If you follow these rules, you never have to type an UNIX path specifier when using LATEX.

You should never break the first rule, otherwise LATEX will have trouble finding auxiliary files. (To run LATEX on someone else's file, copy the file to your directory.) If you break the second rule, specifying a file from another directory in an \input or \include command, you must use a complete path name. For example, to include the file hisfile.tex from Jones' directory /foo/bar, you can type

     \include{/home-theory/jones/foo/bar/hisfile}
A ~ character may not appear in the argument of an \input or \include command, so you can't use a file name such as ~jones/foo/bar/hisfile.

For people who don't like to obey rules, here is exactly how LATEX finds its files. The root file is found by UNIX according to its usual rules. LATEX's auxiliary files are read and written in the directory from which it is run. All file names specified in the LATEX input, including the names of document-style (sty) files specified by the \documentstyle command, are interpreted relative to the directory from which LATEX is run. If LATEX does not find a file starting in this directory, it looks in the system directory /usr/physics/lib/tex. You can change the directories in which LATEX looks for its input files by setting the environment variable TEXINPUTS. Putting the command

     setenv TEXINPUTS :.:/home-theory/jones/myown:/usr/physics/lib/tex:
in your .login file causes LATEX to look for files first in the current directory, then in Jones' myown directory, and then in the system directory. You might want to do this if your name is Jones and you have your own personal document-style files in your myown directory.


next up previous contents
Next: Document Styles Up: Carrying On Previous: Carrying On
Daniel Mitchell
1999-03-03