GeneralInclude the word chapter in table of contents

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
vivek_136
Posts: 4
Joined: Sun Jul 20, 2008 7:35 pm

Include the word chapter in table of contents

Post by vivek_136 »

15.

Hello all,
I need the word chapter (e.g., ‘Chapter 1: … )’ to appear in my table of contents. However, my thesis file only produces a list of numbers such as

1 Introduction
1.1 Motivation
1.2 Previous work
2 Algorithm

Instead I need
Chapter 1: Introduction
1.1
1.2
Chapter 2: Algorithm
and so on…
Would appreciate suggestions..I have been fiddling around with the report.cls file to generate the appropriate change. But if I add the word 'Chapter' before #1 in the .cls file it generates something like Chapter 1 Introduction:

Best

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Include the word chapter in table of contents

Post by localghost »

This issue has been discussed very often in this forum. Please try a forum search (upper right corner of each page) for the tocloft package. In case of occurring problems, feel free to ask further questions.


Best regards and welcome to the board
Thorsten¹
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Include the word chapter in table of contents

Post by gmedina »

You can use the tocloft package, as the following example suggests:

Code: Select all

\documentclass{report}
\usepackage[english]{babel}
\usepackage{tocloft}

\renewcommand{\cftchapfont}{\bfseries}
\renewcommand{\cftchappagefont}{\bfseries}
\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{6em}


\begin{document}
\tableofcontents

  \chapter{First chapter}
  \section{Sec. One one}
  \section{Sec. One two}
  \chapter{Second chapter}
  \section{Sec. Two one}
  \section{Sec. Two two}
  \chapter{Third chapter}
  \section{Sec. Three one}
  \section{Sec. Three two}
\end{document}
Refer to the documentation for further information.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
vivek_136
Posts: 4
Joined: Sun Jul 20, 2008 7:35 pm

Re: Include the word chapter in table of contents

Post by vivek_136 »

Thanks gmedina. Using tocloft changes a lot of my initial settings. My thesis is completely formatted according to the specifications except the Chapter x: Chapter Heading in the table of contents.
That's the reason I've been fiddling with the report.cls file to make just this change. I don't want to get into tocloft and take care of all the changes introduced by using it.
I am looking for a simple renewal command either in the latex source or in the report.cls file.
vivek_136
Posts: 4
Joined: Sun Jul 20, 2008 7:35 pm

Re: Include the word chapter in table of contents

Post by vivek_136 »

I figured out how to do this. I changed the line in my report.cls file. The line marked with **************

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
**************** {\protect Chapter\numberline{\thechapter \;:}#1}% %%%% Change on 07/20/2008
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Include the word chapter in table of contents

Post by localghost »

It has never been a good idea to modify the original class files. There are many packages that yield the same results. And reading some documentation doesn't cost more time than searching the class file for the right place to modify.
amitkverma02
Posts: 1
Joined: Wed Oct 08, 2008 9:23 am

Re: Include the word chapter in table of contents

Post by amitkverma02 »

thanks vivek I used it with some modification and it worked nicely...
pamela
Posts: 1
Joined: Mon Dec 21, 2009 4:34 pm

Re: Include the word chapter in table of contents

Post by pamela »

Thanks vivek_136, your suggestion was REALLY helpful. I was having the same problem as yours.
Post Reply