# Adjusting spacing before and after subparagraph with sectsty

I am helping a friend that is using sectsty to format the titles in his document. How can I adjust the spacing before and after the titles, in particular the subparagraph one?

(I know that titlesec is more powerful. But for now we just need either a quick fix or the full translation of the following to titlesec.)

This is what we have now:

\usepackage{sectsty}
\allsectionsfont{\centering\normalfont\normalsize}
\subsectionfont{\noindent\normalfont\normalsize\emph}
%\subsubsectionfont{\indent\normalfont\normalsize\itshape}
\subparagraphfont{\indent\normalfont\normalsize\itshape}


As usual this is because of thesis requirements made by ignorant people.

• Always post complete examples rather than code snippets, please! – Werner Mar 29 '14 at 5:50
• Which document class do you use? – Mico Mar 29 '14 at 6:23
• apa6, I'll post a complete example when I have access to the original document. – alfC Mar 29 '14 at 7:50

sectsty only updates only the sectional unit font-related setting but still use the traditional \@startsection construction:

\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
%     {\normalfont\Large\bfseries}}
{\normalfont\Large\bfseries\SS@sectfont}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
%     {\normalfont\large\bfseries}}
{\normalfont\large\bfseries\SS@subsectfont}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
%     {\normalfont\normalsize\bfseries}}
{\normalfont\normalsize\bfseries\SS@subsubsectfont}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
%     {\normalfont\normalsize\bfseries}}
{\normalfont\normalsize\bfseries\SS@parafont}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
%     {\normalfont\normalsize\bfseries}}
{\normalfont\normalsize\bfseries\SS@subparafont}}


The normal font-selections are commented out and substituted with the sectsty formatting \SS@.... Read up on the meaning of each component of \@startsection in Where can I find help files or documentation for commands like \@startsection for LaTeX? and focus on arguments 4 (before skip) & 5 (after skip).

Here's an example that adjust the space before and after the \subparagraph unit:

\documentclass{article}
\usepackage{sectsty}
\allsectionsfont{\centering\normalfont\normalsize}
\subsectionfont{\noindent\normalfont\normalsize\emph}
%\subsubsectionfont{\indent\normalfont\normalsize\itshape}
\subparagraphfont{\indent\normalfont\normalsize\itshape}
\begin{document}
\section{A section}
Some text
\subsection{A subsection}
Some text
\subsubsection{A subsubsection}
Some text
\paragraph{A paragraph}
Some text
\subparagraph{A subparagraph}
Some text

\makeatletter
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
{2\baselineskip \@plus1ex \@minus .2ex}%
{\baselineskip}%
%     {\normalfont\normalsize\bfseries}}
{\normalfont\normalsize\bfseries\SS@subparafont}}
\makeatother

\subparagraph{A subparagraph}
Some text

\end{document}


Note that sectsty is assuming that your working with a document class for which the sectional units use \@startsection without modification from the default classes, with the exclusion of KOMA-Script (from the sectsty documentation; section 1 Introduction, p 2):

The secsty package provides a set of commands for changing the font used for the various sectional headings in the standard LaTeX 2e document classes: article, book, and report. This package also works with the KOMA-Script classes scrartcl, scrbook, and scrreprt.

While it "will work" with other document classes, the effect is merely to overwrite the sectional units' definitions with that of the default document classes mentioned above. For example, apa6 defines

\renewcommand{\section}{\@startsection {section}{1}{\z@}%
{\b@level@one@skip}{\e@level@one@skip}%
{\centering\normalfont\normalsize\bfseries}}

\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
{\b@level@two@skip}{\e@level@two@skip}%
{\normalfont\normalsize\bfseries}}

\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\parindent}%
{0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
{-1em}%

\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\parindent}%
{0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
{-1em}%

\renewcommand{\subparagraph}[1]{\@startsection{subparagraph}{5}{1em}%
{0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
{-\z@\relax}%
{\normalfont\normalsize\itshape\hspace{\parindent}{#1}\textit{.}}{\relax}}


In order to maintain the sectional unit structure, you're better off redefining the above set manually* (separate from sectsty, as was done in the first example). The same approach would hold (including a redefinition to your liking within a \makeatletter...\makeatother pair) as apa6 also uses \@startsection to define the sectional units.

* Of course, other packages could be used as well, if they are compatible with apa6, but that seems to be out of the question here.

• Since you have to redefine \subparagragraph anyway, what's the point in using sectsty? – egreg Mar 29 '14 at 9:37
• @egreg: The OP wants to update the \subparagraph spacing, but maintain some consistency/ease in terms of the modification for all other sectional unit fonts. Either way, apa6 (the document class in use) is "not compatible" with sectsty, so I've added some more detail. – Werner Mar 29 '14 at 17:21
• @Werner, "apa6 is not compatible with sectsty". Good to know, I wish we didn't use sectsty to start with, it's being a pain so far. – alfC Mar 30 '14 at 5:39