You need to patch the \@startsection
command; patching \section
is also possible, but it would add a spacing command also for \section*
. Not a big deal, but if it's possible to avoid it, the better.
\documentclass[11pt,a4paper]{scrartcl}
\usepackage{amsmath}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@startsection}
{\@dblarg}
{\artemis@space@loft{#2}\@dblarg}
{}{}
\newcommand{\artemis@space@loft}[1]{%
\ifnum#1=\sectionnumdepth
\doforeachtocfile[float]{%
\addtocontents{\@currext}{\protect\addvspace{\@sectionlistsgap}}%
}%
\fi
}
\newcommand{\@sectionlistsgap}{5pt} % <-- change here the desired gap
\makeatother
\numberwithin{figure}{section}
\begin{document}
\listoffigures
\section{Section}
\begin{figure}[ht]\caption{Figure}\end{figure}
\begin{figure}[ht]\caption{Figure}\end{figure}
\section{Section}
\subsection{SUB}
\begin{figure}[ht]\caption{Figure}\end{figure}
\end{document}
Explanation: \@dblarg
is executed only when we have \section
without *
; so, before TeX executes it, we add \artemis@space@loft
, that adds a vertical space annotation in the .lof
and .lot
files. This is the same as the book
class does for \chapter
(10pt is used there, in an article a smaller space seems more appropriate). It uses a technique suggested by Johannes_B that exploits a feature of Koma-Script; in this way also newly defined float types will get the same treatment.
Parameter #2
to \@startsection
is the section level, so we check it's the same as \sectionnumdepth
. For article
one should use \@ne
instead of \sectionnumdepth
in the body of \artemis@space@loft
.
I added \subsection
in order to check that the spacing is added only for sections (and it is).
Important update for KoMaScript version 3.14
When the newly released version 3.14 of KoMaScript classes and packages has been installed, the above patch doesn't work any more.
For this version one has to change
\patchcmd{\@startsection}
{\@dblarg}
{\artemis@space@loft{#2}\@dblarg}
{}{}
into
\patchcmd{\scr@startsection}
{\scr@section@dblarg}
{\artemis@space@loft{#2}\scr@section@dblarg}
{}{}
Thanks to Johannes_B for having noticed it so early (the new version was uploaded in TeX Live on December 8, 2014).
If both patches are necessary for a cooperative job when one of the parties has not yet updated KoMaScript, then
\makeatletter
\ifdefined\scr@startsection
\patchcmd{\scr@startsection}
{\scr@section@dblarg}
{\artemis@space@loft{#2}\scr@section@dblarg}
{}{}
\else
\patchcmd{\@startsection}
{\@dblarg}
{\artemis@space@loft{#2}\@dblarg}
{}{}
\fi
\newcommand{\artemis@space@loft}[1]{%
...
should do.
listof
and values likechaptergapline
,chaptergapsmall
ornochaptergap
.