將附錄加入目錄時遇到問題

將附錄加入目錄時遇到問題

我正在嘗試將附錄添加到我的論文中,並使用了以下命令:

\begin{appendices}
\chapter{Performance Tables of ABCD}
\input{tab1}
\input{tab2}
\input{tab3}
\input{tab4}
\input{realworld}
\end{appendices}

我使用了以下套件:

\usepackage[titletoc]{appendix}

問題是它顯示以下內容:

在此輸入影像描述

我怎麼才能讓它只顯示附錄A?抱歉,如果這是一個愚蠢的問題。

答案1

我假設你您的序言中已經有一些關於目錄中章節設定方式的定義。因此,以下列出的一些細微調整將允許您關閉Chapter附錄的插入:

在此輸入影像描述

\documentclass{report}

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\newcommand{\frontmatternumberline}{%
  \renewcommand{\numberline}[1]{\@chapapp~##1\hfill\mbox{}\par\nobreak}}
\newcommand{\appendixnumberline}{%
  \renewcommand{\numberline}[1]{##1\hfill\mbox{}\par\nobreak}}
\patchcmd{\l@chapter}% <cmd>
  {#1}% <search>
  {\frontmatternumberline #1}% <replace>
  {}{}% <success><failure>
\AtBeginEnvironment{appendices}{% Do the following when you hit \begin{appendices}
  \addtocontents{toc}{\string\let\string\frontmatternumberline\string\appendixnumberline}}
\makeatother

\usepackage[titletoc]{appendix}

\begin{document}

\tableofcontents

\chapter{Introduction}

\chapter{Preliminaries}
\section{Problem definition}
\section{Genetic algorithms}
\section{Ant algorithms}
\section{Previous work}

\begin{appendices}
\chapter{An appendix}
\section{First appendix}
\section{Second appendix}
\section{Last appendix}
\end{appendices}

\end{document}

使用\string- 與本例類似\protect- 是為了確保 ToC 中的巨集插入不會擴展。

答案2

\chapter*章不應出現在目錄中。

\begin{appendices}
\chapter*{Performance Tables of ABCD}
...
\end{appendices}

相關內容