5

I like to take my notes in LaTeX, and to help my speed, I use restatable theorems so that I can quickly recall the text and re-insert it into my notes when the professor mentions it. However, the issue is when I want to use the \listoftheorems command to make a list of all of them at the beginning (to aid in quickly searching my notes), it repeats all the restated theorems. How can I stop it from doing this?

MWE

\documentclass[12pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsthm,amsmath,amssymb,amsfonts}
\usepackage{thmtools}
\usepackage{multicol}
\usepackage{mathtools}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,      
    urlcolor=blue,
}

\declaretheorem[numberwithin=chapter]{theorem}
\declaretheorem[numberwithin=chapter]{definition}

\renewcommand{\listtheoremname}{List of Theorems and Definitions}
\begin{document}
\listoftheorems[ignoreall,show={theorem,definition}]
\vspace*{\baselineskip}
\hrule

\begin{restatable}[Defintition 1]{definition}{defn}
This is definition 1
\end{restatable}

\begin{restatable}[Theorem 1]{theorem}{thm}
This is theorem 1
\end{restatable}

We will now restate theorem 1, 
\thm*

We will now restate Definition 1,
\defn*
\end{document}

Output of code above

4
+200

The restatable theorems in thmtools first do a generic theorem definition which contains all the information about that theorem, and then just use that definition. The way it distinguishes the main statement of a theorem and a restatement is with the \ifthmt@thisistheone conditional. This conditional is false when you use \begin{restatable*} or \<theorem-command>* and true without the * argument.

However when writing the List of Theorems' entry, it is written unconditionally. This patch (add it to the preamble, after loading thmtools) adds the \ifthmt@thisistheone to the writing, so that it's done only for the main statement:

\usepackage{etoolbox}
\makeatletter
\patchcmd\thmt@generic@postheadhook
  {\addcontentsline}
  {\ifthmt@thisistheone
     \expandafter\addcontentsline
   \else
     \expandafter\@firstoftwo\expandafter\@gobbletwo
   \fi}
  {}{\FAILED}
\makeatother

enter image description here

\documentclass[12pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsthm,amsmath,amssymb,amsfonts}
\usepackage{thmtools}
\usepackage{multicol}
\usepackage{mathtools}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    urlcolor=blue,
}

\usepackage{etoolbox}
\makeatletter
\patchcmd\thmt@generic@postheadhook
  {\addcontentsline}
  {\ifthmt@thisistheone
     \expandafter\addcontentsline
   \else
     \expandafter\@firstoftwo\expandafter\@gobbletwo
   \fi}
  {}{\FAILED}
\makeatother

\declaretheorem[numberwithin=chapter]{theorem}
\declaretheorem[numberwithin=chapter]{definition}

\renewcommand{\listtheoremname}{List of Theorems and Definitions}
\begin{document}
\listoftheorems[ignoreall,show={theorem,definition}]
\vspace*{\baselineskip}
\hrule

\begin{restatable}[Defintition 1]{definition}{defn}
This is definition 1
\end{restatable}

\begin{restatable}[Theorem 1]{theorem}{thm}
This is theorem 1
\end{restatable}

We will now restate theorem 1, 
\thm*

We will now restate Definition 1,
\defn*
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.