Group figures in LOF by chapter (with chapter number, but w/o page number)

I have a problem which I can't seem to solve:

My list of figures is grouped by chapters with a space between the figures of each chapter. What I would like to have though is not only space, but also a chapter heading that states the number and title of the chapter but not the page of the chapter.

Is there any way to do this? Preferrably without the tocloft package which for some reason adds huge spaces at the top of TOC and LOF that I can't seem to get rid of. Also when I include it, the LOF isn't shown in the TOC.

Any ideas?

Edit: I don't know if this qualifies as a minimal example, but this would be my example to show the problem.

\documentclass[12pt,headsepline,toc=bibliography,toc=listof]{scrreprt}

\begin{document}
\chapter{Chapter 1}
\begin{figure}
\caption{Figure 1}
\end{figure}
\begin{figure}
\caption{Figure 2}
\end{figure}

\chapter{Chapter 2}
\begin{figure}
\caption{Figure 3}
\end{figure}

\listoffigures

\end{document}


Which creates the following result. You can see that the figures are listed in groups by chapters with a space in between. I would like it to show "(number of the chapter) (space) (title of the chapter)" above each group, but no page number next to that (the page numbers next to the figures should still be visible, though). By (space) I mean just enough space, so that the first letter of the chapter title starts at exactly the same margin where the numbers of the listed figures do.

• Okay, I added an example. Hope this is what you asked, I'm new here and not quite sure what a 'minimal example' is supposed to look like. – wocknwolla Aug 1 '15 at 5:15
• @ChristianHupfer: It is not difficult to find the place where scrreprt inserts the space. But sadly it hardcodes the insertion to an \addvspace and so it is difficult to change it. If the code would use e.g. \addtocontents{\@currext}{\protect\insertchapterlistsgap} instead if would be easy to manipulate it. – Ulrike Fischer Aug 1 '15 at 11:06

There is a KOMA option to insert all chapters in all lists: chapteratlists=entry (or chapteratlists or listof=chapterentry)

If the chapter page numbers should not be shown in the list of figures (lof) you can use \AfterTOCHead[lof]{\addtokomafont{chapterentrypagenumber}{\nullfont}}.

Code:

\documentclass[12pt,headsepline,toc=bibliography,toc=listof,chapteratlists=entry]{scrreprt}

\begin{document}
\chapter{Chapter 1}
\begin{figure}
\caption{Figure 1}
\end{figure}
\begin{figure}
\caption{Figure 2}
\end{figure}

\chapter{Chapter 2}
\begin{figure}
\caption{Figure 3}
\end{figure}

\listoffigures
\tableofcontents

\end{document}


Update

I found a suggestion by Markus Kohm inserting the chapter only in the list of figures (tables, ...) if there is at least one figure (table, ...) in this chapter.

\documentclass[12pt,headsepline,toc=bibliography,toc=listof,chapteratlists=entry]{scrreprt}

%%%%% from http://www.komascript.de/comment/5070#comment-5070 (Markus Kohm)
\makeatletter
\immediate\write\@auxout{\string\chapterhas{\thechapter}{#1}}%
}
\newcommand*{\chapterhas}[2]{%
\global\@namedef{chapterhas@#1@#2}{true}%
}
\if@chaptertolists
\doforeachtocfile{%
\iftocfeature{\@currext}{chapteratlist}{%
\ifundefinedorrelax{chapterhas@\thechapter @\@currext}{%
}{%
}%
}{}%
}%
\fi
}
\makeatother
%%%%

\begin{document}
\chapter{Chapter 1}
\begin{figure}
\caption{Figure 1}
\end{figure}
\begin{figure}
\caption{Figure 2}
\end{figure}

\chapter{Chapter 2}

\chapter{Chapter 3}
\begin{figure}
\caption{Figure 3}
\end{figure}
\begin{table}
\caption{Table 1}
\end{table}

\listoffigures
\listoftables
\tableofcontents

\end{document}


Run three times to get

• Great, thank you a LOT! How would I add a vertical space between the chapter headings and the listed figures? That is the only modification I would like to to, but I wouldn't know how :( – wocknwolla Aug 2 '15 at 6:14