2

I am using the svmono class with envcountsame option. Unfortunately, this ha issues with cleveref because of how the class defines its environments.

For example, if I have \begin{proposition}\label{xyz} and call \Cref{xyz}, the output will always be Theorem xyz rather than Proposition xyz*, and similarly for any other environments.

A workaround is to add the name of the environment into the label command: so, instead of \begin{proposition}\label{xyz} I use \begin{proposition}\label[proposition]{xyz} and this seems to work.

However, I am now encountering that the environments cleveref recognizes in this way are limited. For example, this does not seem to work with question or exercise, etc., and cleveref will actually display ??? xyz, with no environment name.

How can I add these environments for cleveref to properly get the environment name to display? FWIW, I did load cleveref after all other packages.

Skeptic
  • 3,025
  • 5
  • 26
  • 23
  • Please clarify: Are question and exercise environments set up by the svmono class? If so, are they theorem-like environments? – Mico Apr 21 '21 at 16:48
  • @Mico: Yes, the actual class file declares these environments the same way it does theorem, proposition, etc., there’s no difference between them. I’m starting to think it may actually be an internal issue of cleveref itself, not specific to svnmono (the earlier issues notwithstanding). – Skeptic Apr 21 '21 at 16:51

1 Answers1

3

[Remark: Shortly after I posted the answer shown below, the OP updated the posting to mention that the svmono class is loaded with the option envcountsame. That's a crucial bit of information. The following answer does not apply if envcountsame is in force.]

Not all conceivable environment names are known a priori to cleveref. Happily, the cleveref package provides the macro \crefname to let users spell out how environments with heretofore unknown-to-cleveref names should be labelled. E.g.,

\crefname{exercise}{exercise}{exercises}
\crefname{question}{question}{questions}

Incidentally, what is the basis for your claim that "if [when using the svmono document class] I have \begin{proposition}\label{xyz} and call \Cref{xyz}, the output will always be Theorem xyz rather than Proposition xyz"? According to the following MWE (minimum working example), I'd say that this claim does not appear to be correct.

enter image description here

\documentclass{svmono}

\usepackage[colorlinks,allcolors=blue]{hyperref} \usepackage[nameinlink,noabbrev]{cleveref}

\crefname{exercise}{exercise}{exercises} \crefname{question}{question}{questions}

\begin{document} \begin{theorem} aaa \label{aaa}\end{theorem} \begin{proposition} bbb \label{bbb}\end{proposition} \begin{exercise} ccc \label{ccc}\end{exercise} \begin{question} ddd \label{ddd}\end{question}

\obeylines \cref{aaa}, \Cref{aaa} \cref{bbb}, \Cref{bbb} \cref{ccc}, \Cref{ccc} \cref{ddd}, \Cref{ddd} \end{document}

Mico
  • 506,678
  • Apologies. I forgot that the issue was adding the envcountsame option in the document class. (Edited main post to reflect this.) I tried it with your MWE, and confirmed that with \documentclass[envcountsame]{svmono} the issue resurfaces. Alas, the \crefname workaround does not seem to work in this case. So indeed, it is some kind of conflict between the option and cleveref. – Skeptic Apr 21 '21 at 17:34
  • I really am sorry for forgetting that crucial bit of info. However, the envcountsame is quite important, especially for long bodies of work. Is there any standard workaround to this clash? Or perhaps an alternative to this option? Thanks for your insights. – Skeptic Apr 21 '21 at 17:44
  • 1
    @Skeptic that is why more or less every question should include a complete example document that shows the problem. If you provide a test case you can not omit details – David Carlisle Apr 21 '21 at 18:42