# Section Title in thmtools List of Theorems

The thmtools package provides a \listoftheorems command that generates a list of theorems/definitions/etc.

Here's a MWE:

\documentclass[12pt]{article}
\usepackage{amsthm,thmtools}

\newtheorem{thm}{Theorem}[section]
\newtheorem{defn}{Definition}[section]

\renewcommand{\listtheoremname}{List of definitions}

\begin{document}

\listoftheorems[ignoreall,show={defn}]

\section{First Section}

\begin{defn}[Some definition]
definition text
\end{defn}

\section{Second Section}

\begin{thm}[Some Theorem]
theorem text
\end{thm}

\section{Third Section}

\begin{defn}[Another definition]
definition text
\end{defn}

\begin{defn}
definition without title
\end{defn}

\begin{thm}
theorem without title
\end{thm}

\end{document}


PROBLEM: I'd like to display section names in the List of definitions. The desired effect would look roughly as follows:

1. First Section

1.1 Definition (Some definition) ................................ 1

3. Third Section

3.1 Definition (Another definition) ............................ 1

3.2 Definition ........................................................... 1

I've been trying to adopt the suggestions of this excellent answer, but with little success. The suggested solution is a patch (via etoolbox) to the \thmtlo command from thmtools that annotates chapter breaks in the .loe file; the difficulty lies in that \thmtools has no equivalent command for annotating sections. Looking at the \thmtools documentation, the relevant command is defined on page 29, line 770. My naive attempt was to emulate that chunk of the code in the preamble of the MWE, in which I essentially just replace every occurrence of "chapter" with "section"; i.e., include the following code:

\makeatletter
\def\thmtlo@oldsection{0}%
\newcommand\thmtlo@sectionvspacehack{}
\ifcsname c@section\endcsname
\ifx\c@section\relax\else
\def\thmtlo@sectionvspacehack{%
\ifnum \value{section}=\thmtlo@oldsection\relax\else
\xdef\thmtlo@oldsection{\arabic{section}}%
\fi
}%
\fi
\fi
\makeatother


Sadly, this doesn't work at all, as the .loe file remains unchanged.

• thmtools does a weird stuff there ... :-( – user31729 Jun 15 '15 at 18:27
• @ChristianHupfer, Indeed. What is your feeling about it? Is what I'm asking impossible to implement with thmtools? – Nikita Jun 17 '15 at 16:35
• Not impossible, but extremely difficult. I suspect, it's easier to build the \listoftheorems on your own, with tocloft, for example. I'll try to provide a solution, but it will take time – user31729 Jun 17 '15 at 20:50

if you are still trying to solve this question, I found a way.

First, in the thm-listof.sty file you have to comment out this line:

\addtocontents{loe}{\protect\addvspace{10\p@}}%


then, using etoolbox (and probably some other package I forgot), add this in the header of your .tex file:

\makeatletter
\def\thischaptertitle{}\def\thischapternumber{}
\newtoggle{nothms}

\apptocmd{\@chapter}%
{\gdef\thischaptertitle{#1}\gdef\thischapternumber{\thechapter}%
\global\toggletrue{nothms}}{}{}

\AtBeginDocument{%
\AtBeginEnvironment{definition}{%
\iftoggle{nothms}{

• This seems to focus on adding a chapter title rather than a section title (as requested by the OP). Additionally, how would you handle sections that don't have a definition in them? – Werner Jan 18 '16 at 22:44