TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top



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



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
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
Can you pleae read you .log file and post the version number? – Yiannis Lazarides Mar 10 '12 at 5:56
up vote 11 down vote accepted

Solution 1

Add the following to your header:


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
The link shows version 0.19 2013-12-28. tlmgr info cleveref tells I run 0.19 2014-02-26 which I assume is even newer. Still, I ran latex several times, and it would not detect the listing as a listing. Had to go with solution 1 :( – mcnesium Nov 26 '15 at 10:20
Regarding solutions 1, it didn't work for me. The problem and the solution is explaind here: tex.stackexchange.com/questions/86157/… Basically, lstlisting should be replaced with listing due to some alias problems. – Talouv Dec 30 '15 at 9:46

Your Answer


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.