通过名称引用定理

通过名称引用定理

所以我看到了这里你实际上可以有一个个性化的定理环境名称,但我想知道是否有办法按原样引用它。我选择了解决方案

\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}

由@egreg 给出,我想让它说“根据 Zorn 引理”当我写

by \cref{zorn}.

我知道从技术上讲我不需要它,因为它不应该是会改变的东西,但我们永远不知道。也许我可以用隐藏在文本“Zorn 引理”下的超链接来链接它?

答案1

使用与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}

在此处输入图片描述

答案2

我认为没有必要对命名和未命名(但有编号)的类定理环境进行大区分。事实上,根据上下文,我认为能够通过其编号或名称来引用给定的类定理环境很有用。后者可以借助包hyperref及其\hypertarget/\hyperlink宏对来实现。

当然,如果您创建未编号的定理,您仍然可以使用\hypertarget/\hyperlink机制为它们创建文本交叉引用。

在此处输入图片描述

\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}

相关内容