3

I've run into a situation in a document where I sometimes have a section heading that follows directly after a subsection heading with no generic paragraph content inbetween. In these cases the value I set using \titleformat for padding before section headings seems to be ignored in favor of the value set for after subsection headings. See this MWE:

\documentclass{scrartcl}
\usepackage{titlesec}
\titlespacing*{\section}{0pt}{*6}{*1}
\titlespacing*{\subsection}{0pt}{*2}{*0}
\pagestyle{empty}
\begin{document}
Test
\section*{Section heading}
\subsection*{Subsection heading}
\section*{Another section heading(note lack of padding above)}
Test
\section*{Yet another section heading}
\end{document}

output of MWE missing padding

Normally I do not want any space at all after the subsection headings, but in the case of a subsection->section transition in the document I would like to prioritize the use of the padding value I set for section headers. Is there a way this can be accomplished?

1 Answer 1

4

You must use the largestsep option to titlesec. The default is aftersep:

\documentclass{scrartcl}

\usepackage[largestsep]{titlesec}
\titlespacing*{\section}{0pt}{*6}{*1}
\titlespacing*{\subsection}{0pt}{*2}{*0}
\pagestyle{empty}
\begin{document}

Test
\section*{Section heading}
\subsection*{Subsection heading}
\section*{Another section heading(note lack of padding above)}
Test
\section*{Yet another section heading}

\end{document} 

enter image description here

1
  • Oh largestsep where have you been all my life?!
    – Caleb
    Commented Nov 8, 2014 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .