Closed nilsfleischhacker closed 3 years ago
amsmath
's aligned
does \let\@testopt\alignsafe@testopt
, and \alignsafe@testopt
is the same as the usual \@testopt
except that it does (in expl3
name) \group_align_safe_begin:
and \group_align_safe_end:
. However mathtools
's redefinition does not.
If I got it right, this should work:
\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}
\ExplSyntaxOn
\makeatletter
\long\def\MH_nospace_ifnextchar:Nnn #1#2#3{
\MH_group_align_safe_begin:
\MH_let:NwN\reserved@d=~#1
\def\reserved@a{\MH_group_align_safe_end: #2}
\def\reserved@b{\MH_group_align_safe_end: #3}
\futurelet\@let@token\MH_nospace_nextchar:
}
\makeatother
\ExplSyntaxOn
\begin{document}
\begin{align*}
\begin{aligned}&\end{aligned}
\end{align*}
\end{document}
I have to admit, I'm unsure if you're saying that the current behavior is intended or not.
Sorry, my sloppy writing. I mean that it looks like mathtools
overlooked this case from amsmath
, so it seems like a mathtools
bug to me (with the fix proposed in my previous comment).
Should now be fixed in mhsetup.dtx
using @PhelypeOleinik's suggestion.
(I originally filed this as an issue with the cryptocode package, but it turns out, mathtools is at fault.)
The following document will not compile
however, it compiles fine if the mathtools package is not loaded as in
The issue is also fixed by adding a single whitespace as in
This seems like an unintended side effect of something, but I have no idea what.