The problem is that one of the subpackages loaded by datatool
, namely datatool-base
has the line
\RequirePackage{amsmath}
and mathspec
sets up a (very poor) check for possible loading of amsmath
after it, which triggers the error even if amsmath
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 as mathspec
is concerned. This is undoubtedly a bug.
The package mathspec
says
\let\original@RequirePackage\RequirePackage
\renewcommand\RequirePackage[2][]{
\ifstrequal{#2}{amsmath}
{\PackageError{mathspec}
{`amsmath' must be loaded earlier than `mathspec'}
{Edit the document so that `amsmath' is required earlier than `mathspec'.}}
{\relax}
\original@RequirePackage[#1]{#2}}
\@onlypreamble\RequirePackage
\let\usepackage\RequirePackage
\@onlypreamble\usepackage
which is quite bad code, in my opinion: \RequirePackage
is redefined to check if its mandatory argument is exactly amsmath
. So, if one says
\usepackage{mathspec}
\usepackage{amsmath,amsthm}
the check will fail and amsmath
will be happily loaded after mathspec
.
Judging from the comments in the package, the only reason why amsmath
should be loaded before mathspec
is a problem with the definition of \varTheta
. This can be solved much more easily by changing lines 103–106, which read
103 \ifdef{\varTheta}
104 {\let\eu@cm@varTheta\varTheta}
105 {\relax}
106 \let\varTheta\Theta
into
\AtBeginDocument{
\ifdef{\varTheta}
{\let\eu@cm@varTheta\varTheta}
{}
\let\varTheta\Theta
}
and removing the final lines with the redefinition of \RequirePackage
.
A workaround until the mathspec
package is fixed:
\documentclass{memoir}
\usepackage{fixltx2e}
\usepackage{amsmath}
\usepackage{mathspec}
\makeatletter % undo the wrong changes made by mathspec
\let\RequirePackage\original@RequirePackage
\let\usepackage\RequirePackage
\makeatother
\usepackage{glossaries}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\end{document}
glossaries
(in particulardatatool-base
) requiresamsmath
. The check performed bymathspec
consists in redefining\RequirePackage
to check whether the argument isamsmath
(which is a very poor trick, IMO).