texblog

Stop loosing track of labels by displaying them in the PDF

Sometimes it is hard to keep track of labels, particularly in large documents with many figures, tables or equations. Unless you remember all label names by heart, you will likely scroll up and down till you find the particular position in the text where the label is defined. The showlabels package provides a convenient way for keeping track of label names. It displays them in the PDF next to the text element it was defined for.

Usage is straight forward, it is sufficient to load the package in the preamble of the document:

\usepackage{showlabels}

By default, labels are printed to the outer margin. Options are available to display labels in the inner/left/right margin or inline. See the package documentation for more details.

Furthermore, you can print arguments to pretty much any command. This is particularly useful for cite. See below for an example.

\showlabels{cite}

Obviously, this is not something you want in the final document. Either just delete all the code related to the package or better, use the final option to mute it:

\usepackage[final]{showlabels}

 
Example: figure

 
Example: equation

 
Example: enumerate

 
Example: cite

\documentclass{article}
\usepackage{showlabels, bibentry}
\usepackage{blindtext}
\showlabels{cite}
\begin{filecontents}{publication.bib}
@article{lamport1986latex,
  title={LaTEX: User's Guide \& Reference Manual},
  author={Lamport, L.},
  year={1986},
  publisher={Addison-Wesley}
}
\end{filecontents}
\begin{document}
\blindtext
\section{Figure}
\begin{figure}[ht]
\centering
\rule{4cm}{3cm}
\caption{default}
\label{fig:default}
\end{figure}
\section{Equation}
\begin{equation}\label{eq:default}f(x)=ax^2+bx+c\end{equation}
\section{Enumerate}
\begin{enumerate}
\item First item\label{itm:first}
\item Second item\label{itm:second}
\end{enumerate}
\section{Citation}
\cite{lamport1986latex}\\
\nobibliography{publication}
\end{document}

First seen here.

Exit mobile version