7

if I use the \listoffigures command LaTeX creates a new chapter (I'm using the book class), but there is no chapter heading. Is it like it uses \chapter*{List of figures}. Of course this is what we want most of the cases, but what can I do to obtain a:

Chapter 3
List of figures

Actually I need these for the command \listoftheorems from the thmtools package, but it should be the same.

Werner
  • 603,163
user29372
  • 115

2 Answers2

7

Since \listoftheorems uses internally \listoffigures, you can use the etoolbox package to patch \listoffigures changing the default \chapter* to \chapter (for a solution using amsbook, please see the second example below):

\documentclass{book}
\usepackage{amsmath}
\usepackage{thmtools}
\usepackage{etoolbox}

\declaretheorem[name=Theorem]{theo}

\begin{document}

\listoffigures

\patchcmd{\listoffigures}{\chapter*}{\chapter}{}{}
\listoftheorems
\clearpage
\begin{theo}[a]
Test theorem
\end{theo}
\begin{theo}[b]
Test theorem
\end{theo}
\begin{theo}[c]
Test theorem
\end{theo}
\begin{theo}[d]
Test theorem
\end{theo}

\end{document}

enter image description here

A similar patch can be easily done for other lists if required. For example, for the list of tables, one would say

\patchcmd{\listoftables}{\chapter*}{\chapter}{}{}

A request has been made to perform a similar modification but using amsbook; in this case, some additional work has to be done:

\documentclass{amsbook}
\usepackage{amsmath}
\usepackage{thmtools}
\usepackage{etoolbox}

\declaretheorem[name=Theorem]{theo}

\begin{document}

\listoffigures

\makeatletter
\patchcmd{\@starttoc}{\@makeschapterhead}{\@makechapterhead}{}{}
\def\@dotsep{1000}
\def\listoftheorems{\refstepcounter{chapter}\@starttoc{loe}\listtheoremname}
\def\l@figure{\@tocline{0}{3pt plus2pt}{0pt}{}{}}
\makeatother
\listoftheorems

\clearpage

\begin{theo}[a]
Test theorem
\end{theo}
\begin{theo}[b]
Test theorem
\end{theo}
\begin{theo}[c]
Test theorem
\end{theo}
\begin{theo}[d]
Test theorem
\end{theo}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • +1 I've got to start using \patchcmd! – jub0bs Apr 20 '13 at 19:08
  • It is this possible to do the same with amsbook? – user29372 Apr 20 '13 at 20:03
  • @user29372 No; using amsbook requires some additional work. Please see the second example code in my udpated answer. Please always mention in your questions which document class you are using. As you now know that information is crucial. – Gonzalo Medina Apr 20 '13 at 22:39
0

As far as I understand, you are expecting the following behaviour:

\documentclass{book}

\begin{document}

\makeatletter
\renewcommand\listoffigures{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter{\listfigurename}%
      \@mkboth{\MakeUppercase\listfigurename}%
              {\MakeUppercase\listfigurename}%
    \@starttoc{lof}%
    \if@restonecol\twocolumn\fi
    }

\makeatother

\chapter{AA}

\begin{figure}
\caption{aa}
\end{figure}



\begin{figure}
\caption{baa}
\end{figure}


\begin{figure}
\caption{caa}
\end{figure}


\listoffigures

\end{document}