通过其[名称]引用类似定理的环境

Sea*_*mus 7 latex

我正在使用n定理来排版一组条件.在我的序言中,我有:

\theoremstyle{empty}
\newtheorem{Condtion}{Condtion}
Run Code Online (Sandbox Code Playgroud)

当我想排版一个条件时,我写道:

\begin{Condtion}[name]
\label{cnd:nm}
foo foo foo
\end{Condition}
Run Code Online (Sandbox Code Playgroud)

名称在条件文本开头的同一行显示粗体,没有数字或任何内容.完善.

我现在要做的是通过\ref命令的某个变体引用条件,\ ref调用数字[在其他地方不显示]\thref为第n个条件写入"条件n"\nameref写入SECTION的名称标签.这里提出了一个zref解决方案,但似乎并不令人满意和笨拙.

有关简单方法的任何建议吗?(即使是更简单的zref解决方案也会很好)目前我已经\newcommand为每个条件定义了一个并使用它而不是引用条件本身.这在语义上是不透明的,只是不满意......

(编辑:我通过电子邮件发送了一位n定理的作者Wolfgang May,他解释说在n定理中没有办法实现这一点,因为没有记录[name]选项.)

(编辑:这不是评论中建议的欺骗,因为我有兴趣通过其可选的name命令引用环境,而不是引用它所在的部分/章节.)

Iva*_*rus 10

我认为以下可能会做你想要的.

\makeatletter
\def\namedlabel#1#2{\begingroup
   \def\@currentlabel{#2}%
   \label{#1}\endgroup
}
\makeatother
Run Code Online (Sandbox Code Playgroud)

然后你用它作为

\begin{theorem}
  \namedlabel{thm:seamus}{Seamus' Theorem}
  Here is Seamus' Theorem.
\end{theorem}

Here I reference~\ref{thm:seamus}.
Run Code Online (Sandbox Code Playgroud)

不幸的是,它只能通过名称引用,但我想你也可以使用普通\label(当然使用不同的键).

对于amsthm您可以使用的环境

\makeatletter
\let\@old@begintheorem=\@begintheorem
\def\@begintheorem#1#2[#3]{%
  \gdef\@thm@name{#3}%
  \@old@begintheorem{#1}{#2}[#3]%
}
\def\namedthmlabel#1{\begingroup
   \edef\@currentlabel{\@thm@name}%
   \label{#1}\endgroup
}
\makeatother
Run Code Online (Sandbox Code Playgroud)