1

How do I reduce the spacing between the chapter title (Background) and the section (Recurrent Neural Networks)

enter image description here

\documentclass[pdftex,12pt,a4paper]{report}
\usepackage{titlesec}
%\titleformat{\chapter}{\bfseries\huge}{\thechapter.}{20pt}{\huge}
\titleformat{\chapter}[display] {\normalfont\Huge\bfseries}{\chaptertitlename\ \thechapter}{0pt}{\Huge}
  • 1
    You could use the titlespacing command from the titlesec package. (See this answer: tex.stackexchange.com/a/53341/134144) – leandriis Dec 27 '17 at 23:50
  • i tried \titlespacing{\section}{10pt}{-\parskip}{\parskip} but it is not changing the right thing – Kong Dec 27 '17 at 23:59
  • which code should i use and which bracket should i edit – Kong Dec 28 '17 at 0:00
  • \titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt} \titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt} \titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt} – Kong Dec 28 '17 at 0:00
  • 1
    @kong: For that you can use \titlespacing\chapter{0pt}{50pt}{20pt}, where 0pt and 50pt are the default <left> and <before> separations (used in titlesec). – Werner Dec 28 '17 at 1:27
2

I assume that if you want to reduce the space between the (numbered) chapter header and the following section header, you also want to reduce the space between the lines that contain the chapter number and the chapter header.

Here's a solution that doesn't use any packages (other than etoolbox, which allows the "patching" of existing macros).

Note that this solution does not affect the amount of whitespace above the chapter header.

\documentclass[12pt,a4paper]{report} 

\usepackage{etoolbox} % for "\patchcmd" macro
\makeatletter
% No extra space between chapter number and chapter header lines:
\patchcmd{\@makechapterhead} {\vskip 20}{\vskip 0} {}{}
% Reduce extra space between chapter header and section header lines by 50%:
\patchcmd{\@makechapterhead} {\vskip 40}{\vskip 20}{}{}
\patchcmd{\@makeschapterhead}{\vskip 40}{\vskip 20}{}{} % for unnumbered chapters
\makeatother

\begin{document} 
\setcounter{chapter}{1} % just for this example
\chapter{Background}
\section{Recurrent Neural Networks}
\end{document}

enter image description here

2
\documentclass[pdftex,12pt,a4paper]{report}
\usepackage[english]{babel}

\usepackage{titlesec}
%\titleformat{\chapter}{\bfseries\huge}{\thechapter.}{20pt}{\huge}
\titleformat{\chapter}[display] {\normalfont\Huge\bfseries}{\chaptertitlename\ \thechapter}{0pt}{\Huge}
\titlespacing{\chapter}{1cm}{2cm}{3cm}
\begin{document}


\chapter{Title of Chapter}
\section{Title of Section}

\end{document}

Just needed an extra line of code. In \titlespacing{\chapter}{1cm}{2cm}{3cm} adjust 1 to adjust the left margin, adjust 2 to adjust the vertical space before the title, adjust 3 to adjust the separation between title and non-sectioning text.

  • It might be helpful if you stated the default values of the three arguments of \titlespacing. – Mico Dec 28 '17 at 2:03
  • I guess, the default values you are looking for, have to do with the document class you are using (report). What i know for sure, is that you really don't need them. In case you want to return to the default spacing you can just omit the titlespacing section. – chadoulis Dec 28 '17 at 2:29

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.