0

I am having some difficulty in aligning the multiline chapter title in ToC. ToC example

There is an extra space after Chapter 1:

What I do not want is that extra space. Also, all multiline chapters, sections, and subsections in ToC should be aligned properly, i.e. second, third (so on) lines should align exactly like first line (after removing the space in the first line). In my case, second and third line are aligned properly, but not the first line. Please note that there is an extra space in Appendices (after :) too which I do not need either.

Any of your help is much appreciated.

enter image description here

I am using the below code to achieve (in USC-Thesis class file) ToC settings:

\newlength\mylenprt %part
\newlength\mylenchp %chp
\newlength\mylenapp %app
\newlength\mylena %fig
\newlength\mylenb %tab  

\renewcommand\cftpartpresnum{\partname~}
\renewcommand\cftchappresnum{\chaptername~}
\renewcommand\cftfigpresnum{\figurename~}
\renewcommand\cfttabpresnum{\tablename~}
\renewcommand\cftchapaftersnum{:}
\renewcommand{\cftfigaftersnum}{:}
\renewcommand{\cfttabaftersnum}{:}

\settowidth\mylenprt{\cftpartfont\cftpartpresnum\cftpartaftersnum}
\settowidth\mylenchp{\cftchapfont\cftchappresnum\cftchapaftersnum}
\settowidth\mylenapp{\cftchapfont\appendixname~\cftchapaftersnum}
\settowidth\mylena{\cftfigfont\figurename~\cftfigaftersnum}
\settowidth\mylenb{\cfttabfont\tablename~\cfttabaftersnum}
\addtolength\mylenprt{\cftpartnumwidth}
\addtolength\mylenchp{\cftchapnumwidth}
\addtolength\mylenapp{\cftchapnumwidth}
\addtolength\cftfignumwidth{\mylena}
\addtolength\cfttabnumwidth{\mylenb}

\setlength\cftpartnumwidth{\mylenprt}
\setlength\cftchapnumwidth{\mylenchp}
\setlength\cftbeforefigskip{30pt}

Below is my minimal example:

\documentclass[final]{USC-Thesis}
\usepackage[titles]{tocloft}
\usepackage[lofdepth,lotdepth]{subfig}
\usepackage{appendix} %[titletoc]
\renewcommand{\cftchapfont}{
\bfseries   %\normalfont 
}
\renewcommand{\cftchappagefont}{%
\bfseries   %\normalfont 
}

\begin{document}

\renewcommand{\contentsname}{Table of Contents}
\tableofcontents

\mainmatter

\chapter{This is a super long chapter heading that requires more than one 
line in the Table of Contents. It can go more than 3 lines.}

\section{Section I}

\subsection{This is a super long chapter heading that requires more than one 
line in the Table of Contents. It can go more than 3 lines Section II}

\subsection{Section III}

\subsubsection{Subsection I}

\appendix
\addtocontents{toc}{% NB!!! must be inside the first \include
    \protect\renewcommand\protect\cftchappresnum{\appendixname~}%
    \protect\setlength{\cftchapnumwidth}{\mylenapp} \protect\newpage
    }%
\noappendicestocpagenum
\addappheadtotoc
\chapter{Some title 1}
\chapter{Some title 2}
\chapter{Some title 3}
\end{document}
  • Is the document class file USC_Thesis.cls available online? – Mico Feb 27 '18 at 14:44
  • Yes, it is. Please use this link to download the .cls file: dropbox.com/s/n43mqfkr85q1xvd/USC-Thesis.cls?dl=0 – PManjunatha Feb 27 '18 at 15:06
  • @PManjunatha I tried to get the .cls file from your link. I clicked on the link which got me somewhere in dropbox showing what looked like a .cls file in Firefox. I then clicked on Save page as ... and got a copy of the file. When I looked at it using emacs it consisted of a mess of HTML. All I want is a plain text version of USC-Thesis.cls that I can use to try and help with your problem. What should I have done [GOM]? – Peter Wilson Feb 27 '18 at 19:50
  • @Peter Wilson, I was able to download the .cls file. If you click on the link, it will take you to Dropbox website. On the right corner, there is a download drop-down menu. if you click on the Direct download, USC-Thesis.cls is downloaded to the local folder. – PManjunatha Feb 27 '18 at 21:54
0

I think that you have (at least) two problems in your MWE.

Firstly there is a missing } at the end of your \chapter title.

Secondly you define:

\renewcommand{\cftchapfont}{
  \bfseries
}

whereas it should be

\renewcommand{\cftchapfont}{%
  \bfseries
}

which will eliminate the extra space between the chapter's colon and the start of the title.

  • Thanks, it worked! The extra space between the chapter's colon and the start of the title got eliminated. But now there are two spaces after Chapter 1: and similarly in section, subsection and in Appendices. How can I control it to make just one space or any spaces as a matter of fact? – PManjunatha Feb 27 '18 at 22:01
  • @PManjunatha I really don't know what you have done. I'm guessing that you have made changes to USC-Thesis.cls and then used your modified (but not renamed) version for your MWE. All I know is if I try your MWE as it stands then my answer works. If I add in to the preamble your quoted changes to .cls file then there are errors like Command \mylenprt already defined or ... For someone, and it won't be me, to try and give further help we need to see exactly the code you used --- both the .cls file and the .tex file. You need to ask about the extra space as another question. – Peter Wilson Mar 1 '18 at 21:23

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.