0

I am writing a thesis using my institution's template. My working code is as follows:

\makeatletter
\let\my@xfloat\@xfloat
\makeatother

\documentclass[oneside,12pt,a4paper]{book}
%\documentclass[12pt,a4paper]{book}
\usepackage{UTMThesis, enumerate, amsfonts, longtable, qtree, etoolbox, array, rotating, pgf, tikz, tikz-cd, algorithm, csquotes}

\makeatletter
\def\@xfloat#1[#2]{
    \my@xfloat#1[#2]%
    \def\baselinestretch{1}%
    \@normalsize \normalsize
}
\makeatother

\allowdisplaybreaks
\usetikzlibrary{arrows, matrix, positioning, shapes, shapes.geometric, calc, intersections, decorations.pathreplacing}
\newcommand{\tikznode}[2]{\relax
    \ifmmode%
    \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};
    \else
    \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
    \fi}
\let\openbox\relax
\let\iint\relax
\let\iiint\relax
\let\iiiint\relax
\let\idotsint\relax

\newcommand*{\qed}{\hfill\ensuremath{\square}}

%-------------------------------------------------------------
\usepackage{cite}                       % change  cite from [1,2,3] to [1-3] etc for number system
\makeatletter                           % change from
  \renewcommand{\@biblabel}[1]{#1.}     % [1] to 1. etc 
\makeatother                            % in list of references
%-----------------------------------------------------------
  \setlength{\voffset}{-2.1cm}
  \setlength{\hoffset}{-.4cm}  
%--------------------------------------------------------
\font\fiverm=cmr5 
%\input{Pictex.tex} % using pictex
%---------------------------------------------------------
%\pagestyle{plain}
%-------------------------------------------------------
  \usepackage{fancyhdr}
  \pagestyle{fancy}
  \lhead{}
  \chead{}
  \rhead{}
  \lfoot{}  
  \cfoot{\vspace{-.35cm}\thepage}  % 
  \rfoot{} 
  \renewcommand{\headrulewidth}{0pt}
%-------------------------------------------------------
\begin{document}
\frontmatter

\chapter*{TABLE OF CONTENTS}

\addcontentsline{toc}{section}{\textbf{TABLE OF CONTENTS}}
\contentsline{toc}{\hspace{-1.3cm}\phantom{\textbf{CHAPTER}}\hfill
    \textbf{TITLE}\hspace{1.1cm}}\hfill {\textbf{PAGE\,\,}}

{\setlength{\parskip}{.25cm}
    \setlength{\baselineskip}{.5cm}
    
    \contentsline {chapter}{\numberline {\hspace {-.9cm}CHAPTER 1}\hspace{1cm}THIS IS A VERY LONG LONG LONG LONG LONG LONG TITLE}{1}
    \contentsline {section}{\numberline {\hspace {-.175in}1.1\hspace {.12in}}Background Problem}{1}

\backmatter
\end{document}

that produces:

enter image description here

I want it to look like this one:

enter image description here

In other words, the spacing of the very long title has to be fixed. But I don't know how. Please help.

0

I must admit that I am not fond of your institution's template, whatever that might be. Try the following and see if it produces what you are after.

% thesistocprob.tex  SE 581226

\makeatletter
\let\my@xfloat\@xfloat
\makeatother

\documentclass[oneside,12pt,a4paper]{book}
%\documentclass[12pt,a4paper]{book}

\usepackage{comment}

%\usepackage{UTMThesis, enumerate, amsfonts, longtable, qtree, etoolbox, array, rotating, pgf, tikz, tikz-cd, algorithm, csquotes}

\makeatletter
\def\@xfloat#1[#2]{
    \my@xfloat#1[#2]%
    \def\baselinestretch{1}%
    \@normalsize \normalsize
}
\makeatother

\begin{comment}
\allowdisplaybreaks
\usetikzlibrary{arrows, matrix, positioning, shapes, shapes.geometric, calc, intersections, decorations.pathreplacing}
\newcommand{\tikznode}[2]{\relax
    \ifmmode%
    \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};
    \else
    \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
    \fi}
\let\openbox\relax
\let\iint\relax
\let\iiint\relax
\let\iiiint\relax
\let\idotsint\relax
\end{comment}

\newcommand*{\qed}{\hfill\ensuremath{\square}}

%-------------------------------------------------------------
\usepackage{cite}                       % change  cite from [1,2,3] to [1-3] etc for number system
\makeatletter                           % change from
  \renewcommand{\@biblabel}[1]{#1.}     % [1] to 1. etc 
\makeatother                            % in list of references
%-----------------------------------------------------------
  \setlength{\voffset}{-2.1cm}
  \setlength{\hoffset}{-.4cm}  
%--------------------------------------------------------
\font\fiverm=cmr5 
%\input{Pictex.tex} % using pictex
%---------------------------------------------------------
%\pagestyle{plain}
%-------------------------------------------------------
  \usepackage{fancyhdr}
  \pagestyle{fancy}
  \lhead{}
  \chead{}
  \rhead{}
  \lfoot{}  
  \cfoot{\vspace{-.35cm}\thepage}  % 
  \rfoot{} 
  \renewcommand{\headrulewidth}{0pt}
%-------------------------------------------------------

\usepackage{tocloft}
\renewcommand{\cftchappresnum}{\textbf{CHAPTER }}
\setlength{\cftchapnumwidth}{3cm}
\renewcommand{\contentsname}{TABLE OF CONTENTS}

\begin{document}
\frontmatter

\addtocontents{toc}{\textbf{CHAPTER} \hfill \textbf{TITLE} \hfill \textbf{PAGE} \par}
%\chapter*{TABLE OF CONTENTS}
\addcontentsline{toc}{section}{\contentsname}
\tableofcontents

\begin{comment}
\addcontentsline{toc}{section}{\textbf{TABLE OF CONTENTS}}
\contentsline{toc}{\hspace{-1.3cm}\phantom{\textbf{CHAPTER}}\hfill
    \textbf{TITLE}\hspace{1.1cm}}\hfill {\textbf{PAGE\,\,}}
\end{comment}

\setlength{\parskip}{.25cm}
    \setlength{\baselineskip}{.5cm}
\begin{comment}    
%    \contentsline {chapter}{\numberline {\hspace {-.9cm}CHAPTER 1}\hspace{1cm}THIS IS A VERY LONG LONG LONG LONG LONG LONG TITLE}{1}
    \contentsline {chapter}{\numberline {CHAPTER 1}\hspace{2.5cm}THIS IS A VERY LONG LONG LONG LONG LONG LONG TITLE}{1}
    \contentsline {section}{\numberline {\hspace {-.175in}1.1\hspace {.12in}}Background Problem}{1}
\end{comment}
\mainmatter

\chapter{THIS IS A VERY LONG LONG LONG LONG LONG LONG TITLE}
\section{Background Problem}

\backmatter
\end{document}

It is a heavily revised version of your MWE but generally abides by the usual LaTeX style. It uses the regular LaTeX \chapter, unlike your MWE, but uses the tocloft package to get the ToC as I think that your template wants.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.