# Wrong cross-references and warnings

I get a warning if I compile this code:

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{amssymb,amsmath}
\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{satz}{Satz}[section]
\theoremstyle{definition}
\newtheorem{definition}[satz]{Definition}
\theoremstyle{remark}
\newtheorem{bemerkung}[satz]{Bemerkung}

\usepackage[ngerman]{varioref}
\usepackage{hyperref}

\begin{document}
Let's go to the next page.
\clearpage
\begin{bemerkung}\label{bem:1}
\begin{itemize}
\item item 1
\item item 2
\item item 3
\end{itemize}
\end{bemerkung}

As we have seen in Bemerkung~\ref{bem:1}...
\end{document}


If i click on the reference I am at page 1 and not at the 'Bemerkung'. Has somebody an idea what the problem could be?

Thank you!

• What is the warning? I suspect you need to rerun LaTeX to get the bookmarks right -- cross-referencing generally needs two passes, sometimes more. – Chris H Aug 11 '16 at 9:04
• The warning is: name{satz.3.3} has been referenced but does not exist, replaced by a fixed one. – user110902 Aug 11 '16 at 9:13
• – Ulrike Fischer Aug 11 '16 at 9:25
• I have already seen that but as mentioned in this post, the layout is changed: The items start in a new line. Can you undo that? – user110902 Aug 11 '16 at 10:01

The nested list environments (itemize) and bemerkung confuse hyperref when a \label command is issued.

Use a \mbox{} to jump out of the current mode, the following \label is placed correctly afterwards, as well as the hyperanchor.

Interestingly, using cleveref this \mbox{} command isn't necessary at all (I recommend this here anyway).

Alternative solution: Explicitly use a \phantomsection before \label, but this can become tedious.

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{amssymb,amsmath}
\usepackage{amsthm}

\theoremstyle{plain}

\newtheorem{satz}{Satz}[section]
\theoremstyle{definition}
\newtheorem{definition}[satz]{Definition}
\theoremstyle{remark}
\newtheorem{bemerkung}[satz]{Bemerkung}

\usepackage[ngerman]{varioref}
\usepackage{hyperref}
%\usepackage[ngerman]{cleveref} %If used then after hyperref is loaded!

\begin{document}
Let's go to the next page.
\section{Foo}
\clearpage
\begin{bemerkung}
\mbox{}%
\label{bem:1}

\begin{itemize}
\item item 1
\item item 2
\item item 3
\end{itemize}

\end{bemerkung}

As we have seen in Bemerkung~\ref{bem:1}...
\end{document}