2

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. enter image description here 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.

  • Please add your (minimal) code to the question. – user11232 Aug 1 '15 at 4:39
  • 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
  • 1
    @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
1

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}}.

enter image description here

Code:

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

\AfterTOCHead[lof]{\addtokomafont{chapterentrypagenumber}{\nullfont}}

\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}

\AfterTOCHead[lof]{\addtokomafont{chapterentrypagenumber}{\nullfont}}
\AfterTOCHead[lot]{\addtokomafont{chapterentrypagenumber}{\nullfont}}

%%%%% from http://www.komascript.de/comment/5070#comment-5070 (Markus Kohm)
\makeatletter
\let\chapterhas@original@addcontentsline\addcontentsline
\renewcommand*{\addcontentsline}[1]{%
  \immediate\write\@auxout{\string\chapterhas{\thechapter}{#1}}%
  \chapterhas@original@addcontentsline{#1}%
}
\newcommand*{\chapterhas}[2]{%
  \global\@namedef{chapterhas@#1@#2}{true}%
}
\renewcommand*{\addchaptertocentry}[2]{%
  \addtocentrydefault{chapter}{#1}{#2}%
  \if@chaptertolists
    \doforeachtocfile{%
      \iftocfeature{\@currext}{chapteratlist}{%
        \ifundefinedorrelax{chapterhas@\thechapter @\@currext}{%
        }{%
          \addxcontentsline{\@currext}{chapteratlist}[{#1}]{#2}%
        }%
      }{}%
    }%
    \@ifundefined{float@addtolists}{}{\scr@float@addtolists@warning}%
  \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

enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.