我正在使用 MikTeX 2.9。处理以下内容时:
\documentclass{article}
\usepackage{hyperref}
\usepackage[hyperref]{ntheorem}
\usepackage{aliascnt}
\newtheorem{lemma}{Lemma}
\newaliascnt{definition}{lemma}
\newtheorem{definition}[definition]{Definition}
\aliascntresetthe{definition}
\begin{document}
\begin{definition}
\label{def:first}
This is my definition.
\end{definition}
\begin{definition}[Alternative to \autoref{def:first}]
This is my second definition.
\end{definition}
\end{document}
我得到:
! TeX capacity exceeded, sorry [grouping levels=255].
\HyRef@autoref #1#2->\begingroup
\Hy@safe@activestrue \expandafter \HyRef@au...
l.31 ...ition}[Alternative to \autoref{def:first}]
如果我删除 autoref,一切都会好起来。使用amsthm
而不是 时不会发生这种情况ntheorem
。我做错了什么吗?这是一个ntheorem
错误吗?一个aliascnt
错误?
答案1
这似乎有效;问题似乎出在柜台的名字上
\documentclass{article}
\usepackage[hyperref]{ntheorem}
\usepackage{aliascnt}
\usepackage{hyperref}
\newcommand\definautorefname{Definition}
\newtheorem{lemma}{Lemma}
\newaliascnt{defin}{lemma}
\newtheorem{definition}[defin]{Definition}
\begin{document}
\begin{definition}
\label{def:first}
This is my definition.
\end{definition}
\begin{definition}[Alternative to \autoref{def:first}]
This is my second definition.
\end{definition}
\end{document}
答案2
好吧,至少我可以为此获得一个很好的宏:
\makeatletter
\def\newaliasedtheorem#1[#2]#3{%
\newaliascnt{#1@alt}{#2}
\newtheorem{#1}[#1@alt]{#3}
\expandafter\newcommand\csname #1@altname\endcsname{#3}
}
\makeatother
使用它来代替 \newtheorem
,即而不是:
\newtheorem{mynewenv}[existingcounter]{MyNewEnvName}
做
\newaliasedtheorem{mynewenv}[existingcounter]{MyNewEnvName}