# Cleveref displays ?? 3.2.2 instead of the correct reference name

I'm trying to use cleverref for my references but up to now it does not work for me. Currently my setup looks like this:

\documentclass[a4paper]{article}

% PACKAGES
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage[ngerman]{varioref}
\usepackage[ngerman]{cleveref}

\begin{document}

\section{Test}\label{test}

This is some text containing a self-reference \cref{test}.

\end{document}


This yealds:

This is some text containing a self-reference ??.


Latex tells me:

LaTeX Warning: Reference test' on page 1 undefined on input line 14.


And when I run it a second time (just using pdflatex test.tex):

LaTeX Warning: \Cref reference format for label type ' undefined on input line 14.


I already tried to set the language globally by putting ngerman into \documentclass[a4paper,ngerman] .. and also tried german and even english instead with no effect.

Does anyone have an idea what I'm doing wrong?

-
Have you try compiling twice? – Romain Picot May 9 '14 at 11:33
What do you mean with compiling twice? I'm using latexmk for building and already tried to delete all .aux-files and everthing else within the build directory but that had no effect. Did you mean that? – ma0ho May 9 '14 at 11:45
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Jubobs May 9 '14 at 11:52
Ok, I added a minimal example that compiles and has the same effect. – ma0ho May 9 '14 at 12:16
@cgnieder that should be an answer :) – Gonzalo Medina May 9 '14 at 12:25

You need to change the package loading order. varioref should be loaded before hyperref and cleveref needs to be the last of the referencing related packages:

\documentclass[a4paper]{article}

% PACKAGES
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}

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

\begin{document}

\section{Test}\label{test}

This is some text containing a self-reference \cref{test}.

\end{document}


-
Ok, this now works for the minimal example above - but not for a bigger project I'm just working on. Unfortunaly I cannot paste the whole code here so you could try that out. I do not get the ?? anymore. But I'm not able to make it use german language for the \cref. It tried setting the language to ngerman and german globally (in the documentclass) as well as as options to varioref and cleveref. I'm still getting section xyz instead of Abschnitt xyz. – ma0ho May 9 '14 at 12:38
@MathisHoffmann The active language in the document is the last one passed to babel (except if you change it explicitly, e.g., with \selectlanguage). But that's nothing to do with cleveref. – clemens May 9 '14 at 12:40
If you load \usepackage[ngerman]{cleveref} then cleveref uses German captions even if you don't load ngerman with babel or even if you don't load babel at all – clemens May 9 '14 at 12:44
That's excactly what I tried and what works for me in the small test file - but not in a bigger project I'm working on.. :( – ma0ho May 9 '14 at 12:55
@MathisHoffmann sounds like a new question to me :) – clemens May 9 '14 at 13:31