Mathematics Department - Understanding Tex

Understanding Tex



The general teTeX distribution is stored in /usr/local/teTex/share/texmf. Some specialized TeX materials useful for work at Rutgers are available in sudirectories of /math/share/texmf. In particular, the file /math/share/texmf/doc/corrdefs.doc explains the use of the special macros in the file /math/share/texmf/tex/generic/corrdefs.tex, which are used in /math/share/texmf/samples/letform.tex, a ``fill in the blanks'' template which allows you to prepare typeset letters with little knowledge of TeX. A provision is included for mass mailings (same letter, but different addresses) and window envelopes (ideal for writing letters of recommendation).

The file /math/share/texmf/tex/latex/ruthesis.cls is the ru-thesis document style useful in preparing a thesis in LaTeX. Some other useful macros for working in plain TeX can be found in the file /math/share/texmf/tex/generic/mathdefs.tex. The documentation for these macros is in /math/share/texmf/doc/mathdefs.doc.

The system is set up to look for TeX files, first in the directory /usr/local/teTex/share/texmf, then in the directory /math/share/texmf, and finally in the subdirectory texmf of your home directory. Hence, it can be useful to create the subdirectory texmf and place in it TeX files that you use frequently.

Converting TeX Documents to PDF

Here is a list of commands that, when run in order, will produce a pdf document from the ouput of your TeX file (dvi). The following commands will take a dvi file called file.dvi and create a file called file.pdf in the very same direcrtory.

*Note: This will overwrite previous verions of file.ps and file.pdf in that same directory.

dvips file.dvi -o file.ps
ps2pdf file.ps


Alternatively, you can use a script similar to tex2pdf, which was written originally by Eric Luhrs for use by the Department. You would run this shell script, once downloaded and made executable, on your TeX file. It will determine, based on the output from UNIX commands, what type of TeX file you have, and attempt to run the appropriate commands to transform your TeX file into a DVI file, the DVI into a PS file, and finally, the PS file into a PDF.

*Note: This will overwrite previous verions of file.ps and file.pdf in that same directory, where file[.tex] is the input.


Printing TeX Documents

You will not be able to print the resulting dvi file directly to the printer once you have TeX'd the document. The most basic approach to printing would be to create a ps (or PostScript) version of that file using the command:

dvips file.dvi -o file.ps

which will take the file called file.dvi and convert it to PostScript, storing the result in the file called file.ps. You can then print out the ps file you just created on the commandline using the lpr command as shown here. One additional option is to simply type the command:

dvips -P printer file.dvi

which will send the PostScript equivalent of your dvi file directly to the printer.

*Note: This last option does not always function as expected. It is usually easier to create the ps file and print that instead. If you would like to print select pages from your TeX document, the following two options exist.

The command dviselect allows a simple way of printing only a few pages of a TeX document. For example, the command

dviselect -i file1.dvi -o file2.dvi 3:5

creates a dvifile named file2.dvi out of pages 3-5 of the input file file1.dvi. This new file may then be printed in the usual way.

This same function can be accomplished by using the dvips command. For example, typing

dvips file1.dvi -p=3 -l=5 file1.ps

will create a Postscript file file1.ps containing pages 3-5 of the input file file1.dvi. A third possibility is to use dvips to generate the entire document, preview it using ghostview, and then mark the desired pages for printing and select Print marked pages.

If you wish to print your TeX document single-sided instead, the following command line option can be used:

dvips file.dvi -o \!"lpr -S"

which will print to the default printer lp29. To print to a differnt printer using this approach, use the following command:

dvips file.dvi -o \!"lpr -S -P<printer>"

where <printer> is lp29, lp59, lp69, or any other networked printer.
This page was last updated on August 01, 2017 at 11:02 am and is maintained by webmaster@math.rutgers.edu.
For questions regarding courses and/or special permission, please contact ugoffice@math.rutgers.edu.
For questions or comments about this site, please contact help@math.rutgers.edu.
© 2017 Rutgers, The State University of New Jersey. All rights reserved.