[OS X TeX] Finding duplicate labels - a perl script

Victor Ivrii vivrii at gmail.com
Mon Jun 24 19:07:27 CEST 2013

log file lists all multiple defined labels and undefined references

On Mon, Jun 24, 2013 at 1:02 PM, Richard Seguin <riseguin at earthlink.net>wrote:

> Anyone who has written a very long math document has probably encountered
> the problem of accidentally creating duplicate labels. Right now I have 352
> labels, and I have run into this problem several times. I stumbled on a way
> of detecting exactly which labels have duplicates here:
> http://www.mawode.com/blog/blog/2012/03/21/finding-duplicate-latex-labels/
> It involves running this perl script in the terminal:
> perl -nE 'say $1 if /(\\label[^}]*})/' *.tex | sort | uniq -c | sort -n
> Just substitute the full path to your .tex file for the "*.tex" string in
> the above. You can do that by first copy/pasting
> perl -nE 'say $1 if /(\\label[^}]*})/'          <-------make sure the
> ending space is there
> then dragging your file to the terminal, and finally copy/pasting
> | sort | uniq -c | sort -n
> and running the script. It creates a sorted list of all your labels
> together with the number of occurrences of each within the terminal window.
> Finding duplicates is just a matter of scanning the list for counts > 1.
> It's also very fast.
> It seems to me that an Applescript could be created to run this perl
> script from BBEdit or TeXShop, finding the path of the front .tex document,
> assembling the perl script, and then passing it on and running it in the
> terminal, essentially making it a one-click operation. Unfortunately, I'm
> not handy enough with Applescript to figure out how to do this.
> Richard Séguin
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
> List Archive: http://tug.org/pipermail/macostex-archives/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex

Victor Ivrii, Professor, Department of Mathematics, University of Toronto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/macostex-archives/attachments/20130624/21528674/attachment.html>

More information about the macostex-archives mailing list