I know that the indenting size of chapter, section and subsection can be changed in tocloft package using \cftsetindents. I am using a Latex template and I shouldn't use tocloft or any other TOC packages. So my question is how can I control those indents in the standard TOC? it's okay if I need to modify the cls files, etc but I don't know what are the settings to be changed.

\usepackage[top=25mm, bottom=25mm, left=40mm, right=25mm]{geometry}










\addcontentsline{toc}{chapter}{\textbf{LIST OF ABBREVIATIONS}}





\addcontentsline{toc}{chapter}{\textbf{BIODATA OF STUDENT}}
\include{biodata}                                                %
\addcontentsline{toc}{chapter}{\textbf{LIST OF PUBLICATIONS}}
\include{listofpublications}                                    %

Update: I increased the indention for chapter titles using \setlength\@tempdima{5.5em} but still couldn't find the way to increase the indention of sections and subsections. https://imgur.com/a/3lUcG

  \ifnum \c@tocdepth >\m@ne
\setcounter{tocdepth}{2} %   
    \vskip .1cm \@plus \p@ %{the v-distance between the headings in the contents}
    \setlength\@tempdima{5.5em}% %{the distance between the number of the chapter and its title}
           \parindent\z@ \rightskip \@pnumwidth
            \parfillskip -\@pnumwidth
      \advance \leftskip \@tempdima 
      \hskip  -\leftskip 
% CCW: The following 3 lines add dots to the chapter TOC listings
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
      \hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
  • 1
    Welcome to TeX SX! Unrelated: epsfig is totally obsolete (for more than twenty years) and should be replaced with \includegraphics. Is there any reason not to use a toc package? You load geometry, which certainly modifies the general layout. – Bernard Jan 9 '18 at 19:59
  • You're loading epstopdf twice, by the way – user31729 Jan 9 '18 at 19:59
  • @Bernard Thanks for your reminder about theepsfig package. Other toc packages change the appearance of the table of content and I don't have time to change them back to the original design. I just need to increase the indents. – R. Toward Jan 9 '18 at 20:09
  • 1
    The chapter (for example) TOC entry is formatted by \l@chapter, so search MyThesisEnglish.cls for \l@chapter an modify accordingly. Often these use \@dottedtocline where the indentation is the second argument. – John Kormylo Jan 9 '18 at 21:35
  • And you probably don't need to load epstopdf at all unless you're using a really old version of TeX. – cfr Jan 10 '18 at 0:47

The ToC entries for \chapters, \sections and \subsections are handled by \l@chapter, \l@section and \l@subsection, respectively. Here are the definitions of each (from report.cls):

  \ifnum \c@tocdepth >\m@ne
    \vskip 1.0em \@plus\p@
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par

Within \l@chapter, the length \@tempdima specifies the box width that holds the chapter number. The default definition, as you can see above, is 1.5em. You can change this using the following

% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}

to increase the box width to 5.5em, say.

Note how \l@section's definition also uses 1.5em as the first length parameter, followed by 2.3em. The first length is the indentation, while the second length is the width of the box containing the section number. The first length in \l@subsection is 3.8em (or 1.5em + 2.3em) and puts its number in a box of width 3.2em. So it seems the indentation of the sub-level is the sum of the indentation of its parent level and the parent's box width. With this is mind, \l@subsubsection should have an indentation of 7em (3.8em + 3.2em):


Look at that!

You can change the \section and \subsection indentation to now coincide with your 5.5em \l@chapter number-box width using

\patchcmd{\l@section}{5.5em}{2.3em}{}{}% Since \l@chapter uses 5.5em for \@tempdima
\patchcmd{\l@subsection}{7.8em}{3.2em}{}{}% Since \l@section uses 5.5em + 2.3em
  • Thanks, this works well. \patchcmd{\l@chapter}{1.5em}{5.5em}{}{} \patchcmd{\l@section}{1.5em}{5.5em}{}{} \patchcmd{\l@subsection}{3.8em}{7.8em}{}{} The only problem is that the chapter titles are long and when line breaks there is double-space gap between the first line and the second line of the chapter title. How to remove the extra space? – R. Toward Jan 10 '18 at 9:53
  • More info: imgur.com/a/Ex901 – R. Toward Jan 10 '18 at 10:06
  • @R.Toward: That may be related to your use of \addtocontents{toc}{\addvspace{.5cm}} before including every chapter. Perhaps try \addtocontents{toc}{\par\addvspace{.5cm}} (can't test it since I don't have your \documentclass or chapters). – Werner Jan 10 '18 at 16:20
  • Adding \par or removing the {\addvspace{.5cm}} doesn't affect the result. I have uploaded the cls file here. textuploader.com/dmdg6 – R. Toward Jan 10 '18 at 16:55

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.