我想重新定义一个价值观在运行时。更准确地说,我正在创建自己的环境,并且在序言中我想更改一个值,然后将其重新设置。
\newenvironment{reptheorem}[1]%
{%
\makeatletter%
\def\@thmcounterend{new}%In this environment, @thmcounterend has a new value
\makeatother%
}%
{%
\makeatletter%
\def\@thmcounterend{old}%We reset @thmcounterend to its previous value.
\makeatother%
}
显然,这段代码不起作用,因为 \def 不是在创建环境时执行的,而是在之后执行的。
任何想法?
答案1
\makeatletter
并且\makeatother
给出得太晚了。类别代码在环境定义时非常重要,当\@thmcounterend
被标记时:
\makeatletter
\newenvironment{reptheorem}[1]{%
\def\@thmcounterend{new}%
}{%
\def\@thmcounterend{old}%
}
\makeatother