I'm trying to redefine the List of Theorems environment from thmtools
to typeset a List of Theorems that looks like
Definition 1 Foo ......1
Theorem 2 ..............2
rather than the usual
1 Definition (Foo) ....1
2 Theorem ..............2
My current attempt is this MWE:
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheorem{theorem}
\declaretheorem[sibling=theorem]{definition}
\let\oldnumberline\numberline%
\renewcommand{\numberline}[1][\negmedspace]{#1 \oldnumberline}
\makeatletter
\@for\thmt@envname:=\thmt@allenvs\do{
\def\ll@envname{%
\protect\numberline[\thmt@thmname]{\csname the\thmt@envname\endcsname}%
\ifx\@empty\thmt@shortoptarg%
\else
\thmt@shortoptarg%
\fi
}
}
\makeatother
\begin{document}
\section{Section}
\begin{theorem}[Named Theorem]
\end{theorem}
\begin{definition}[Named Definition]
\end{definition}
\begin{definition}
\end{definition}
\listoftheorems
\end{document}
It seems to change nothing when compared with the usual construction. I believe the problem is the the \@for
loop. I guess I might be running it wrongly, or using the wrong list of environments. I tried to construct it by looking at the thmtools
documentation, as I couldn't really find the \ll@envname
definition on the package's code. This belief is due to the fact that the following code does precisely what I have in mind, but works only for the definition
environment (and I'd like to have something that works for all, without need to copy and paste the code every time I declare a new theorem):
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheorem{theorem}
\declaretheorem[sibling=theorem]{definition}
\let\oldnumberline\numberline%
\renewcommand{\numberline}[1][\negmedspace]{#1 \oldnumberline}
\makeatletter
\def\ll@definition{%
\protect\numberline[\thmt@thmname]{\csname the\thmt@envname\endcsname}%
\ifx\@empty\thmt@shortoptarg%
\else
\thmt@shortoptarg%
\fi
}
\makeatother
\begin{document}
\section{Section}
\begin{theorem}[Named Theorem]
\end{theorem}
\begin{definition}[Named Definition]
\end{definition}
\begin{definition}
\end{definition}
\listoftheorems
\end{document}
How can I correctly state the \@for
loop so that the code generalizes to all declared theorem-like environments? Alternatively, is there another way of obtaining the result I'm looking for?