Making a cleveref String Lowercase

I'm using cleveref to cross-reference my theorems throughout my document. However, since certain theorems are so popular, I much prefer to refer to them by names as opposed to their theorem numbers; but I would still like them to be clickable, so that clicking on a theorem's name, wherever it's mentioned, will take you straight to it.

To create custom string, I implemented the solution provided by this answer, which can be shown in the MWE below.

\documentclass{article}
\usepackage{amsthm, parskip, hyperref, cleveref}

% Theorems
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}

% Solution from https://tex.stackexchange.com/a/109864/78913
\makeatletter
\newcommand{\myref}[1]{\cref{#1}\mynameref{#1}{\csname r@#1\endcsname}}
\newcommand{\Myref}[1]{\Cref{#1}\mynameref{#1}{\csname r@#1\endcsname}}

\def\mynameref#1#2{%
\begingroup
\edef\@mytxt{#2}%
\edef\@mytst{\expandafter\@thirdoffive\@mytxt}%
\ifx\@mytst\empty\else
\space(\nameref{#1})\fi
\endgroup
}
\makeatother

\begin{document}
\section{Group Actions}

\begin{theorem}[Orbit-Stabiliser Theorem]
\label{thm:ost}
Let $G$ be a finite group acting on a finite set $X$. Then
$|G| = \mathop{\mathrm{Orb}}(x) \times \mathop{\mathrm{Stab}}(x).$
\end{theorem}

\begin{example}
Let $G$ act on $X$, where $|G| = 55$ and $|X| = 18$. Show that the action has at least two fixed points.

By the \nameref{thm:ost}, ...
\end{example}

\end{document}


This code provides the following output:

Is there a way I can change the label so that the text is in lower-case? I tried using \MakeLowercase{}, but this didn't work. And is there a way I can modify the label in general? If I have something like "Cauchy's Theorem" for example, I'd like to have it appear as "Cauchy's theorem" in text, with a lower-case t.

I appreciate any assistance.

• cref macros are not expandable, in most cases – user31729 Nov 15 '17 at 12:56
• Actually, you're asking about a lowercase nameref. – user31729 Nov 15 '17 at 13:14
• You should have \DeclareMathOperator{\Orb}{Orb} and \DeclareMathOperator{\Stab}{Stab}, with \lvert G\rvert=\lvert\Orb(x)\rvert\times\lvert\Stab(x)\rvert rather than the awkward \mathop construction (requires amsmath, of course). – egreg Dec 28 '17 at 22:30
• @egreg That's what I do in the actual document, I only switch to \mathop for the MWE. Thanks though. – Luke Collins Dec 28 '17 at 22:40

You're going to have to tell LaTeX explicitly how you want the theorem name capitalised. There's no way to automatically detect which words are proper nouns like "Cauchy" that should stay capitalised.

Referring to things by name falls more within the remit of the nameref package. Cleveref is concerned with referring to things by their label. But since you'll have to specify the correctly-capitalised theorem name explicitly anyway, there is a way to do it with just cleveref without much extra effort:

\documentclass{article}
\usepackage{amsthm, parskip, hyperref, cleveref}

% Theorems
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}

\begin{document}
\section{Group Actions}

\begin{theorem}[Orbit-Stabiliser Theorem]
\label{thm:ostnum}
\label[ost]{thm:ostname}
\crefformat{ost}{#2orbit-stabiliser theorem#3}
\Crefformat{ost}{#2Orbit-stabiliser theorem#3}
Let $G$ be a finite group acting on a finite set $X$. Then
$|G| = \mathop{\mathrm{Orb}}(x) \times \mathop{\mathrm{Stab}}(x).$
\end{theorem}

\begin{example}
Let $G$ act on $X$, where $|G| = 55$ and $|X| = 18$. Show that the action has at least two fixed points.

By the \cref{thm:ostname}, which is given in \cref{thm:ostnum}, \dots
\end{example}

\end{document}


This works by defining a new cross-reference type ost, and telling cleveref to format references to it using the correctly capitalised theorem name. The additional thm:ostnum label is just to demonstrate how you can still refer to the theorem by its label too, if desired.

If you want to do this often, it could be tidied up a bit by bundling the \label, \crefformat, \Crefformat and maybe even the theorem definition into a new macro or environment.

• This is exactly what I was looking for! Thanks @Toby Cubitt – Luke Collins Nov 16 '17 at 11:26
• A minor thing to point out: assuming you wanted to render the output "By the orbit-stabiliser theorem, which is given in theorem 1.1", I think you need to put \label{thm:ostnum} before the \crefformat{}{} lines. – Luke Collins Nov 16 '17 at 11:28
• @Luke Collins Indeed - edited my answer to fix this. Thanks! It's really that the unadorned \label{...} must come before the the \label[ost]{...}. The \crefformat's can go anywhere before the first reference to thm:ostname. Putting them in the preamble would be safest, but more confusing. – Toby Cubitt Nov 16 '17 at 13:50
• This is by no means a perfect solution. E.g. the need for the \crefformat's to come before the first reference, and the ordering requirements for the \label's. A better solution would be for the nameref package to allow multiple variants of theorem (or section) names to be specified for different purposes - one for the title, one for references in-text. (Cf. \crefname/format and \Crefname/format.) But as far as I know that would require enhancing the nameref package. – Toby Cubitt Nov 16 '17 at 14:10

I've written the crossreftools package some weeks ago (it's available on CTAN, TeXLive and MikTeX, current version is 0.4), which provides expandable extraction of the cross-reference information stored by hyperref and cleveref.

\MakeLowercase won't work with \nameref, since \nameref isn't expandable, so the name information has to be extracted first, then apply \MakeLowercase.

The name reference is done with \crtrefname, but this would not provide a hyperlink, which would make the whole issue unexpandable again. The hyper anchor can be extracted with \crtrefanchor, together with a \hyperlink wrapped in a new command, say \lowernameref this will give the lower case title.

Please note, that \lowernameref is unexpandable of course.

\documentclass{article}
\usepackage{amsthm, parskip, hyperref, cleveref}

\usepackage{crossreftools}

% Theorems
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}

% Solution from https://tex.stackexchange.com/a/109864/78913
\makeatletter
\newcommand{\myref}[1]{\cref{#1}\mynameref{#1}{\csname r@#1\endcsname}}
\newcommand{\Myref}[1]{\Cref{#1}\mynameref{#1}{\csname r@#1\endcsname}}

\def\mynameref#1#2{%
\begingroup
\edef\@mytxt{#2}%
\edef\@mytst{\expandafter\@thirdoffive\@mytxt}%
\ifx\@mytst\empty\else
\space(\nameref{#1})\fi
\endgroup
}
\makeatother

\begin{document}
\section{Group Actions}

\begin{theorem}[Orbit-Stabiliser Theorem]
\label{thm:ost}
Let $G$ be a finite group acting on a finite set $X$. Then
$|G| = \mathop{\mathrm{Orb}}(x) \times \mathop{\mathrm{Stab}}(x).$
\end{theorem}

\begin{example}
Let $G$ act on $X$, where $|G| = 55$ and $|X| = 18$. Show that the action has at least two fixed points.

By the \lowernameref{thm:ost}, ...
\end{example}

\end{document}


• Thanks! Any idea how something like 'by Cauchy's theorem' can be achieved though? – Luke Collins Nov 15 '17 at 13:53
• @LukeCollins: Sorry, not yet. TeX/LaTeX is bad in detecting lower/upper case – user31729 Nov 15 '17 at 14:13
• Load textcase, use \MakeTextLowercase instead of \MakeLowercase and input \begin{theorem}[\NoCaseChange{Cauchy}] – egreg Dec 28 '17 at 22:27