4

I have a theorem that consists entirely of an enumerated list. I want to give the theorem a label (as opposed to giving items in the list labels), and link to it later in the document. I'm using the "hyperref" package but cannot get the label to associate to the start of the theorem.

I find that if I put the label before the "enumerate" environment, the reference links to the start of the document and the display box when I hover over the link is blank. I can put the label at the end of one of the items on the list, or after the list, in which case the reference links to that precise place. But I really want the link to take you to the heading (or first line) of the theorem.

In the simplified example that follows, it doesn't really matter if you put the label after the list, or after the item. But in my actual document the items in my list are long and it makes a difference (also in my doc I have a blank \item[] before the first real one so that all numbers are aligned, but this is inconsequential to the problem).

\documentclass{amsart}
\usepackage{lipsum,hyperref}
\hypersetup{colorlinks=true}
\newtheorem{thm}{Theorem}
\begin{document}
\lipsum
\begin{thm}\label{theorem}
    \begin{enumerate}
        \item An item.
    \end{enumerate}
\end{thm}
Check out Theorem \ref{theorem}.
\end{document}

I noticed some discussions about similar things in other environments but was unable to translate that to an answer to this question. If this question is considered a duplicate, would you do me the favor of pointing out where in the other question I can find my answer?

2
  • Did you try \begin{thm}\begin{enumerate}\label{lem:Py1y2}?
    – A.G.
    Oct 4, 2017 at 4:46
  • @A.G. Yeah, it has the same effect as putting the label where it is in the question.
    – j0equ1nn
    Oct 4, 2017 at 4:55

1 Answer 1

6

Just add a \phantomsection at the top of the theorem. Now the hyperlink shows as:

enter image description here

The \phantomsection command inserts a hyperref anchor at this location. It is sometimes necessary because hyperref doesn't know the right place to link to. See the answers to Hyperref \pageref links point to first page for more details.

Here is the full code:

\documentclass{amsart}
\usepackage{lipsum,hyperref}
\hypersetup{colorlinks=true}
\newtheorem{thm}{Theorem}
\begin{document}
\lipsum
\begin{thm}\phantomsection\label{theorem}
    \begin{enumerate}
        \item An item.
    \end{enumerate}
\end{thm}
Check out Theorem \ref{theorem}.
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .