# Add part title in KOMA-Script LoF/LoT

As specified in §3.20. Floating Environments of Tables and Figures on page 128 sq. of KOMA-Script documentation, one can add the option listof=withchapterentry to

Marks chapter starts at the lists of floating environments by a copy of their entries to the table of contents.

I.e. it adds chapter title above figures belonging to this chapter:

List of Figure

Chapter 1
1.1  My first figure.......................13
1.2  My second figure......................17

Chapter 42
42.1 My last figure.......................210


Question: As I use the scrbook class, what I'd like to do, is to emulate the same behavior yet with part titles, instead of chapter ones. I.e. to kind of create the listof=withpartentry option.
(I only need to make part titles appear, not chapter ones)

How could I do this?

Some questions already deal with this issue (e.g., Chapters inside LoF and LoT?, Include chapters in List of Figures with titletoc?). However, they are intended for standard classes (book). I think 'dirty' workarounds could be avoided with the scrbook class since the feature is already implemented for chapters.

You could patch \addparttocentry to get an entry for each part in LOF and LOT:

\documentclass{scrbook}

\unsettoc{lof}{chapteratlist}% remove the chapter gap in LOF
\unsettoc{lot}{chapteratlist}% % remove the chapter gap in LOT

\usepackage{xpatch}
\addxcontentsline{lof}{part}[{#1}]{#2}% copy the part entry to LOF
\addxcontentsline{lot}{part}[{#1}]{#2}% copy the part entry to LOT
}{}{\PatchFailed}

\begin{document}
\listoffigures
\part{Part One}
\chapter{Chapter One}
\captionof{figure}{My first figure}
\captionof{figure}{My second figure}
\chapter{Chapter Two}
\captionof{figure}{A figure in Chapter Two}
\part{Part Two}
\chapter{Chapter Three}
\captionof{figure}{My next figure}
\chapter{Chapter Four}
\chapter{Chapter Five}
\captionof{figure}{My last figure}
\end{document}


Or in all lists controlled by package tocbasic:

\documentclass[listof=ignorechapter]{scrbook}

\usepackage{xpatch}
\makeatletter
\doforeachtocfile{%
\ifstr{\@currext}{toc}{}{%
}%
}%
}{}{\PatchFailed}
\makeatother

\begin{document}
\listoffigures
\part{Part One}
\chapter{Chapter One}
\captionof{figure}{My first figure}
\captionof{figure}{My second figure}
\chapter{Chapter Two}
\captionof{figure}{A figure in Chapter Two}
\part{Part Two}
\chapter{Chapter Three}
\captionof{figure}{My next figure}
\chapter{Chapter Four}
\chapter{Chapter Five}
\captionof{figure}{My last figure}
\end{document}


Result:

It is also possible to declare a new style for the part entries in the lists. Example without page numbers for the part entries:

\documentclass[listof=ignorechapter]{scrbook}
\usepackage{xpatch}
\makeatletter
\doforeachtocfile{%
\ifstr{\@currext}{toc}{}{%
}%
}%
}{}{\PatchFailed}

\DeclareTOCStyleEntry[
pagenumberbox=\@gobble,
level=-1,
indent=0pt,
numwidth=0pt,
dynnumwidth
]{part}{partatlists}
\makeatother

\begin{document}
\listoffigures
\part{Part One}
\chapter{Chapter One}
\captionof{figure}{My first figure}
\captionof{figure}{My second figure}
\chapter{Chapter Two}
\captionof{figure}{A figure in Chapter Two}
\part{Part Two}
\chapter{Chapter Three}
\captionof{figure}{My next figure}
\chapter{Chapter Four}

• Great, thank you! The second solution is more compact, and - imho - better. Two more clarifications: is it possible to remove page numbers on part titles lines (here 3, 9 and 15)? How to not include part titles if there is no figure within this part? (I do understand this might be a bit complex, since the listof=chapterentry option does not implement it -- i.e. all chapters, even empty, are listed) – ebosi Jan 20 '17 at 9:53