Macros – Adding the Word ‘Chap’ Before Chapter Numbers in TOC

macrostable of contents

I'm using the book class and I need to add the word "Chap" before the chapters numbers in the TOC. Please keep in mind that the "Chap" should only appear before my chapters numbers, not before starred chapters titles, the Index, appendices or anything similar in the TOC.
By the way, I prefer to use the book class codes rather than to use packages.
Can anybode help me accomplish this?
Here is a minimal example:

\documentclass{book}‎
‎\usepackage[nottoc]{tocbibind}‎‎
‎\begin{document}‎‎
‎\tableofcontents‎‎
‎\chapter{One‎}‎‎
‎\chapter{Two‎}‎‎‎‎
‎\section{B‎la}‎‎
‎\chapter*{B‎la bla}
‎\addcontentsline{toc}{chapter}{bla‎ ‎bla}‎‎
‎\appendix‎‎
‎\chapter{App one}‎
‎\begin{thebibliography}{99}‎‎
‎\bibitem{bla‎}‎
‎bla‎
‎\end{thebibliography}‎‎‎             
‎\end{document}

Best Answer

Make a copy of \@chapter and then redefine \@chapter to add the word "Chap"; from the point on where the word must not appear, restore the original meaning of \@chapter:

\documentclass{book}

\makeatletter
\let\orig@chapter\@chapter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {Chap~\protect\numberline{\thechapter}#1}%
                       \else
                         \addcontentsline{toc}{chapter}{#1}%
                       \fi
                    \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

\frontmatter
\chapter{Acknowledgements}

\mainmatter
\chapter{Test Chapter One}
\chapter{Test Chapter Two}

\makeatletter
\let\@chapter\orig@chapter
\makeatother
\appendix
\chapter{Test Appendix One}

\end{document}

An image of the resulting ToC:

enter image description here

Related Question