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?

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

  • Oh largestsep where have you been all my life?! – Caleb Nov 8 '14 at 9:07

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.