奇怪的错误和错误变化

奇怪的错误和错误变化

排版:

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

\begin{document}


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

产量:

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}]

加载中thmtools amsthm解决所有问题,并消除hyperref收益:

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}]

所以问题是:这个错误是什么:

./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}]

为什么它会在听到警告和加载后消失amsthm thmtools? 为什么删除会hyperref如此彻底地改变错误?调用是什么ntheorem

答案1

的文档thmtools告诉您应该在 之前加载amsthm(或) ,以便包可以调整其宏。因此正确的调用是ntheoremthmtools

\usepackage{amsmath,thmtools}

的存在hyperref无关紧要。但是,错误会发生变化,因为在加载时,hyperref看到thmtoolsamsthm都已加载,因此它会假设一切都已正确完成,因为它无法知道您在加载顺序上犯了错误。好吧,它也可以检查 的加载thm-amsthm,但它没有这样做。

关于 的警告ntheorem是虚假的,它与 无关hyperref。它是由 中的错误代码引起的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 }

让我们分析一下在最后执行的代码thmtools

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

如果amsthm尚未加载,则\@ifpackageloaded执行第三个参数,即

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

\@begindocumenthook然后存储的是

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

缺少了 的第三个参数\@ifpackageloaded。应该是

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

因此,第三个参数\@ifpackageloaded实际上是后面跟着的 token,这肯定是一个需要修复的错误。上面的代码应该变成

 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 }

相关内容