Manage your labels with the showkeys package

Here’s another LaTeX trick that might come in handy. With the showkeys package, the labels you’ve defined are printed in the margins of the document. This way you have a perfect overview of which label is defined where and how they are called. The package affects the following commands: label, ref, pageref, cite and bibitem.

An example

Let’s start with an example. Since we will be working with cross-reference, the essential cleveref package will also be used.

\documentclass[]{article}
 
\usepackage[]{showkeys}
\usepackage{cleveref}
 
\begin{document}
\section{First section}\label{sec:first}
 
\begin{equation}\label{eq:einstein}
	e = mc^{2}
\end{equation}
 
In \cref{sec:first} on page \pageref{sec:first} we 
find the famous Einstein equation (\cref{eq:einstein}).
\end{document}

This shouldn’t be all to hard to understand. A section is created and labelled, as well as an equation. Then, cross-references are made to these labels. The empty square brackets in \usepackage[]{showkeys} are there because we will be discussing some of the package options later. For now, create a LaTeX document just like this and notice that the labels are printed in the page margins. You should be seeing this.

Package options

By default, the label keys are shown in the margin. In order to suppress them, add the final option:

\usepackage[final]{showkeys}

The options notref and notcite stop the package from redefining the normal cross-references and citations, respectively.

Leave a Reply




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>