Im trying to make a customized Table of Content. The section numbering in the document is as follows:
- Title of section. (Underline, in running text, with the first letter capitalized)
In table of Contents, I want it to be under the respective chapter as:
SECTION 1 - Title of Section
I want to set \thesection in a manner that complies with the above requirement.
\documentclass{book}
\usepackage[total={6.5in,8.75in},top=1in, left=2.5cm,right=2.5cm]{geometry}
\usepackage{calc}
\usepackage{float}
\usepackage{ulem}
\useunder{\uline}{\ulined}{}
\renewcommand{\ULdepth}{1.6pt}
\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{chngcntr}
\usepackage{tocloft}
\usepackage{url}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{alphalph}
\usepackage{chappg}
\usepackage{refcount}
\usepackage{lastpage}
\pagenumbering{roman}
\newcommand{\partfnt}{\fontsize{12}{12}}
\newcommand{\chapfnt}{\fontsize{12}{12}}
\newcommand{\secfnt}{\fontsize{12}{12}}
\newcommand{\ssecfnt}{\fontsize{12}{12}}
\titleformat{\part}{\centering\normalsize \partfnt}{\underline{\Huge\ PART \thepart - }}{0em}{\Huge \uppercase \uline}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{0}% Space above number
{\parindent \z@ \normalfont
\interlinepenalty\@M
\normalsize\centering \underline{\normalsize\ CHAPTER \thechapter}%
\par\vspace{12pt}% Space between number and title
\centering \underline{\MakeUppercase{#1}}%
\par\vspace{12pt}% Space between title and text
}}
\makeatother
\titleformat{\section}{\centering\normalsize \secfnt}{\underline{\normalsize\ SECTION \thesection - }}{0em}{\uppercase \uline}
\titleformat{\subsection}{\normalfont \ssecfnt}{\thesubsection}{1em}{\uppercase \uline} %FINAL for unbold subsection
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\ifnum\value{subsection}<10 010\fi\arabic{subsection}.}
\newlength{\mylen} % a "scratch" length
\settowidth{\mylen}{\normalfont \cftsecpresnum\cftsecaftersnum} % extra space
\addtolength{\cftsecnumwidth}{\mylen} % add the extra space
\begin{document}
\renewcommand\contentsname{\underline{CONTENTS}}
\renewcommand{\cfttoctitlefont}{\hfill\normalsize\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill}
\setcounter{tocdepth}{1}
\renewcommand{\cftpartfont}{\uppercase \normalfont} % set part font
\renewcommand{\cftpartpagefont}{\normalfont}
\renewcommand{\cftpartdotsep}{100000000000} % adds dots between part name and page number but setting large value will remove dots
\renewcommand{\cftpartleader}{\cftdotfill{\cftpartdotsep}}
\renewcommand{\cftpartafterpnum}{\cftparfillskip} % add space after page number if needed
\renewcommand{\cftpartpresnum}{PART}
\renewcommand{\cftpartaftersnum}{-}
\renewcommand{\cftpartaftersnumb}{\\}
\renewcommand{\cftbeforepartskip}{12}
\renewcommand{\cftchapfont}{\normalfont}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\cftchapdotsep}{100000000000}
\renewcommand{\cftchapleader}{\cftdotfill{\cftchapdotsep}}
\renewcommand{\cftchapaftersnum}{.}
\renewcommand{\cftchapaftersnumb}{\\}
\renewcommand{\cftbeforechapskip}{12}
\renewcommand{\cftchapnumwidth}{3em}
\renewcommand{\cftsecfont}{\normalfont}
\renewcommand{\cftsecpagefont}{\normalfont}
\renewcommand{\cftsecdotsep}{100000000000}
\renewcommand{\cftsecleader}{\normalfont\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsecpresnum}{SECTION\ }
\renewcommand{\cftsecaftersnum}{\ -\ }
\renewcommand{\cftsecaftersnumb}{\\}
\renewcommand{\cftsecindent}{5em}
\tableofcontents
\addtocontents{toc}{\textbf{CHAPTER}\hfill\textbf{SUBJECT}\hfill\textbf{PAGE NO}\par}
\addcontentsline{toc}{chapter}{\hspace{5em} \normalfont Promulgation}
\addcontentsline{toc}{chapter}{\hspace{5em} \normalfont Improvement}
\newpage
\clearpage
\renewcommand\thepage{\arabic{chapter}-\arabic{page}}
\part{General}
\setcounter{page}{1}
\chapter{Chapter}
ABCD
\section{somthing}
something
\subsection{Something}
Something
\part{Special}
\setcounter{page}{1}
\chapter{Chapter}
ABCD
\section{somthing}
something
\subsection{Something}
Something
\end{document}
\documentclass{}and end with\end{document}, a Minimal Working Example (MWE) please. It makes copy and pasting easier when the code can be compiled and also we do not need to guess what commands or packages you are using. There is also way too much code here, could you reduce it down and make it compile for us please?