thmtools:“您的后端不允许样式定理”警告

thmtools:“您的后端不允许样式定理”警告

我正在编写一个包。以下是其中的一部分,应该足以让人们尝试重现我的问题:

%[…]
\ProvidesPackage{mworks}
%[…]
\RequirePackage{amsmath,amssymb,amsfonts,nicefrac}
\RequirePackage{multirow}
\RequirePackage{xparse}
\RequirePackage{thmtools,mathtools}
%[…]
\newif\ifmworks@thm\mworks@thmfalse
\DeclareOption{thm}{\mworks@thmtrue}
%[…]
\ProcessOptions\relax
%[…]
%Option "thm"
\ifmworks@thm
\newcommand{\setlistwidth}[1][4em]{\renewcommand\thmt@listnumwidth{#1}}
\newcommand{\thlist}{\listoftheorems}
\newcommand{\deflist}{\renewcommand\listtheoremname{Definizioni, Teoremi, Proposizioni, ecc.}
\listoftheorems[ignoreall,show={defi,teor,oss,propo,coro,fatto,lemma,pt,riass,es}]
\renewcommand\listtheoremname{Esercizi assegnati a lezione}
\listoftheorems[ignoreall,show={ese}]}
\newcommand{\changename}{\renewcommand\listtheoremname}
\declaretheoremstyle[
spaceabove=\topsep, spacebelow=\topsep,
headfont=\normalfont\bfseries,
notefont=\bfseries, notebraces={}{},
bodyfont=\normalfont\itshape,
postheadspace=0.5em,
name={\ignorespaces},
numbered=no,
headpunct=]
{mystyle}
\declaretheorem[style=mystyle]{@thmattr}
\ExplSyntaxOn
\NewDocumentEnvironment{xtheor}{moO{x}ooo}
{\renewcommand{\thmtformatoptarg}[1]{ #1}\IfNoValueTF{#2}
      {\def\theorem@attr{#1}}
      {\@ifundefined{c@#2}
            {\newcounter{#2} \setcounter{#2}{1}}
            {\addtocounter{#2}{+1}}
      \def\counters{
      \str_if_eq:nnTF{#3}{c}
      {
            \arabic{chapter}.\arabic{#2}
      }
      {
                  \str_if_eq:nnTF{#3}{s}
                  {
                        \arabic{chapter}.\arabic{section}.\arabic{#2}
                  }
                  {
                        \str_if_eq:nnTF{#3}{x}
                        {
                              \arabic{chapter}.\arabic{section}.\arabic{subsection}.\arabic{#2}
                        }
                        {
                              \str_if_eq:nnTF{#3}{n}
                              {
                              \arabic{#2}
                              }
                              {
                              \errmessage{Illegal argument in counter definition}
                              \errhelp{The third argument must be either c, s or x, for chapter, section and subsection respectively}
                              }
                        }
                 }}}\def\theorem@attr{#1\,\,\counters\IfValueTF{#4}{\,\,}{}}}
                 \def\name@thmlist{\IfValueTF{#2}{\counters\,\,}{}#1\IfValueTF{#4}{\IfValueTF{#6}{\,\,#6}{\,\,#4}}{}}
\IfNoValueTF{#4}
      {\begin{@thmattr}[{name=[\name@thmlist]\theorem@attr}]}
      {\IfNoValueTF{#5}
            {\begin{@thmattr}[{name=[\name@thmlist]\theorem@attr (#4)}]}
            {\begin{@thmattr}[{name=[\name@thmlist]\theorem@attr (#4)},label=#5]}}}
{\end{@thmattr}}
\renewcommand\thmt@listnumwidth{-1.5em}
\ExplSyntaxOff
\newcommand{\e}[1][1]{
\qwerty=#1
\ifnum\qwerty>0
    {\loop\!\advance\qwerty by -1\ifnum\qwerty>0\repeat}
\else
    {\loop\,\advance\qwerty by 1\ifnum\qwerty<0\repeat}
\fi}
\fi
%[…]
\endinput

其中的几行%[…]是一些包代码,我认为对于这个问题来说这些代码是无用的,因此省略了。代码如下:

\documentclass[a4paper]{report}
\usepackage{amsmath,amssymb,amsfonts,mathtools,mathptmx}
\usepackage{xparse}
\usepackage[all]{mworks}

\begin{document}

\end{document}

通过 XeTeX 运行,我得到:

This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
(./MworksGreek.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/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2013/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/mh/mathtools.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/tools/calc.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/mh/mhsetup.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/psnfss/mathptmx.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3names.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3bootstrap.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/etex-pkg/etex.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3basics.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3expan.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3tl.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3seq.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3int.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3quark.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3prg.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3clist.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3token.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3prop.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3msg.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3file.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3skip.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3keys.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3fp.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3box.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3coffins.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3color.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3luatex.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/l3kernel/l3candidates.sty)
(/usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/ifpdf.sty)))
(./mworks.sty
Package `Mworks' <Mon 2014-04-01 >.
(/usr/local/texlive/2013/texmf-dist/tex/latex/units/nicefrac.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/ifthen.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/multirow/multirow.sty)
(/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/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/generic/mathdots/mathdots.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/tools/multicol.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/fontspec/fontspec-patches.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/fixltx2e.sty)
*************************************************
* LaTeX warning: "xparse/redefine-command"
* 
* Redefining document command \oldstylenums with arg. spec. 'm' on line 128.
*************************************************
) (/usr/local/texlive/2013/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/euenc/eu1enc.def)
(/usr/local/texlive/2013/texmf-dist/tex/latex/euenc/eu1lmr.fd))
(/usr/local/texlive/2013/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/tipa/t3enc.def
(/usr/local/texlive/2013/texmf-dist/tex/latex/euenc/eu1lmss.fd))
(/usr/local/texlive/2013/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/local/texlive/2013/texmf-dist/tex/xelatex/xetex-def/xetex.def))))
(/usr/local/texlive/2013/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2013/texmf-dist/tex/latex/xltxtra/xltxtra.sty
(/usr/local/texlive/2013/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/realscripts/realscripts.sty
*************************************************
* LaTeX warning: "xparse/redefine-command"
* 
* Redefining document command \textsubscript with arg. spec. 's' on line 25.
*************************************************
*************************************************
* LaTeX warning: "xparse/redefine-command"
* 
* Redefining document command \textsuperscript with arg. spec. 's' on line 28.
*************************************************
) (/usr/local/texlive/2013/texmf-dist/tex/latex/metalogo/metalogo.sty))
(/usr/local/texlive/2013/texmf-dist/tex/latex/graphics/color.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/latexconfig/color.cfg))
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/textcomp.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/ts1enc.def))
(/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/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))
(/usr/local/texlive/2013/texmf-dist/tex/latex/enumitem/enumitem.sty)
(/usr/local/texlive/2013/texmf-dist/tex/latex/marginnote/marginnote.sty)

Package thmtools Warning: Your backend doesn't allow styling theorems on input 
line 1142.


./mworks.sty:1143: Package thmtools Error: \declaretheorem key `spaceabove' not
 known.

See the thmtools package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1143 \declaretheorem[style=mystyle]{@thmattr}

这是什么意思?我该如何解决?

答案1

你的例子远非简单。如果我删除所有与错误无关的代码,我会得到

\documentclass{report}
\usepackage{thmtools}

\declaretheoremstyle[
spaceabove=\topsep
]{mystyle}
\declaretheorem[style=mystyle]{@thmattr}
\begin{document}

\end{document}

这会产生所示的错误。

 ! Package thmtools Error: \declaretheorem key `spaceabove' not known.

注释掉该spaceabove行可以消除错误。或者,如 egreg 所述,您可以添加

\usepackage{amsthm}

在加载之前thmtools,密钥已被定义。

相关内容