[Tex/LaTex] List of theorems with thmtools not working – Missing \endcsname inserted

theoremsthmtools

I am trying to generate a list of all equations in a document. I have searched and it seemed a good solution would be to use the thmtools, which can generate a list of all theorems(if im correct). What I am looking for is (in the following example, at the chapter CheatSheet) a list with the contents of all equate-theorems, as such (with LaTeX formatting):

$Some_{Lowtext}$                                   (1)
$Some^{Hightext}$                                  (2)

Minimal (not) Working Example:

\documentclass[a4paper,12pt]{report}
\usepackage{theorem}
\newtheorem{equate}{}
\usepackage{thmtools}
\renewcommand{\listtheoremname}{List of Equations}
\begin{document}
\tableofcontents
\newpage
\chapter{Name of Chapter}
\section{Name of Section}
\subsection{Name of SubSection}
sometext
\begin{equate}
$Some_{Lowtext}$
\end{equate}
    Some other Text
\begin{equate}
$Some^{Hightext}$
\end{equate}
    And some more

\chapter{CheatSheet}

\listoftheorems

\end{document}

This gives me the following errors (line 24 is the line after \listoftheorems):

test.tex:24: Missing \endcsname inserted. []
test.tex:24: Too many }'s. []

I am wondering if this is the way to produce such a list and how I can solve my error.

Best Answer

Use declaretheorem instead of \newtheorem

The theorem and thmtools packages use different mechanisms for defining theorem environments: Frank Mittelbach's theorem package uses the LaTeX-kernel \newtheorem macro, whereas Ulrich Schwarz's thmtools package provides a \declaretheorem macro.

The thmtools package also provides a \listoftheorems macro, but the latter only lists the theorem environments declared with \declaretheorem, not those simply declared with \newtheorem. Therefore, if you want to take advantage of \listoftheorems, you should declare all your theorems with thmtools's \declaretheorem and not use \newtheorem explicitly.

\documentclass[a4paper,12pt]{report}

\usepackage{thmtools}
\declaretheorem{equate}
\renewcommand{\listtheoremname}{List of Equations}

\begin{document}
\begin{equate}[Low text]
$Some_{Lowtext}$
\end{equate}
    Some other Text
\begin{equate}[High text]
$Some^{Hightext}$
\end{equate}
\listoftheorems
\end{document}

enter image description here

More details on the errors you report

If \declaretheorem is not used at least once in the input file, \listoftheorems generates the two errors you report. Here is some minimum code that reproduces the issue:

\documentclass{report}
\usepackage{thmtools}
%\declaretheorem{foo}
\begin{document}
\listoftheorems
\end{document}

No errors are generated if the third line of the code above is uncommented. In my opinion, that behaviour is unintended and qualifies as a bug; the author should probably be notified about it.

Related Question