我有一个由许多子文档组成的文档。这些文档可以使用 LaTeX 和软件包分别编译,subfiles
但当我同时使用newtxtext
和时bm
则不行。我该如何解决这个问题?
例如,文件main.tex
:
\documentclass{report}
\usepackage{newtxtext}
\usepackage{newtxmath}
\usepackage{bm}
\usepackage{subfiles}
\begin{document}
\subfile{sub1}
\end{document}
sub1.tex
同一目录中的文件:
\documentclass[main]{subfiles}
\begin{document}
$\bm{x}$
\end{document}
主文件编译没有问题,但尝试单独编译 sub1 会报告错误,但仅当newtxtext
包含时才会报告错误。
日志文件告诉我
Runaway argument?
{document}\ifx \reserved@a \@currenvir \else \@badend {document}\fi \clearpage
\ETC.
! File ended while scanning use of \reserved@a.
<inserted text>
\par
<*> \input sub1.tex
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.
! Emergency stop.
<*> \input sub1.tex
*** (job aborted, no legal \end found)
$\bm{x}$
在和 之间添加一个段落分隔符,\end{document}
可以传达以下信息
! Paragraph ended before \bm@test@token was complete.
搜索此消息提出了一个问题软件包不兼容:etoolbox、hyperref 和 bm,独立吗?。这可能是类似的问题吗?
添加\listfiles
可得到
*File List*
report.cls 2005/09/16 v1.4f Standard LaTeX document class
size10.clo 2005/09/16 v1.4f Standard LaTeX file (size option)
newtxtext.sty 2014/04/26 v1.27
fontaxes.sty 2014/03/23 v1.0d Font selection axes
xkeyval.sty 2006/11/18 v2.5f package option processing (HA)
xkeyval.tex 2006/11/18 v2.5f key=value parser (HA)
etoolbox.sty 2011/01/03 v2.1 e-TeX tools for LaTeX
etex.sty 1998/03/26 v2.0 eTeX basic definition package (PEB)
fontenc.sty
t1enc.def 2005/09/27 v1.99g Standard LaTeX file
textcomp.sty 2005/09/27 v1.99g Standard LaTeX package
ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
newtxmath.sty 2014/04/26 v1.27
amsmath.sty 2000/07/18 v2.13 AMS math features
amstext.sty 2000/06/29 v2.01
amsgen.sty 1999/11/30 v2.0
amsbsy.sty 1999/11/29 v1.2d
amsopn.sty 1999/12/14 v2.01 operator names
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
binhex.tex
bm.sty 2004/02/26 v1.1c Bold Symbol Support (DPC/FMi)
subfiles.sty 2012/05/23 Federico Garcia
verbatim.sty 2003/08/22 v1.5q LaTeX2e package for verbatim enhancements
omlntxmi.fd 2012/03/22 Fontinst v1.933 font definitions for OML/ntxmi.
omsntxsy.fd 2012/11/14 Fontinst v1.933 font definitions for OMS/ntxsy.
untxexa.fd 2012/04/16 Fontinst v1.933 font definitions for U/ntxexa.
ts1cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
t1ntxrx.fd 2012/12/25 v1.0
sub1.tex
untxmia.fd 2012/04/16 Fontinst v1.933 font definitions for U/ntxmia.
untxsya.fd 2012/04/12 Fontinst v1.933 font definitions for U/ntxsya.
untxsyb.fd 2012/04/12 Fontinst v1.933 font definitions for U/ntxsyb.
untxsyc.fd 2012/04/12 Fontinst v1.933 font definitions for U/ntxsyc.
***********
安装最新的 TeX Live 并删除我之前安装的软件包后,错误仍然存在,日志文件显示
*File List*
report.cls 2007/10/19 v1.4h Standard LaTeX document class
size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
newtxtext.sty 2014/04/07 v1.25
fontaxes.sty 2014/03/23 v1.0d Font selection axes
xkeyval.sty 2012/10/14 v2.6b package option processing (HA)
xkeyval.tex 2012/10/14 v2.6b key=value parser (HA)
etoolbox.sty 2011/01/03 v2.1 e-TeX tools for LaTeX
etex.sty 1998/03/26 v2.0 eTeX basic definition package (PEB)
fontenc.sty
t1enc.def 2005/09/27 v1.99g Standard LaTeX file
textcomp.sty 2005/09/27 v1.99g Standard LaTeX package
ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
newtxmath.sty 2014/04/07 v1.25
amsmath.sty 2013/01/14 v2.14 AMS math features
amstext.sty 2000/06/29 v2.01
amsgen.sty 1999/11/30 v2.0
amsbsy.sty 1999/11/29 v1.2d
amsopn.sty 1999/12/14 v2.01 operator names
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
binhex.tex
bm.sty 2004/02/26 v1.1c Bold Symbol Support (DPC/FMi)
subfiles.sty 2012/05/23 Federico Garcia
verbatim.sty 2003/08/22 v1.5q LaTeX2e package for verbatim enhancements
omlntxmi.fd 2012/03/22 Fontinst v1.933 font definitions for OML/ntxmi.
omsntxsy.fd 2012/11/14 Fontinst v1.933 font definitions for OMS/ntxsy.
untxexa.fd 2012/04/16 Fontinst v1.933 font definitions for U/ntxexa.
ts1cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
t1ntxrx.fd 2012/12/25 v1.0
sub1.tex
untxmia.fd 2012/04/16 Fontinst v1.933 font definitions for U/ntxmia.
untxsya.fd 2012/04/12 Fontinst v1.933 font definitions for U/ntxsya.
untxsyb.fd 2012/04/12 Fontinst v1.933 font definitions for U/ntxsyb.
untxsyc.fd 2012/04/12 Fontinst v1.933 font definitions for U/ntxsyc.
***********
受到这个问题的启发软件包不兼容:etoolbox、hyperref 和 bm,独立吗?,etoolbox.sty
我注释掉了
\patchcmd\enddocument
{\deadcycles}
{\let\AfterEndDocument\@firstofone
\@afterenddocumenthook
\deadcycles}
{}
{\let\etb@@end\@@end
\def\@@end{%
\let\AfterEndDocument\@firstofone
\@afterenddocumenthook
\etb@@end}}
{<environment>}{<code>}
这样就可以sub1.tex
自行编译而不会出现错误。这表明存在链接问题中描述的类型的冲突。
答案1
该newtxtext
包加载了etoolbox
重新定义 的包\@@end
。它真的不应该这样做。既然如此,您可以这样做以在本地恢复它。
\makeatletter
\let\@@@@@@end\@@end
\def\fixend{\let\@@end\@@@@@@end}
\makeatother
\documentclass[main]{subfiles}
\begin{document}
$\fixend\bm{x}$
\end{document}