我正在使用 ntheorem 来排版一组条件。在我的序言中,我有:
\theoremstyle{empty}
\newtheorem{Condtion}{Condtion}
当我想排版一个条件时,我写:
\begin{Condtion}[name]
\label{cnd:nm}
foo foo foo
\end{Condition}
该名称与条件文本的开头在同一行上显示为粗体,没有数字或任何内容。完美的。
我现在想做的是通过
\ref
的一些变体来引用条件。命令,\ref 调用号码 [不在其他任何地方显示]
\thref 为第 n 个条件写入“条件 n”
\nameref 写入标签的 SECTION 名称。
建议使用 zref 解决方案 here ,但似乎并不令人满意和笨拙。
有关执行此操作的简单方法的任何建议? (即使是更简单的 zref 解决方案也会很好)目前我刚刚定义了一个
\newcommand
对于每个条件并使用它而不是引用条件本身。这在语义上是不透明的,只是不令人满意......(编辑:我给 ntheorem 的一位作者 Wolfgang May 发了电子邮件,他解释说在 ntheorem 中没有真正的方法可以做到这一点,因为没有记录 [name] 选项。)
(编辑:这不是评论中建议的欺骗,因为我有兴趣通过其可选名称命令引用环境,而不是引用它所在的部分/章节。)
最佳答案
我认为以下可能会做你想做的。
\makeatletter
\def\namedlabel#1#2{\begingroup
\def\@currentlabel{#2}%
\label{#1}\endgroup
}
\makeatother
然后你用它作为
\begin{theorem}
\namedlabel{thm:seamus}{Seamus' Theorem}
Here is Seamus' Theorem.
\end{theorem}
Here I reference~\ref{thm:seamus}.
不幸的是,它只能通过名称引用,尽管我想您可以使用普通的
\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
关于latex - 通过其 [名称] 引用类似定理的环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2767389/