I am seeking to add chapter headings to my list of figures, tables etc. I could not find a solution in the memoir manual, although the solution is probably contained within it I do not know what I am looking for exactly so my apologies.
I have modified RicoRally's EDIT solution here to apply to chapters but memoir is not detecting the titles or they are called something else which I do not know. The code with \documentclass{memoir} produces this lof:
Whereas the code with \documentclass{report} produces this lof:
The code that I am using is:
\documentclass[oneside]{memoir}
\usepackage{lipsum}
\usepackage{etoolbox}
\makeatletter
\def\thischaptertitle{}\def\thischapternumber{}
\newtoggle{noFigs}
\apptocmd{@chapter}%
{\gdef\thischaptertitle{#1}\gdef\thischapternumber{\thechapter}%
\global\toggletrue{noFigs}}{}{}
\AtBeginDocument{%
\AtBeginEnvironment{figure}{%
\iftoggle{noFigs}{
\addtocontents{lof}{\protect\contentsline {chapter}%
{\protect\numberline {\thischapternumber.} {\thischaptertitle}}{}{} }
\global\togglefalse{noFigs}
}{}
}%
}
\long\def@caption#1[#2]#3{%
\par
\gdef\my@caption{#2}
\begingroup
@parboxrestore
\if@minipage
@setminipage
\fi
\normalsize
@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\renewenvironment{figure}%
{@float{figure}}%
{\end@float
\addcontentsline{lof}{figure}%
{\protect\numberline{\thefigure}{\my@caption}}%
}%
\renewenvironment{figure*}%
{@dblfloat{figure}}%
{\end@dblfloat
\addcontentsline{lof}{figure}%
{\protect\numberline{\thefigure}{\my@caption}}%
}%
\makeatother
%\usepackage{hyperref}
\begin{document}
\listoffigures
\chapter{Testing}
\lipsum
\section{Hallo}
\begin{figure}[t]
\caption{First figure}
Test
\end{figure}
\begin{figure}[b]
\caption{Second figure}
Test
\end{figure}
\chapter{Hallo}
\lipsum
\section{Hallo}
\begin{figure}[t]
\caption{First figure}
Test
\end{figure}
\begin{figure}[b]
\caption{Second figure}
Test
\end{figure}
\end{document}
I sort of get the gist of the code between \makeatletter and \makeatother although I do not understand what the \long\def section is doing. If anyone could help me add chapter headings to the memoir lof I would appreciate it.
Neither the memoir or report code works with hyperref either, it gives this error message:
Package hyperref Warning: old lof file detected, not used; run LaTeX again.
[1{c:/texlive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] [2]
! Undefined control sequence.
<argument> ...umberline {\thefigure }{\my@caption
}}{\thepage }{@currentHre...
l.60 \end{figure}
If someone could help me with that in the same breath I would sincerely appreciate it although I could ask it as a separate question if needed.




\@chapter. It does however use\@m@mchapterwhere #1 contains the (short) title. – John Kormylo Jul 04 '21 at 17:00\gdef\thischaptertitle{#1}\gdeffrom #1 to #2 the code worked perfectly as is, in case anyone in the future runs into this issue. Thank you for that, nice one! – Jul 04 '21 at 23:06