6

I'm trying to change the formatting of the \listoftheorems command from the thmtools package. It currently prints "Theorem (Name of Theorem).... Page Number", and I would like it to print "Name of Theorem....Page Number". I have attempted to use the fixes here Only show \NAME in \listoftheorems and here Generating lists of custom environment. to no avail.

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}
\renewcommand{\listtheoremname}{List of Important Theorems}

\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\bfseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=0.5 em,
qed={}
]{theorem}

\declaretheorem[style=theorem]{theorem}
\begin{document}
\listoftheorems
\begin{theorem}[Test]
This is a test theorem.
\end{theorem}
\end{document}
user52567
  • 163

1 Answers1

5

In fact, the answer given by egreg to Generating lists of custom environment. applies here, mutatis mutandis:

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}

\renewcommand{\listtheoremname}{List of Important Theorems}

\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\bfseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=0.5 em,
qed={},
]{theorem}

\declaretheorem[style=theorem]{theorem}

\makeatletter
\def\ll@theorem{%
  \protect\numberline{\csname the\thmt@envname\endcsname}%
  \ifx\@empty\thmt@shortoptarg
    \thmt@thmname
  \else
    \thmt@shortoptarg
  \fi}
\def\l@thmt@theorem{} 
\makeatother

\begin{document}
\listoftheorems
\begin{theorem}[First test theorem]
This is a test theorem.
\end{theorem}
\begin{theorem}[Second test theorem]
This is another test theorem.
\end{theorem}
\begin{theorem}
This is another test theorem.
\end{theorem}

\end{document}

enter image description here

As can be seen in the example above, the previous solution will still typeset just "Number Theorem ... Page" for theorems in which no optional argument is used. If you want to suppress those from the list and only include there those which have a name, then you can use:

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}

\renewcommand{\listtheoremname}{List of Important Theorems}
\makeatletter
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\bfseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=0.5 em,
qed={},
postheadhook={%
  \ifx\@empty\thmt@shortoptarg
    \renewcommand\addcontentsline[3]{}
  \fi}
]{theorem}
\makeatother

\declaretheorem[style=theorem]{theorem}

\makeatletter
\def\ll@theorem{%
  \protect\numberline{\csname the\thmt@envname\endcsname}%
  \ifx\@empty\thmt@shortoptarg
    \thmt@thmname
  \else
    \thmt@shortoptarg
  \fi}
\def\l@thmt@theorem{} 
 \makeatother

\begin{document}
\listoftheorems
\begin{theorem}[First test theorem]
This is a test theorem.
\end{theorem}
\begin{theorem}[Second test theorem]
This is another test theorem.
\end{theorem}
\begin{theorem}
This is another test theorem.
\end{theorem}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Will there be a way to format it using tocbasic package, so that the list of theorems maintains the formatting of the other indexes in the document that use that package? – Aradnix Nov 28 '23 at 14:26