编译因为包冲突而无法停止,这种情况下该如何定位问题呢?

编译因为包冲突而无法停止,这种情况下该如何定位问题呢?

考虑以下代码:

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{create-theorem}
\CreateTheorem { theorem } {}

\begin{document}

\begin{theorem}
    Text.
\end{theorem}

\end{document}

当我尝试编译它时,编译永远不会停止(可能是由于thmtools和之间存在冲突create-theorem),并且.log文件不完整,所以我不知道如何找到导致此行为的原因。在这种情况下我能做些什么吗?


以下是使用日志文件pdflatex

LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-05-04> (/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@section=\count186
\c@subsection=\count187
\c@subsubsection=\count188
\c@paragraph=\count189
\c@subparagraph=\count190
\c@figure=\count191
\c@table=\count192
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
) (/usr/local/texlive/2022/texmf-dist/tex/latex/amscls/amsthm.sty
Package: amsthm 2020/05/29 v2.20.6
\thm@style=\toks16
\thm@bodyfont=\toks17
\thm@headfont=\toks18
\thm@notefont=\toks19
\thm@headpunct=\toks20
\thm@preskip=\skip49
\thm@postskip=\skip50
\thm@headsep=\skip51
\dth@everypar=\toks21
) (/usr/local/texlive/texmf-local/tex/latex/local/betas/create-theorem/create-theorem.sty (/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty (/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2022-05-04 L3 programming layer (loader) 
 (/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2022-04-20 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count193
\l__pdf_internal_box=\box50
))
Package: l3keys2e 2022-01-12 LaTeX2e option processing using LaTeX3 keys
)
Package: create-theorem 2022/05/22 Initializing theorem-like environments with multilingual support
 (/usr/local/texlive/2022/texmf-dist/tex/latex/oberdiek/aliascnt.sty
Package: aliascnt 2018/09/07 v1.5 Alias counters (HO)
) (/usr/local/texlive/texmf-local/tex/latex/local/betas/crefthe/crefthe.sty
Package: crefthe 2022/05/13 Cross referencing with proper definite articles
 (/usr/local/texlive/2022/texmf-dist/tex/latex/cleveref/cleveref.sty
Package: cleveref 2018/03/27 v0.21.4 Intelligent cross-referencing
Package cleveref Info: `amsthm' support loaded on input line 3026.
Package cleveref Info: `aliascnt' support loaded on input line 3193.
) (/usr/local/texlive/2022/texmf-dist/tex/latex/regexpatch/regexpatch.sty
Package: regexpatch 2021/03/21 v0.2f Extending etoolbox patching commands
 (/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
Package: xparse 2022-01-12 L3 Experimental document command parser
)))
\c@application=\count194
\c@assertion=\count195
\c@assumption=\count196
\c@axiom=\count197
\c@claim=\count198
\c@conclusion=\count199
\c@conjecture=\count266
\c@construction=\count267
\c@convention=\count268
\c@corollary=\count269
\c@definition=\count270
\c@example=\count271
\c@exercise=\count272
\c@fact=\count273
\c@hypothesis=\count274
\c@lemma=\count275
\c@notation=\count276
\c@observation=\count277
\c@postulate=\count278
\c@problem=\count279
\c@property=\count280
\c@proposition=\count281
\c@question=\count282
\c@recall=\count283
\c@remark=\count284
\c@theorem=\count285
\c@definition-proposition=\count286
\c@definition-theorem=\count287
\c@proposition-definition=\count288
\c@theorem-definition=\count289
) (/usr/local/texlive/2022/texmf-dist/tex/latex/thmtools/thmtools.sty
Package: thmtools 2020/08/01 v0.72
\thmt@toks=\toks22
\c@thmt@dummyctr=\count290
 (/usr/local/texlive/2022/texmf-dist/tex/latex/thmtools/thm-patch.sty
Package: thm-patch 2020/08/01 v0.72
 (/usr/local/texlive/2022/texmf-dist/tex/latex/thmtools/parseargs.sty
Package: parseargs 2020/08/01 v0.72
\@parsespec=\toks23
)) (/usr/local/texlive/2022/texmf-dist/tex/latex/thmtools/thm-kv.sty
Package: thm-kv 2020/08/01 v0.72
Package thm-kv Info: Theorem names will be uppercased on input line 42.
 (/usr/local/texlive/2022/texmf-dist/tex

xelatex

LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-05-04> (/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c@part=\count181
\c@section=\count182
\c@subsection=\count183
\c@subsubsection=\count184
\c@paragraph=\count185
\c@subparagraph=\count186
\c@figure=\count187
\c@table=\count188
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
) (/usr/local/texlive/2022/texmf-dist/tex/latex/amscls/amsthm.sty
Package: amsthm 2020/05/29 v2.20.6
\thm@style=\toks16
\thm@bodyfont=\toks17
\thm@headfont=\toks18
\thm@notefont=\toks19
\thm@headpunct=\toks20
\thm@preskip=\skip49
\thm@postskip=\skip50
\thm@headsep=\skip51
\dth@everypar=\toks21
) (/usr/local/texlive/texmf-local/tex/latex/local/betas/create-theorem/create-theorem.sty (/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty (/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2022-05-04 L3 programming layer (loader) 
 (/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-xetex.def
File: l3backend-xetex.def 2022-04-20 L3 backend support: XeTeX
\g__graphics_track_int=\count189
\l__pdf_internal_box=\box50
\g__pdf_backend_object_int=\count190
\g__pdf_backend_annotation_int=\count191
\g__pdf_backend_link_int=\count192
))
Package: l3keys2e 2022-01-12 LaTeX2e option processing using LaTeX3 keys
)
Package: create-theorem 2022/05/22 Initializing theorem-like environments with multilingual support
 (/usr/local/texlive/2022/texmf-dist/tex/latex/oberdiek/aliascnt.sty
Package: aliascnt 2018/09/07 v1.5 Alias counters (HO)
) (/usr/local/texlive/texmf-local/tex/latex/local/betas/crefthe/crefthe.sty
Package: crefthe 2022/05/13 Cross referencing with proper definite articles
 (/usr/local/texlive/2022/texmf-dist/tex/latex/cleveref/cleveref.sty
Package: cleveref 2018/03/27 v0.21.4 Intelligent cross-referencing
Package cleveref Info: `amsthm' support loaded on input line 3026.
Package cleveref Info: `aliascnt' support loaded on input line 3193.
) (/usr/local/texlive/2022/texmf-dist/tex/latex/regexpatch/regexpatch.sty
Package: regexpatch 2021/03/21 v0.2f Extending etoolbox patching commands
 (/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
Package: xparse 2022-01-12 L3 Experimental document command parser
)))
\c@application=\count193
\c@assertion=\count194
\c@assumption=\count195
\c@axiom=\count196
\c@claim=\count197
\c@conclusion=\count198
\c@conjecture=\count199
\c@construction=\count266
\c@convention=\count267
\c@corollary=\count268
\c@definition=\count269
\c@example=\count270
\c@exercise=\count271
\c@fact=\count272
\c@hypothesis=\count273
\c@lemma=\count274
\c@notation=\count275
\c@observation=\count276
\c@postulate=\count277
\c@problem=\count278
\c@property=\count279
\c@proposition=\count280
\c@question=\count281
\c@recall=\count282
\c@remark=\count283
\c@theorem=\count284
\c@definition-proposition=\count285
\c@definition-theorem=\count286
\c@proposition-definition=\count287
\c@theorem-definition=\count288
) (/usr/local/texlive/2022/texmf-dist/tex/latex/thmtools/thmtools.sty
Package: thmtools 2020/08/01 v0.72
\thmt@toks=\toks22
\c@thmt@dummyctr=\count289
 (/usr/local/texlive/2022/texmf-dist/tex/latex/thmtools/thm-patch.sty
Package: thm-patch 2020/08/01 v0.72
 (/usr/local/texlive/2022/texmf-dist/tex/latex/thmtools/parseargs.sty
Package: parseargs 2020/08/01 v0.72
\@parsespec=\toks23
)) (/usr/local/texlive/2022/texmf-dist/tex/latex/thmtools/thm-kv.sty
Package: thm-kv 2020/08/01 v0.72
Package th

(并不是说我没有完全复制,而是th无论我尝试多少次,它都只是停在了 )

答案1

仅回答“如何找到问题”(而不是如何解决问题)

添加\tracingall

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{create-theorem}

\tracingall
\CreateTheorem {theorem} {}

\begin{document}

\begin{theorem}
    Text.
\end{theorem}

\end{document}

过一会儿(本地运行)你会看到日志稳定下来:

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

显然,这是在循环并不断\thetheorem_crthm_regional向自身扩展。您可以使用 Ctrl-c 来中断:

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 

~........\thetheorem_crthm_regional ->\thetheorem_crthm_regional 
! Interruption.
\cref@old@refstepcounter ...sname the#1\endcsname 
                                                  }
\refstepcounter@optarg ...@old@refstepcounter {#2}
                                                  \cref@constructprefix {#2}...

\cref@thmoptarg ...}\else \refstepcounter [#1]{#3}
                                                  \def \@tempa {\@oparg {\@b...

\environment theorem code ..._crthm_regional}[#1]}
                                                  \bool_if:NF \l__crthm_regi...

\l__cmd_tmpb_tl ->\__cmd_add_arg:o \c_novalue_tl 
                                                  
<to be read again> 
                   T
l.13     T
          ext.
? 

此时你可以停止x

? x
No pages of output.
Transcript written on cc312.log.

答案2

它是thmtools错误,完整分析请参见https://github.com/muzimuzhi/thmtools/issues/27

解决方法是使用

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{create-theorem}

\makeatletter
\IfPackageAtLeastTF{thmtools}{2022/01/01} % current version is 2021/05/27 v0.73
  {}
  {% \xpatchcmd is provided by `xpatchcmd` package, which is loaded by
   % `crefthe`, which is loaded by `create-theorem`.
    \xpatchcmd\thmt@autorefsetup
      {\@xa\let\csname the\thmt@envname\@xa\endcsname}
      {\@xa\global\@xa\let\csname the\thmt@envname\@xa\endcsname}
      {}{\PatchFailed}
  }
\makeatother

\CreateTheorem { theorem } {}

\begin{document}
\begin{theorem}
    Text.
\end{theorem}
\end{document}

相关内容