# Chapters inside LoF and LoT?

I was wondering if it was possible to section the LoF (and similarly LoT) by Parts and/or Chapters.

Currently, I have :

List of Figures

1.1 blablabla

1.2 blablabla

1.3 blablabla

2.1 blablabla

2.2 blablabla

1.1 blablabla

1.2 blablabla

And I'd like to obtain :

Part 1

Chapter 1

1.1 blablabla

1.2 blablabla

1.3 blablabla

Chapter 2

2.1 blablabla

2.2 blablabla

Part 2

Chapter 1

1.1 blablabla

1.2 blablabla

-
Are you using any special class? –  Martin Scharrer Oct 26 '11 at 7:22
You would need to add \addcontentsline{lof}{chapter}{#1} and \addcontentsline{lot}{chapter}{#1} for every \chapter (#1 is the chapter title), either manually or by patching \chapter. However, I guess there is already a read-made solution available somewhere, so I wait before posting such code. –  Martin Scharrer Oct 26 '11 at 7:28
If you are using a KOMA-Class you can use the option listof=chapterentry for chapters. –  Marco Daniel Oct 26 '11 at 11:36

You can insert part, chapter or any other references in a table of contents, list of figures or list of tables with \addcontentsline{ext}{type}{text} where ext is the extension of auxiliar file (usually toc, lof, lot), type specifies type of contents and text what you want to be shown in the list. Here you have a simple example.

\documentclass{book}

\begin{document}
\tableofcontents
\listoffigures
\part{A}
\chapter{A1}
\section{A11}
\begin{figure}
\caption{FigA1}
\end{figure}
\begin{figure}
\caption{FigA2}
\end{figure}
\chapter{A2}
\begin{figure}
\caption{FigA21}
\end{figure}
\part{B}

\end{document}


The result is

The package tocloft allows you to define or change the format of a table of contents but I've never used it. You can read its introduction and will learn how ToC works in LaTeX.

EDIT: You can avoid typing twice chapter names and part names if you declare your own commands. Look at the example \mypart command contains \part and \addcontentsline. This way, parts and chapters in lof will look the same as in toc.

\documentclass{book}
\newcommand{\mypart}[1]{%
\part{#1}
}

\newcommand{\mychapter}[1]{%
\chapter{#1}
}

\begin{document}
\tableofcontents
\listoffigures
\mypart{A}
\mychapter{A1}
\section{A11}
\begin{figure}
\caption{FigA1}
\end{figure}
\begin{figure}
\caption{FigA2}
\end{figure}
\mychapter{A2}
\begin{figure}
\caption{FigA21}
\end{figure}
\mypart{B}

\end{document}


-
Perfect ! Is it possible to have them Chapter or Parts numbered (as in the ToC ?) –  oo1on Oct 26 '11 at 8:05
I've updated the answer. Hope it helps. –  Ignasi Oct 26 '11 at 9:51
Perfect. Thanks ! –  oo1on Oct 26 '11 at 12:14
With \mypart and \mychapter, the optional argument of \part and \chapter cannot be used. –  Gonzalo Medina Oct 26 '11 at 14:22
@GonzaloMedina: I know it. I've also read somewhere about problems with hyperref and addcontentsline which probably persist with my partial solution. I've never used a lof or lot and any package to configure them so I hope somebody else will provide us with a better approach. –  Ignasi Oct 26 '11 at 15:21

In order to add automatically the entries to the list of figures, you can patch the relevant commands:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@chapter}
{}{}
\patchcmd{\@part}