I have a document made up of many sub-documents. These documents can be compiled separately using LaTeX and the subfiles package but not when I use both newtxtext and bm as well. How can I overcome this?
For example, file main.tex:
\documentclass{report}
\usepackage{newtxtext}
\usepackage{newtxmath}
\usepackage{bm}
\usepackage{subfiles}
\begin{document}
\subfile{sub1}
\end{document}
File sub1.tex in the same directory:
\documentclass[main]{subfiles}
\begin{document}
$\bm{x}$
\end{document}
The main file compiles without a problem, but trying to compile sub1 by itself reports an error but only when newtxtext is included.
The log file tells me
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)
Adding a paragraph break between $\bm{x}$ and the \end{document} gives the message
! Paragraph ended before \bm@test@token was complete.
Searching for this message brings up the question Package incompatibilites: etoolbox, hyperref, and bm, standalone?. Could this be a similar problem?
Adding \listfiles gives
*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.
***********
After installing the latest TeX Live and removing my previously installed packages, the error remains and the log file gives
*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.
***********
Inspired by the question Package incompatibilites: etoolbox, hyperref, and bm, standalone?, in etoolbox.sty I commented out
\patchcmd\enddocument
{\deadcycles}
{\let\AfterEndDocument\@firstofone
\@afterenddocumenthook
\deadcycles}
{}
{\let\etb@@end\@@end
\def\@@end{%
\let\AfterEndDocument\@firstofone
\@afterenddocumenthook
\etb@@end}}
{<environment>}{<code>}
This allows sub1.tex to be compiled on its own without error. This suggests that there is a conflict of the type described in the linked question.
$\bm{x}$either. – egreg May 27 '14 at 20:29\listfilesto your main document and report the relevant part of the .log file you get. – egreg May 28 '14 at 09:42report.clshas been last changed on 2007/10/19 andamsmath.styon 2013/01/14, for instance). Adding the most recent version ofnewtxandsubfilesto such an old distribution can expose to all kinds of problems. Update your TeX distribution, which seems to be eight years old. – egreg May 28 '14 at 10:39newtxtext. – egreg Jul 07 '14 at 15:10