3

I'm using the package showlabels which has the effect that when I label something with \label{thing1} the thing1 gets typeset in the margin of my document next to where I put the label. This works fine for equations in align and proof environments, and things like that.

The problem is that it does not work when I label a theorem, which I do like this:

\begin{theorem}\label{fact1}
Important math statement.
\end{theorem}

I can still refer to said theorem via \ref{fact1} but I cannot get the label to typeset in the margin next to the theorem.

EDIT: I originally failed to include a compilable example of the problem. @DavidCarlisle posted an example of the problem not occurring, but with showlabels replaced with showkeys, upon which I noticed that showkeys did not produce the problem.

Looking more closely at my preamble, the problem had to do with the hyperref package. The following does not result in the label on the theorem being displayed.

\documentclass{article}

\usepackage{showlabels}
\usepackage{hyperref}
\usepackage[english]{babel}

\newtheorem{theorem}{Theorem}[section]

\begin{document}

\begin{theorem}\label{a theorem}
    Important math statement.
\end{theorem}

\end{document}

On the other hand, if one moves the hyperref package so it is implemented before showlabels, as follows, it works.

\documentclass{article}

\usepackage{hyperref}
\usepackage{showlabels}
\usepackage[english]{babel}

\newtheorem{theorem}{Theorem}[section]

\begin{document}

\begin{theorem}\label{a theorem}
    Important math statement.
\end{theorem}

\end{document}
  • 1
    Can you please make a complete compilable example? – egreg Jan 23 '16 at 14:20
  • 1
    This made me realize that I probably would have answered my own question before posting if I'd made the minimal example first. This is probably obvious to many, but from now on I'm going to do that as a rule. – j0equ1nn Jan 23 '16 at 15:27
5

With showlabels

enter image description here

\documentclass{article}
\usepackage{showlabels}
\newtheorem{theorem}{Theorem}

\begin{document}

\section{Zzzz}
zzz

\begin{theorem}\label{fact1}
Important math statement.
\end{theorem}

\end{document}

enter image description here

or with showkeys

\documentclass{article}
\usepackage{showkeys}
\newtheorem{theorem}{Theorem}

\begin{document}

\section{Zzzz}
zzz

\begin{theorem}\label{fact1}
Important math statement.
\end{theorem}

\end{document}
  • Great, thanks very much! I want to include that when adding 'showkeys' I had to remove 'showlabels' to avoid equations getting 2 overlapping labels. But this was not a problem because showkeys gave exactly what I wanted. – j0equ1nn Jan 23 '16 at 14:28
  • @j0equ1nn showkeys and showlabels are designed to do exactly the same thing, just using slightly different code, loading both would be strange to say the least – David Carlisle Jan 23 '16 at 14:29
  • That makes sense, though for some reason in my case the labels shown by showlabels is a proper subset of the labels shown by showkeys. This probably has to do with the other packages I used, which I failed to include. Nonetheless this does the trick! – j0equ1nn Jan 23 '16 at 14:31
  • @j0equ1nn but your comment made me realize I had answered with one package when you had used another. Either work I've changed the answer to show both forms. – David Carlisle Jan 23 '16 at 14:33
  • Weird.. Well, although switching to showkeys resolved my issue, for the benefit of others let me try to find a minimal example of the issue I experienced and I will edit the question to include it. – j0equ1nn Jan 23 '16 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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