Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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


share|improve this question
    
Are you using any special class? –  Martin Scharrer Oct 26 '11 at 7:22
4  
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
1  
If you are using a KOMA-Class you can use the option listof=chapterentry for chapters. –  Marco Daniel Oct 26 '11 at 11:36
add comment

2 Answers 2

up vote 10 down vote accepted

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}
\addcontentsline{lof}{part}{Part A}
\chapter{A1}
\addcontentsline{lof}{chapter}{Chapter A1}
\section{A11}
\begin{figure}
\caption{FigA1}
\end{figure}
\begin{figure}
\caption{FigA2}
\end{figure}
\chapter{A2}
\addcontentsline{lof}{chapter}{Chapter A2}
\begin{figure}
\caption{FigA21}
\end{figure}
\part{B}

\end{document}

The result is

enter image description here

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}
\addcontentsline{lof}{part}{\thepart\hspace{1em}#1}
}

\newcommand{\mychapter}[1]{%
\chapter{#1}
\addcontentsline{lof}{chapter}{\numberline{\thechapter}#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}

enter image description here

share|improve this answer
    
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
1  
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
add comment

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

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@chapter}
  {\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}}
  {\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
   \addcontentsline{lof}{chapter}{\protect\numberline{\thechapter}#1}%
   \addcontentsline{lot}{chapter}{\protect\numberline{\thechapter}#1}}
  {}{}
\patchcmd{\@part}
  {\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}}
  {\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
   \addcontentsline{lof}{part}{\thepart\hspace{1em}#1}%
   \addcontentsline{lot}{part}{\thepart\hspace{1em}#1}}
\makeatother

However this will print the lines also when there are no figures or tables in the chapter.

Generally speaking, I'd not recommend such detailed listings, as the figure or table numbers already say where they belong.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.