0

I am writing my dissertation into a series that has rather strict guidelines e.g. on the spacing before and after chapter and section titles. There are supposed to be two blank lines before and after the first level heading (ie chapter), two blank lines before and one after the second level heading (ie section) and one blank line before and after the third level (ie subsection). However, if there is a lower-level heading directly under the previous higher-level heading, the blank lines before the lower-level heading should be suppressed. I can't seem to find a way to do this with the titlesec package. MWE below.

\documentclass[a4paper]{report}
\usepackage{titlesec}

\titlespacing{\chapter}{0pt}{2\baselineskip}{2\baselineskip}
\titlespacing{\section}{0pt}{2\baselineskip}{\baselineskip}
\titlespacing{\subsection}{0pt}{\baselineskip}{\baselineskip}
\begin{document}
\chapter{First chapter}
\section{First section of the first chapter}
Text text text
\chapter{Second chapter}
Text text text
\section{First section of the second chapter}
Text text text
\end{document}

In this case, the first section heading has too much leading vertical space, ie. 4 blank rows, when it should only have the two blank rows dictated by the chapter heading. How could I suppress the before blank rows if the current heading is directly under the higher-level heading?

  • Your example document doesn't show what you are saying. In fact the spacing after the first chapter title is bigger than the second one. – Piet van Oostrum Nov 24 '16 at 12:33
  • This is precisely what I am trying to prevent. I edited the question to try to clarify this. – Markku Koskinen Nov 24 '16 at 12:48
  • Sorry, I tried again with your document, and I measured it with a ruler: and the space is the same in both cases. Moreover, the spaces are not 2 lines and 1 line as you said it should be. Have you tried your own document? – Piet van Oostrum Nov 24 '16 at 13:08
  • I did, and also measured it with a ruler before I submitted the question. The spacing between "First chapter" and "First section of ..." is 1.8cm; the spacing between "Second chapter" and "Text text text" is 1.6cm. – Markku Koskinen Nov 24 '16 at 13:47
  • That difference is caused by the section title text being larger than the normal text. If you would put {\Large\bfseries First text} as the first text after the chapter title, then the distance is the same. So it seems that LaTeX is already eliminating the space above the section title if it immediately folows the chapter title. And the needed 2 blank rows would be about 10 mm, not 16 mm. In fact your chapter titlespacing isn't working at all. Just put some ridiculous numbers there and check. You will see that it makes no difference. The spacing of the chapter title is the LaTeX default. – Piet van Oostrum Nov 24 '16 at 14:12
1

I think this should come close to the requirement. I don't know how the chapter title should be formatted, so you probably will have to adjust that. Also you may have to fine tune the measurements. Please note that the \titlespacing{\chapter} command will not have any effect without the \titleformat{chapter} command.

\titleformat{\chapter}[display]{\Huge\bfseries}{\huge Chapter \thechapter}{1ex}{}
\titlespacing{\chapter}{0pt}{2\baselineskip}{1.5\baselineskip}
\titlespacing{\section}{0pt}{\baselineskip}{\baselineskip}
\titlespacing{\subsection}{0pt}{\baselineskip}{\baselineskip}

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.