In the source below I have a namedtheorem environment which, when used, displays, instead of the usual "Theorem", the value of the key name in its optional argument.
That name has initial letters capitalized (except conjunctions and prepositions), as in any title.
However, when referring to the theorem in text, I want to lowercase all those initial letters — except proper nouns such as "Euler" that should of course remain uppercase.
How can this be done?
\documentclass{article}
\usepackage[left=0.75in,right=0.75in]{geometry}
\usepackage{textcase}
\usepackage{amsthm}
\usepackage{thmtools}
\swapnumbers
\makeatletter
\declaretheoremstyle[
headfont= \bfseries,
headpunct={\bfseries.},
postheadspace=0.5em,
notefont=\bfseries,
headformat=\NAME\NUMBER\let\thmt@space\@empty\NOTE,
bodyfont=\mdseries\itshape,
spaceabove=12pt,spacebelow=12pt,
]{thmstyle}
\declaretheoremstyle[
headfont=\bfseries,
notefont=\bfseries, notebraces={}{},
headformat=\NUMBER\let\thmt@space\@empty\NOTE,
bodyfont=\mdseries\itshape,
spaceabove=12pt,spacebelow=12pt,
]{namedthmstyle}
\makeatother
\theoremstyle{thmstyle}
\declaretheorem[name=Theorem,numberwithin=section]{theorem}
\declaretheorem[
style=namedthmstyle,name=Theorem,title = {},numberlike=theorem
]{namedtheorem}
\usepackage[pdftex]{hyperref}
\hypersetup{colorlinks,linkcolor=red}
\usepackage[nameinlink,noabbrev,capitalize]{cleveref}
\usepackage{crossreftools}
\begin{document}
\section{The theorems}
\begin{theorem}[equalities of \MakeUppercase{E}uclid]
\label{thm:prelim}
$a = b$ and $b = c$
\end{theorem}
\begin{namedtheorem}[name=Fundamental Theorem of \NoCaseChange{Euler}]
\label{thm:euler}
$a = c$.
\end{namedtheorem}
\bigskip
\emph{Original text of name:} Fundamental Theorem of Euler
\bigskip
\emph{Desired modification:} fundamental theorem of Euler
\bigskip
\emph{Attempts:}
\begin{itemize}
\item
\MakeTextLowercase{Fundamental Theorem of \NoCaseChange{Euler}} ---\verb!\MakeTextLowercase{Fundamental Theorem of \NoCaseChange{Euler}}!\\
works OK directly.
\item
\MakeTextLowercase{\nameref*{thm:euler}} --- \verb!\MakeTextLowercase{\nameref*{thm:euler}}! \\
of no use.
\item
\crtnameref*{thm:euler} --- \verb!\crtnameref*{thm:euler}!\\
try starting here now.
\item
%\MakeTextLowercase{\crtnameref*{thm:euler}} ---
\verb!\MakeTextLowercase{\crtnameref*{thm:euler}}! causes error:
\begin{verbatim}
./try.tex:84: Missing \endcsname inserted.
<to be read again>
\relax
l.84 \MakeTextLowercase{\crtnameref*{thm:euler}}
? x
\end{verbatim}
\end{itemize}
\end{document}
In the source above, one line is commented out because it causes an error preventing output.
Unsatisfactory method: add \crefformat labels
As shown in https://tex.stackexchange.com/a/401600/13492, including immediately after \label{thm:euler}
\label[fte]{thm:euler}
\crefformat{fte}{#2fundamental theorem of Euler#3}
and then using `\cref*{thm:euler} does give the desired "fundamental theorem of Euler".
However:
- it fails if the
\crefcomes before the environment with the labels; and - when there are quite a number of such
namedtheoremenviroments, it does require a lot of extra labeling.
A solution: use \MakeTextLowercase together with commands from crossreftools
This modifies the preamble code shown in https://tex.stackexchange.com/a/401438/13492, by:
- adopting the comment there by @egreg to use
\MakeTextLowercaseinstead of\MakeLowercase; and - omitting the phrase
\hyperlink{\crtrefanchor{#1}}from the definition of\lowernamerefthere.
Namely:
\makeatletter
\newcommand{\lowernameref}[1]{{\MakeTextLowercase{\crtrefname{#1}}}}
\def\mynameref#1#2{%
\begingroup
\edef\@mytxt{#2}%
\edef\@mytst{\expandafter\@thirdoffive\@mytxt}%
\ifx\@mytst\empty\else
\space(\nameref{#1})\fi
\endgroup
}
\makeatother
Then in the body of the document,
\lowernameref{thm:euler}
produces the desired output:
fundamental theorem of Euler

