# cleveref doesn't print correct caption for listings

I want to set the caption for referenced listings:

\documentclass{scrbook}

\usepackage{listings}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\crefname{lstlisting}{Quelltext}{Quelltext}
\Crefname{lstlisting}{Quelltext}{Quelltext}

Ref: \ref{test}.
Cref: \vref{test}.
\clearpage
\begin{lstlisting}[caption={Test},label={test}]
test
\end{lstlisting}

\end{document}


According to another post, I'd expect Quelltext 1 but it prints listing 1.

What is wrong?

-
\crefname{listing}{Quelltext}{Quelltext} works. I don't know why the package decided to use listing instead of lstlisting. – egreg Dec 8 '12 at 21:30

Use

\crefname{listing}{Quelltext}{Quelltext}
\Crefname{listing}{Quelltext}{Quelltext}


There is an alias from lstlisting to listing, but apparently it doesn't work.

\documentclass{scrbook}

\usepackage{listings}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\crefname{listing}{Quelltext}{Quelltext}
\Crefname{listing}{Quelltext}{Quelltext}

Ref: \ref{test}.
Cref: \vref{test}.
\clearpage
\begin{lstlisting}[caption={Test},label={test}]
test
\end{lstlisting}

\end{document}


-
Thank you so much :) – Matthias Dec 9 '12 at 0:08
Note: It is important to load package cleveref after loading package listings. – Florian Mar 17 '15 at 12:39
@Florian cleveref should always be the last loaded package (with perhaps just a few exceptions). – egreg Mar 17 '15 at 12:41