I want to add "Chapter" word before chapter number in Table of Content. I have searched the solutions but the most answered question is when we using tocloft package that I didn't use. Can I give that word when using tocbibind package?
Asked
Active
Viewed 695 times
1 Answers
1
The hard part was getting the hanging indentation right.
\documentclass{report}
\makeatletter
\renewcommand*\l@chapter[2]{%
\ifnum \c@tocdepth >\m@ne
\addpenalty{-\@highpenalty}%
\vskip 1.0em \@plus\p@
\setlength\@tempdima{1.5em}%
\begingroup
\settowidth{\@tempdimb}{\normalsize\bfseries \chaptername~}%
\advance\leftskip by \@tempdimb
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@tempdima
\leavevmode \bfseries
\advance\leftskip\@tempdima
\hskip -\leftskip
\chaptername~#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\penalty\@highpenalty
\endgroup
\fi}
\makeatother
\begin{document}
\tableofcontents
\chapter{A very very very very very very very very very very very very very very very very very very long title}
\end{document}
John Kormylo
- 79,712
- 3
- 50
- 120
-
-
@S_25 - Save and restore the original \l@chapter. Or just put the redefinition inside a group {...} with the TOC (but not the LOF). – John Kormylo Jun 24 '17 at 21:18
-
@JohnKormylo could you please show how to implement this for only chapters without the lists; example: list of figures, and appendices? – Ahmed Sayed Jul 12 '19 at 19:24
-
@AhmedSayed - As it turns out, my previous comment was invalid, since you have no control of \l@chapter while the TOC is being printed. One would need a way to distinguish between two different kinds of chapters. You might try asking a new question with a complete MWE. – John Kormylo Jul 13 '19 at 14:53
-
@john kormylo I have already created a new question through this link https://tex.stackexchange.com/questions/499707/add-chapter-word-into-toc-page-number?noredirect=1#comment1262176_499707 – Ahmed Sayed Jul 13 '19 at 15:48

tocloftthen? Both packages are maintained by our fellow user Will Robertson and are compatible to each other,but do address different issues.tocbibindis basically only for the inclusion toc in toc, whereastocloftdoes provide hooks to the toc - entries – Nov 18 '15 at 08:58