将“章节、附录”字词添加到自动生成的索引中

将“章节、附录”字词添加到自动生成的索引中

你好,我想在索引中添加“章节:附录:等”字样...因为自动索引只显示章节编号,所以我找到了这个技巧

\usepackage{tocloft}
\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{25mm}

这可以正常工作,但是当存在附录时,索引中也会采用章节名称。

这是我的代码示例:

\documentclass[%
    a4paper,
    openright,
    12pt
]{book}

\usepackage[utf8]{inputenc} 
\usepackage[%
  top     = 25mm, bottom     = 25mm,
  outer   = 25mm, inner      = 25mm,
  headsep = 25mm, headheight = 12pt,
  marginparwidth = 15mm ]{geometry}

\usepackage{tocloft}
\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{25mm}


\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3} 

\begin{document}

\begin{titlepage}
\begin{center}
\begin{Huge}
\textsc{Title}
\end{Huge}
\end{center}
\end{titlepage}

\newpage
$\ $
\thispagestyle{empty}

\chapter*{}
\pagenumbering{Roman}
\begin{flushright}
\textit{Dedicated to my family}
\end{flushright}

\chapter*{Acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}
\markboth{Acknowledgements}{Acknowledgements}

Tank to all

\chapter*{Summary}
\addcontentsline{toc}{chapter}{Summary}
\markboth{Summary}{Summary}

the summary

\tableofcontents


\cleardoublepage
\addcontentsline{toc}{chapter}{Figure List}
\listoffigures

\cleardoublepage
\addcontentsline{toc}{chapter}{Table List}
\listoftables


\chapter{Introduction}\label{cap.introduccion}
\pagenumbering{arabic}
Bla Bla Bla
\section{Section}
Bla bla bla
\subsection{Subsection1}
Ble ble ble
\subsubsection{SubSubSection}
Bli bli bli


\chapter{the name of chapter 1}\label{cap.nudo}
Bla bla bla bla

\chapter{the name of chapter 2}\label{cap.desenlace}

Bla bla bla bla

\appendix
\chapter{the name of appendix 1}\label{aped.A}
Bla bla bla bla

\chapter{the name of appendix 2}\label{aped.B}
Bla bla bla bla

\cleardoublepage
\addcontentsline{toc}{chapter}{Bibliography}
\bibliographystyle{acm}
\bibliography{yyyy}

\end{document}

该指数的结果是

Acknowledgements III
Summary V
Figure List VII
Table List IX
Chapter 1: Introduction 1
1.1 Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Subsection1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1.1 SubSubSection . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2: the name of chapter 1 3
Chapter 3: the name of chapter 2 5
Chapter A: the name of appendix 1 7
Chapter B: the name of appendix 2 9
Bibliography

但我想要类似的东西

Acknowledgements III
Summary V
Figure List VII
Table List IX
Chapter 1: Introduction 1
1.1 Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Subsection1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1.1 SubSubSection . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2: the name of chapter 1 3
Chapter 3: the name of chapter 2 5
Appendix
Appendix A: the name of appendix 1 7
Appendix B: the name of appendix 2 9
Bibliography

答案1

您可以通过将章节编号前面的名称重置为\appendixname:来更改它。

\documentclass[%
    a4paper,
    openright,
    12pt
]{book}

\usepackage[utf8]{inputenc} 
\usepackage[%
  top     = 25mm, bottom     = 25mm,
  outer   = 25mm, inner      = 25mm,
  headsep = 25mm, headheight = 12pt,
  marginparwidth = 15mm ]{geometry}

\usepackage[titles]{tocloft}
\usepackage[nottoc]{tocbibind}
\usepackage{emptypage}

\renewcommand{\cftchappresnum}{\chaptername\ }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{30mm}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3} 

\begin{document}

\frontmatter\pagenumbering{Roman}% for uppercase Roman numerals

\begin{titlepage}
\begin{center}
\Huge
\textsc{Title}
\end{center}
\end{titlepage}

\begin{flushright}
\textit{Dedicated to my family}
\end{flushright}

\chapter{Acknowledgements}

Thanks to all

\chapter{Summary}

the summary

\tableofcontents

\listoffigures

\listoftables

\mainmatter

\chapter{Introduction}\label{cap.introduccion}
Bla Bla Bla
\section{Section}
Bla bla bla
\subsection{Subsection1}
Ble ble ble
\subsubsection{SubSubSection}
Bli bli bli


\chapter{the name of chapter 1}\label{cap.nudo}
Bla bla bla bla

\chapter{the name of chapter 2}\label{cap.desenlace}

Bla bla bla bla

\appendix
%%% change \cftchappresnum here!
\addtocontents{toc}{%
  \protect\renewcommand\protect\cftchappresnum{\appendixname\ }%
}

\chapter{the name of appendix 1}\label{aped.A}
Bla bla bla bla

\chapter{the name of appendix 2}\label{aped.B}
Bla bla bla bla

\bibliographystyle{acm}
\bibliography{xampl}

\end{document}

我还对你的代码做了一些修复。

  1. 除非有充分理由不这样做,否则请始终使用此titles选项tocloft

  2. 列表tocbibind和参考书目自动进入目录

  3. 加上emptypage空白页\cleardoublepage(这是隐含的\chapter)是完全空白的

  4. \Huge是一个命令而不是环境

  5. 当在时\frontmatter\chapter不产生数字

在此处输入图片描述

相关内容