# Change the bottom and top margin of section and subsection

In my current document, section and subsection have too much bottom and top margin. How can I change that globally to be less? I use the document class as book.

-

As you didn't specify how much less, here's a general answer: \usepackage[compact]{titlesec}.

\documentclass{article}

\usepackage[compact]{titlesec}

\begin{document}

\section{First}

\subsection{First-first}

Some text.

\section{Second}

Some text.

\end{document}


EDIT: Here's an example how to change the spacing starting from values corresponding to the book class (see secion 9.2 of the titlesec manual for details):

\documentclass{book}

\usepackage{titlesec}

% Spacing corresponding to book class
% \titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
% \titlespacing*{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

% Spacing before/after reduced by 1ex each
\titlespacing*{\section} {0pt}{2.5ex plus 1ex minus .2ex}{1.3ex plus .2ex}
\titlespacing*{\subsection} {0pt}{2.25ex plus 1ex minus .2ex}{0.5ex plus .2ex}

\begin{document}

\chapter{First}

\section{First-first}

\subsection{First-first-first}

Some text.

\section{First-second}

Some text.

\end{document}


-
I thought we would be setting those as values but apparently not. Thanks! –  tugberk May 5 '12 at 14:22
@tugberk If you edit your question to include the document class and the top/bottom spacing you strive for, a more specific answer is likely to be provided. –  lockstep May 5 '12 at 14:24