2

I was wondering if it is possible to use both options (full reference name and abbreviations of reference names) in the cleveref package.

The case at hand is a document containing both references within text mode and references above = signs in math mode (e.g. in the example below). Ideally, I would like to use the full reference name (Theorem 0.1) in text mode, while using the abbreviated version (Thm. 0.1 or something like that) in cases like $\stackrel{\text{\Cref{th:theorem1}}}{=}$ for reasons of the space required for printing the reference above the = sign.

Does anyone know how to achieve this?

Below is a minimal working example:

\documentclass[a4paper,english]{scrbook}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage[nameinlink, noabbrev]{cleveref}

\newtheorem{theorem}{Theorem}[chapter]
\newtheorem*{theorem*}{Theorem}

\begin{document}
\begin{theorem}\label{th:theorem1}
If $A$ is closed, then $A$ is closed.
\end{theorem}
\begin{proof}
Left to the reader.
\end{proof}

In \Cref{th:theorem1} we have seen that ...

\begin{equation}
a + b \stackrel{\text{\Cref{th:theorem1}}}{=} 0\,.
\end{equation}
\end{document}
  • 1
    The solution presented in cleveref — using both abbreviated and full form references? should also work in your case. Please also be aware, that \Cref will always result in the non-abbreviated form. – leandriis Dec 1 '19 at 10:53
  • Thank you for pointing that out! I have modified so that it works with both \Cref and \cref in abbreviated and non-abbreviated form. – ml4294 Dec 1 '19 at 11:16
0

Thanks to leandriis for giving the hint: cleveref -- using both abbreviated and full form references?

This modified solution works for both \Cref and \cref in abbreviated and non-abbreviated form:

\usepackage[nameinlink, noabbrev]{cleveref}

\DeclareRobustCommand{\abbrevcrefs}{%
\Crefname{theorem}{Thm.}{Thms.}%
\Crefname{example}{Ex.}{Exs.}%
\crefname{equation}{eqn.}{eqns.}%
}

\DeclareRobustCommand{\Cshref}[1]{{\abbrevcrefs\Cref{#1}}}
\DeclareRobustCommand{\cshref}[1]{{\abbrevcrefs\cref{#1}}}

I hope it will be helpful.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.