[Tex/LaTex] Splitting list of figures

appendicestable of contents

I'm starting to accumulate a large and fairly unwieldy list of figures at the start of my thesis and want to split that list into two. I want to have a list of the 'main' figures included in the front matter and another list at the start of the appendices . This second list should just include any figures that are part of the appendices.

I've found a few examples that detail how I could suppress the figures in the appendix but nothing that describes how I would be able to then list them at a later point in my work.

Any ideas?

Thanks!

Best Answer

This can be easily done with the help of the titletoc package and its features for partial lists; \startlist, \printlist, \stoplist; the idea is to have to partial lists; the first one stops just before the appendices and at this point, the second list begins; a little example:

\documentclass{book}
\usepackage{graphicx}
\usepackage{titletoc}

\newcommand\myfigure{% just to quickly generate captioned images in the document
  \begin{figure}
  \centering
  \includegraphics[height=2cm]{example-image-a}
  \caption{test figure~\thefigure}
  \end{figure}%
}

\begin{document}

\startlist[main]{lof}% starts main list of figures
\printlist[main]{lof}{}{\chapter*{List of Figures in Main Part}}% prints main list of figures

\mainmatter
\chapter{Test chapter one}
\myfigure
\myfigure
\myfigure
\myfigure
\chapter{Test chapter one}
\myfigure
\myfigure
\myfigure
\myfigure
\myfigure
\myfigure

\appendix
\clearpage
\stoplist[main]{lof}% stops main list of figures

\startlist[appendix]{lof}% starts list of figures in appendices
\printlist[appendix]{lof}{}{\chapter*{List of Figures in 
Appendices}}% prints list of figures in appendices

\chapter{Test appendix one}
\myfigure
\myfigure
\myfigure

\chapter{Test appendix two}
\myfigure
\myfigure
\myfigure

\end{document}

An image of the main list:

enter image description here

An image of the list for images in appendices:

enter image description here

Without additional packages this can also be done with a little more work; the idea now is to change \ext@figure (controlling the extension of the auxiliary file in which the information for figure captions is written to) just at the beginning of the appendixes and to have a new list of figures through a new command defined in a similar way to the standard \listoffigures; a patch of \@chapter is necessary in order to have the default spacing (10pt) in the new list when a new chapter begins:

\documentclass{book}
\usepackage{xpatch}
\usepackage{graphicx}

\makeatletter
\newcommand\listofappfigures{%
  \renewcommand\ext@figure{lfa}%
   \renewcommand\listfigurename{List of Figures in Appendices}%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename}%
      \@mkboth{\MakeUppercase\listfigurename}%
              {\MakeUppercase\listfigurename}%
    \@starttoc{lfa}%
    \if@restonecol\twocolumn\fi
    }
\xpatchcmd{\@chapter}{\addtocontents{lot}{\protect\addvspace{10\p@}}}{\addtocontents{lot}{\protect\addvspace{10\p@}}\addtocontents{lfa}{\protect\addvspace{10\p@}}}{}{}
\makeatother

\newcommand\myfigure{%
  \begin{figure}
  \centering
  \includegraphics[height=2cm]{example-image-a}
  \caption{test figure~\thefigure}
  \end{figure}%
}

\begin{document}

\listoffigures

\mainmatter
\chapter{Test chapter one}
\myfigure
\myfigure
\myfigure
\myfigure
\chapter{Test chapter one}
\myfigure
\myfigure
\myfigure
\myfigure
\myfigure
\myfigure

\appendix

\listofappfigures

\chapter{Test appendix one}
\myfigure
\myfigure
\myfigure

\chapter{Test appendix two}
\myfigure
\myfigure
\myfigure

\end{document}