26

I am trying to use the cleveref package.

I have the following counters defined (hopefully this is the right way to do it!)

\newtheorem{thm}{Theorem}[section]
\newtheorem{lemma}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}

This works as I would like (i.e. Theorem 1.1, Corollary 1.2, Lemma 1.3, etc.)

My problem is \cref always returns Theorem 1.2, Theorem 1.3. I

Perhaps this is not right? (In my preamble)

\crefname{thm}{theorem}{theorem's}
\crefname{lemma}{lemma}{lemma's}

1 Answer 1

23

The behaviour you describe comes from the standard LaTeX \newtheorem command; the problem can be solved by using the amsthm or ntheorem packages:

\documentclass{article}
\usepackage{amsthm}
\usepackage{cleveref}

\newtheorem{thm}{Theorem}[section]
\newtheorem{lemma}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}

\begin{document}

\begin{thm}\label{thm:test}
test
\end{thm}

\begin{lemma}\label{lem:test}
test
\end{lemma}

As shown in \cref{thm:test} and \cref{lem:test}

\end{document}

The \newtheorem commands have to come after the loading of cleveref. Additionally, the cleverref package has to be loaded after ntheorem or amsthm. In total this gives the following order:

\usepackage{ntheorem}
\usepackage{cleveref}
\newtheorem{...}

By the way, the plural forms of theorem and lemma don't use an apostrophe, so you should use

\crefname{thm}{theorem}{theorems}
\crefname{lemma}{lemma}{lemmas}
8
  • thanks, I agree it works with what you have posted! Two strange things - (1) I have amsthm package loaded already and (2) I need to use \crefname, whereas it doesn't require you to? (I have split the file across multiple documents with \input{foo1.tex} if that makes a difference)
    – Qwirk
    May 26, 2011 at 12:08
  • @Qwirk: using subsidiary files and \input, it's necessary to use the \crefname commands as you did. Do not use the .tex extension in the argument of \input: use \input{foo1} instead of \input{foo1.tex}. Delete all auxiliary files (with extension .aux) and compile again. If your problem presists, please add to your question a minimal working example illustrating the problem. May 26, 2011 at 14:00
  • 4
    Thank you. I had to move the newtheorem definitions to after the cleverref package was loaded!
    – Qwirk
    May 27, 2011 at 1:02
  • 2
    After wasting an hour - let me repeat @Qwirk's remark. The definitions of the \newtheorem's have to come after the loading of cleveref!
    – Dror
    Aug 8, 2013 at 15:12
  • @Dror isn't that what my code shows? :-) Aug 8, 2013 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .