1

I have a list of figure where figures are grouped by chapter (see image below).

list of figures with gaps

I have already tried numbers of solutions but none of them worked. Here's a MWE:

    \documentclass{report}
\usepackage[german]{babel}
\usepackage{graphicx} % Required for inserting images

\begin{document} \renewcommand{\listfigurename}{Abbildungsverzeichnis} \listoffigures \chapter{chapter1} \begin{figure} \centering \includegraphics[width=3cm]{Figures/fig1.png} \caption{Caption 1} \end{figure} \begin{figure} \centering \includegraphics[width=3cm]{Figures/fig1.png} \caption{Caption 2} \end{figure}

\chapter{chapter1} \begin{figure} \centering \includegraphics[width=3cm]{Figures/fig1.png} \caption{Caption 1} \end{figure} \begin{figure} \centering \includegraphics[width=3cm]{Figures/fig1.png} \caption{Caption 2} \end{figure}

\chapter{chapter1} \begin{figure} \centering \includegraphics[width=3cm]{Figures/fig1.png} \caption{Caption 1} \end{figure} \begin{figure} \centering \includegraphics[width=3cm]{Figures/fig1.png} \caption{Caption 2} \end{figure} \end{document}

Thanks for your help

2 Answers2

2

You can remove these gaps by patching \@chapter; it inserts gaps in both the List of Figures (lot) and List of Tables (lot). Patching is done using a search-and-replace technique provided by etoolbox's \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}.

enter image description here

\documentclass{report}

\usepackage[german]{babel} \usepackage{graphicx} \usepackage{etoolbox}

\renewcommand{\listfigurename}{Abbildungsverzeichnis}

\makeatletter \patchcmd{@chapter}% <cmd> {\addtocontents{lof}{\protect\addvspace{10\p@}}}% <search> {}% <replace> {}{}% <success><failure> \patchcmd{@chapter}% <cmd> {\addtocontents{lot}{\protect\addvspace{10\p@}}}% <search> {}% <replace> {}{}% <success><failure> \makeatother

\begin{document}

\listoffigures

\chapter{First chapter} \begin{figure} \caption{Caption 1} \caption{Caption 2} \end{figure}

\chapter{Second chapter} \begin{figure} \caption{Caption 1} \caption{Caption 2} \end{figure}

\chapter{Third chapter} \begin{figure} \caption{Caption 1} \caption{Caption 2} \end{figure}

\end{document}

You need at least two compilations on the first change in order for the patch to reflect in the LoF/LoT.

Werner
  • 603,163
1

This is caused by the definition of \chapter in the report class. It calls another command \@chapter which calls \addtocontents{lof {\protect\addvspace{10\p@}}% adding vertical space to the list of figues auxiliary file. You don't want this to happen. One way to "fix" this: is to copy the \@chapter command into your document and comment out the offending line.

\documentclass{report}
%\usepackage[german]{babel}
\usepackage{graphicx} % Required for inserting images

\makeatletter %\show@chapter \def@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne \refstepcounter{chapter}% \typeout{@chapapp\space\thechapter.}% \addcontentsline{toc}{chapter}% {\protect\numberline{\thechapter}#1}% \else \addcontentsline{toc}{chapter}{#1}% \fi \chaptermark{#1}% % \addtocontents{lof}{\protect\addvspace{10\p@}}% \addtocontents{lot}{\protect\addvspace{10\p@}}% \if@twocolumn @topnewpage[@makechapterhead{#2}]% \else @makechapterhead{#2}% @afterheading \fi} \makeatother

\begin{document} \renewcommand{\listfigurename}{Abbildungsverzeichnis} \listoffigures \chapter{chapter1} \begin{figure} \centering \includegraphics[width=3cm]{fig1.png} \caption{Caption 1} \end{figure} \begin{figure} \centering \includegraphics[width=3cm]{fig1.png} \caption{Caption 2} \end{figure}

\chapter{chapter1} \begin{figure} \centering \includegraphics[width=3cm]{fig1.png} \caption{Caption 1} \end{figure} \begin{figure} \centering \includegraphics[width=3cm]{fig1.png} \caption{Caption 2} \end{figure}

\chapter{chapter1} \begin{figure} \centering \includegraphics[width=3cm]{fig1.png} \caption{Caption 1} \end{figure} \begin{figure} \centering \includegraphics[width=3cm]{fig1.png} \caption{Caption 2} \end{figure} \end{document}