1

I posted once before about this issue, here, but would like to start a new thread with more information and a MWE. I hope that's OK. (In the old post I did not very adequately explain the situation, and forgot an MWE, for which I apologize. But it means there were some comments based on inaccurate info, which makes it a less useful thread.)

The issue is that in sv classes like svmono, adding the envcountsame option causes cleveref to not correctly identify the namerefs of environments. Everything appears as "Theorem", regardless of environment.

One workaround, which I found here, is to define a custom \label command. That works mostly, but not completely. Some environments, for whatever reason, continue not to show correctly.

Examples of environments that work: proposition, lemma, corollary, remark

Examples of environments that don't work: exercise, question

I cannot find anything in the svmono class itself that would account for this. As far as I can tell, they are all defined identically.

Specifying \Crefname for these environments does not seem to help. In fact, it does not seem to be a cleveref issue, at least not entirely. For example, for the environments that don't work, \namecref and \labelcref still work, and pick up the information correctly.

Would anyone have any insights on what might be going on, and even better, any ideas on how to fix this behavior?

I attached the MWE below.

EDITS: spelling, fixes to MWE

\documentclass[envcountsame]{svmono}

\usepackage[capitalise]{cleveref}
\usepackage{thmtools}

\makeatletter
\newcommand{\labelx}[1]{
    \relax
    \ifmmode
        \label{#1} 
    \else 
        \ifnum\pdfstrcmp{\@currenvir}{document}=0
            \label{#1}
        \else
            \label[\@currenvir]{#1}
        \fi
    \fi
}
\makeatother

\begin{document}

\crefname{exercise}{Exercise}{Exercise}
\Crefname{exercise}{Exercise}{Exercise}
\crefname{question}{Question}{Question}
\Crefname{question}{Question}{Question}

\begin{proposition}\label{prop_with_label}
    Proposition with label. 
\end{proposition}

\begin{proposition}\labelx{prop_with_labelx}
    Proposition with labelX.    
\end{proposition}

\begin{corollary}\label{cor_with_label}
    Corollary with label.   
\end{corollary}

\begin{corollary}\labelx{cor_with_labelx}
    Corollary with labelX.  
\end{corollary}

\begin{exercise}\label{exer_with_label}
    Exercise with label.    
\end{exercise}

\begin{exercise}\labelx{exer_with_labelx}
    Exercise with labelX.   
\end{exercise}

\begin{question}\label{quest_with_label}
    Test    
\end{question}

\begin{question}\labelx{quest_with_labelx}
    Test    
\end{question}


Let's cite these, now.

With label, nothing works right: \Cref{prop_with_label}, \Cref{cor_with_label}, \Cref{exer_with_label}, \Cref{quest_with_label}.

With labelX, some things work: \Cref{prop_with_labelx}, \Cref{cor_with_labelx}. 

But some things still don't: \Cref{exer_with_labelx}, \Cref{quest_with_labelx}.

\end{document}
3
  • move the \crefname definitions into the preamble. Sep 10, 2021 at 11:11
  • Thanks very much for this! I tried this earlier, and got an error. But since you mentioned it again, it occurred to me to try another editor, and indeed it works. I use TexPad normally, and there I get an "infinite loop" error if I put the crefname definitions into the preamble. But now I tried in TexShop, and it works just fine. How odd! Thank you again for your time and help.
    – Skeptic
    Sep 10, 2021 at 11:15
  • The option that works for me is Werner's "crude" solution posted in reply to this related question. In a nutshell, avoid envcountsame class option altogether, and enforce the desired behavior in your preamble. To make cleveref work, clone the counters with aliascnt.
    – AndreasT
    Nov 6 at 4:47

1 Answer 1

0

Svmono is dead and a mess. A dead mess. Or a messy corpse; you name it. I also don't know how to reference questions.

After this short but delightful complaint (due to my fighting with issues expressed in, say, svmono+enumitem: how to discourage a page break between a remark head and a following list and With svmono, how to introduce more horizontal space between a theorem head and the theorem contents without occasionally introducing vertical space?), let me tell you that I still know how to reference exercises, and here is what I do:

\documentclass[envcountsame]{svmono}% using v5.10
\pagestyle{empty}
\usepackage{graphicx}
\usepackage[capitalise]{cleveref}
\crefname{exercise}{Exercise}{Exercise}
\Crefname{exercise}{Exercise}{Exercise}
\Crefformat{exercise}{Exercise #2#1#3}
\crefformat{exercise}{Exercise #2#1#3}
\begin{document}
\begin{exercise}\label[exercise]{exer_with_option}
    Exercise body.
\end{exercise}
\begin{question}{Question head.}
    Question body.
\end{question}
\Cref{exer_with_option}, \cref{exer_with_option}.
\end{document}

Pdflatexing this yields

output

You can try \label[environmentName]{labelName} with lots of environments (for example, with remarks and definitions).

As for questions, I wouldn't know how to reference them anyway because they are not numbered (in my test) for svmono v5.10.

You must log in to answer this question.

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