1

I want chapters in the report class to start 3em below the end of the previous chapter. To do this, I patch the \chapter command using titlesec and etoolbox. However, this adds blank space above the chapter name even if is on the top of a new page, which I don't want. How can I remove the spacing if the chapter starts at the top of a new page? I want the Sixth chapter heading like in the right hand side figure below, not the one at the left.

Actual output and wanted output

\documentclass[12pt,a4paper]{report}

\usepackage{lipsum}  
\usepackage{titlesec}  
\usepackage{etoolbox}

\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}%
    {\par\vspace{\baselineskip}}{}{}
\makeatother
\titlespacing*{\chapter}{0mm}{3em}{1em}

\begin{document}

\chapter*{First chapter}
\lipsum[1-4]
\chapter*{Second chapter}
\lipsum[1-2]
\chapter*{Third chapter}
\lipsum[2]
\chapter*{Fourth chapter}
\lipsum[1-3]
\chapter*{Fifth chapter}
\lipsum[2]
\chapter*{Sixth chapter}
\lipsum[1-2]

\end{document}
1

titlesec inserts the "traditional" forced vertical space as part of setting the chapter title header. You need to also change this \vspace* to \vspace so the space is gobbled at the start of a page:

enter image description here

\documentclass[a4paper]{report}

\usepackage{lipsum}  
\usepackage{titlesec}  
\usepackage{etoolbox}

\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}%
    {\par\addvspace{\baselineskip}}{}{}
\titlespacing*{\chapter}{0mm}{3em}{1em}
\patchcmd{\ttl@save@mkschap}{*}{}{}{}
\makeatother

\begin{document}

\chapter*{First chapter}
\lipsum[1-4]
\chapter*{Second chapter}
\lipsum[1-2]
\chapter*{Third chapter}
\lipsum[2]
\chapter*{Fourth chapter}
\lipsum[1-3]
\chapter*{Fifth chapter}
\lipsum[2]
\chapter*{Sixth chapter}
\lipsum[1-2]

\end{document}
  • This worked in the MWE, but I encountered new spacing problems once I started messing with titleformat. Bernard's solution works even in that case, though. – Solstrand Mar 17 '18 at 5:06
0

You don't need to patch whatever. Just change the class of \chapter to straight:

\documentclass[12pt,a4paper]{report}

\usepackage[showframe]{geometry}
\usepackage{lipsum}
\usepackage{titlesec}

\titleclass{\chapter}{straight}
\titleformat{\chapter}{\bfseries\huge}{\thechapter}{0.4em}{}
\titlespacing*{\chapter}{0mm}{3em}{1em}

\begin{document}

\chapter*{First chapter}
\lipsum[1-4]
\chapter*{Second chapter}
\lipsum[1-2]
\chapter*{Third chapter}
\lipsum[2]
\chapter*{Fourth chapter}
\lipsum[1-3]
\chapter*{Fifth chapter}
\lipsum[2]
\chapter*{Sixth chapter}
\lipsum[1-2]

\end{document} 

enter image description here

  • This worked a treat. So, I assume the straightremoves all the formatting? – Solstrand Mar 17 '18 at 5:07
  • @Solstrand: In principle it only changes the fact that \chapter doesn't start a new page: it behaves like \section. However, I had an error message for some reason, which disappears using \titleformat, which I made roughly like the default. Strangely enough, doing the same for \part produces no error message. – Bernard Mar 17 '18 at 9:20

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.