Possible Duplicate:
Which packages should be loaded after hyperref instead of before?
I'm trying to use cleveref's \namecref command to get the name of the type of section a label is in, but it's not working. Minimal example:
\documentclass[a4paper,10pt]{article}
\usepackage{cleveref}
\usepackage{hyperref}
\begin{document}
\section{A Section}\label{sec}
In this \namecref{sec} we will discuss the fact that cleveref is not working right now.
\end{document}
Instead of the expected output ("In this section...") I get question marks ("In this ??..."). Also, latex and xetex both emit this warning:
Reference `cref' on page 1 undefined on input line 6.
What's going on here?
\usepackage{cleveref}after all other package imports. Because you import hyperref before you import cleveref, something breaks. Moving the cleveref import to be last of all packages imported fixes the problem and produces the expected "In this section...". And yes, I did just answer my own question so that people who encounter the same problem in the future get something useful when they Google the warning message. – Josh Hansen Aug 03 '12 at 03:21hyperrefinstead of before? – Werner Aug 03 '12 at 03:34