1

So I've seen here that you can actually have a personnalized theorem environment name but I was wondering if there was a way to refer to it as is. I've chosen the solution

\documentclass{article}
\usepackage{amsthm}

\swapnumbers % optional, of course \newtheorem{thm}{Theorem}[section] % the main one \newtheorem{lemma}[thm]{Lemma} % other statement types \theoremstyle{plain} % just in case the style had changed \newcommand{\thistheoremname}{} \newtheorem{genericthm}[thm]{\thistheoremname} \newenvironment{namedthm}[1] {\renewcommand{\thistheoremname}{#1}% \begin{genericthm}} {\end{genericthm}}

\begin{document}

\section{Something}

A theorem

\begin{thm} $1+1=2$. \end{thm}

And a named theorem

\begin{namedthm}{Zorn's Lemma}[Zermelo]\label{zorn} All well-behaved ordered sets have maximal elements. \end{namedthm}

\end{document}

given by @egreg and I would like to have it say "by Zorn's Lemma" when I write

by \cref{zorn}.

I know that I don't technically need it since it shouldn't be something that changes but we never know. Maybe I could link it with a hyperlink hidden under the text "Zorn's lemma"?

Jolia
  • 61
  • 3

2 Answers2

0

Using the same trick as in https://tex.stackexchange.com/a/709531/36296

\documentclass{article}
\usepackage{amsthm}

\swapnumbers % optional, of course \newtheorem{thm}{Theorem}[section] % the main one \newtheorem{lemma}[thm]{Lemma} % other statement types \theoremstyle{plain} % just in case the style had changed \newcommand{\thistheoremname}{} \newtheorem{genericthm}[thm]{\thistheoremname}

\makeatletter \NewDocumentEnvironment{namedthm}{ m o } {\renewcommand{\thistheoremname}{#1}% \begin{genericthm}[#2] \def@currentlabelname{#1} } {\end{genericthm}} \makeatother
\usepackage{nameref}

\begin{document}

\section{Something}

A theorem

\begin{thm} $1+1=2$. \end{thm}

And a named theorem

\begin{namedthm}{Zorn's Lemma}[Zermelo]\label{zorn} All well-behaved ordered sets have maximal elements. \end{namedthm}

by \nameref{zorn}

\end{document}

enter image description here

0

I see no need to make a big distinction between named and unnamed (but numbered) theorem-like environments. In fact, depending on the context, I think it's useful to be able to refer to a given theorem-like environment either by its number or by its name. The latter may be achieved with the help of the hyperref package and its \hypertarget/\hyperlink pair of macros.

Of course, if you create unnumbered theorems, you can still use the \hypertarget/\hyperlink mechanism to create textual cross-references to them.

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{amsthm}
\usepackage[colorlinks,allcolors=blue]{hyperref}
\usepackage[capitalize,nameinlink]{cleveref}
\newtheorem{thm}{Theorem}

\begin{document}

\begin{thm}[\hypertarget{Zorn}{Zorn's Lemma}]\label{thm:zorn} All well-behaved ordered sets have maximal elements. \end{thm}

By \cref{thm:zorn}, \dots

By \hyperlink{Zorn}{Zorn's Lemma}, \dots

\end{document}

Mico
  • 506,678