How to horizontally center chapter name in table of contents?

\documentclass[12pt,a4paper]{report}  \usepackage{setspace} \usepackage{etoolbox} \makeatletter \patchcmd{\@dottedtocline}{\hbox{.}}{}{}{} \patchcmd{\[email protected]}{1.5em}{5.6cm}{}{} \renewcommand*\[email protected]{\@dottedtocline{1}{1.5em}{5cm}} \renewcommand*\[email protected]{\@dottedtocline{1}{2.5em}{4.6cm}} \makeatother   \begin{document}      \pagenumbering{roman}       \tableofcontents       \addtocontents{toc}{\textbf{Chapter No}\hspace{3cm}\textbf{Title}\hfill\textbf{Page}\par}     \thispagestyle{empty}      \newpage     \addcontentsline{toc}{chapter}{\protect\numberline{}\listfigurename}     \onehalfspacing     \listoffigures     \addtocontents{lof}{\textbf{Figure No}\hspace{3cm}\textbf{Title}\hfill\textbf{Page}\par}     \thispagestyle{empty}     \newpage      \addcontentsline{toc}{chapter}{\protect\numberline{}\listtablename}     \onehalfspacing     \listoftables     \addtocontents{lot}{\textbf{Table No}\hspace{3cm}\textbf{Title}\hfill\textbf{Page}\par}     \thispagestyle{empty}     \newpage  \chapter{Introduction}  \section{Problem}      This is the minimal code      \begin{figure}[h]         \caption{Abcd}      \end{figure}      \begin{table}[h]         \caption{Xyz}      \end{table}      \subsection{Only}  \chapter{Related Works}  \begin{figure}     \caption{Bcde}  \end{figure}  \end{document} 

List of figures

Figure No Title Page

 1.1          Abcd             iv  2.1          Bcde             v 

List of Tables
Table No Title Page 1.1 Xyz iv

I call two commands but calls error:

\renewcommand*\[email protected]{\@dottedlofline{1}{2.5em}{5cm}} \renewcommand*\[email protected]{\@dottedlotline{1}{2.5em}{5cm}} 

Replay

Here is a solution. We need to

  1. remove dots in section like entries
  2. redefine commands \[email protected], \[email protected], ...
  3. adjust spacing for starred chapters by \addcontentsline{toc}{chapter}{\protect\numberline{}\listfigurename}

Note in the example below you still have to redefine \[email protected] ... if needed.



Update For list of figure we only need to redefine \[email protected] it's similar to \[email protected]

\renewcommand*\[email protected]{\@dottedtocline{1}{1.5em}{5cm}}

Note that Figure No is not same length as Chapter No so i find it's better to replace 3cm with 3.4cm in

\addtocontents{lof}{\textbf{Figure No}\hspace{3cm}\textbf{Title}\hfill\textbf{Page}\par}


\documentclass[12pt,a4paper]{report}
\usepackage{setspace}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@dottedtocline}{\hbox{.}}{}{}{}
\patchcmd{\[email protected]}{1.5em}{5.6cm}{}{}
\renewcommand*\[email protected]{\@dottedtocline{1}{1.5em}{5cm}}
\renewcommand*\[email protected]{\@dottedtocline{1}{1.5em}{5cm}}
\makeatother
\begin{document}
     \pagenumbering{roman}
     \tableofcontents
     \addtocontents{toc}{\textbf{Chapter No}\hspace{3cm}\textbf{Title}\hfill\textbf{Page}\par}
    \thispagestyle{empty} \newpage
    \addcontentsline{toc}{chapter}{\protect\numberline{}\listfigurename}
    \onehalfspacing
    \listoffigures
    \addtocontents{lof}{\textbf{Figure No}\hspace{3.4cm}\textbf{Title}\hfill\textbf{Page}\par}
    \thispagestyle{empty}
    \newpage
\chapter{Introduction}
 \section{Problem}
     This is the minimal code
 \chapter{Related Works}
 \end{document}

How to horizontally center chapter name in table of contents?

Category: table of contents Time: 2016-07-30 Views: 1

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.134 (s). 12 q(s)