I would like section numbers to be placed in the margin. I found a solution here (Theorem Name/Numbering in Margin) which works with a caveat: when the section title is very long, the title text line does not break. Explicit breaks (using \\
or \newline
) don't work either.
\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage[showframe=true]{geometry}
\titleformat{\section}%
{\Large\sffamily\bfseries}% format
{\llap{% label
\thesection\hskip 12pt}#1}%
{0pt}% horizontal sep
{}% before
\begin{document}
\section{A long long long long long long long long long long long long long long long title}
Normal text.
\end{document}
I don't fully understand what \llap
does, but I'm more interested in a solution that keeps the section numbers in the margin but allows the section title to line break. Using KOMA classes is fine, though I understand that may mean not using titlesec
.