<div dir="ltr">log file lists all multiple defined labels and undefined references</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 24, 2013 at 1:02 PM, Richard Seguin <span dir="ltr"><<a href="mailto:riseguin@earthlink.net" target="_blank">riseguin@earthlink.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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:<br>
<br>
<a href="http://www.mawode.com/blog/blog/2012/03/21/finding-duplicate-latex-labels/" target="_blank">http://www.mawode.com/blog/blog/2012/03/21/finding-duplicate-latex-labels/</a><br>
<br>
It involves running this perl script in the terminal:<br>
<br>
perl -nE 'say $1 if /(\\label[^}]*})/' *.tex | sort | uniq -c | sort -n<br>
<br>
Just substitute the full path to your .tex file for the "*.tex" string in the above. You can do that by first copy/pasting<br>
<br>
perl -nE 'say $1 if /(\\label[^}]*})/' <-------make sure the ending space is there<br>
<br>
then dragging your file to the terminal, and finally copy/pasting<br>
<br>
| sort | uniq -c | sort -n<br>
<br>
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.<br>
<br>
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.<br>
<br>
Richard Séguin<br>
<br>
----------- Please Consult the Following Before Posting -----------<br>
TeX FAQ: <a href="http://www.tex.ac.uk/faq" target="_blank">http://www.tex.ac.uk/faq</a><br>
List Reminders and Etiquette: <a href="http://email.esm.psu.edu/mac-tex/" target="_blank">http://email.esm.psu.edu/mac-tex/</a><br>
List Archive: <a href="http://tug.org/pipermail/macostex-archives/" target="_blank">http://tug.org/pipermail/macostex-archives/</a><br>
TeX on Mac OS X Website: <a href="http://mactex-wiki.tug.org/" target="_blank">http://mactex-wiki.tug.org/</a><br>
List Info: <a href="https://email.esm.psu.edu/mailman/listinfo/macosx-tex" target="_blank">https://email.esm.psu.edu/mailman/listinfo/macosx-tex</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>========================<br>Victor Ivrii, Professor, Department of Mathematics, University of Toronto<br><a href="http://www.math.toronto.edu/ivrii">http://www.math.toronto.edu/ivrii</a>
</div>