1

This issue seems rather exotic, but I encountered it in a medium-sized document, and it took me a while to indentify which particular combination of packages was responsible.

When I load amsmath, cleveref and hyperref (implicitly via pdfcomment), ref/autoref to an equation no longer work, i.e., LaTeX throws an Reference ... on page 1 undefined error. See the following MWE:

\documentclass[12pt]{scrartcl}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{amsmath}

%% Hyperlinks
%\usepackage[breaklinks]{hyperref}
\usepackage{cleveref}
%% implicitly loads `hyperref`
\usepackage{pdfcomment}

\begin{document}

\section{Test}
Etwas Fülltext, bevor die Gleichung kommt:
\begin{equation}
E_\mathrm{kin} = \frac{m}{2} v^2 \label{eq:kinErg}
\end{equation}
Jemand fand heraus, dass \autoref{eq:kinErg} gilt.

\end{document}

If I include hyperref explicitly, then everything works except I get this warning. Not a deal breaker, but I'd prefer to avoid it and just use hypersetup for the additional options for hyperref.

Also, if I omit amsmath, everything works, too. I suppose that each package partially overwrites each other's settings...

If this is a bug, then where should I report it?

  • 2
    You're loading packages in the wrong order. Each package manipulates at least one aspect of the \label-\ref system, so the correct order of loading is crucial here: amsmathhyperrefcleveref – user31729 Apr 26 '17 at 10:29
3

Load cleveref always after hyperref as one of the few exception where packages should be loaded after hyperref!

Doing it in the wrong order, the counter information is overwritten and \autoref can't get grip of the counter i.e. the label is 'undefined', leading to wrong references or ?? as output.

\documentclass[12pt]{scrartcl}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{amsmath}

%% Hyperlinks
%\usepackage[breaklinks]{hyperref}
%% implicitly loads `hyperref`
\usepackage{pdfcomment}

\usepackage{cleveref}


\begin{document}

\section{Test}
Etwas Fülltext, bevor die Gleichung kommt:
\begin{equation}
  E_\mathrm{kin} = \frac{m}{2} v^2 \label{eq:kinErg}
\end{equation}
Jemand fand heraus, dass \autoref{eq:kinErg} gilt.

\end{document}
| improve this answer | |
  • I see no advantage of \autoref here – user31729 Apr 26 '17 at 10:44

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.