[Tex/LaTex] Enumerate after \label

cross-referencinghyperref

I have the following code:

\usepackage{hyperref}
\newtheorem{thm}{Theorem}

\begin{thm} \label{mythm}
   \begin{enumerate}
      \item 
   \end{enumerate}
\end{thm}

\ref{mythm}

The ref prints the right number. However, when I click on it, it will lead me to a wrong page (basically, to the beginning of the document). pdflatex also has some warning. If I add $ $ between \begin{thm} and \begin{enumerate}, the problem disappears, but now, the enumeration starts a new line. Is there any way to fix this?

Best Answer

You can use the \phantomsection command from hyperref:

\documentclass{book}
\usepackage{amsthm}
\usepackage{hyperref}

\newtheorem{thm}{Theorem}

\begin{document}

\begin{thm}\phantomsection \label{mythm}
   \begin{enumerate}
      \item 
   \end{enumerate}
\end{thm}

\ref{mythm}

\end{document}

Another option would be to use the ntheorem package instead of amsthm:

\documentclass{book}
\usepackage{ntheorem}
\usepackage{hyperref}

\newtheorem{thm}{Theorem}

\begin{document}
\mbox{}\newpage
\begin{thm}
\label{mythm}
   \begin{enumerate}
      \item
   \end{enumerate}
\end{thm}

\newpage
\ref{mythm}

\end{document}
Related Question