Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass{scrbook}

\usepackage{listings}
\usepackage{cleveref}

\begin{document}

Ref: \ref{test}.
Cref: \cref{test}.

\begin{lstlisting}[caption={Test},label={test}]
test
\end{lstlisting}

\end{document}

This produces Ref: 1. Cref: ?? 1.. I expected something like Ref: 1. Cref: Listing 1.

I get a LaTeX Warning: \Cref reference format for label type 'lstlisting' undefined on input line 9.

share|improve this question
2  
Works for me. What versions are you using? –  Yiannis Lazarides Mar 10 '12 at 5:44
    
("C:\Program Files\MiKTeX 2.9\tex\latex\cleveref\cleveref.sty" Package: cleveref 2011/03/22 v0.17.9 Intelligent cross-referencing Package cleveref Info: listings' support loaded on input line 2312.)` Please check you log file. –  Yiannis Lazarides Mar 10 '12 at 5:48
    
I am using the last version from here: ctan.org/tex-archive/macros/latex/contrib/cleveref –  Dennis Mar 10 '12 at 5:54
    
@YiannisLazarides - I added the same log meesage to my question. –  Dennis Mar 10 '12 at 5:55
1  
Can you pleae read you .log file and post the version number? –  Yiannis Lazarides Mar 10 '12 at 5:56
show 3 more comments

1 Answer

up vote 7 down vote accepted

Solution 1

Add the following to your header:

\crefname{lstlisting}{listing}{listings}
\Crefname{lstlisting}{Listing}{Listings}

Solution 2

Download the newest version from here (cleveref.dtx and cleveref.ins) and run latex cleveref.ins.

share|improve this answer
    
As I mentioned in the comments, your original MWE works fine if you just run it twice. –  Peter Grill Mar 12 '12 at 4:09
    
It didn't, even after running it 10 times, because of the LaTeX Warning: \Cref reference format for label type 'lstlisting' undefined on input line 9.. Seriously, my cleveref version was to old :). –  Dennis Mar 12 '12 at 4:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.