# Cross-referencing with amsthm and cleveref [closed]

I have to reference lemmas and theorems I have created using amsthm, but I want the actual word (e.g"Lemma" or "Theorem") to show up whenever I reference them. \ref didn't do the trick, as that only gave me a number. After some googling I came across cleveref, which is supposed to solve it. Unfortunately, whenever I typeset my document, it gives me two question marks instead of the name of the environment I'm trying to reference (e.g. instead of getting "Lemma 7.3" I get "?? 7.3). Here's a MWE:

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{cleveref}
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\theoremstyle{plain}
\newtheorem{thm}[defn]{Theorem}
\newtheorem{lemma}[defn]{Lemma}
\newtheorem{cor}[defn]{Corollary}

\crefname{lemma}{lemma}{lemma}
\Crefname{lemma}{Lemma}{Lemmas}

\begin{document}
\begin{lemma}[My lemma]\label{lemma1}
\end{lemma}

Hence, by \cref{lemma1}

\end{document}


Is there something I'm doing wrong here?

-
Your MWE is missing \begin{document}; when I include it everything works as expected – cmhughes Feb 10 '12 at 3:19
@cmhughes That's not the problem, that's just a typo in the MWE. I fixed it, copied it into Texshop, and I'm still getting the same problem (I get "Hence, by ?? 0.1"). – FPP Feb 10 '12 at 4:11
Add \listfiles immediately before your \begin{document} and post the output. Sounds like your distribution is not up to date – cmhughes Feb 10 '12 at 4:25
Here's the output: File List article.cls 2005/09/16 v1.4f Standard LaTeX document class size12.clo 2005/09/16 v1.4f Standard LaTeX file (size option) amsmath.sty 2000/07/18 v2.13 AMS math features amstext.sty 2000/06/29 v2.01 amsgen.sty 1999/11/30 v2.0 amsbsy.sty 1999/11/29 v1.2d amsopn.sty 1999/12/14 v2.01 operator names amsthm.sty 2004/08/06 v2.20 cleveref.sty 2009/11/02 v0.12 Intelligent cross-referencing *********** I can't believe I didn't think of checking to see whether my distribution of cleverer was up to date or not, though... – FPP Feb 10 '12 at 6:49
Did an update fix your problem? If so, we can flag this so that the moderators can make a decision – cmhughes Feb 10 '12 at 16:53
show 1 more comment

## closed as too localized by lockstep, cmhughes, Joseph Wright♦Feb 12 '12 at 9:41

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.