This is my first question on stackexchange!

I am using the tocloft package for my thesis and my university requires doublespacing before and after the chapter titles in the ToC, but only if the chapter has sections.

I am thinking that I will require some way to detect if the chapter has sections, or add a newline before the first section in each chapter. Can somebody suggest a way to achieve this?

  • Welcome to TeX.sx! Am I correct that there should be additional vertical space before/after chapter titles in the table of contents? (You added the tocloft tag, but did not mention the ToC in your actual question.) – lockstep Nov 11 '11 at 19:10
  • BTW, you don't have to sign with your name since it automatically appears in the lower right corner of your post. – lockstep Nov 11 '11 at 19:11
  • Thanks lockstep! There should be additional space after the chapter title if the chapter has sections within it. The section titles themselves are single spaced. I have \setlength{\cftbeforechapskip}{\baselineskip} but this only helps me in adding space before section titles. – Nikhil Gupta Nov 11 '11 at 19:26

If I understood your question, you can use the etoolbox package to hook to the \section command to add a vertical spacing in the ToC if the section counter is one:





\chapter{A chapter with sections}
\section{Section one one}
\section{Section one two}
\chapter{A chapter without sections}
\chapter{Another chapter with sections}
\section{Section one one}
\section{Section one two}


enter image description here

| improve this answer | |
  • @Nikhil Gupta: Hmm... now that I see my answer, this surely is not what you need, or is it? – Gonzalo Medina Nov 11 '11 at 19:31
  • However, the correct code is ` \preto\section{% \ifnum\value{section}=1\addtocontents{toc}{\vskip10pt}\fi }` – Nikhil Gupta Nov 11 '11 at 19:59
  • @NikhilGupta: are you sure? If so, then I didn't fully understand your question. – Gonzalo Medina Nov 11 '11 at 20:01
  • In the version that you composed, you were adding extra space in the else condition so it would add space before all sections except the first. That's the only modification I made. – Nikhil Gupta Nov 11 '11 at 20:05
  • @NikhilGupta: maybe I am misunderstanding you, but the code I posted produces the result illustrated in the attached image; i.e., extra space before the first section. – Gonzalo Medina Nov 11 '11 at 20:09

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.