In a table of contents style list of figures I would like to combine the appearance of each of these questions.
Part title in list of figures and tables?
Include chapters in List of Figures with titletoc?
Part title
Chapter title
List of Figures in this chapter
Chapter title
List of Figures in this chapter
Part title
Chapter title
List of Figures in this chapter
Chapter title
List of Figures in this chapter
I have tried to combine the parts, but in my MWE below, I don't seem to get the inclusion of the parts titles and I can't seem to change the formatting of these newly added titles. I need to add a little more space between them and make them more visibly different from the titles of the figures I am referencing?
\documentclass{report} \usepackage{etoolbox} % or xpatch \usepackage{bookmark} \usepackage{hyperref} \makeatletter % initial definitions of the part info (name and number) \def\thisparttitle{}\def\thispartnumber{} \def\thischaptertitle{}\def\thischapternumber{} \newtoggle{noFigs} \newtoggle{noTabs} \apptocmd{\@chapter}{\gdef\thischaptertitle{#1}\gdef\thischapternumber{\thechapter}\global\toggletrue{noFigs}}{}{} \apptocmd{\@part}{\gdef\thisparttitle{#1}\gdef\thispartnumber{\thepart}\global\toggletrue{noFigs}\global\toggletrue{noTabs}}{}{} % the figure environment does the job: the first time it is used after a \chapter command, it writes the information of the chapter to the LoF \AtBeginDocument{% \AtBeginEnvironment{figure}{% \iftoggle{noFigs}{ \addtocontents{lof}{\protect\contentsline{part}% {\protect\numberline{\thisparttitle}}{}{3.2em} } \addtocontents{lof}{\protect\contentsline {chapter}% {\protect\numberline {\thischapternumber} {\thischaptertitle}}{}{} } \global\togglefalse{noFigs} }{} }% \AtBeginEnvironment{table}{% \iftoggle{noTabs}{ \addtocontents{lot}{\protect\contentsline{part}% {\protect\numberline{\thisparttitle}}{}{} } \addtocontents{lot}{\protect\contentsline {chapter}% {\protect\numberline {\thischapternumber} {\thischaptertitle}}{}{} } \global\togglefalse{noTabs} }{} }% } \makeatother \begin{document} \tableofcontents \listoffigures \part{The first} \chapter{Introduction with no Figures} \chapter{Test Chapter with Figures} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \chapter{Test Chapter with no Figures} \part{The second} \chapter{Another Test Chapter with Figures} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \end{document} UPDATE
If I replace the document block of the solution below with this:
\begin{document} \tableofcontents \listoffigures \part{The first} \chapter{Introduction with no Figures} \chapter{Test Chapter with Figures} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \chapter{Test Chapter with no Figures} \part{The second} \chapter{Look no figures here either} \chapter{Another Test Chapter with Figures} \begin{figure} \caption{caption text} \end{figure} \chapter{Another in the same part} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \begin{figure} \caption{caption text} \end{figure} \end{document} I then get:

which duplicates Part titles even when the chapters are sequential (4 and 5 circled in blue to highlight this) and aren't interspersed with a chapter missing figures.


grouping?