T. W. Shield

Retex: Automatic reTeXing and Display program


When working on a TeX or LaTeX document, its get tiresome running TeX/LaTeX each time and then launching Xdvi to view the formatted text. So I wrote a perl script to do this for me. This script is for Linux/Unix only.

Advantages

What it does:

The retex script does the following when you run it with a TeX/LaTex file as an arguement

  1. Checks for a matching DVI file for the TeX/LaTex file on the command line. If its found, it displays this file with Xdvi. If it does not find a DVI file it runs TeX/LaTex to generate one, if errors occur, retex will exit at this point. Fix the errors and rerun retex.
  2. Watches for changes to the file on the command line. When the file is changed (that is resaved from your editor) it re-TeX's the file and tells Xdvi to redisplay the file. Retex also watches for changes to files that are included from the one on the command line.
  3. If errors occurr during Tex/LaTeXing then the error box is displayed and you can examine the script output for the cause of the error. The errorbox allows the window in which you ran retex in to be hidden and yet you still get notified of errors.

What you need:

Besides a computer running Linux/Unix. (I've used this under SGI Irix and Linux, but not any other Un*x's.

File Description
retex Main Perl script
texerror.tcl helper tcl script to display an error box
Perl, Tcl/Tk,
TeX/LaTeX and Xdvi
Standard parts of Linux and most Unixes.

Installation: put both of these scripts in a directory that is in your path.

How to Use It:

Usage: retex filename[.tex] [landscape]

Suppose you have paper.tex in the current directory, do the following:

  1. launch your favorite editor on paper.tex in the background or separate window.
  2. retex paper.tex

Step 2 will open an Xdvi window showing your paper. When you save changes to paper.tex from your editor, the changes will appear shortly in the Xdvi window.

Bugs

Xdvi sometimes dies while the DVI file is being rewritten. You can avoid this by not making Xdvi redisplay during DVI file generation. To restart Xdvi you must kill and restart the retex script.

Fixed (maybe) The latest version of retex stops (SIGSTOP) and continues (SIGCONT) the Xdvi process while the file is being TeX'ed to try and avoid this problem. However, this means Xdvi will not respond while the TeX'ing is in progress.