问:为什么这会导致无限循环?(完整代码如下。)没有let
按照我的想法做?
\let \oldchapter \chapter
\renewcommand \chapter [2] {\oldchapter{#2}}
使用报告作为基类,我想要一些 listoffigures 类型的列表(例如 \listoftables、\listoftheorems)作为编号附录;例如“附录 A:定理列表“为此,我有一个环境,,TocLikeListInternal
它暂时重新定义了\chapter
。(这似乎是支持各种包列表的最可靠和最直接的选项。)
完整内容:
\ExplSyntaxOn
\cs_new:Npn \desert__listof_fix:nn #1#2
{
\let \oldchapter \chapter
\renewcommand \addcontentsline [3] {}
\bool_if:nTF {#1} % want numbered?
{ \renewcommand \chapter [2] {\oldchapter{#2}} } % always number
{ \renewcommand \chapter [2] {\oldchapter*{#2}} } % never number
\bool_if:nF {#2} % want in TOC?
{ \renewcommand \addcontentsline [3] {} }
}
\ProvideDocumentEnvironment {TocLikeListInternal} { m m }
{ \desert__listof_fix:nn{#1}{#2} }
{}
\NewDocumentCommand \ShowListOfTheorems { s t! m }
{
\begin{TocLikeListInternal}{#1}{#2}
\listoftheorems[#3]
\end{TocLikeListInternal}
}