如何在回忆录类上设置两种类型的附录?

如何在回忆录类上设置两种类型的附录?

我需要设置两种类型的附录:附录和附件

它们必须在章节标题中显示为“附录 A - 附录 A 的标题”等,以及“附件 A - 附件 A 的标题”等(我设法用 . 来实现\renewcommand{\appendixname}{Annex}) 。

我还需要它们以这种方式出现在目录中......但\renewcommand{\cftappendixname}{Annex}在全球范围内有效......

答案1

我的浏览器不喜欢这个网站上的表格,所以我会在这里回答。

\cftinserthook{toc}{AAA}

在文档中放置命令时将钩子命令插入到 toc 文件中。相应的钩子代码无需定义,否则将被忽略。

在我们的例子中,我们可以简单地将序言中的钩子定义为

\cftinsertcode{AAA}{\renewcommand*{\cftappendixname}{Annex}}

这样做的好处是,人们不必担心\protect

答案2

这种事情通常很尴尬,因为你需要在\tableofcontents工作时进行更改。一个肮脏的伎俩是把更改附录名称的命令放在目录使用的里面文件.toc

\documentclass{memoir}
%
\makeatletter
\newcommand\@switch[1]{ \@writefile{toc}{\renewcommand*{\cftappendixname}{#1 \space}} }
\newcommand{\switchchapname}[1]{ \protected@write \@auxout {}{\string\@switch{#1} }}
\makeatother
%
\begin{document}
\renewcommand*{\cftappendixname}{Appendix \space}
\tableofcontents
\chapter{A chapter}
text.
\appendix
\chapter{An appendix}
more text.
\switchchapname{Annex}% Corrected from \switchapname → \switchchapname
\renewcommand{\appendixname}{Annex}
\chapter{An annex}
Yet more text.
\switchchapname{Another name}% Corrected from \switchapname → \switchchapname
\renewcommand{\appendixname}{Another name}
\chapter{Something else}
Yet more text.
\end{document}

相关内容