# [texhax] List of labels

Steve Schwartz s.schwartz at imperial.ac.uk
Thu Jun 24 23:41:45 CEST 2010

On Thu, 2010-06-24 at 17:50 +0100, Sam Albers wrote:
> Good morning all,
>
> I am writing a large document with many labels for tables and figures.
> Often I can't remember what that label is when I want to reference it
> later in the text. Does anyone know of a way to create a list of all
> the labels used for an entire document that can then be handily
> referenced? I am using emacs, and ubuntu as my setup.

grep newlabel texfile.aux

will show you all your labels, where your source is texfile.tex. And if
you want to make it prettier, I guess you could redirect the output to a
file labels.tex, e.g.,

grep newlabel texfile.aux > labels.tex

and then write a short label_main.tex that has

\documentclass{article}
\renewcommand\newlabel[2]{#1 & \newsublabel#2\\}
\newcommand\newsublabel[2]{#1 &  #2}

\begin{document}

\begin{tabular}{lcc}
Label & ref & page \\\hline
\input{labels.tex}
\end{tabular}

\end{document}

This generates a table with the label, the reference, and the page
number. If you have lots, you might want to replace the tabular
environment by longtable or supertab or something else to split it
across more than one page.

HTH

Steve

--
+-------------------------------------------------------------------+
Professor Steven J Schwartz        Phone: +44-(0)20-7594-7660
Head, Space & Atmospheric Physics  Fax:   +44-(0)20-7594-7772
The Blackett Laboratory            E-mail: s.schwartz at imperial.ac.uk
Imperial College London            Office: Huxley 6M67A
London SW7 2AZ, U.K.               Web: www.sp.ph.ic.ac.uk/~sjs
+-------------------------------------------------------------------+