# Adding vertical spacing between chapter and its first section in table of contents

I'm using the style files given by my university for my thesis but they are quite old (eethesis document class). In my PDF output, the vertical space before and after the major headings in the table of contents is not consistent.

I want to insert a vertical space between a chapter heading and its first section (Refer to: Related question) but only if the chapter has any sections within. Currently the definitions for l@chapter in eethesis.cls is given below

\def\l@chapter#1#2{\pagebreak[3]
\vskip 0.75em plus 1pt   % space above chapter line
{\leftskip 2em\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent 2em\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima 4em\relax       % width of box holding chapter number
\advance\leftskip \@tempdima \hbox{}\hskip -\leftskip
\uppercase{#1}\nobreak\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfill \nobreak \hbox to\@pnumwidth{\hfil\rm #2}\par}
\vskip 0em}  % space below chapter line


and the definition of @chapter in eethe12.sty is

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}
\typeout{\@chapapp\space\thechapter.}
\addcontentsline{toc}{chapter}{\protect
\numberline{\thechapter}\uppercase{#1}}
\else\addcontentsline{toc}{chapter}{#1}\fi
\chaptermark{#1}
%   \addtocontents{toc}{\protect\vskip{0.75em plus 1pt}} % Add vertical space line
\if@twocolumn                                 % Tests for two-column mode.
\@topnewpage[\@makechapterhead{#2}]
\else \@makechapterhead{\uppercase{#2}}
\@afterheading                  % Routine called after chapter and
\fi}                                  % section heading.


Uncommenting the line - Add vertical space line - in the above definition does add a vertical space between the chapter heading and first section but it also increases the space between those chapters that have no sections.

What changes need to be done in order to get consistent spacing before and after all Chapter headings?

-
– lockstep Aug 10 '12 at 12:30
Can you please also add the definition of \section in your .cls class file? If no definition is given, then, please let us know in which document class eethesis.cls is based – Gonzalo Medina Aug 10 '12 at 13:20

## 1 Answer

Here's a possible solution using a redefinition of \section to test if the space must be added or not (I used the files eethesis.cls and custom_shortcuts.sty found in the link provided); you can adjust the vertical space according to your needs by changing the argument of \addvspace (I chose 10pt for the exampĺe) in the line marked with % change here:

\documentclass[phdthesis]{eethesis}

\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\sectiontitlefont%
\ifnum\value{section}>1
\else
\addtocontents{toc}{\protect\addvspace{10pt}}% change here
\fi}}
\makeatother

\title{The Title}
\author{The Author}

\begin{document}

\tableofcontents

\chapter{Test Chapter With Sections}
\section{Test Section One One}
\section{Test Section One Two}
\chapter{Test Chapter Without Sections}
\chapter{Another Test Chapter Without Sections}
\chapter{Another Test Chapter With Sections}
\section{Test Section Three One}
\section{Test Section Three Two}

\end{document}

-
Thank you. This helps. – Sirisha Mantravadi Aug 10 '12 at 18:14