(first reported in latex3/mathtools#55 (comment))
Loading lualatex-math before amsmath throws error
! Illegal parameter number in definition of \__hook package/amsmath/after.
% !TeX program = lualatex
\documentclass{article}
\usepackage{lualatex-math}
\begin{document}
content
\end{document}
The problem is caused by two LuaTeX primitive \alignmark used in
\__lltxmath_after_package_or_now:nn { amsmath } {
...
\@ifpackagelater { amsmath } { 2020/09/23 } { } {
\__lltxmath_patch:NNnnn \subarray \cs_set:Npn { #1 } {
...
$ \m@th \scriptstyle ## $
\hfil
\crcr
} {
...
\Ustartmath
\m@th
\scriptstyle
\alignmark \alignmark
\Ustopmath
\hfil
\crcr
}
...
}
}
Replacing \alignmark \alignmark with ## seems to solve the problem. I'm guessing that's because \alignmark is not doubled by hook macros.
What surprised me is, using \alignmark in \AddToHook directly in preamble won't throw such an error.
% !TeX program = lualatex
\begin{filecontents}[force]{x-math.sty}
\AddToHook{package/amsmath/after}{%
\def\y{\alignmark\alignmark}%
}
\end{filecontents}
\documentclass{article}
\AddToHook{package/amsmath/after}{%
\def\x{\alignmark\alignmark}%
}
\input x-math.sty % errors
\usepackage{x-math} % errors
\begin{document}
content
\end{document}
(first reported in latex3/mathtools#55 (comment))
Loading
lualatex-mathbeforeamsmaththrows errorThe problem is caused by two LuaTeX primitive
\alignmarkused inlualatex-math/lualatex-math.dtx
Line 564 in c4c7e63
Replacing
\alignmark \alignmarkwith##seems to solve the problem. I'm guessing that's because\alignmarkis not doubled by hook macros.What surprised me is, using
\alignmarkin\AddToHookdirectly in preamble won't throw such an error.