3

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.

4

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}
\xapptocmd\addparttocentry{%
  \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}
\addpart{Unnumbered Part}
\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
\xapptocmd\addparttocentry{%
  \doforeachtocfile{%
    \ifstr{\@currext}{toc}{}{%
      \addxcontentsline{\@currext}{part}[{#1}]{#2}%
    }%
  }%
}{}{\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}
\addpart{Unnumbered Part}
\chapter{Chapter Five}
\captionof{figure}{My last figure}
\end{document}

Result:

enter image description here


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
\xapptocmd\addparttocentry{%
  \doforeachtocfile{%
    \ifstr{\@currext}{toc}{}{%
        \addxcontentsline{\@currext}{partatlists}[{#1}]{#2}%
    }%
  }%
}{}{\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}
\addpart{Unnumbered Part}
\chapter{Chapter Five}
\captionof{figure}{My last figure}
\end{document}

enter image description here

  • 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
  • 1
    I have added an example with a new style for the part entries in the lists to show how you can remove the page numbers. For the second question in your comment you can find a suggestion for chapters on the KOMA-Script website. Maybe you can adapt this for parts. – esdd Jan 20 '17 at 22:38
  • Thank you. The link is really interesting. Ich soll ja mein Deutsch wieder üben, aber nicht, dass mir das missfällt ! I should have a look at KOMA-Script website more often! – ebosi Jan 21 '17 at 12:52

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.