如何在目錄中的附錄標題下形成附錄

如何在目錄中的附錄標題下形成附錄

我希望每個附錄都位於目錄中的“附錄”標題下。這是我的 MWE:

\documentclass[12pt,oneside]{book}
\usepackage{titletoc}
\usepackage{appendix}

\begin{document}
   \tableofcontents
   \chapter{CHAPTERR}
   \section{Sectionn}
    Some stuff.
   \chapter{CHAPTERRR}
   \section{Sectionnn}
    Other stuff.
\begin{appendices}
   \chapter{TABLESS}
   \section{DATA}
   \chapter{FIGURESS}
   \section{CODE}
\end{appendices}

\end{document}

我的輸出是在此輸入影像描述

但我想要這個:在此輸入影像描述

答案1

我認為您可以使用命令 \addcontentline{toc} 在目錄中的「部分」層級新增一行。只有當您有一個接受“部分”環境的文件時,它才起作用,這裡就是這種情況。

這是工作:

\documentclass[12pt,oneside]{book}
\usepackage{titletoc}
\usepackage{appendix}

\begin{document}
   \tableofcontents
   \chapter{CHAPTERR}
   \section{Sectionn}
    Some stuff.
   \chapter{CHAPTERRR}
   \section{Sectionnn}
    Other stuff.

    \addcontentsline{toc}{part}{Appendix}%
    \appendix

   \chapter{TABLESS}
   \section{DATA}
   \chapter{FIGURESS}
   \section{CODE}

\end{document}

答案2

對於“附錄”標題,自從您加載後appendix,您就可以[toc]選擇。

另外,如果您不想要目錄中的附錄部分,您可以在環境開頭更改目錄深度appendices

\documentclass[12pt,oneside]{book}
\usepackage{titletoc}
\usepackage[toc]{appendix}
\usepackage{xpatch}
\xpatchcmd{\addappheadtotoc}{%
\appendixtocname}{%
\hspace{1.32em}\MakeUppercase{\appendixtocname}}{}{}

\begin{document}

   \tableofcontents
   \chapter{CHAPTERR}
   \section{Sectionn}
    Some stuff.
   \chapter{CHAPTERRR}
   \section{Sectionnn}
    Other stuff.
\begin{appendices}
\addtocontents{toc}{\setcounter{tocdepth}{0}}
   \chapter{TABLESS}
   \section{DATA}
   \chapter{FIGURESS}
   \section{CODE}
\end{appendices}

\end{document} 

在此輸入影像描述

相關內容