I got a "LaTeX Warning: There were multiply-defined labels", and I know what it means but my document is pretty big and it has various files. So, how can I find the multiply-defined label?

I am using TeXShop in MacOS.

This is the whole warning (I believe):

(./Thesis.bbl [29] [30] [31] [32] [33] [34] [35]) [36] (./Thesis.aux)
LaTeX Warning: There were undefined references.
LaTeX Warning: There were multiply-defined labels.

4 Answers 4


The log message you quoted is a sort of "summary" of earlier, more detailed warnings, telling you exactly which references are undefined/multiply defined. Scroll up through the log file and you should find more detailed messages that look like the one below:

LaTeX Warning: Label `foo' multiply defined.
  • 16
    Using grep "multiply defined" master.log worked like a charm for me. Thanks!
    – David L
    Commented Dec 12, 2013 at 19:26
  • this doesn't occur if it is a label in the TOC (or doesn't for me)
    – Ian Turton
    Commented Mar 19, 2014 at 15:21
  • @DavidL maybe grep "multiply defined" master.log | uniq in addition?
    – stephanmg
    Commented Oct 24, 2020 at 10:45

There are ways to find duplicate labels in complex documents that have not been mentioned in the other answers. To show how they work I will use a simple (non-complex) test case:



\section{Section 1}

\section{Section 2}



RefTeX can find duplicate labels with the function reftex-find-duplicate-labels which produce a list of all duplicate labels in the document. To use it simply do M-x reftex-find-duplicate-labels. When doing this on the file with the test case it opens a new buffer with the following content:

 Move point to label and type `r' to run a query-replace on the label
 and its references.  Type `q' to exit this buffer.

 LABEL               FILE


As noted by Walt Mankowski one can use a Perl one-liner to find duplicate labels. The one-liner is as follows:

perl -nE 'say $1 if /(\\label[^}]*})/' *.tex | sort | uniq -c | sort -n

To use it open a terminal and cd to the directory of the document you want to check for duplicate labels in and then execute the one-liner. The output for the test case is as follows:

      2 \label{foo}

Relatedly you may also want to check for unused labels.

  • 1
    This RefTex advice is worth gold. Commented Oct 16, 2013 at 21:58
  • 1
    the perl one-liner just saved my life :-)
    – Ian Turton
    Commented Mar 19, 2014 at 15:20
  • 1
    My problem is that my work is scattered in several directories. Is there a version of this one-liner that scans a directory? I know nothing of Perl.
    – piffy
    Commented Jan 11, 2017 at 17:09
  • 1
    I'd like to extend that oneliner for tex documents which include or input tex files from subdirectories: perl -nE 'say $1 if /(\\label[^}]*})/' $(find . -name '*.tex' | sed ':a;N;$!ba;s/\n/ /g') | sort | uniq -c | sort -n See this question on using SED for replacing newlines. Commented Mar 15, 2018 at 18:48

Besides looking into the .log file, the showlabels package could help you if you would like to check the labels in the output.

To check the input, you could open a terminal and grep for labels:

grep label filename.tex

This gives you a compact overview.

  • 1
    Solved by deleting my .aux file, but this answer deserves a +1.
    – gsamaras
    Commented Mar 2, 2015 at 23:14
  • 1
    grep label{ filename.tex gives only the label tags. Commented Sep 26, 2019 at 22:31

Extension: I just finished a debug tracking down multiply-defined label but only one instance of creating that label. Turns out if you have a table break across pages and a first head is not defined, multiple instances of the label occur.

\caption{my text \label{tab:mine}}\\
\caption{my text, continued}\\
  • 1
    This will be reported in the log file just as in Seamus' answer. Commented Apr 12, 2017 at 15:09
  • 2
    @AndrewSwann The label itself was reported as being multiply defined, true. But it does not say why in the log file, especially when there is only one instance of \label in the tex file. This answer explains why which is how I got rid of it. +1 to @KC7HP.
    – Paul
    Commented Aug 26, 2017 at 20:47
  • 1
    Your code in a minimal document does not produce such a warning (even with longer table contents that spread over several pages). Yes, you should read the longtable documentation carefully before placing the \label command. Commented Aug 27, 2017 at 9:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .