TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a large document using LaTeX and WinEdt. I have labeled each chapter, section and so on. I would like to print out a list of just the labels (so that I don't duplicate one later on, and so that I have it handy in order to write \refs).

Is there a way to do this?

share|improve this question

migrated from stackoverflow.com Apr 6 '11 at 3:40

This question came from our site for professional and enthusiast programmers.

up vote 5 down vote accepted

This can be done in a very simple manner directly within WinEdt:

  1. Show the Gather interface (from the View menu in WinEdt>=6)
  2. Press the Collect Items button in its toolbar
  3. Jump to the Label tab and there you can see all your labels

Also, you can now press the button Copy in the interface toolbar and paste it in a blank document to perform a search on your labels

share|improve this answer

I don't know about a list of labels, but you can try using the showkeys package from CTAN to print the labels in the margins wherever you define them. I use this in my final proof reading to make sure I have everything labeled and in order.

share|improve this answer
Thanks! That's useful, although it isn't exactly what I wanted. – Peter Flom Apr 6 '11 at 19:57

I had the same problem. I solved it with just a few code lines using the tocloft package. In my opinion the advantage over other solutions is the easy use (put it in an separate file or package and comment it in or out), it is easy to understand and it is easy to adapt to your own needs or to dublicate for other lists (i.e. citations, collect section names, counting your footnotes, ...).


% create a new list incl. counter
\newlistof{labelTagCounter}{labelTags}{List of \textbackslash labeltags}

% redefine the  label command
\refstepcounter{labelTagCounter}% step the counter
\addcontentsline{labelTags}{labelTagCounter}{\thelabelTagCounter:\quad#1}% add item to list
\myLabel{#1}% now execute the original label command

\listoflabelTagCounter% print the list

Lorem ipsum dolor\label{labelA} sit amet, consetetur sadipscing elitr\label{labelB},  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam\label{labelC} erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidun\label{labelA}t ut labore et dolore magna aliquyam erat, sed diam voluptua\label{labelD}. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat\label{labelC}, sed diam voluptua. At vero eos et accusam et justo duo\label{labelC} dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Duis autem vel eum iriure dolor in\label{labelE} hendrerit in vulputate velit esse molestie consequat, vel illum\label{labelA} dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue\label{labelC} duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
share|improve this answer

I do not have WinEdt. So I cannot test the following in WinEdt.

You could use the lablst.tex file. Compile lablst.tex file.
(That is, do Something like latex lablst.tex)

(1) It will ask you to type the name of your latex file. Enter the name of your latex file. (For example, if the name of your latex file is myfile.tex then type myfile.)

(2) It will ask you to type the document class. Enter the document class. (For example, if your document class is article then enter article)

(3) It will ask you to type the list of packages you used. (you can just hit enter fro this or, if you prefer, type the list.)

Then it will produce a file with a list of all the labels you have used. The following is an example. My file name is test.tex, which is given below. (I used TeXShop to do this.)


\section{Table of Contents}\label{toc}
The \verb-\tableofcontents- command produces table of contents.

\subsection{List of figures\label{list} and Tables}\label{lof}
The commands \verb-\listoffigures- and \verb-\listoftables- produce
list of figures and list of tables, respectively. 

\section{Cross Referencing}
You can assign a \textit{key} of your choice to a \verb-figure-, a \verb-table-, 
an \verb-equation-, \verb-equation array-, \verb-enumerate-, \verb-theorems- 
or a \verb-section-.  The key is assigned a number by the \verb-\label- command  
and the number is printed by the \verb-\ref- command.  For example, 
``see section~\ref{toc} for table of contents" can be produced by 
\verb-see section~\ref{toc} for table of contents-.  \verb-toc- is the key assigned 
to section 1 by \verb-\label{toc}-. 

\subsection*{labeling words}
You can label a word with a key and refer to it back using \verb-\pageref- command.  
For example, the list of figures sub-section appears on page~\pageref{list}.


The following is the lablst.tex output.

enter image description here

share|improve this answer
I don't have it too but I remember this was a feature on v5. There is a Build Tree option which would collect all references, bibliography entry keys etc. Then, you can see the existing ones either while typing or, if I remember correctly, using <kbd>Ctrl</kbd>+<kbd>Enter</kbd>. – percusse Dec 26 '11 at 20:18
A better answer is to use egreg's newlablst.sty. Copy newlablst.sty into your ~/texmf/tex/latex/ folder. Then include \usepackage{newlablst} to your preamble. See an example at github. Label list will be printed at the end of your output document. – Sony Dec 29 '11 at 0:20

I wanted a list of all the labels in my project and wasn't entirely satisfied with the answers listed here so I wrote a bit of Python to search through my LaTeX project files, find all the labels, and print them out by category. Here is an iPython notebook that demonstrates the code. This code presumes that all your labels are of the form chp:chapter_name or fig:fig_name. i.e. word characters with a colon in the middle. The regular expressions patterns can be modified to fit whatever convention you're using.

Here is the important part of the code:

# reg exp to find full label specifications
patt = re.compile("\\label{(\w*:\w*)}") 
# reg exp to find `addtotoc` labels
app_patt = re.compile("(\w+:\w+)")

lbls = []
for root, dirs, files in os.walk(chdir):
    for fn in files: 
        if fn == 'main.tex':
            # my project has some appendices that are pulled into
            # the project using includepdf and the labels for these
            # are specified using `addtotoc`. This if statement
            # finds those labels in main.tex.
            with open(os.path.join(root, fn)) as f:
                lbls.extend(re.findall(app_patt, f.read()))
        elif fn.endswith(".tex") and fn<>"zTemplateChapter1.tex":
            # there's a template file in my project that I don't
            # want to search for labels.
            with open(os.path.join(root,fn)) as f:
                txt = f.read()
                labels = re.findall(patt, txt)
typs = []
names = []
for lbl in lbls:
    t, n = lbl.split(':')

The output for my project looks like:






share|improve this answer

In the .log file, you can see the warning where duplicate labels are listed. Then, get to the Search/Find menu -> Select "Find in Files" and type in the duplicate label to navigate where they are in the file(s).

share|improve this answer
The question does not ask about duplicate labels, but all labels in a document. – mafp Apr 1 '14 at 22:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.