I'm working on a book
using titlesec
&titletoc
and want to include chapters (with their numbers and names, but no page number) in the list of figures, if and only if they contain figures. Manually adding
\addtocontents{lof}{\contentsline {chapter}{\numberline {\thechapter} {#1}}{} }}
after each chapter works (#1
is the chaptername), and I could also fix the alignment (not part of MWE),
but I couldn't append this to \chapter
.
Can I get titletoc
to include chapters into the list of figures?
Or how do I modify \chapter
to add themselves to the lof?
\documentclass[a4paper,12pt]{book}
\usepackage[pagestyles,psfloats,clearempty,newlinetospace]{titlesec}
\usepackage{titletoc}
\titleformat{\chapter}{\huge\bfseries\filcenter}{\vspace{1cm}\thechapter}{0.5cm}{}[]
%\let\Oldchapter\chapter
%\renewcommand{\chapter}[1]{\Oldchapter{#1}\addtocontents{lof}%
%{\contentsline {chapter}{\numberline {\thechapter} {#1}}{} }}
\begin{document}
\tableofcontents
\listoffigures
\mainmatter
\chapter{Introduction}
\section{First}
\chapter{Has Figures}
\begin{figure}
\rule{1cm}{1cm}
\caption{caption text}
\end{figure}
\end{document}