1

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?

  • 2
    Hey @user17219, here's the deal: The problem is that you didn't pay attention when you read the manual. You were instructed there that you should put \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:21
  • 2
  • 3
    Welcome to TeX.SX. It is ok (even welcomed) to answer your own question. Yet you should not do that in a lengthy comment, but rather in a real answer, which you then can accept, so the question will be marked as answered. – bodo Aug 03 '12 at 04:33

0 Answers0