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}


\newcommand*\l@chapterinfo&\def\@nodottedtoclineand replacing\addcontentslineby\addtocontents{lof}{\contentsline {chapter}{\numberline {\thischapternumber} {\thischaptertitle}}{} }.titletoctakes care of the formating. – Markus Schmassmann Apr 21 '12 at 03:46\protectsome commands, otherwise thelofwon't be human readable. – Markus Schmassmann Apr 21 '12 at 15:05\addtocontentsto make it compatible withhyperref. – Gonzalo Medina Apr 21 '12 at 15:21tbph), then numbering in lists of figures/tables is messed up (e.g., fig 5.1 [not including placement hint forh] will show up in chapter 4's list of figures) --- if you're having this issue, it's a fairly quick fix to just add placement hints to the floats in question. – randomusername Sep 07 '22 at 22:36