Table of Contents Titles – Part Title in List of Figures and Tables with KOMA-Script

koma-scripttable of contentstitles

I'm using KOMAScript. I have a \listoffigures and a \listoftables. My document has several \part{}'s. In the two lists the figures and tables are already grouped (small vertical space) by the chapters.

What I'd like to have additionally to the ("anonymous") chapter vspace grouping is the part title over each "part group" of figures and tables in the two lists. Is this somehow possible without having to code a list from scratch?

Best Answer

You can setup your own entry by:

\newcommand{\addtocentrylistof}[3]{%
  \ifstr{#2}{}{%
    \addcontentsline{lof}{#1}{#3}%
    \addcontentsline{lot}{#1}{#3}%
  }{%
    \addcontentsline{lof}{#1}{\protect\numberline{#2}#3}%
    \addcontentsline{lot}{#1}{\protect\numberline{#2}#3}%
  }%
}

\renewcommand*{\addparttocentry}[2]{%
  \addtocentrydefault{part}{#1}{#2}%
  \addtocentrylistof{part}{#1}{#2}%
}

Here a small example:

\documentclass[english]{scrreprt}
\usepackage{babel}
\newcommand{\addtocentrylistof}[3]{%
  \ifstr{#2}{}{%
    \addcontentsline{lof}{#1}{#3}%
    \addcontentsline{lot}{#1}{#3}%
  }{%
    \addcontentsline{lof}{#1}{\protect\numberline{#2}#3}%
    \addcontentsline{lot}{#1}{\protect\numberline{#2}#3}%
  }%
}

\renewcommand*{\addparttocentry}[2]{%
  \addtocentrydefault{part}{#1}{#2}%
  \addtocentrylistof{part}{#1}{#2}%
}
\def\examplefig{\begin{figure}[!ht]\caption{foo}\end{figure}\begin{table}[!ht]\caption{foo}\end{table}}
\begin{document}
\tableofcontents
\listoffigures
\listoftables

\part{O I}
\chapter{foo}
\examplefig\examplefig\examplefig
\chapter{foo}
\examplefig\examplefig\examplefig
\chapter{foo}
\examplefig\examplefig\examplefig
\part{O II}
\chapter{bar}
\examplefig\examplefig\examplefig
\chapter{bar}
\examplefig\examplefig\examplefig
\chapter{bar}
\examplefig\examplefig\examplefig

\end{document}
Related Question