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.
- Saves a bit of typing, just hit Save in your editor to re-TeX the
- If you are looking at a page deep in a long document, you don't have
to find the page again in Xdvi to see the changes. Xdvi will redisplay the new
file at the page you are currently viewing.
What it does:
The retex script does the following when you run it with a TeX/LaTex
file as an arguement
- 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.
- 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.
- 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.
||Main Perl script
||helper tcl script to display an error box
TeX/LaTeX and Xdvi
|Standard parts of Linux and most Unixes.
Installation: put both of these scripts in a directory that is in your
How to Use It:
Usage: retex filename[.tex] [landscape]
Suppose you have paper.tex in the current directory, do the
- launch your favorite editor on paper.tex in the background or
- 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
- To stop retex, enter <ctrl>-C in the window that your ran it
in. This will stop the script and kill the Xdvi window as well.
- Use the landscape option to make Xdvi display pages in landscape. I
find this useful when writing presentations using the seminar package. How I do
this is described here.
- When errors occur, click on the error box to dismiss it and let retex
continue processing the file. Retex will not continue until this error box is
- Do not put retex in the background, it needs to stay in the
foreground to display the output of the TeX/LaTex command so you can see what
caused an error, etc.
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.