From 36b3c596a78ed56283ca4cd0286aaf6c09e0d3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Tue, 22 Jun 2021 23:24:25 +0200 Subject: [PATCH] Add {gather} support --- luamml-patches-amsmath.sty | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/luamml-patches-amsmath.sty b/luamml-patches-amsmath.sty index 6b01eeb..f2c9205 100644 --- a/luamml-patches-amsmath.sty +++ b/luamml-patches-amsmath.sty @@ -3,6 +3,12 @@ \lua_now:n { require'luamml-amsmath' } +% For all of these changes, the redefinitions appear huge. +% But they are almost identical to the original and only +% add luamml commands in appropriate places, so they would +% mostly disappear if there were enough hooks in amsmath. + +% aligned and friends \cs_set:Npn \start@aligned #1#2 { \RIfM@ \else @@ -66,6 +72,66 @@ \__luamml_amsmath_finalize_inner_table: } +% gather +\cs_set:Npn \gather@ #1 { + \ingather@true + \let \split \insplit@ + \let \tag \tag@in@align + \let \label \label@in@display + \chardef \dspbrk@context \z@ + \intertext@ \displ@y@ \Let@ + \let \math@cr@@@ \math@cr@@@gather + \gmeasure@ {#1} + \global \shifttag@false + \tabskip \z@skip + \global \row@ \@ne + \halign to \displaywidth \bgroup + \strut@ + \setboxz@h { + $ + \m@th + \displaystyle + {##} + \luamml_flag_save:Nn \displaystyle {mtd} + $ + } + \__luamml_amsmath_add_box_to_row: + \calc@shift@gather + \set@gather@field + \tabskip\@centering + & + \setboxz@h { + \strut@ + {##} + } + \place@tag@gather + \__luamml_amsmath_set_tag: + \tabskip \iftagsleft@ + \gdisplaywidth@ + \else + \z@skip + \span \fi + \crcr + #1 +} +\cs_new_eq:NN \__luamml_amsmath_original_gmeasure:n \gmeasure@ +\cs_set:Npn \gmeasure@ #1 { + \exp_last_unbraced:Nno + \use_ii_i:nn + { \luamml_flag_ignore: } + { \__luamml_amsmath_original_gmeasure:n {#1} } +} + +\cs_set:Npn \endgather { + \math@cr + \black@ \totwidth@ + \__luamml_amsmath_finalize_table: + \egroup + $$ + \ignorespacesafterend +} + +% align and friends \cs_set:Npn \align@preamble { & \hfil