我想在同一个(部分)计数器上对所有定理和推论进行计数。但是当我这样做的时候,cleveref把它们都命名为“定理”。下面是一个最小的例子:
\documentclass{amsart}
\usepackage{amsthm, cleveref}
%\crefname{theorem}{theorem}{theorems}
%\crefname{corollary}{corollary}{corollaries}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\begin{document}
\section{Section title}
\begin{theorem}\label{thm:test}
Here is the theorem.
\end{theorem}
\begin{corollary}\label{cor:test}
Here is the corollary.
\end{corollary}
The theorem reference is given by \cref{thm:test} and the corollary reference is given by \cref{cor:test}.
\end{document}这里的推论参考是“定理1.2”。即使在显式声明crefname时,此问题仍然存在。
有什么建议吗?
发布于 2012-01-04 19:32:16
如果您希望cleveref区分使用相同计数器的不同类定理环境,则需要加载n定理或amsthm包。这些包存储了有关cleveref使用的类似定理的环境的附加信息。请注意,它们必须在cleveref之前加载。
与在\label中使用一个可选参数相比,使用ntheorem (现在已经通过hyperref选项兼容hyperref很长一段时间了)或amsthm (也兼容hyperref)和cleveref是一个更好的解决方案。而且也不需要退回到\thref。如果你正在使用ntheorem,那么\cref将做\thref做的所有事情,甚至更多(多引用,定制格式,等等)。实际上,当使用cref选项加载ntheorem时,cleveref会将\cref重新定义为\cref的别名。
(有一个技巧-在cleveref手册中也有描述-使用aliascnt包来区分类似于定理的环境,而不是There或amsthm。但这需要更多的工作,坦率地说,当一个简单的\usepackage{n定理}或\usepackage{amsthm}就可以完美地完成工作时,为什么还要费心呢?)
发布于 2011-08-06 04:39:30
好的,这里有一个变通方法。
指定要在可选标签参数中显示的名称,即:
\begin{corollary}\label[corollary]{cor:test}
Here is the corollary.
\end{corollary}这提供了所需的输出,同时将环境名称保留在相同的位置(尽管写入了两次)。
发布于 2011-07-20 20:35:12
我看不出这有什么问题。我已经用你的脚本运行了
%\crefname{theorem}{theorem}{theorems}
%\crefname{corollary}{corollary}{corollaries}注释和未注释,我得到了预期的结果
'The theorem reference is given by theorem 1.1 and the corollary reference is
given by corollary 1.2.'也许你有一个过时的包。
如果您使用的是文章类,还要确保在amsthm (和hyperref)之后加载cleveref,因为这将导致您看到的错误
https://stackoverflow.com/questions/6499504
复制相似问题