I am customizing my table of contents style.
The title of TOC should be CONTENTS (underlined and in the center).
The headings of TOC have to be CHAPTER SUBJECT and PAGE NO like:
I am unable to adjust the chapter number indentation and chapter name style (tends to show Underline).
Here is the main.tex code:
\documentclass[english,12pt,letterpaper,twoside,openright]{book}
\usepackage{tocloft}
% iIn length control the veratical space between chapters
%\setlength{\cftparskip}{1.5\baselineskip}
\usepackage{url}
%for landscape pages use this
\usepackage{pdflscape} %Use \begin{landscape} for start and \end{landscape} to finish landscaping pages
%for adjeusting list numbering
\usepackage{enumerate}
\usepackage{enumitem}
%For setting margins of page use this
\usepackage[total={6.5in,8.75in},top=1in, left=2.5cm,right=2.5cm]{geometry}
%For inserting Blindtext using \blindtext[]
\usepackage{blindtext}
\usepackage{emptypage}
\usepackage{calc}
\usepackage{float}
%To Setup Listings
\usepackage{listings}
%%%SETTING UP APPENDIX
%\usepackage{appendix}
\usepackage{chngcntr}
%Setting Font to Times New Roman
\usepackage{fontspec}
\setmainfont{Times New Roman}
%Or alternatievly for Times new roman but not used for our purpose
%\usepackage{times}
%\usepackage{mathptmx} %\usepackage[scaled=0.9]{helvet} %\usepackage{courier}
\usepackage{titlesec} %Package for setting title, section heading and subsection sizes
\usepackage{titletoc} %For Setting up Header and Footer
\usepackage{fancyhdr} % For setting headers and footer
\usepackage{array}
%for Table
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{multirow}
%For inserting Graphics and Pictures
\usepackage{xcolor} %For Images
\usepackage{graphicx}
\graphicspath{C:\Users\Workstation-02\Desktop\latex lec\SAMPLE\Graphics}
\usepackage{wrapfig}
\usepackage{subcaption}
%\usepackage{hyperref}
\usepackage{alphalph}
\usepackage{ulem}
\usepackage{chappg}
\usepackage{refcount}
\usepackage{lastpage}
\renewcommand{\headrulewidth}{0pt} %for header line width
\renewcommand{\footrulewidth}{0pt} %for footer line width
%Helps setup Header & Footer
\fancyhead{}
%\rhead{DRAFT}
%\chead{RESTRICTED}
%\lhead{PBR-}
\fancyfoot{}
%\rfoot{DRAFT}
%\cfoot{RESTRICTED}
%\lfoot{PBR-}
%\fancyfoot[c]{\thepage}
%MANUAL SETUP OF HEADER
\fancyhead[c]{RESTRICTED}
%\fancyfoot[c]{RESTRICTED}
%MANUAL SETUP OF FOOTER
\fancyfoot[c]{\centering \thepage \ PBR- \hspace{5.7cm} \centering RESTRICTED \hspace{5.7cm} Draft}
%PAGE NUMBERING - ###
%\usepackage{fncystyle}
%\setlenght{\headheight}{0.3in}
%\setlenght{\headsept}{0.2in}
%\setlenght{\footskip}{0.6in}
%SETTING PAGE STYLE AND NUMBER
\pagestyle{fancy} %Setting page style
\pagenumbering{roman} %Setting Page Number
%%%%%%% CHAPTER SECTION AND SUBSECTION SETTINGS (GLOBAL)
\titleformat{\chapter}{\normalfont\secfnt}{\thechapter}{1 em}{} %FINAL
\titleformat{\section}{\normalfont\secfnt}{\thesection}{1 em}{} %FINAL
\titleformat{\subsection}{\normalfont\ssecfnt}{\thesubsection}{1 em}{} %FINAL for unbold subsection
%%%%%%%%%%%%%%%%%
% Setup line spacing for document %
%%%%%%%%%%%%%%%%%
%\usepackage{setspace}
%\singlespacing
%\onehalfspacing
%\doublespacing
%\setstretch{1.1}
%\usepackage{parskip}
%\usepackage[onehalfspacing]{setspace}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{hyperref}
% for section numbering
\renewcommand\thesection{\ifnum\value{section}<10 010\fi\arabic{section}.}
\renewcommand\thesubscection{\thesection.\ifnum\value{subsection}<10 010 \fi\arabic{subsection}}
%For small caps
%\titlecontents{chapter}
%[6em] %Overall adjustment
%{\smallskip}
%{\thecontentslable\hspace{-6em}} %Chapter headings adjustment
%{\hspace*{0.5em}} %Pre chapter heading adjustment
%{,,\tiltlerule{.}\contentspage}
%\DeclareTOCStyleEntry[level=\chaptertocdepth]
\begin{document}
\fancypagestyle{empty}
%frontmatter & Title
%\titleformat{\chapter}[display]
%{\normalfont\filcenter}
%{\titlerule[0pt]%
% \vspace{0pt}%
% \titlerule
% \vspace{0pc}%
%\MakeUppercase {\chaptertitlename}\thechapter}
%{0pc}
%{\titlerule
% \vspace{1pc}}
% \newcommand{\chapfnt}{\fontsize{12}{12}}
% \renewcommand{\chaptername}{\centering\underline{\normalsize\ CHAPTER}}{\underline}
% \titleformat{\chapter}[display]{\normalfont}
% \titleformat{\chapter}[display]{\centering\normalsize\chapfnt}{\chaptertitlename\ \thechapter}{20pt}{\chapfnt}
% \titlespacing*{\chapter}{0pt}{0pt}{12pt}
\newcommand{\chapfnt}{\fontsize{12}{12}}
%\renewcommand{\chaptername}{\centering\underline{\normalsize\ CHAPTER}}{\underline}
\titleformat{\chapter}[display]{\centering\normalsize\chapfnt}{\underline{\normalsize\ CHAPTER \thechapter}}{20pt}{\chapfnt}
\titlespacing*{\chapter}{0pt}{0pt}{12pt}
%TABLE OF CONTENT FORMATTING (CHATPER, SUBJECT & PAGE NO HEADING)
\addtocontents{toc}{~\textbf{CHAPTER}\hfill\textbf{SUBJECT}\hfill\textbf{PAGE NO.}\vspace{1pt}}
%Settings for Enumerate listing
\setlist[enumerate, 1]{align=left, leftmargin=pt, labelindent=0pt, listparindent=\parindent, labelwidth=20pt, itemindent=!}
\setlist[enumerate, 2]{align=left, leftmargin=24pt, labelindent=34pt,listparindent=26pt, labelwidth=28pt, itemindent=33}
\setlist[enumerate, 3]{align=left, leftmargin=36pt, labelindent=34pt,listparindent=26pt, labelwidth=26pt, itemindent=33}
%\setlist[enumerate, 4]{align=left, leftmargin=30pt, labelindent=34pt,listparindent=26pt, labelwidth=26pt, itemindent=33} %EITHER THIS FOR FOURTH LEVEL OR THE ONE BELOW
\setlist[enumerate, 4]{align=left, leftmargin=36pt, labelindent=34pt,listparindent=26pt, labelwidth=26pt, itemindent=28}
%Alternative setting for enumerate
%\setlist[enumerate, 2]{left=2\parindent, listparindent=20pt, labelwidth=20pt, itemindent=20pt, labelindent=35pt, leftmargin=23pt}
%\setlist[enumerate, 3]{left=2\parindent, listparindent=0pt, labelwidth=2pt, itemindent=20pt, labelindent=\parindent, leftmargin=12pt}
%\setlist[enumerate, 4]{left=2\parindent, listparindent=0pt, labelwidth=2pt, itemindent=20pt, labelindent=\parindent, leftmargin=10pt}
%\titleformat{\chapter}[display]
%{\normalfont\Large\rmfamily \filcenter}
%{\MakeUppercase{\chapter{\chaptertitlename}\thechapter}
% [1pc]
\input{Title-Front-Matter/1-Title-page}
\input{Title-Front-Matter/2-Diary Ack}
\input{Title-Front-Matter/2-Distribution}
\addcontentsline{toc}{chapter}{\hspace{2.5cm} \normalfont Distribution}
% \newpage
% \stepcounter{page}
\input{Title-Front-Matter/3-Improvement}
\addcontentsline{toc}{chapter}{\hspace{2.5cm} \normalfont Improvement}
% \newpage
% \stepcounter{page}
\input{Title-Front-Matter/4-Record-of-changes}
\addcontentsline{toc}{chapter}{\hspace{2.5cm} \normalfont Record of Changes/Amendments}
% \newpage
% \stepcounter{page}
\input{Title-Front-Matter/5-Preface}
\addcontentsline{toc}{chapter}{\hspace{2.5cm} \normalfont Preface}
%\newpage
%\stepcounter{page}
\setcounter{tocdepth}{0} %This sets Toc depth in table of contents i.e. do we want to see sections, subsections etc?
%THIS WILL SET THE TITLE OF TABLE OF CONTENTS AS "CONTENTS"
\newpage
\renewcommand{\contentsname\centering}{\bfseries\underline{\normalsize\textbf{CONTENTS} }\vspace{-70pt}}
\tableofcontents
%\contentsline{chapter}{\numberline{1}}\relax$@{\hbox{INTRODUCTION TO SHIP HUSBANDRY}}
\clearpage
%\pagenumbering{arabic}
%\fancyfoot[c]{\centering \thechapter - \thepage \ PBR- \hspace{5.5cm} \centering RESTRICTED \hspace{5.5cm} Draft}
%This will setup Page numbering format on each page as <Chapter Number>-<Page Number>
\renewcommand\thepage{\arabic{chapter}-\arabic{page}}
\include{Mainmatter-Chapters/Ch1}
%\include{Mainmatter-Chapters/Ch2}
%\include{Mainmatter-Chapters/Ch3}
%\include{Mainmatter-Chapters/Ch4}
\end{document}
%%%% CHAPTERS ARE LIKE THIS
% !TEX root = ../main.tex
\setcounter{page}{1}
% !TEX root = ../main.tex
\setcounter{page}{1}
%\chapter{\underline{INTRODUCTION TO THE TOPIC}} %% NEEDS TO BE CAPITAL AND UNDERLINED. CHAPTER 1 CENTER AND ON NEXT LINE THERE SHOULD BE CHAPTER NAME IN CAPS AND UNDERLINE
%\section{\underline{\normalsize asdsadsad}}
%\begin{enumerate}
% \item abcd
%\end{enumerate}
%\section{\underline{\normalsize asdasd}}
%and so on...

\renewcommand\thesubscection{\thesection.\ifnum\value{subsection}<10 010 \fi\arabic{subsection}}and\renewcommand{\contentsname\centering}{\bfseries\underline{\normalsize\textbf{CONTENTS} }\vspace{-70pt}}. Look at the log, fix all the errors it raises, then once you have a successfully compiling document you can worry about customising it. – Dai Bowen Apr 23 '23 at 14:07