latex3 / mathtools

Mathematical tools to use with amsmath
LaTeX Project Public License v1.3c
54 stars 6 forks source link

Error with RequirePackage{amsmath} #55

Closed fortierq closed 1 year ago

fortierq commented 1 year ago

Hello, I try to use mathtools but I have the following problem :

/usr/local/texlive/2023/texmf-dist/tex/latex/mathtools/mathtools.sty:122: Illegal parameter number in definition of \__hook package/amsmath/after.
<to be read again> 
\Ustopmath 
l.122 \RequirePackage{amsmath}[2016/11/05]

Any idea ?

FrnchFrgg commented 10 months ago

How did you solve this (since you marked as completed) ? BTW I think the bug is actually caused by amsmath and not mathtools

muzimuzhi commented 10 months ago

Most likely, such error was caused by code before loading mathtools, which looked like \AddToHookWithArguments{package/amsmath/after}{#1}, adding some code containing #1 or #<n> to hook package/amsmath/after, with \AddToHookWithArguments.

Since this generic hook has no arguments, no #1, #2, ..., #9 can be used in its code. Doubled-# are accepted, for example

\AddToHook{package/amsmath/after}{\def\x##1{##1}}

\AddToHookWithArguments also works, but it gives a wrong implication that the hook package/amsmath/after is argumented takes arguments.

car222222 commented 10 months ago

Nice word: "argumented".
I shall submit it to the OED. 😃

FrnchFrgg commented 10 months ago

Here I do not use mathtools (at least it is not loaded at that point) but lualatex-math triggers the same problem. The workaround I found was to load lualatex-math after amsmath but the documentation of lualatex-math tells that less issues with amsmath and lualatex will be fixed that way.

u-fischer commented 10 months ago

@FrnchFrgg as neither the OP nor you provided a full example it is quite impossible to say what triggers your error.

muzimuzhi commented 10 months ago

See a full example loading lualatex-math and some analysis in https://github.com/phst/lualatex-math/issues/26.