Whenever a label is defined multiple times in Latex, there will be a general warning, and also earlier in the log file the specific instances of the labels will be mentioned.
Nonetheless, you may also directly look in the project files for such duplicate labels if you want to be fancy. Here is a one-liner perl script that will do the job and was originally shared by Walt Mankowski. Run this script in the directory that your latex files reside.
perl -nE 'say $1 if /(\\label[^}]*})/' *.tex | sort | uniq -c | sort -nYou will see a list of the duplicate labels. Then use
grep
to find those labels. For example if one of the duplicate labels is \label{sec:party_structure}
, then you can use this command:
grep "\label{sec:party_structure}" *.tex
Faster way
You can also combine
grep
and uniq
for a faster solution. To see the number of repetitions, try
grep -o \\label{.*} *.tex | uniq -cor to see only the duplicate labels, try
grep -o \\label{.*} *.tex | uniq -dThis solution was given here.
No comments:
Post a Comment