In this code, i want the spacing before and after of my section, subsection, and subsubsection headings to be exactly 1.5cm regardless of the font size or my line spacing. How can i do this?
I know that this question has been asked before several times on this site but I want a package-free solution.
\documentclass[a4paper]{book}
\usepackage{lipsum}
\begin{document}
\chapter{A Chapter}
\lipsum[2]
\section{Foo}
\lipsum[2]
\subsection{Bar}
\lipsum[2]
\subsubsection{Foo Bar}
\lipsum[2]
\end{document}
Edit
I know that the spacing before, say, section headings is controlled by the code below, but when I enter -1.5cm instead of -3.25ex, the vertical space before the heading doesn't become exactly 1.5cm on the output. Why?
\makeatletter
\newcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}}
\makeatother
-1.5cm \@plus -1ex \@minus -.2ex? – Werner Jan 21 '15 at 17:17titlesecpackage. – Sisabe Jan 21 '15 at 17:31\@plusand\@minus, you allow for1.5cmto increase by1exor decrease by.2ex(see What is glue stretching?). If you use only-1.5cm, you should get a fixed skip of1.5cmfrom the baseline of the last paragraph to the top of the baseline of the section title. – Werner Jan 21 '15 at 17:52