The mathspec package has problems with ctexbook. But it also has problems with fontspec because it patches it in possibly dangerous ways.
You can do the following at your own risk.
\PassOptionsToPackage{no-math}{fontspec}
\documentclass{ctexbook}
%%%% Fix the error
\ExplSyntaxOn
\NewCommandCopy{\kernelRequirePackage}{\RequirePackage}
\RenewDocumentCommand{\RequirePackage}{O{}mo}
{
\str_if_eq:nnF { #2 } { fontspec }
{
\IfNoValueTF{#3}{\kernelRequirePackage[#1]{#2}}{\kernelRequirePackage[#1]{#2}[#3]}
}
}
\ExplSyntaxOff
\usepackage{mathspec}
\RenewCommandCopy{\RequirePackage}{\kernelRequirePackage}
%%%
\begin{document}
Some words.
\end{document}
Explanation: ctexbook already loads fontspec so I disable mathspec trying to load it (where the error happens) and pass it the no-math option at the beginning.
I see no real reason to use mathspec nowadays.
mathspec, because it does damages tofontspec– egreg Mar 17 '24 at 23:25fontspecwas updated on 13th Feb., 2024. So the error may be related to it. – M. Logic Mar 18 '24 at 07:18ctexbookandmathspec. By the way,mathspecdoes “patch”fontspecand it's quite likely that updates to the latter can break the former. – egreg Mar 18 '24 at 08:19