[Tex/LaTex] Defining cross-reference names for custom theorem environments in cleveref

amsthmcleverefcross-referencingtheorems

I am concerned with the difference between this working example

\documentclass{article}
\usepackage{amsthm}
\usepackage[capitalise]{cleveref}

\newtheorem{thm}{Theorem}


\begin{document}

\begin{thm}\label{thm1}
My first theorem
\end{thm}

\begin{thm}\label{thm2}
My second theorem
\end{thm}

Using \cref{thm1,thm2} we obtain another theorem.
\end{document}

whose last line is displayed as

Using ?? 1?? 2 we obtain another theorem.

and the code

\documentclass{article}
\usepackage{amsthm}
\usepackage[capitalise]{cleveref}

\newtheorem{theorem}{Theorem}


\begin{document}

\begin{theorem}\label{thm1}
My first theorem
\end{theorem}

\begin{theorem}\label{thm2}
My second theorem
\end{theorem}

Using \cref{thm1,thm2} we obtain another theorem.
\end{document}

whose last displayed line is the intended

Using Theorems 1 and 2 we obtain another theorem.

I found inside cleveref.sty the right (non abbreviated) names of the basic \newtheorem definitions (theorem,lemma, corollary, proposition, definition) which are predefined in cleveref. But what is the full description that one must give to cleveref so that it handles a theorem environment properly (including the capitalise option)?

Best Answer

You can use the \crefname{<type>}{<singular>}{<plural>} syntax to define cross reference names for customized theorem-like environments. (see page 12 of the cleveref manual)

\documentclass{article}
\usepackage{amsthm}
\usepackage[capitalise]{cleveref}

\newtheorem{thm}{Theorem}
\crefname{thm}{Theorem}{Theorems}

\begin{document}

\begin{thm}\label{thm1}
My first theorem
\end{thm}

\begin{thm}\label{thm2}
My second theorem
\end{thm}

Using \cref{thm1,thm2} we obtain another theorem.
\end{document}

enter image description here