4

Hi I want to add the words Chapter: Appendix: etc... to the index, because the autoindex only shows the number of the chapter, i found this trick

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

this works ok but when exist appendix, the take the name of Chapter too in the index.

this is my code example:

\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}

the result of the index is

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

but i want something like

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
2
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – egreg
    Commented Jun 25, 2015 at 14:30
  • thanks for your interest I update my question with the full code examplI
    – efirvida
    Commented Jun 25, 2015 at 16:11

1 Answer 1

3

You can change the name in front of the chapter number by resetting it to \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}

I've made also some fixes to your code.

  1. Always use the titles option to tocloft unless you have good reasons not to

  2. With tocbibind the lists and the bibliography automatically go in the table of contents

  3. With emptypage blank pages added by \cleardoublepage (that's implicit in \chapter) are completely blank

  4. \Huge is a command and not an environment

  5. When in \frontmatter, \chapter does not produce numbers

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .