I would like to include the chapter titles in my list of figures. @GonzaloMedina previously answered this question using titletoc. However, not all my chapters are numbered, so I would like the chapter titles in the lof to be shown just as they are in the toc.
This is Gonzalo Medina's preamble:
\documentclass{report}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\usepackage{etoolbox} % or xpatch
\usepackage{titletoc}
\makeatletter
% initial definitions of the chapter info (name and number)
\def\thischaptertitle{}\def\thischapternumber{}
\newtoggle{noFigs}
\apptocmd{\@chapter}%
{\gdef\thischaptertitle{#1}\gdef\thischapternumber{\thechapter}%
\global\toggletrue{noFigs}}{}{}
% 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 {chapter}%
{\protect\numberline {\thischapternumber} {\thischaptertitle}}{}{} }
\global\togglefalse{noFigs}
}{}
}%
}
\makeatother
And creating the following document:
\begin{document}
\tableofcontents
\listoffigures
\setcounter{secnumdepth}{-1}
\chapter{Preface with a figure}
\setcounter{chapter}{0}
\setcounter{secnumdepth}{2}
\begin{figure}
\caption{caption text}
\end{figure}
\chapter{Test Chapter with Figures}
\begin{figure}
\caption{caption text}
\end{figure}
\begin{figure}
\caption{caption text}
\end{figure}
\end{document}
yields

and

My questions are
- How to surpress the preface's chapter number to be shown?
- How to combine this with the
hyperrefpackage to let the chapters in the lof be hyperlinks?
