# Error using hyperref, cleveref and \newtheorem: no counter defined [duplicate]

Here's my problem: I'm writing some mathematics lecture notes. I needed some different theorem types, such as propositions, lemmas, plus observations, examples and definitions whose numbering depends on theorems. Plus, I'm Italian, and wanted custom output labels for those. So I declared them as follows (found that solution probably here on StackExchange, even if I can't find the question right now).

\theoremstyle{plain}
\newtheorem{thm}{Teorema}[chapter]

\theoremstyle{definition}
\newtheorem{defn}[thm]{Definizione}
\newtheorem{exmp}[thm]{Esempio}
\newtheorem{obs}[thm]{Osservazione}
\newtheorem{prop}[thm]{Proposizione}
\newtheorem{lemmy}[thm]{Lemma}


However, right now, I get some problems with their numbering when using both the hyperref and cleveref packages. I want to use those to refer to a Proposition or such made somewhere before, such that I can be automatically redirected to where it is written by clicking on it, but with the link label automatically presenting the theorem type (Lemma, Osservazione and such), and eventually changing automatically if I decide to rename Lemma to, say, Short Theorem. I made a short example:

\documentclass[twoside]{book}
\usepackage{amsthm}
\usepackage{cleveref}
\usepackage{hyperref}

\usepackage{mathtools}

\theoremstyle{plain}
\newtheorem{thm}{Teorema}[chapter]

\theoremstyle{definition}
\newtheorem{lemma}[thm]{Lemma}

\begin{document}
\chapter{Chapter}
\begin{lemma}
\label{foo}Proposition here
\end{lemma}

As stated in \hyperref[foo]{ \cref*{foo}}

\end{document}


Even if I replace \cref with \ref here, not actually using cleveref, I get the error anyway, so it depends just on the packages declaration.

The error I get is the following:

! LaTeX Error: No counter 'l' defined


If I replace "lemma" with "observation" I get the same error with counter 'o', and so on. Practically, it sees the first letter of the name of the theorem type I have declared as the counter, or something similar. Has anyone got any clue on how to get rid of this conflict?

## marked as duplicate by lockstep, Peter Jansson, Jesse, cmhughes, texenthusiastJan 30 '14 at 17:32

• cleveref is one of the few packages that must be loaded after hyperref. – jub0bs Jan 30 '14 at 16:04
• Don't beat yourself up. The source of the error may not have been obvious to you because, in most cases, hyperref should be loaded last. And welcome to TeX.SX! – jub0bs Jan 30 '14 at 16:10