A method for re-indexing LaTeX files

Getting the Files

The files (DOS -- based programs only, sorry)  used here are:


It will be necessary to download these files to your computer and put them into a directory in your path.

How to use the program

The file that you should now run is  called scrub.bat, you can change the name if you want.  Here is how it works.

  You have to be a little careful how you number your labels in the latex file.  For example for lemmas's use a label like \label{l.abc} and for theorems \label{t.cameron-martin} and for equations I use \label{e.123}  etc.  It is important to have a prefix for each new environment. Otherwise the label program may screw things up.

Here is how you use the program. 

  1.  Run Latex on the file first two times.  Make sure there are no duplicate labels or undefined labels.  (Say the file is named bounds.tex.)

  2.  Run the batch file  scrub.bat on the file (bounds.tex) by typing:    scurb bounds

The computer should respond:

The output files name is BOUNDS.CNG
Use this file as the table when using the Scrublist program.
Do you want a numbering prefix? (Y/N)

 You now must answer Y or N.  If you answer N jump to (#) below and while if you answer Y you will see.

 Enter an optional prefix for numbering.

 At this point you might enter  bb  (and then return)
(#)  You will see then see:

Copyright 1987 by Elfring Consulting, Inc.
FILSCRUB  V1.0 a table driven search and replace utility
1 file(s) copied
1 file(s) copied

What the program has done

 At this point the program has done the following:

  1. Run scrublst.exe on  bounds.aux  to produce a ``change'' file bounds.cng

  2. Run filscrub.exe  filscrub bounds.cng bounds.tex bounds.ttt
     The result it store the relabled TeX file in  bounds.ttt

  3. copy bounds.tex to bounds.tmp

  4. copy bounds.ttt bounds.tex

  5. del bounds.ttt

So the old tex file is now in bounds.tmp
The new relabeled tex file is again called bounds.tex

Remark:  If you answered Y above then you will see labels in the file like:

        \begin{prop} \label{p.bb1.2} Let $X$ solve Eq. (\ref{e.bb1.3})

 So all labels will be of the form {??.bb?.??}.  If you answered N above you would get instead:

         \begin{prop} \label{p.1.2} Let $X$ solve Eq.  (\ref{e.1.3})


  1.  You may want to answer yes above and choose a prefix like ``bb'' when you are going to merge two files together that have conflicting labels.  So you would run through the above procedure on one of the files with a label prefix. Then merge the two files together and then run through the routine on the merged file.

  2. When I am writing I tend to just use very simple labels like \label{e.a} and \label{t.1}  etc.  Then every once in a while I run the above procedure to clean things up when it gets to messy.  Then I go back to using the simple labels for the new text that I am writing and look at the hard copy when referring to previously defined labels.


Warning!!  I have had fairly good luck with this program but I take no responsibility if it screws up your file. (So always back up your file before using this program on it. )  However you should be careful with it.  I always run latex on the relabeled file immediately after relabeling to make the sure the references work out right.  If they do not and the file is messed up, the original file is stored in  file.tmp , i.e. bounds.tmp in the example above. 

Good Luck,  I hope that you find it useful.

Bruce Driver

08/15/2016 02:53 PM