答案1
假设你正在使用book
类。它具有以下定义:
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\protect\numberline{\thechapter}#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
让宏\appendix
重新定义它,只将章节名称添加到目录中,但不添加其编号:
\documentclass{book}
\makeatletter
\def\appendix{%
\def\@chapter[##1]##2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\fi
\addcontentsline{toc}{chapter}{##1}%
\else
\addcontentsline{toc}{chapter}{##1}%
\fi
\chaptermark{##1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{##2}]%
\else
\@makechapterhead{##2}%
\@afterheading
\fi}%
\setcounter{chapter}{0}%
\renewcommand{\thechapter}{\Alph{chapter}}%
\renewcommand{\chaptername}{\appendixname}}
\makeatother
\begin{document}
\tableofcontents
\chapter{First}
\section{second}
\appendix
\chapter{Appendix}
\section{Aaaa}
\end{document}