通过[名称]引用类似定理的环境
我正在使用 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 解决方案,但似乎并不令人满意且笨重。
关于执行此操作的简单方法有什么建议吗? (即使是更简单的 zref 解决方案也很好)目前,我刚刚为每个条件定义了一个 \newcommand
并使用它,而不是引用条件本身。这在语义上是不透明的,而且令人不满意......
(编辑:我给 ntheorem 的一位作者 Wolfgang May 发了电子邮件,他解释说在 ntheorem 中实际上没有办法做到这一点,因为 [name] 选项没有被记录。)
(编辑:这不是评论中建议的欺骗,因为我有兴趣通过其可选名称命令引用环境,而不是引用它所在的部分/章节。)
I am using ntheorem to typeset a set of conditions. In my preamble I have:
\theoremstyle{empty}
\newtheorem{Condtion}{Condtion}
When I want to typeset a condition, I write:
\begin{Condtion}[name]
\label{cnd:nm}
foo foo foo
\end{Condition}
The name appears boldface on the same line as the start of the text of the condition, with no number or anything. Perfect.
What I want to do now is refer to the condition by some variant of the \ref
command,
\ref calls the number [which is not displayed anywhere else]
\thref writes "Condition n" for the nth condition
\nameref writes the name of the SECTION of the label.
a zref solution was suggested here, but seems unsatisfactory and unwieldly.
Any suggestions on a simple way to do this? (Even a simpler zref solution would be nice) At the moment I've just defined a \newcommand
for each condition and use that rather than citing the condition itself. This is semantically opaque and just unsatisfying...
(edit: I emailed one author of ntheorem, Wolfgang May, and he explained that there isn't really a way to do this within ntheorem, since the [name] option isn't recorded.)
(edit: This isn't a dupe as suggested in the comment, since I'm interested in referencing an environment by its optional name command, not referencing the section/chapter it sits in.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为以下内容可能会满足您的要求。
然后您将其用作
不幸的是,它只能通过名称引用,尽管我想您也可以使用普通的
\label
(当然使用不同的密钥)。对于
amsthm
环境,您可以使用I think the following may do what you want.
Then you use it as
Unfortunately, it can then only be referenced by name, though I suppose you could use a normal
\label
as well (with a different key of course).For the
amsthm
environments you can use这是一个不久前已修复的 nameref bug:
http://web.archiveorange.com/archive/v/9uUx5EuqoCGynIvx3om7#lY2MJxvge2oMgOi
不幸的是,一些 Linux 发行版(例如 Debian/Ubuntu)附带了非常旧的软件包版本(Ubuntu 11.04 仍然附带 TeX Live 2009,尽管最新版本是 TeX Live 2011)。如果您使用这样的 Linux 发行版,请停止使用发行版中的 Tex Live 软件包,并直接从此处安装 TeX Live:http://www.tug.org/texlive/ 然后您可以使用 tlmgr(一个非常酷的工具,不随 Debian/Ubuntu 一起提供)更新软件包。
This is a nameref bug that was already fixed a while ago:
http://web.archiveorange.com/archive/v/9uUx5EuqoCGynIvx3om7#lY2MJxvge2oMgOi
Unfortunately some Linux distros like Debian/Ubuntu ship with horribly old versions of the packages (Ubuntu 11.04 still ships TeX Live 2009 although the latest version is TeX Live 2011). If you're using such a Linux distro stop using the Tex Live package in the distro, and install TeX Live directly from here: http://www.tug.org/texlive/ You can then update packages using tlmgr (a really cool tool that doesn't ship with Debian/Ubuntu).
您可能需要查看已分发的
nameref
包与hyperref
。nameref
文档中有一个关于引用“stuff”的部分。有关引用的更多信息,请参阅 TeX FAQ 项目 按名称引用事物。
you may want to check out the
nameref
package, which is distributed withhyperref
. There is a section in thenameref
documentation about referencing "stuff".More on referencing can be found in the TeX FAQ item Referring to things by their name.
我想其他人可能会发现这很有帮助。即使我安装了更新的
hyperref
包,我也必须在\usepackage{hyperref}
之后显式调用\usepackage{nameref}
才能从\nameref
获取正确的行为。如果没有显式调用\usepackage{nameref}
,\nameref
可以工作,但会出现此线程中讨论的错误。更新:对于最小示例(我检查过),不需要此解决方法。我不知道我的样式文件中是否有更复杂的事情,但如果我发现一些东西,我会更新它。这可能仍然可以帮助遇到与我相同问题的人。
I thought others might find this helpful. Even though I had an updated
hyperref
package installed, I had to explicitly call\usepackage{nameref}
after\usepackage{hyperref}
in order to get the correct behavior from\nameref
. Without the explicit call to\usepackage{nameref}
,\nameref
worked, but exhibited the bug discussed in this thread.Update: this workaround isn't requred for a minimal example (which I checked). I don't know if there's something more complicated going on in my style files, but I'll update this if I find something. This may still help someone running into the same issue I was.