At here Adding the word "Chap" before the chapters numbers in the TOC
the word Chapter
added in \documentclass{book}
. Now I want to use them in \documentclass{report}
. How can I do that?
-
I don't understand the error. Can you please mention the code? right now in my thesis, \section are used for every chapter which displays chapter like 1 introduction, 2 literature. I'm using this \documentclass[12pt, chapterprefix]{article} \usepackage[a4paper, margin=20mm]{geometry}?– Sajed ahmadMar 13 at 4:44
2 Answers
Here's the modification for the report
class (basically, it's the same code but suppressing the conditional test for the \frontmatter
); I defined two commands \AddChap
and \SuppChap
to activate (deactivate, resp.) the addition:
\documentclass{report}
\makeatletter
\let\orig@chapter\@chapter
\newcommand\SuppChap{%
\let\@chapter\orig@chapter}
\newcommand\AddChap{%
\def\@chapter[##1]##2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{Chap~\protect\numberline{\thechapter}##1}%
\else
\addcontentsline{toc}{chapter}{##1}%
\fi
\chaptermark{##1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{##2}]%
\else
\@makechapterhead{##2}%
\@afterheading
\fi}%
}
\makeatother
\begin{document}
\tableofcontents
\chapter{Acknowledgements}
\AddChap
\chapter{Test Chapter One}
\chapter{Test Chapter Two}
\SuppChap
\appendix
\chapter{Test Appendix One}
\end{document}
-
I am a Vietnamese. If I use
\usepackage[utf8]{vietnam}
. Can I repair the "Chap" into the "Chương" or "Chuong"? Feb 12, 2014 at 16:03 -
A much simpler solution with the tocloft
package.
\documentclass{report}
\usepackage{tocloft}
\newlength\mylength
\renewcommand\cftchappresnum{Chap~}
\settowidth\mylength{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}
\begin{document}
\tableofcontents
\chapter{Intro}
\chapter{Test}
\end{document}
Output (ToC):
EDIT
If you want to add the word "Appendix" instead of "Chap" for your appendices, you can load the package etoolbox
and add the following lines in your preamble:
\apptocmd{\appendix}
{\addtocontents{toc}{%
\protect\addtolength\protect\cftchapnumwidth{-\mylength}%
\protect\renewcommand{\protect\cftchappresnum}{Appendix~}%
\protect\settowidth\mylength{\bfseries\protect\cftchappresnum\protect\cftchapaftersnum}%
\protect\addtolength\protect\cftchapnumwidth{\mylength}}%
}{}{}
Complete MWE:
\documentclass{report}
\usepackage{tocloft}
\usepackage{etoolbox}
\apptocmd{\appendix}
{\addtocontents{toc}{%
\protect\addtolength\protect\cftchapnumwidth{-\mylength}%
\protect\renewcommand{\protect\cftchappresnum}{Appendix~}%
\protect\settowidth\mylength{\bfseries\protect\cftchappresnum\protect\cftchapaftersnum}%
\protect\addtolength\protect\cftchapnumwidth{\mylength}}%
}{}{}
\newlength\mylength
\renewcommand\cftchappresnum{Chap~}
\settowidth\mylength{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}
\begin{document}
\tableofcontents
\chapter{Intro}
\chapter{Test}
\appendix
\chapter{Conclusions}
\end{document}
Output (ToC):
-
-
@minthao_2011 Do you have something like
\chapter*{appendix}
in your document? Feb 13, 2014 at 5:13 -
-
@minthao_2011 Are you saying that you want to insert the word
Appendix
instead ofChap
for your appendices? Feb 13, 2014 at 5:21 -