3

I'm trying to use the \listoftheorems command from thmtools, but there seems to be an issue with the amsbook class. I get the following error

(./foo.loe
! Undefined control sequence.
\@dottedtocline ... \hbox {$\m@th \mkern \@dotsep
                                                  mu\hbox {.}\mkern \@dotsep...
l.1 ...\numberline {1}\MakeUppercase {t}heorem}{2}

where "foo.tex" is the name of the following MWE:

\documentclass{amsbook}
    \usepackage[english]{babel}
    \usepackage{thmtools}
    \declaretheorem{theorem}
\begin{document}
\listoftheorems
    \begin{theorem}
        This is my favorite theorem.
    \end{theorem}
\end{document}

The same issue was raised long ago here.

In the original file "paper.tex" where I'm trying to use \listoftheorems[ignoreall, show={theorem,definition,corollary}], I don't get the error above but the List of Theorems is empty and the output of pdflatex says

showing theorem
showing definition
showing corollary
List of Theorems
No file paper.loe.

I don't understand yet what cause the error being raised only in the MWE and the .loe file being generated only by the latter.

EDIT: As for the last mystery, it seems to be caused by \usepackage{constants}: adding it to the above MWE cause an empty List of Theorems (even after Andrew Swann's fix below).

  • note that your mwe is compiling issue-less well if you use scrartcl instead of amsbook as document class. – ebosi Sep 16 '16 at 9:56
  • The problem with constants and thmtools list of theorems occurs in ordinary article documents. I think you should ask a separate question for this. – Andrew Swann Sep 16 '16 at 11:15
  • 2
    The constants package has a strange \AtEndDocument hook, that does not interact well with thmtools. – Andrew Swann Sep 16 '16 at 11:26
1

You just need to define \@dotsep, e.g. via

 \providecommand{\@dotsep}{5}

Sample output

\documentclass{amsbook}

\makeatletter
\providecommand{\@dotsep}{5}
\makeatother

\usepackage[english]{babel}
\usepackage{thmtools}
\declaretheorem{theorem}

\begin{document}

\listoftheorems

\begin{theorem}
  This is my favorite theorem.
\end{theorem}

\end{document}

Alternatively if you want the style to be like that of the list of figures etc. then you need to go into some internal definitions to replace \@dottedtoline with @tocline, which has a different number of arguments:

Second sample

\documentclass{amsbook}

\usepackage[english]{babel}
\usepackage{thmtools}

\makeatletter
\renewcommand\listoftheorems[1][]{%
  \bgroup
  \setlisttheoremstyle{#1}%
  \let\listfigurename\listtheoremname
  \def\contentsline##1{%
    \csname thmt@contentsline@##1\endcsname{##1}%
  }%
  \@for\thmt@envname:=\thmt@allenvs\do{%
  \@xa\protected@edef\csname l@\thmt@envname\endcsname{%
    \@nx\@tocline{1}{0pt}{1.5em}{\@nx\thmt@listnumwidth}{}%   %%Changed
  }%
  }%
  \let\thref@starttoc\@starttoc
  \def\@starttoc##1{\thref@starttoc{loe}}%
  \@fileswfalse
  \AtEndDocument{%
    \if@filesw
      \@ifundefined{tf@loe}{%
        \expandafter\newwrite\csname tf@loe\endcsname
        \immediate\openout \csname tf@loe\endcsname \jobname.loe\relax
      }{}%
    \fi
  }%
  \listoffigures
  \egroup
}

\renewcommand\thmt@mklistcmd{%
  \@xa\protected@edef\csname l@\thmt@envname\endcsname{%
    \@nx\@tocline{1}{0pt}{1.5em}{\@nx\thmt@listnumwidth}{}%  %%Changed
  }%
  \ifthmt@isstarred
    \@xa\def\csname ll@\thmt@envname\endcsname{%
      \protect\numberline{\protect\let\protect\autodot\protect\@empty}%
      %% Grouping added
      {\thmt@thmname
      \ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi}%
    }%
  \else
    \@xa\def\csname ll@\thmt@envname\endcsname{%
      \protect\numberline{\csname the\thmt@envname\endcsname}%
      %% Grouping added
      {\thmt@thmname
      \ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi}%
    }%
  \fi
  \@xa\gdef\csname thmt@contentsline@\thmt@envname\endcsname{%
    \thmt@contentslineShow
  }%
}

\makeatother

\declaretheorem{theorem}
\declaretheorem[sibling=theorem]{corollary}

\begin{document}

\listoftheorems

\begin{theorem}
  This is my favorite theorem.
\end{theorem}

\begin{theorem}
  Another theorem.
\end{theorem}

\begin{corollary}
  Something else.
\end{corollary}

\end{document}

The above code copies the definitions from thm-listof.sty and makes the marked changes. Patching via etoolbox fails on the first of these commands.

  • Great! I also discovered what cause the List of Theorems to be empty in my file "paper.tex": it's \usepackage{constants}. I'm updating the question. – Immanuel Weihnachten Sep 16 '16 at 10:13
3

As I answered to the cross-post at LaTeX-Community.org, you could simply let \@dottedtocline call amsbook's \@tocline:

\makeatletter
\def\@dottedtocline#1#2#3#4#5{\@tocline{#1}{0pt}{#2}{#3}{}{#4}{#5}}
\makeatother

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.