Operating System Information --> Unix Information --> Unix Utilities --> UNIX: How To Convert And Print TeX/LaTeX Documents -->

UNIX: How To Convert And Print TeX/LaTeX Documents

These are the steps necessary to convert a TeX (pronounced "tek") or LaTeX (pronounced "latek") document from the original source to a readable/printable form on the OIT UNIX systems. Some of the steps detailed below will be slightly different on different UNIX platforms. Differences will be noted wherever possible.

To determine if the document is a TeX or LaTeX document, you need to examine the first few lines. All UNIX TeX and LaTeX documents should follow the naming convention of:

  filename.tex

where filename is any descriptive name you wish to give the file. The "tex" extension is the same for both TeX and LaTeX.

If the first line is one of:

  /documentclass{xxxx}
  /documentclass[yyyy]{xxxx}

where xxxx will be some format of document (like "article", "report" "book" etc.), and yyyy will be typesetting or page-format information (like "12pt" or "twocolumn"), then you're dealing with a LaTeX document.

If the first line does NOT contain a line similar to one of the lines above, it is a TeX document.

To use either TeX or LaTeX on the TerpConnect system, you must first tap them. This sets up environment variables and adds the path to the software for the user, simplifying the steps necessary to run many packages. To do this, type:

  tap  tetex

You'll get a brief blurb on recent TeX/LaTeX announcements, like user group info, mailing lists, package version info, etc.

To format either a TeX or LaTeX document, the general process is the same. You first run it through the appropriate formatter which creates a DVI (DeVice Independent) output file. This file is then converted into the printing/viewing format which best suits your local environment; the local favorite seems to be PostScript.

To format a TeX document, you type:

  tex  filename.tex

where filename is the name of your command file (with the ".tex" extension). This will create two new files, one named filename.log and the other named filename.dvi. The log file is just a record of the formatting process, including any error messages needed for debugging. The dvi file is the file containing the eventual product.

To format a LaTeX document, you type:

  latex  filename.tex

where filename is the name of your command file (with the ".tex" extension). This will create several new files, including filename.log, filename.dvi, filename.aux and possibly others like filename.toc, etc. The log and dvi files serve the same purpose as above, the .aux file is an auxiliary log file, and other files like the .toc file will have additional information necessary for the final formatting.

At this point, how you deal with the files depends upon what platform you are using. Some, like X-windows, have a DVI previewer; if so, you can load the DVI file into this for viewing/printing. To do so you can usually find the icon for the DVI file using your file viewer and double-click on it, or in the case of an X-windows connection to TerpConnect, you can type:

    xdvi filename.dvi

For those working in text-only windows, the next step would be to convert the file into a format that can be dealt with. On TerpConnect this generally means to convert it to PostScript format for printing. To do this, you can use a conversion command; they're usually named "dvips" or "dvi2ps". To check to see which is available, use the 'which' command:

    which dvips

If the program exists, the full pathname will be given. It currently lives in the directory tree where the tex and latex commands live, and will only be available if you run the tap tetex command shown above.

To use the dvips command, you type:

  dvips  filename.dvi  -o 

to create an output file with the same root filename as the input file, or:

  dvips  filename.dvi  -o  filename.ps

to create an output file with a different filename from the input file (we suggest using the ".ps" extension to remind you it's a PostScript file.), or:

    dvips  filename.dvi | qpr -q queue

to send it directly to a printer, bypassing the creation of a PostScript file. We suggest only doing this for a last draft, once most/all of the errors are eliminated.

If you use either of the first two methods above, you'll have the PostScript version of the file in "filename.ps", but you'll still need to print it to see what it says and how it looks. To print a PostScript file you can use the 'qpr' command:

    qpr  -q  queue  filename.ps

where queue is a valid PostScript print queue for your system.

How are we doing? Comments on this page?
Office of Information Technology
Office of Information Technology Help Desk Web Site University of Maryland Web Site Office of Information Technology Web Site