0

I want to add the chapter name to the list of figure. I managed to do that using the following code

\addtocontents{lof}{{% 
\textbf{Chapter 01}
\vspace{10pt}}{} 
}

Im using Lyx so i added this code after every chapter title and i got this: enter image description here but i want something different, i want something like this: enter image description here

Werner
  • 603,163
Djope Ben
  • 3
  • 1
  • Can you provide a minimal example that sets up a document with a couple of figures spread across a couple of chapters? Most importantly, we'd like to see what \documentclass you're using and packages associated with your LoF. It's obvious you're doing some additions since the default behaviour does not include the word Figure before every number. Can you do this? – Werner May 14 '20 at 16:51
  • For the document class Im using "Report (Standard Class)", and Im not using any specific packages just followed the answer in the below link to add the word "Figure" to my list of figures https://tex.stackexchange.com/questions/155177/how-to-add-the-word-figure-to-the-list-of-figures – Djope Ben May 14 '20 at 17:15

1 Answers1

1

The following code uses etoolbox to patch \@chapter, adding a "chapter ornament" to the LoF immediately after the default space (of 10\p@ that is usually added). You can change the code of \lofchapter to suit your ornament needs.

enter image description here

\documentclass{report}

\usepackage{lipsum}
\usepackage{etoolbox}

\makeatletter
% Update \@chapter to insert the chapter ornament in the LoF
\patchcmd{\@chapter}% <cmd>
  {\addtocontents{lof}{\protect\addvspace{10\p@}}}% <search>
  {\addtocontents{lof}{%
     \protect\addvspace{10\p@}% Default space between chapters in LoF
     \protect\lofchapter{\thechapter}% Add chapter ornament
  }}% <replace>
  {}{}% <success><failure>
\makeatother

\newcommand{\lofchapter}[1]{%
  \noindent
  \rule[.5ex]{.4\linewidth}{.2ex}\hfill
  \textsc{Chapter #1}\hfill
  \rule[.5ex]{.4\linewidth}{.2ex}\par
  \nobreak
}

\begin{document}

\sloppy% Just for this example

\listoffigures

\chapter{First chapter}
\lipsum[1-10]\begin{figure}\caption{First figure}\end{figure}
\lipsum[11-20]\begin{figure}\caption{Second figure}\end{figure}
\lipsum[21-30]\begin{figure}\caption{Third figure}\end{figure}
\lipsum[31-40]\begin{figure}\caption{Last figure}\end{figure}
\lipsum[41-50]

\chapter{Second chapter}
\lipsum[1-10]\begin{figure}\caption{First figure}\end{figure}
\lipsum[11-20]\begin{figure}\caption{Second figure}\end{figure}
\lipsum[21-30]\begin{figure}\caption{Third figure}\end{figure}
\lipsum[31-40]\begin{figure}\caption{Last figure}\end{figure}
\lipsum[41-50]

\chapter{Third chapter}
\lipsum[1-10]\begin{figure}\caption{First figure}\end{figure}
\lipsum[11-20]\begin{figure}\caption{Second figure}\end{figure}
\lipsum[21-30]\begin{figure}\caption{Third figure}\end{figure}
\lipsum[31-40]\begin{figure}\caption{Last figure}\end{figure}
\lipsum[41-50]

\chapter{Last chapter}
\lipsum[1-10]\begin{figure}\caption{First figure}\end{figure}
\lipsum[11-20]\begin{figure}\caption{Second figure}\end{figure}
\lipsum[21-30]\begin{figure}\caption{Third figure}\end{figure}
\lipsum[31-40]\begin{figure}\caption{Last figure}\end{figure}
\lipsum[41-50]

\end{document}
Werner
  • 603,163