包不兼容?

包不兼容?

我有一本用 LaTeX(WinEdt 9,Windows 7)编写的书,在换了一台新电脑后无法编译(之前运行正常)。在下面的最小示例中,错误是You can't use prefix with "\begingroup on one of the \Newassociation-lines(package answers)。问题似乎是包之间的不兼容,但我无法确定哪个包是问题所在。在下面的示例中,错误出现在行\Newassociation{hint}{Hint}{hint} 上,但如果我删除 \newtheorem-line,错误就会出现在行 上\Newassociation{sol}{Solution}{sol}。我无法通过切换命令的顺序来消除错误,\usepackage正如这里另一个讨论中所建议的那样。有什么建议吗?

\documentclass{book}
\usepackage{siunitx}
\usepackage{answers}
\usepackage{amsthm}
\usepackage{graphicx,epstopdf}
\usepackage[format=plain,font=small,labelfont=bf,up]{caption}
\usepackage[version=3]{mhchem}
\usepackage{float}
\usepackage{placeins}
\usepackage{pdfpages}
\usepackage{makeidx}
\usepackage{enumerate}
\usepackage{fixltx2e}
\usepackage{xspace}
\usepackage{textgreek}
\newtheorem{Ex}{Exercise}
\Newassociation{ans}{Answer}{ans}
\Newassociation{hint}{Hint}{hint}
\Newassociation{sol}{Solution}{sol}
\Newassociation{solt}{SolutionTeacher}{solt}
\begin{document}
Short text
\end{document}

----更多信息---- 我相信我至少正在使用最新版本的所有软件,因为我的电脑不到一年。我正在运行:这是 pdfTeX,版本 3.1415926-2.5-1.40.14(MiKTeX 2.9 64 位)(预加载格式=pdflatex 2015.5.19)

我添加了 \listfiles 并使用了建议的解决方法(否则 \listfiles 将不起作用;该解决方法也适用于整本书的文档)并得到以下内容:

*File List*
book.cls    2007/10/19 v1.4h Standard LaTeX document class
bk10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
siunitx.sty    2015/01/21 v2.6e A comprehensive (SI) units package
expl3.sty    2015/03/01 v5547 L3 programming layer (loader) 
expl3-code.tex    2015/03/01 v5547 L3 programming layer 
etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
l3unicode-data.def    2015/03/01 v5544 L3 Unicode data
l3pdfmode.def    2015/03/01 v5544 L3 Experimental driver: PDF mode
xparse.sty    2014/11/25 v5471 L3 Experimental document command parser
amstext.sty    2000/06/29 v2.01
amsgen.sty    1999/11/30 v2.0
array.sty    2008/09/09 v2.4c Tabular extension package (FMi)
l3keys2e.sty    2014/11/25 v5471 LaTeX2e option processing using LaTeX3 keys
translator.sty    2010/06/12 ver 1.10
keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
translator-language-mappings.tex
answers.sty    2014/08/24 v2.16 Production of solution sheets in LaTeX2e
verbatim.sty    2003/08/22 v1.5q LaTeX2e package for verbatim enhancements
amsthm.sty    2004/08/06 v2.20
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
epstopdf.sty    2010/02/09 v2.5 Conversion with epstopdf on the fly (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
caption.sty    2013/05/02 v3.3-89 Customizing captions (AR)
caption3.sty    2013/05/02 v1.6-88 caption3 kernel (AR)
mhchem.sty    2015/04/07 v4.00 for typesetting chemical formulae
l3regex.sty    2014/11/25 v5471 L3 Experimental regular expressions
l3tl-build.sty    2014/08/25 v5378 L3 Experimental token list construction  
l3tl-analysis.sty    2014/05/06 v4745 L3 Experimental token lists analysis
l3str.sty    2014/11/25 v5471 L3 Experimental strings
l3flag.sty    2014/11/25 v5471 L3 Experimental flags
l3str-convert.sty    2014/06/03 v5028 L3 Experimental string encoding conversions
calc.sty    2007/08/22 v4.3 Infix arithmetic (KKT,FJ)
amsmath.sty    2013/01/14 v2.14 AMS math features
amsbsy.sty    1999/11/29 v1.2d
amsopn.sty    1999/12/14 v2.01 operator names
ifthen.sty    2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
float.sty    2001/11/08 v1.3d Float enhancements (AL)
placeins.sty    2005/04/18  v 2.2
pdfpages.sty    2015/04/15 v0.4w Insert pages of external PDF documents (AM)
eso-pic.sty    2013/10/06 v2.0d eso-pic (RN)
atbegshi.sty    2011/10/05 v1.16 At begin shipout hook (HO)
xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
pppdftex.def    2015/04/15 v0.4w Pdfpages driver for pdfTeX (AM)
makeidx.sty    2000/03/29 v1.0m Standard LaTeX package
enumerate.sty    1999/03/05 v3.00 enumerate extensions (DPC)
xspace.sty    2009/10/20 v1.13 Space after command names (DPC,MH)
textgreek.sty    2011/10/09 v0.7 Greek symbols in text
lgrenc.def    2013/12/02 v0.11.2 LGR Greek font encoding definitions
greek-fontenc.def    2014/12/12 v0.12 Common Greek font encoding definitions
lgrcmr.fd    2013/09/01 v1.0 Greek European Computer Regular
translator-basic-dictionary-English.dict    
siunitx-abbreviations.cfg    2015/01/21 v2.6e siunitx: Abbreviated units
supp-pdf.mkii

----更正---- 删除了双重 \usepackage{caption}(仍然是相同的错误)。文件列表已更新(可能没有改变)。

----问题解决了----我更新了 MikTeX 和所有软件包;这解决了这个问题。

答案1

您遇到了 2015 版内核之前的 LaTeX 中的一个不为人知的错误。我怀疑“新”机器的 TeX 发行版没有更新。

您能做的最好的事情就是确保 TeX 发行版是最新的,并且所有更新都已到位。

无论如何,有一个解决方法:只需在错误发生之前定义一个新的计数器。

\Newassociation{ans}{Answer}{ans}
\newcounter{neverusedcounter}
\Newassociation{hint}{Hint}{hint}
\Newassociation{sol}{Solution}{sol}
\Newassociation{solt}{SolutionTeacher}{solt}

相关内容