cleveref gets names wrong when using the SIAM document class

When I try to use cleveref in conjunction with the SIAM style files, references to theorems, sections, figures and tables are accurate, but all other references' names (corollaries, definitions, lemmas, ...) are replaced with "Theorem". Here's a minimal example:

\documentclass[final]{siamltex}
\usepackage{cleveref}

\begin{document}

Here's a definition.

\begin{definition}
\label{def:somedef} Some definition.
\end{definition}

If I use cleveref to try to refer to the above, I get \Cref{def:somedef}''.

\end{document}


which produces:

Here’s a definition.
Definition 0.1. Some definition.
If I use cleveref to try to refer to the above, I get “Theorem 0.1”.


A similar question was asked a while ago, and the answer was to rely on ntheorem or amsthm. I suppose I could get away with this by redefining all problematic environments (mydefinition, mylemma and so on), but is there a simpler or cleaner way?

-

When several environments share the same counter -- as is the case for theorems, lemmas, corollaries, propositions, and definitions in the siamltex document class --- cleveref needs some help in order to figure out which one of the possible environments is actually being used for a given label.

The easiest solution to your problem, I believe, is to load the ntheorem package explicitly and then to re-run all of siamltex's definitions of its five theorem-like environments. (Naturally, if you don't need to use all five environments in your paper, you can skip redefining those environments you don't employ.)

The following is a modified form of your MWE that uses this approach.

\documentclass[final]{siamltex}
\usepackage{ntheorem,cleveref}
\makeatletter
% The next few lines are from 'siamltex.cls', but now with
\if@onethmnum
\renewtheorem{theorem}{Theorem}
\renewtheorem{lemma}[theorem]{Lemma}
\renewtheorem{corollary}[theorem]{Corollary}
\renewtheorem{proposition}[theorem]{Proposition}
\renewtheorem{definition}[theorem]{Definition}
\else
\renewtheorem{theorem}{Theorem}[section]
\renewtheorem{lemma}[theorem]{Lemma}
\renewtheorem{corollary}[theorem]{Corollary}
\renewtheorem{proposition}[theorem]{Proposition}
\renewtheorem{definition}[theorem]{Definition}
\fi
\makeatother

\begin{document}
\section{In the beginning}

Here's a definition.

\begin{definition}
\label{def:somedef} Some definition.
\end{definition}

If I use \textbf{cleveref} to try to refer to the above, I now get \cref{def:somedef}''.

\end{document}


Addendum As Ahmed Musa has pointed out in his answer, the code I copied from the siamltex.cls file (what's sandwiched between the \makeatletter and \makeatother instructions) seems unnecessarily complicated. For the sake getting cleveref to recognize the variants of the basic theorem environment, all that's actually needed are the following four instructions:

\renewtheorem{lemma}[theorem]{Lemma}
\renewtheorem{corollary}[theorem]{Corollary}
\renewtheorem{proposition}[theorem]{Proposition}
\renewtheorem{definition}[theorem]{Definition}

-
Thanks, this works indeed. I will need to make further modifications however, because the SIAM environments typesets theorem names and numbers using \sc. –  Anthony Labarre Dec 20 '11 at 8:04
Good. Why don't you post a follow-up question in which you note the additional issues. –  Mico Dec 20 '11 at 11:02
I'm considering it, but I'm currently hesitating between that and simply dropping cleveref when the manuscript is ready, because I'm not sure the folks at SIAM will be too happy about a submission that redefines their macros (I know other publishers aren't, at least). Thanks for your suggestion anyway. –  Anthony Labarre Dec 20 '11 at 12:03
Getting cleveref to work does require redefinitions of some the environments of the siamltex document class. However, the appearance of the redefined environments is, by design, identical to that of the original environment. All that happens, so to say, is that ntheorem's algorithms get involved and insert some extra (invisible) code which, in turn, helps out cleveref. –  Mico Dec 20 '11 at 14:04

I don't know who made the siamltex class file but I was curious about the conditional in Mico's code. I had to find siamltex.cls (which isn't in MiKTeX or TeXLive), where I saw the original definitions. I don't know why the conditional there appears unusual. Please why isn't it as follows? The trace file is 20 miles long; I may save some time here. The following gave me exactly the output that Mico reported. In fact, I tried other things and there were no surprises.

\makeatletter
\if@onethmnum
\renewtheorem{theorem}{Theorem}
\else
\renewtheorem{theorem}{Theorem}[section]
\fi
\makeatother
\renewtheorem{lemma}[theorem]{Lemma}
\renewtheorem{corollary}[theorem]{Corollary}
\renewtheorem{proposition}[theorem]{Proposition}
\renewtheorem{definition}[theorem]{Definition}

-
I don't know, I suppose it's because they format everything differently (see my comment to Mico's answer). –  Anthony Labarre Dec 20 '11 at 8:05
I actually considered modifying/simplifying the code contained in siamltex.cls exactly as you did in your answer! In fact, the redefinitions can be simplified even further, by leaving out all of the code between (and including) the \makeatletter and \makeatother instructions. However, in order to keep my answer focused on addressing the OP's concern, I chose to copy the code that's provided by the siamltex class and merely replace the \newtheorem statements with \renewtheorem statements. –  Mico Dec 20 '11 at 14:11