# Repost it with a minimal working example for the amsmath must be loaded earlier than mathspec problem

See the following mwe:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathspec}
\usepackage{unicode-math}

\begin{document}
\begin{equation*}
1 + 2 = 3
\end{equation*}
\end{document}


Run the above code with xelatex will meet the following error:

! Package mathspec Error: amsmath' must be loaded earlier than mathspec'.

See the mathspec package documentation for explanation.
Type  H <return>  for immediate help.
...

l.54 \RequirePackage{amsmath}

?


\$ xelatex --version XeTeX 3.14159265-2.6-0.999991 (TeX Live 2019)

Regards

• You should not load both mathspec and unicode-math. They fight each other. – egreg Mar 19 '20 at 9:03
• – David Carlisle Mar 19 '20 at 14:04

The mathspec package uses a hand-made test to suggest amsmath being loaded before it: precisely, it redefines \RequirePackage, which is quite a bad thing to do.
The redefinition is not really dangerous in itself, but it's rather naïve: the redefined command just checks whether the mandatory argument to \RequirePackage is amsmath and, in this case, it emits the error message.
It happens that recent versions of unicode-math indeed do \RequirePackage{amsmath}, so the error is triggered.
However, this is a false problem: mathspec and unicode-math are very unfriendly to each other, because they want to do the same thing, namely, to take control of math typesetting.