5

Typesetting:

\documentclass[a4paper]{report}
\usepackage{thmtools,amsthm,hyperref}
\newtheorem{defi}{Definizione}

\begin{document}


\renewcommand\listtheoremname{Definizioni, Teoremi, Proposizioni, ecc.}
\listoftheorems[ignoreall,show={defi}]
\end{document}

yields:

This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
(./gungugungu4.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thmtools.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-patch.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/parseargs.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-kv.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-autoref.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/aliasctr.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/carlisle/remreset.sty)))
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-listof.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-restate.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/amscls/amsthm.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/local/texlive/2013/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/local/texlive/2013/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/local/texlive/2013/texmf-dist/tex/latex/url/url.sty))

Package hyperref Message: Driver (autodetected): hxetex.

(/usr/local/texlive/2013/texmf-dist/tex/latex/hyperref/hxetex.def
(/usr/local/texlive/2013/texmf-dist/tex/latex/hyperref/puenc.def)
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/stringenc.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(./gungugungu4.aux)

Package thmtools Warning: amsthm loaded after thmtools .


Package thmtools Warning: ntheorem loaded after thmtools .

(/usr/local/texlive/2013/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./gungugungu4.out) (./gungugungu4.out)

Package hyperref Warning: Rerun to get /PageLabels entry.

./gungugungu4.tex:9: Extra \else.
\@forloop ...lse #5\def #4{#2}\ifx #4\@nnil \else 
                                                  #5\@iforloop #3\@@ #4{#5}\...
l.9 \listoftheorems[ignoreall,show={defi}]

Loading thmtools after amsthm solves everything, and removing hyperref yields:

This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
(./gungugungu4.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thmtools.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-patch.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/parseargs.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-kv.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-autoref.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/aliasctr.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/carlisle/remreset.sty)))
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-listof.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/thmtools/thm-restate.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/amscls/amsthm.sty)
(./gungugungu4.aux)

Package thmtools Warning: amsthm loaded after thmtools .


Package thmtools Warning: ntheorem loaded after thmtools .

./gungugungu4.tex:9: Missing \endcsname inserted.
<to be read again> 
                   \relax 
l.9 \listoftheorems[ignoreall,show={defi}]

So the questions are: what is that error:

./gungugungu4.tex:9: Extra \else.
\@forloop ...lse #5\def #4{#2}\ifx #4\@nnil \else 
                                                  #5\@iforloop #3\@@ #4{#5}\...
l.9 \listoftheorems[ignoreall,show={defi}]

and why does it vanish by listening to the warning and loading amsthm before thmtools? Why does removing hyperref change the error so radically? What is calling ntheorem?

  • 2
    The documentation of thmtools tells you that amsthm must be loaded before it. So do it. The error is different because hyperref gets confused since it sees both amsthm and thmtools loaded and it can't know thmtools has ignored amsthm. – egreg Apr 21 '14 at 14:56
  • @egreg -- but where does ntheorem come from? is that perpetrated by hyperref??? (oh, dear!) – barbara beeton Apr 21 '14 at 15:15
  • @barbarabeeton I'm not sure why the warning is issued. In any case it's a spurious warning that doesn't show up when the correct order of packages is used. – egreg Apr 21 '14 at 15:25
  • 1
    @barbarabeeton The spurious warning is due to misplaced braces in thmtools.sty. – egreg Apr 21 '14 at 15:47
  • 1
    Fixed packages at [absatzen.de/thmtools-v66.tar.gz]/[http://absatzen.de/… and going to CTAN in a few moments. – Ulrich Schwarz Apr 21 '14 at 18:29
5

The documentation of thmtools tells you that amsthm (or ntheorem) should be loaded before thmtools, so that the package can adjust its macros. So the correct call is

\usepackage{amsmath,thmtools}

The presence of hyperref is irrelevant. However, the error changes because at loading time, hyperref sees that both thmtools and amsthm are loaded, so it does its work assuming everything was done properly, because it has no way to know you made a mistake in the loading order. Well, it could also check for the loading of thm-amsthm, but it doesn't.

The warning about ntheorem is spurious and it is independent of hyperref. It is caused by bad code in thmtools:

 49 \@ifpackageloaded{amsthm}{%
 50   \RequirePackage{thm-amsthm}
 51 }{%
 52   \AtBeginDocument{%
 53   \@ifpackageloaded{amsthm}{%
 54     \PackageWarningNoLine{thmtools}{%
 55       amsthm loaded after thmtools
 56     }{}%
 57   }}%
 58 }
 59 \@ifpackageloaded{ntheorem}{%
 60   \RequirePackage{thm-ntheorem}
 61 }{%
 62   \AtBeginDocument{%
 63   \@ifpackageloaded{ntheorem}{%
 64     \PackageWarningNoLine{thmtools}{%
 65       ntheorem loaded after thmtools
 66     }{}%
 67   }}%
 68 }

Let's analyze the code, which is executed at the end of thmtools:

\@ifpackageloaded{amsthm}{%
  \RequirePackage{thm-amsthm}
}{%
  \AtBeginDocument{%
  \@ifpackageloaded{amsthm}{%
    \PackageWarningNoLine{thmtools}{%
      amsthm loaded after thmtools
    }{}%
  }}%
}

If amsthm has not been loaded, the third argument to \@ifpackageloaded is executed, which is

  \AtBeginDocument{%
  \@ifpackageloaded{amsthm}{%
    \PackageWarningNoLine{thmtools}{%
      amsthm loaded after thmtools
    }{}%
  }}%

What's stored in \@begindocumenthook is then

  \@ifpackageloaded{amsthm}{%
    \PackageWarningNoLine{thmtools}{%
      amsthm loaded after thmtools
    }{}%
  }

which misses the third argument to \@ifpackageloaded. It should be

  \@ifpackageloaded{amsthm}{%
    \PackageWarningNoLine{thmtools}{%
      amsthm loaded after thmtools%
    }%
  }{}

So the third argument of \@ifpackageloaded turns out to be whatever token follows and this is certainly a bug to be fixed. The code above should become

 49 \@ifpackageloaded{amsthm}{%
 50   \RequirePackage{thm-amsthm}
 51 }{%
 52   \AtBeginDocument{%
 53   \@ifpackageloaded{amsthm}{%
 54     \PackageWarningNoLine{thmtools}{%
 55       amsthm loaded after thmtools%
 56     }%
 57   }{}}%
 58 }
 59 \@ifpackageloaded{ntheorem}{%
 60   \RequirePackage{thm-ntheorem}
 61 }{%
 62   \AtBeginDocument{%
 63   \@ifpackageloaded{ntheorem}{%
 64     \PackageWarningNoLine{thmtools}{%
 65       ntheorem loaded after thmtools%
 66     }%
 67   }{}}%
 68 }
  • thanks for the diagnosis. i reported to the author, link to this answer, and have received a reply that he will try to fix in time for tex live 2014. – barbara beeton Apr 21 '14 at 18:22

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.