[Tex/LaTex] cleveref doesn’t use correct capitalized name if used with amsthm

amsthmcapitalizationcleverefcross-referencingtheorems

It seems that the cleveref package does not capitalize properly when referring to a newtheorem if both \crefname and \Crefname have been defined. Or is it just me? Here is my MWE:

 \documentclass[a4paper,10pt]{article}
 \usepackage{amsthm}
 \newtheorem{theorem}{Theorem}
 \usepackage[capitalise]{cleveref}
 \crefname{theorem}{theoLowercase}{theoLowercaseS}
 \Crefname{theorem}{TheoUpperCase}{TheoUppercasesS}
 \begin{document}
 \begin{theorem}\label{theo:test}
    Test theorem
 \end{theorem}
 This is a reference to \cref{theo:test}.

 \begin{figure} Test Figure
    \caption{Test figure caption}
    \label{fig:test}
 \end{figure}
 This is a reference to \cref{fig:test}.
 \end{document}

On my machine, the refrence to the theorem uses the lowercase version if both \crefname and \Crefname are defined, namely :

This is a reference to theoLowercase 1.

If I comment out the \crefname definition on line 5, I get the expected:

This is a reference to TheoUpperCase 1.

In both cases,
the reference to the figure is correctly capitalized though.

Am I crazy?

Best Answer

Seems to be "by design". Quoting from section 6.1 of the cleveref manual:

[With the capitalise option,] [a]ll the default cross-reference formats will [...] have the first letter capitalised, as will the automatically generated \cref variants [...] (However, if you explicitly define a \cref variant to not be capitalised, cleveref will still honour your denition. In other words, you're responsible for defining the capitalisation correctly in your own format denitions.)

If you want your custom definitions to be respondend to the capitalise option, use the internal \if@cref@capitalise conditional:

\documentclass[a4paper,10pt]{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\usepackage[capitalise]{cleveref}
\makeatletter
\if@cref@capitalise
\crefname{theorem}{TheoUpperCase}{TheoUppercasesS}
\else
\crefname{theorem}{theoLowercase}{theoLowercaseS}
\fi
\makeatother
\Crefname{theorem}{TheoUpperCase}{TheoUppercasesS}
\begin{document}
\begin{theorem}\label{theo:test}
   Test theorem
\end{theorem}
This is a reference to \cref{theo:test}.

\begin{figure} Test Figure
   \caption{Test figure caption}
   \label{fig:test}
\end{figure}
This is a reference to \cref{fig:test}.
\end{document}
Related Question