在新页面中单独列出附录

在新页面中单独列出附录

我需要在新页面中获取单独的附录列表,但出现错误

Undefined control sequence

我的代码是

\documentclass[12pt,a4paper,oneside]{report}
\usepackage[titletoc]{appendix}
\usepackage{tocloft}
\begin{document}

\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}
\tableofcontents
\newpage

\listofappendices

\newpage

\chapter{a1}
aaaaaaaaaaaaaaaaaa
\chapter{b1}
bbbbbbbbbbbbbbbbbbbb

\addcontentsline{toc}{chapter}{APPENDICES}
\begin{appendices}
\chapter{MY}
ccccccccccccccccccccccccccc
\chapter{DFG}
dddddddddddddddd
\end{appendices}

\end{document}

答案1

没有环境appendices。有一个命令appendix介绍附录。

要获取附录列表,您需要一个新的辅助文件。在下面的示例中,新的辅助文件的扩展名为toa(有能力的oFA附录)。下一步,您必须声明附录的所有条目都写入新文件。因此,我使用以下包xpatch

\listfiles
\documentclass[12pt,a4paper,oneside]{report}
\usepackage[titletoc]{appendix}
\usepackage{tocloft}
\usepackage{xpatch}
\makeatletter
\newcommand\listofappendixname{Table of \appendixname}

\newcommand\listofappendices{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listofappendixname
        \@mkboth{%
           \MakeUppercase\listofappendixname}{\MakeUppercase\listofappendixname}}%
    \@starttoc{toa}%
    \if@restonecol\twocolumn\fi
    }
\g@addto@macro\appendix{%
  \addcontentsline{toc}{chapter}{\appendixname}%
  \xpatchcmd{\@part}{\addcontentsline{toc}}{\addcontentsline{toa}}{}{}%
  \xpatchcmd{\@part}{\addcontentsline{toc}}{\addcontentsline{toa}}{}{}%
  \xpatchcmd{\@chapter}{\addcontentsline{toc}}{\addcontentsline{toa}}{}{}%
  \xpatchcmd{\@chapter}{\addcontentsline{toc}}{\addcontentsline{toa}}{}{}%
  \xpatchcmd{\@sect}{\addcontentsline{toc}}{\addcontentsline{toa}}{}{}%
  \xpatchcmd{\@sect}{\addcontentsline{toc}}{\addcontentsline{toa}}{}{}%
}
\makeatother
\begin{document}


\tableofcontents


\listofappendices

\newpage

\chapter{a1}
aaaaaaaaaaaaaaaaaa
\chapter{b1}
bbbbbbbbbbbbbbbbbbbb


\appendix

\chapter{MY}
ccccccccccccccccccccccccccc
\chapter{DFG}
dddddddddddddddd


\end{document}

相关内容