1

In the article class, is is possible to group items in the list of figures by chapter? e.g.:

enter image description here

Already I'm using the following to allow figures to by numbered relative to their chapter in the article class:

\usepackage{chngcntr}
\counterwithin{figure}{section}
  • Related: http://tex.stackexchange.com/questions/200360/list-of-tables-or-figures-by-section-latex –  Apr 07 '16 at 16:07

2 Answers2

2

I've added automatically a \addtocontents{lof}{\addvspace{...} after each section, but only, if the last figure counter is greater than zero.

Additionally I added a \FloatBarrier to prevent figures to leak from section into another one.

The amount of spacing can be controlled with \setlength{\figurelofgroupskip}{15pt} etc.

\documentclass{article}

\usepackage{placeins}

\newlength{\figurelofgroupskip}
\setlength{\figurelofgroupskip}{15pt}

\usepackage{chngcntr}
\counterwithin{figure}{section}

\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@sect}{%
  \ifnum #2>\c@secnumdepth
}{%
  \FloatBarrier
  \def\temp@@a{section}
  \edef\temp@@b{#1}
  \ifx\temp@@a\temp@@b
  \ifnum\value{figure} > 0 
  \addtocontents{lof}{\protect\addvspace{\figurelofgroupskip}}
  \fi
  \fi
  \ifnum #2>\c@secnumdepth
}{}{}
\makeatother


\usepackage{pgffor}

\begin{document}
\listoffigures
\section{First one}

\foreach \x in {1,...,10}{%
\begin{figure}
  \caption{This is figure \x\ from section \thesection}
\end{figure}
}

\section{Second one}

\subsection{Subsection of \thesection}
\foreach \x in {1,...,10}{%
\begin{figure}
  \caption{This is figure \x\ from section \thesection}
\end{figure}
}
\end{document}

enter image description here

1

If by chapter you really mean section, you can manually add spaces after each section using \addtocontents.

\documentclass{article}
\usepackage{caption}
\usepackage{chngcntr}
\counterwithin{figure}{section}
\renewcommand{\thefigure}{\thesection.\arabic{figure}}

\begin{document}
\listoffigures
\section{First}
\captionof{figure}{Ichi}
\captionof{figure}{Ni}
\section{Second}
\addtocontents{lof}{\rule{\textwidth}{0pt}}
\captionof{figure}{San}
\captionof{figure}{Shi}
\end{document}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120