MWE: greatly trimmed from a large document; XeLaTeX; full TeXLive2012 completely up-to-date:
\documentclass{memoir}
\usepackage{fixltx2e}
\usepackage{amsmath}
\usepackage{mathspec}
\usepackage{glossaries}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\end{document}
Fails with "! Package mathspec Error: 'amsmath' must be loaded earlier than `mathspec'."
Now, if I eliminate glossaries
, or move it above mathspec in the file, things work. But it isn't very convenient to have to sort ones packages whenever anything gets a new dependency. And in any case, I do load amsmath before mathspec, don't I?
Really puzzled by this one. Any illumination would be most welcome.
(BTW, not strictly MWE, as it also fails with article
.
Best Answer
The problem is that one of the subpackages loaded by
datatool
, namelydatatool-base
has the lineand
mathspec
sets up a (very poor) check for possible loading ofamsmath
after it, which triggers the error even ifamsmath
has already been loaded when another package requires it.The normal setup of LaTeX is not reloading packages, so the call by
datatool-base
should be completely harmless, as far asmathspec
is concerned. This is undoubtedly a bug.The package
mathspec
sayswhich is quite bad code, in my opinion:
\RequirePackage
is redefined to check if its mandatory argument is exactlyamsmath
. So, if one saysthe check will fail and
amsmath
will be happily loaded aftermathspec
.Judging from the comments in the package, the only reason why
amsmath
should be loaded beforemathspec
is a problem with the definition of\varTheta
. This can be solved much more easily by changing lines 103–106, which readinto
and removing the final lines with the redefinition of
\RequirePackage
.A workaround until the
mathspec
package is fixed: