Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

add comment

5 Answers

up vote 3 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
add comment

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
add comment

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.)

\documentclass[12pt]{article}
\begin{document}

\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}.

\end{document} 

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
1  
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
add comment

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, ...).

\documentclass{article}
\usepackage{tocloft}

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

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

\AtEndDocument{
\cleardoublepage
\listoflabelTagCounter% print the list
}

\begin{document}
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.
\newpage
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.
\end{document}
share|improve this answer
add comment

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 at 22:22
add comment

Your Answer

 
discard

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.