2

Suggest me LaTeX command and package on how the words Chapter 1 can be appeared in the table of contents instead of just 1 and so on for the next chapters. Following is the template of the thesis of our university:

\documentclass[12pt,openany,oneside]{book}
\usepackage[pdftex]{graphicx}
\usepackage[a4paper,portrait,left=1.5in,
right=1in,top=1in, bottom=1.33in, footskip=0.33in]{geometry}
%\usepackage{sectsty}
%\sectionfont{\fontsize{12}{15}\selectfont}
\usepackage{titlesec}
\usepackage{lipsum}
%\titleformat{\chapter}[display]
%{\normalfont\Large\filcenter\sffamily}
%{\vspace*{\fill}
    %\titlerule[1pt]
    %\vspace{1pc}
    %\LARGE\MakeUppercase{\chaptertitlename}~\thechapter}
%{1pc}
%{\titlerule\Huge}
%[\vspace*{\fill}\newpage]

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\centering}{\chaptertitlename
    \ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{250pt}{40pt}
\usepackage{epstopdf}
\usepackage{subfigure}
\usepackage{epsfig}
\usepackage{color}
%\usepackage{a4wide}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{ntheorem}
\usepackage[normalem]{ulem}
\usepackage{chngcntr}
%\usepackage[pdfencoding = auto, psdextra, bookmarksdepth = 4]{hyperref}




%\usepackage{microtype}
\overfullrule=5pt
\hfuzz=20pt
\vfuzz=20pt
\hbadness=10000
\vbadness=\maxdimen
\renewcommand{\chaptermark}[1]{
    \markboth{\chaptername\  \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{
    \markright {\thesection.\ #1}}
\parindent0pt
\newlength{\defbaselineskip}
\setlength{\defbaselineskip}{\baselineskip}
\newcommand{\setlinespacing}[1]%
{\setlength{\baselineskip}{#1 \defbaselineskip}}
\newcommand{\doublespacing}{\setlength{\baselineskip}%
    {2.0 \defbaselineskip}}
\newcommand{\singlespacing}{\setlength{\baselineskip}{\defbaselineskip}}
\setlinespacing{1.5}
\newtheorem*{theorem-non}{Theorem}
\newtheorem{definition}{Definition}[chapter]
\newtheorem{lemma}{Lemma}[chapter]
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{remark}{Remark}[chapter]
\newtheorem{example}{Example}[chapter]
\newtheorem{corollary}{Corollary}[chapter]
\newenvironment{proof}%
{\medskip\par\noindent{\bf Proof\;}}%
{\hspace{\fill}$\Box$\medskip\par}
\numberwithin{equation}{chapter}
\numberwithin{theorem}{chapter}
\numberwithin{lemma}{chapter}
\numberwithin{corollary}{chapter}
\numberwithin{example}{chapter}
\numberwithin{remark}{chapter}
\numberwithin{definition}{chapter}
\renewcommand{\bibname}{}
\hyphenpenalty 50
\newtheorem{property}{Property}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\newcommand{\cchapter}[1]{\chapter[#1]}{\centering #1}}
%%%%%%%%%%%%%%%%%%%%%
%\newgeometry{left=1.5in, right=1.0in, bottom=1.75in, top=1in, footskip=0.75in}
%\addtolength{\oddsidemargin}{0.5cm}
%    \addtolength{\evensidemargin}{0.5cm}
%    \addtolength{\textwidth}{0.0cm}
%    \addtolength{\topmargin}{0.0cm}
%    \addtolength{\textheight}{0.0cm}
%%%%%%%%%%%%%%%%%%%
\usepackage[noabbrev]{cleveref}
\begin{document}
\pagestyle{plain} \setlinespacing{1.5}
%\input{Acknowledgement}
\newpage
\input{mytitle.tex}
%%%%%%%%%%%%%%%%%%%%
\newpage
\pagenumbering{arabic}
\setcounter{page}{1}
\input{chap1.tex}
%%%%%%%%%%%%%%%%%%
\input{chap2.tex}
%%%%%%%%%%%%%%%%%%
\input{chap3.tex}
%%%%%%%%%%%%%%%%
\input{chap4.tex}
%%%%%%%%%%%%%%%%%
\input{chap5.tex}
%%%%%%%%%%%%%%%%%%%
\input{chap6.tex}
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
\input{chap7.tex}
%%%%%%%%%%%%%%%%%%%
\input{chap8.tex}
\input{bib.tex}
%%%%%%%%%%%%%%%
\end{document}

Table of contents have the following command:

\newpage
\tableofcontents
3
  • 1
    Off-topic: (a) Don't load the epstopdf and epsfig packages. (b) Don't load the subfigure package, as it's badly depecated; instead, load either subfig or subcaption. (c) Don't specify the option pdftex while loading graphicx. (d) Load xcolor, not color.
    – Mico
    Commented May 28, 2023 at 8:57
  • 1
    For the sake of obtaining a useful answer to your query, your code could be stripped down to its essentials, e.g., \documentclass{book} \begin{document} \tableofcontents \chapter{AAA} \section{A1} \section{A2} \chapter{BBB} \section{B1} \section{B2} \end{document}.
    – Mico
    Commented May 28, 2023 at 10:08
  • 1
    @Mico: Hear hear. In order to help we need to know what code you have used. Do not rely on anyone else guessing what you might have done. If you are using a package then ask the package creator Commented May 28, 2023 at 18:14

1 Answer 1

3

I suggest you employ the tocloft package to achieve your formatting objective. Observe that the only thing the code shown below does is to insert the word "Chapter" (and space) before the chapter number. In particular, the appearance of section-level entries in the Table of Contents is not modified.

enter image description here

\documentclass{book}

\usepackage{calc} % for '\widthof' macro
\usepackage[titles]{tocloft}
\renewcommand\cftchappresnum{Chapter }
\cftsetindents{chap}{0pt}{\widthof{\large\textbf{Chapter 1}}}

\begin{document}
\tableofcontents

\chapter{AAA}
\section{A1}
\section{A2}

\chapter{BBB}
\section{B1}
\section{B2}

\end{document}
4
  • Thank you very much for your suggestion. However, I used \usepackage{subfigure} \usepackage[subfigure]{tocloft} instead of \usepackage[titles]{tocloft} as it was making error. Moreover, now the problem is that we have "Contents" instead of "Table of Contents" as the main heading. We want to achieve "Table of Contents". Commented May 28, 2023 at 13:31
  • @user20255650 - Repeat after me: "The subfigure package is deprecated and shouldn't be used." Just because the tocloft package can work around some (but not all) of the problems created by the subfigure package is in no way a valid reason for using the subfigure in the first place. If your document contains subfigures and/or subtables, I suggest you look into using the subfig or subcaption package. To change the title, run \renewcommand{\contentsname}{Table of Contents} in the preamble. (\contentsname is a macro provided by the book document class.)
    – Mico
    Commented May 28, 2023 at 13:57
  • Thank you very much again for your prompt and kind response. subfig and subcaption both are generating errors. Morover, I want to add that in the table contents as in sections and subsections there is a dotted line between the section/subsection title and page number, university format requirement is that there must also be a dotted line between Chapter and its pg number, for example " Chapter 1 Introduction . . . . . . . . . . 1 ". Last thing references are not the separate chapter. However, it must appear in the table of contents also with dotted lines also need to be present here as above. Commented May 28, 2023 at 16:33
  • Instead of dribbling out your requirements one by one, could you please edit your posting to list all of them at once? You say something is “generating errors” — what are you doing, and which error messages are you getting? Is merely loading a package causing an error?!
    – Mico
    Commented May 28, 2023 at 17:19

You must log in to answer this question.

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