%%
%% This is file `mathtools.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mathtools.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2002-2011 by Morten Hoegholm
%% Copyright (C) 2012-2019 by Lars Madsen
%% Copyright (C) 2020-     by Lars Madsen, the LaTeX3 project
%% 
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2008/05/04 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is
%% Lars Madsen and the LaTeX3 project
%% 
%% This work consists of the main source file mathtools.dtx
%% and the derived files
%%    mathtools.sty, mathtools.pdf, mathtools.ins, mathtools.drv.
%% 
\ProvidesPackage{mathtools}%
  [2022/02/07 v1.28a mathematical typesetting tools]
\RequirePackage{keyval,calc}
\RequirePackage{mhsetup}[2021/03/18]
\MHInternalSyntaxOn
 % borrowed from fixltx2e
\def\EQ_MakeRobust#1{%
  \@ifundefined{\expandafter\@gobble\string#1}{%
    \@latex@error{The~control~sequence~`\string#1'~is~undefined!%
      \MessageBreak There~is~nothing~here~to~make~robust}%
    \@eha
  }%
  {%
    \@ifundefined{\expandafter\@gobble\string#1\space}%
    {%
      \expandafter\let\csname
      \expandafter\@gobble\string#1\space\endcsname=#1%
      \edef\reserved@a{\string#1}%
      \def\reserved@b{#1}%
      \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
      \edef#1{%
        \ifx\reserved@a\reserved@b
          \noexpand\x@protect\noexpand#1%
        \fi
        \noexpand\protect\expandafter\noexpand
        \csname\expandafter\@gobble\string#1\space\endcsname}%
    }%
    {\@latex@info{The~control~sequence~`\string#1'~is~already~robust}}%
   }%
}
\def\forced_EQ_MakeRobust#1{%
  \@ifundefined{\expandafter\@gobble\string#1}{%
    \@latex@error{The~control~sequence~`\string#1'~is~undefined!%
      \MessageBreak There~is~nothing~here~to~make~robust}%
    \@eha
  }%
  {%
    % \@ifundefined{\expandafter\@gobble\string#1\space}%
    % {%
      \expandafter\let\csname
      \expandafter\@gobble\string#1\space\endcsname=#1%
      \edef\reserved@a{\string#1}%
      \def\reserved@b{#1}%
      \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
      \edef#1{%
        \ifx\reserved@a\reserved@b
          \noexpand\x@protect\noexpand#1%
        \fi
        \noexpand\protect\expandafter\noexpand
        \csname\expandafter\@gobble\string#1\space\endcsname}%
 %    }%
 %    {\@latex@info{The control sequence `\string#1' is already robust}}%
   }%
}
\def\MT_options_name:{mathtools}
\newcommand*\mathtoolsset[1]{\setkeys{\MT_options_name:}{#1}}
\MH_new_boolean:n {fixamsmath}
\DeclareOption{fixamsmath}{
  \MH_set_boolean_T:n {fixamsmath}
}
\DeclareOption{donotfixamsmathbugs}{
  \MH_set_boolean_F:n {fixamsmath}
}
\DeclareOption{allowspaces}{
  \MH_let:NwN \MaybeMHPrecedingSpacesOff
              \relax
    \MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \kernel@ifnextchar
}
\DeclareOption{disallowspaces}{
  \MH_let:NwN \MaybeMHPrecedingSpacesOff
              \MHPrecedingSpacesOff
  \MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \MH_nospace_ifnextchar:Nnn
}
\MH_new_boolean:n {robustify}
\MH_set_boolean_T:n {robustify}
\DeclareOption{nonrobust}{
  \MH_set_boolean_F:n {robustify}
}
\DeclareOption*{
  \PassOptionsToPackage{\CurrentOption}{amsmath}
}
\ExecuteOptions{fixamsmath,disallowspaces}
\ProcessOptions\relax
\MHInternalSyntaxOff
\RequirePackage{amsmath}[2016/11/05]
\MHInternalSyntaxOn
\AtEndOfPackage{\MHInternalSyntaxOff}
\def\MT_true_false_error:{
  \PackageError{mathtools}
    {You~ have~ to~ select~ either~ `true'~ or~ `false'}
    {I'll~ assume~ you~ chose~ `false'~ for~ now.}
}
\def\MT_define_tagform:nwnn #1[#2]#3#4{
  \@namedef{MT_tagform_#1:n}##1
    {\maketag@@@{#3\ignorespaces#2{##1}\unskip\@@italiccorr#4}}
}
\providecommand*\newtagform[1]{%
  \@ifundefined{MT_tagform_#1:n}
  {\@ifnextchar[%
    {\MT_define_tagform:nwnn #1}%
    {\MT_define_tagform:nwnn #1[]}%
  }{\PackageError{mathtools}
  {The~ tag~ form~ `#1'~ is~ already~ defined\MessageBreak
  You~ probably~ want~ to~ look~ up~ \@backslashchar renewtagform~
  instead}
  {I~ will~ just~ ignore~ your~ wish~ for~ now.}}
}
\newtagform{default}{(}{)}
\providecommand*\renewtagform[1]{%
  \@ifundefined{MT_tagform_#1:n}
  {\PackageError{mathtools}
  {The~ tag~ form~ `#1'~ is~ not~ defined\MessageBreak
  You~ probably~ want~ to~ look~ up~ \@backslashchar newtagform~ instead}
  {I~ will~ just~ ignore~ your~ wish~ for~ now.}}
  {\@ifnextchar[%
    {\MT_define_tagform:nwnn #1}%
    {\MT_define_tagform:nwnn #1[]}%
  }
}
\providecommand*\usetagform[1]{%
  \@ifundefined{MT_tagform_#1:n}
    {
      \PackageError{mathtools}{%
        You~ have~ chosen~ the~ tag~ form~ `#1'\MessageBreak
        but~ it~ appears~ to~ be~ undefined}
        {I~ will~ use~ the~ default~ tag~ form~ instead.}%
        \@namedef{tagform@}{\@nameuse{MT_tagform_default:n}}
      }
  { \@namedef{tagform@}{\@nameuse{MT_tagform_#1:n}} }
  \MH_if_boolean:nT {show_only_refs}{
    \MH_let:NwN \MT_prev_tagform:n \tagform@
    \def\tagform@##1{\MT_extended_tagform:n {##1}}
  }
}
\MH_new_boolean:n {manual_tag}
\MH_new_boolean:n {raw_maketag}
\MH_let:NwN \MT_AmS_tag_in_align: \tag@in@align
\def\tag@in@align{
  \global\MH_set_boolean_T:n {manual_tag}
  \MT_AmS_tag_in_align:
}
\def\tag@in@display#1#{
  \relax
  \global\MH_set_boolean_T:n {manual_tag}
  \tag@in@display@a{#1}
}
\def\MT_extended_tagform:n #1{
  \MH_set_boolean_F:n {raw_maketag}
  \MH_if_meaning:NN \df@label\@empty
    \MH_if_boolean:nTF {manual_tag}% this was \MH_if_boolean:nT before
    { \MH_if_boolean:nTF {show_manual_tags}
      { \MT_prev_tagform:n {#1} }
      { \stepcounter{equation}  }
    }{\kern1sp}% this last {\kern1sp} is new.
  \MH_else:
    \MH_if_boolean:nTF {manual_tag}
      { \MH_if_boolean:nTF {show_manual_tags}
          { \MT_prev_tagform:n {#1} }
          { \@safe@activestrue
            \@ifundefined{MT_r_\df@label}
              { \global\MH_set_boolean_F:n {manual_tag} \kern1sp } % kern added 2020
              { \MT_prev_tagform:n {#1} }
              \@safe@activesfalse
          }
      }
      {
        \@safe@activestrue
        \@ifundefined{MT_r_\df@label}
          { \kern1sp }% kern added 2020
          { \refstepcounter{equation}\MT_prev_tagform:n {#1} }
        \@safe@activesfalse
      }
  \MH_fi:
  \global\MH_set_boolean_T:n {raw_maketag}
}
\def\MT_extended_maketag:n #1{
  \ifx\df@label\@empty
    \MT_maketag:n {#1}
  \MH_else:
    \MH_if_boolean:nTF {raw_maketag}
      {
        \MH_if_boolean:nTF {show_manual_tags}
          { \MT_maketag:n {#1} }
          { \@safe@activestrue
            \@ifundefined{MT_r_\df@label}
              { }
              { \MT_maketag:n {#1}     }
            \@safe@activesfalse
          }
      }
      { \MT_maketag:n {#1} }
  \MH_fi:
  \global\MH_set_boolean_F:n {manual_tag}
}
\def\MT_extended_eqref:n #1{
  \protected@write\@auxout{}
    {\string\MT@newlabel{#1}}
  \textup{\let\df@label\@empty\MT_prev_tagform:n {\ref{#1}}}
}
\EQ_MakeRobust\MT_extended_eqref:n
\newcommand*\refeq[1]{
  \textup{\ref{#1}}
}
\def\MT_extended_refeq:n #1{
  \protected@write\@auxout{}
    {\string\MT@newlabel{#1}}
  \textup{\ref{#1}}
}
\newcommand*\MT@newlabel[1]{  \global\@namedef{MT_r_#1}{}  }
\MH_new_boolean:n {show_only_refs}
\MH_new_boolean:n {show_manual_tags}
\define@key{\MT_options_name:}{showmanualtags}[true]{
  \@ifundefined{MH_boolean_show_manual_tags_#1:}
    { \MT_true_false_error:
      \@nameuse{MH_boolean_show_manual_tags_false:}
    }
    { \@nameuse{MH_boolean_show_manual_tags_#1:} }
}
\newcommand*\MT_showonlyrefs_true:{
  \MH_if_boolean:nF {show_only_refs}{
    \MH_set_boolean_T:n {show_only_refs}
    \MH_let:NwN \MT_incr_eqnum: \incr@eqnum
    \MH_let:NwN \incr@eqnum \@empty
    \MH_let:NwN \MT_array_parbox_restore: \@arrayparboxrestore
    \@xp\def\@xp\@arrayparboxrestore\@xp{\@arrayparboxrestore
      \MH_let:NwN \incr@eqnum \@empty
    }
    \MH_let:NwN \MT_prev_tagform:n \tagform@
    \MH_let:NwN \MT_eqref:n \eqref
    \MH_let:NwN \MT_refeq:n \refeq
    \MH_let:NwN \MT_maketag:n \maketag@@@
    \MH_let:NwN \maketag@@@ \MT_extended_maketag:n
    \def\tagform@##1{\MT_extended_tagform:n {##1}}
    \MH_let:NwN \eqref \MT_extended_eqref:n
    \MH_let:NwN \refeq \MT_extended_refeq:n
  }
}
\def\MT_showonlyrefs_false: {
  \MH_if_boolean:nT {show_only_refs}{
    \MH_set_boolean_F:n {show_only_refs}
    \MH_let:NwN \tagform@  \MT_prev_tagform:n
    \MH_let:NwN \eqref \MT_eqref:n
    \MH_let:NwN \refeq \MT_refeq:n
    \MH_let:NwN \maketag@@@ \MT_maketag:n
    \MH_let:NwN \incr@eqnum \MT_incr_eqnum:
    \MH_let:NwN \@arrayparboxrestore \MT_array_parbox_restore:
  }
}
\define@key{\MT_options_name:}{showonlyrefs}[true]{
  \@nameuse{MT_showonlyrefs_#1:}
}
\renewcommand\nonumber{
  \if@eqnsw
    \MH_if_meaning:NN \incr@eqnum\@empty
      \MH_if_boolean:nF {show_only_refs}
        {\addtocounter{equation}\m@ne}
    \MH_fi:
  \MH_fi:
  \MH_let:NwN \print@eqnum\@empty \MH_let:NwN \incr@eqnum\@empty
  \global\@eqnswfalse
}
\MHInternalSyntaxOff
\newcommand\noeqref[1]{\@bsphack%
  \@for\@tempa:=#1\do{%
    \@safe@activestrue%
    \edef\@tempa{\expandafter\@firstofone\@tempa}%
    \@ifundefined{r@\@tempa}{%
      \protect\G@refundefinedtrue%
      \@latex@warning{Reference `\@tempa' on page \thepage \space
        undefined (\string\noeqref)}%
    }{}%
    \if@filesw\protected@write\@auxout{}%
    {\string\MT@newlabel{\@tempa}}\fi%
  \@safe@activesfalse}%
  \@esphack}

\providecommand\@safe@activestrue{}%
\providecommand\@safe@activesfalse{}%

\MHInternalSyntaxOn
\providecommand*\xleftrightarrow[2][]{%
  \ext@arrow 3095\MT_leftrightarrow_fill:{#1}{#2}}
\def\MT_leftrightarrow_fill:{%
  \arrowfill@\leftarrow\relbar\rightarrow}
\providecommand*\xLeftarrow[2][]{%
  \ext@arrow 0055{\Leftarrowfill@}{\ #1}{\ #2}}
\providecommand*\xRightarrow[2][]{%
  \ext@arrow 0055{\Rightarrowfill@}{#1\ }{#2\ }}
\providecommand*\xLeftrightarrow[2][]{%
  \ext@arrow 0055{\Leftrightarrowfill@}{\ #1\ }{\ #2\ }}
\def\MT_rightharpoondown_fill:{%
  \arrowfill@\relbar\relbar\rightharpoondown}
\def\MT_rightharpoonup_fill:{%
  \arrowfill@\relbar\relbar\rightharpoonup}
\def\MT_leftharpoondown_fill:{%
  \arrowfill@\leftharpoondown\relbar\relbar}
\def\MT_leftharpoonup_fill:{%
  \arrowfill@\leftharpoonup\relbar\relbar}
\def\MT_longrightarrow_fill:{%
  \arrowfill@\relbar\relbar\longrightarrow}
\def\MT_longleftarrow_fill:{%
  \arrowfill@\longleftarrow\relbar\relbar}
\providecommand*\xrightharpoondown[2][]{%
  \ext@arrow 0359\MT_rightharpoondown_fill:{#1}{#2}}
\providecommand*\xrightharpoonup[2][]{%
  \ext@arrow 0359\MT_rightharpoonup_fill:{#1}{#2}}
\providecommand*\xleftharpoondown[2][]{%
  \ext@arrow 3095\MT_leftharpoondown_fill:{#1}{#2}}
\providecommand*\xleftharpoonup[2][]{%
  \ext@arrow 3095\MT_leftharpoonup_fill:{#1}{#2}}
\providecommand*\xleftrightharpoons[2][]{\mathrel{%
  \raise.22ex\hbox{%
    $\ext@arrow 3095\MT_leftharpoonup_fill:{\phantom{#1}}{#2}$}%
  \setbox0=\hbox{%
    $\ext@arrow 0359\MT_rightharpoondown_fill:{#1}{\phantom{#2}}$}%
  \kern-\wd0 \lower.22ex\box0}}
\providecommand*\xrightleftharpoons[2][]{\mathrel{%
  \raise.22ex\hbox{%
    $\ext@arrow 0359\MT_rightharpoonup_fill:{\phantom{#1}}{#2}$}%
  \setbox0=\hbox{%
    $\ext@arrow 3095\MT_leftharpoondown_fill:{#1}{\phantom{#2}}$}%
  \kern-\wd0 \lower.22ex\box0}}
\providecommand*\xlongrightarrow[2][]{%
  \ext@arrow 0359\MT_longrightarrow_fill:{#1}{#2}}
\providecommand*\xlongleftarrow[2][]{%
  \ext@arrow 3095\MT_longleftarrow_fill:{#1}{#2}}
\providecommand*\xhookleftarrow[2][]{%
  \ext@arrow 3095\MT_hookleft_fill:{#1}{#2}}
\def\MT_hookleft_fill:{%
  \arrowfill@\leftarrow\relbar{\relbar\joinrel\rhook}}
\providecommand*\xhookrightarrow[2][]{%
  \ext@arrow 3095\MT_hookright_fill:{#1}{#2}}
\def\MT_hookright_fill:{%
  \arrowfill@{\lhook\joinrel\relbar}\relbar\rightarrow}
\providecommand*\xmapsto[2][]{%
  \ext@arrow 0395\MT_mapsto_fill:{#1}{#2}}
\def\MT_mapsto_fill:{%
  \arrowfill@{\mapstochar\relbar}\relbar\rightarrow}
\providecommand*\underbracket{
  \@ifnextchar[
    {\MT_underbracket_I:w}
    {\MT_underbracket_I:w[\l_MT_bracketheight_fdim]}}
\def\MT_underbracket_I:w[#1]{
  \@ifnextchar[
    {\MT_underbracket_II:w[#1]}
    {\MT_underbracket_II:w[#1][.7\fontdimen5\textfont2]}}
\def\MT_underbracket_II:w[#1][#2]#3{%
  \mathop{\vtop{\m@th\ialign{##
    \crcr
      $\hfil\displaystyle{#3}\hfil$%
    \crcr
      \noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}%
      \upbracketfill {#1}{#2}%
    \crcr}}}
  \limits}
\def\upbracketfill#1#2{%
  \sbox\z@{$\braceld$}
  \edef\l_MT_bracketheight_fdim{\the\ht\z@}%
  \upbracketend{#1}{#2}
  \leaders \vrule \@height \z@ \@depth #1 \hfill
  \upbracketend{#1}{#2}%
}
\def\upbracketend#1#2{\vrule \@height #2 \@width #1\relax}
\providecommand*\overbracket{
  \@ifnextchar[
    {\MT_overbracket_I:w}
    {\MT_overbracket_I:w[\l_MT_bracketheight_fdim]}}
\def\MT_overbracket_I:w[#1]{
  \@ifnextchar[
    {\MT_overbracket_II:w[#1]}
    {\MT_overbracket_II:w[#1][.7\fontdimen5\textfont2]}}
\def\MT_overbracket_II:w[#1][#2]#3{%
  \mathop{\vbox{\m@th\ialign{##
        \crcr
          \downbracketfill{#1}{#2}%
        \crcr
          \noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}%
          $\hfil\displaystyle{#3}\hfil$
        \crcr}}}%
  \limits}
\def\downbracketfill#1#2{%
  \sbox\z@{$\braceld$}\edef\l_MT_bracketheight_fdim{\the\ht\z@}
  \downbracketend{#1}{#2}
  \leaders \vrule \@height #1 \@depth \z@ \hfill
  \downbracketend{#1}{#2}%
}
\def\downbracketend#1#2{\vrule \@width #1\@depth #2\relax}
\MH_let:NwN \LaTeXunderbrace \underbrace
\def\underbrace#1{\mathop{\vtop{\m@th\ialign{##\crcr
   $\hfil\displaystyle{#1}\hfil$\crcr
   \noalign{\kern.7\fontdimen5\textfont2\nointerlineskip}%
   \upbracefill\crcr\noalign{\kern.5\fontdimen5\textfont2}}}}\limits}
\MH_let:NwN \LaTeXoverbrace \overbrace
\def\overbrace#1{\mathop{\vbox{\m@th\ialign{##\crcr
  \noalign{\kern.5\fontdimen5\textfont2}%
  \downbracefill\crcr
  \noalign{\kern.7\fontdimen5\textfont2\nointerlineskip}%
  $\hfil\displaystyle{#1}\hfil$\crcr}}}\limits}
\providecommand*\lparen{(}
\providecommand*\rparen{)}

\def\vcentcolon{\mathrel{\mathop\ordinarycolon}}
\providecommand\ordinarycolon{:}
\begingroup
  \catcode`\:=\active
  \lowercase{\endgroup
\def\MT_activate_colon{%
    \ifnum\mathcode`\:=32768\relax
      \let\ordinarycolon= :%
    \else
      \mathchardef\ordinarycolon\mathcode`\: %
    \fi
    \let :\vcentcolon
  }
}
\MH_new_boolean:n {center_colon}
\define@key{\MT_options_name:}{centercolon}[true]{
  \@ifundefined{MT_active_colon_#1:}
    { \MT_true_false_error:n
      \@nameuse{MT_active_colon_false:}
    }
    { \@nameuse{MT_active_colon_#1:} }
}
\def\MT_active_colon_true: {
  \MT_activate_colon
  \MH_if_boolean:nF {center_colon}{
    \MH_set_boolean_T:n {center_colon}
    \edef\MT_active_colon_false:
      {\mathcode`\noexpand\:=\the\mathcode`\:\relax}
    \mathcode`\:=32768
  }
}
\AtBeginDocument{
  \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon}
  \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=}
  \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=}
  \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon}
  \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon}
  \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon}
  \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon}
  \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx}
  \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx}
  \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim}
  \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim}
}
\let \AMS@math@cr@@ \math@cr@@
\MH_new_boolean:n {mult_firstline}
\MH_new_boolean:n {outer_mult}
\newcount\g_MT_multlinerow_int
\newdimen\l_MT_multwidth_dim
\newcommand*\MT_test_for_tcb_other:nnnnn [1]{
  \MH_if:w t#1\relax
    \expandafter\MH_use_choice_i:nnnn
  \MH_else:
    \MH_if:w c#1\relax
      \expandafter\expandafter\expandafter\MH_use_choice_ii:nnnn
    \MH_else:
      \MH_if:w b#1\relax
        \expandafter\expandafter\expandafter
        \expandafter\expandafter\expandafter\expandafter
        \MH_use_choice_iii:nnnn
      \MH_else:
        \expandafter\expandafter\expandafter
        \expandafter\expandafter\expandafter\expandafter
        \MH_use_choice_iv:nnnn
      \MH_fi:
    \MH_fi:
  \MH_fi:
}
\def\MT_mult_invisible_line: {
  \crcr
  \global\MH_set_boolean_F:n {mult_firstline}
  \hbox to \l_MT_multwidth_dim{}\crcr
  \noalign{\vskip-\baselineskip \vskip-\normallineskip}
}
\def\MT_mult_mathcr_atat:w [#1]{%
  \MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi:
  \MH_if_boolean:nT {mult_firstline}{
    \kern\l_MT_mult_left_fdim
    \MT_mult_invisible_line:
  }
  \crcr
  \noalign{\vskip#1\relax}
  \global\advance\g_MT_multlinerow_int\@ne
  \MH_if_num:w \g_MT_multlinerow_int=\l_MT_multline_lastline_fint
    \MH_let:NwN \math@cr@@\MT_mult_last_mathcr:w
  \MH_fi:
}
\def\MT_mult_firstandlast_mathcr:w [#1]{%
  \MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi:
  \kern\l_MT_mult_left_fdim
  \MT_mult_invisible_line:
  \noalign{\vskip#1\relax}
  \kern\l_MT_mult_right_fdim
}
\def\MT_mult_last_mathcr:w [#1]{
  \MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi:\math@cr@@@
  \noalign{\vskip#1\relax}
  \kern\l_MT_mult_right_fdim}
\newcommand\MT_start_mult:N [1]{
  \MT_test_for_tcb_other:nnnnn {#1}
    { \MH_let:NwN \MT_next:\vtop }
    { \MH_let:NwN \MT_next:\vcenter }
    { \MH_let:NwN \MT_next:\vbox }
    {
      \PackageError{mathtools}
        {Invalid~ position~ specifier.~ I'll~ try~ to~ recover~ with~
        `c'}\@ehc
    }
  \collect@body\MT_mult_internal:n
}
\newcommand*\MT_shoveright:wn [2][0pt]{%
  #2\hfilneg
  \setlength\@tempdima{#1}
  \kern\@tempdima
}
\newcommand*\MT_shoveleft:wn [2][0pt]{%
  \hfilneg
  \setlength\@tempdima{#1}
  \kern\@tempdima
  #2
}
\newcommand*\MT_mult_internal:n [1]{
 \MH_if_boolean:nF {outer_mult}{\alignedspace@left} %<-- requires amsmath 2016/11/05
  \MT_next:
  \bgroup
    \Let@
    \def\l_MT_multline_lastline_fint{0 }
    \chardef\dspbrk@context\@ne \restore@math@cr
    \MH_let:NwN \math@cr@@\MT_mult_mathcr_atat:w
    \MH_let:NwN \shoveleft\MT_shoveleft:wn
    \MH_let:NwN \shoveright\MT_shoveright:wn
    \spread@equation
    \MH_set_boolean_F:n {mult_firstline}
    \MT_measure_mult:n {#1}
    \MH_if_dim:w \l_MT_multwidth_dim<\l_MT_multline_measure_fdim
      \MH_setlength:dn \l_MT_multwidth_dim{\l_MT_multline_measure_fdim}
    \fi
    \MH_set_boolean_T:n {mult_firstline}
    \MH_if_num:w \l_MT_multline_lastline_fint=\@ne
      \MH_let:NwN \math@cr@@ \MT_mult_firstandlast_mathcr:w
    \MH_fi:
    \ialign\bgroup
      \hfil\strut@$\m@th\displaystyle{}##$\hfil
      \crcr
      \hfilneg
      #1
}
\newcommand\MT_measure_mult:n [1]{
  \begingroup
    \measuring@true
    \g_MT_multlinerow_int\@ne
    \MH_let:NwN \label\MT_gobblelabel:w
    \MH_let:NwN \tag\gobble@tag
    \setbox\z@\vbox{
      \ialign{\strut@$\m@th\displaystyle{}##$
        \crcr
        #1
        \crcr
      }
    }
    \xdef\l_MT_multline_measure_fdim{\the\wdz@}
    \advance\g_MT_multlinerow_int\m@ne
    \xdef\l_MT_multline_lastline_fint{\number\g_MT_multlinerow_int}
  \endgroup
  \g_MT_multlinerow_int\@ne
}
\MaybeMHPrecedingSpacesOff
\newcommand*\MT_multlined_second_arg:w [1][\@empty]{
  \MT_test_for_tcb_other:nnnnn {#1}
    {\def\MT_mult_default_pos:{#1}}
    {\def\MT_mult_default_pos:{#1}}
    {\def\MT_mult_default_pos:{#1}}
    {
      \MH_if_meaning:NN \@empty#1\@empty
      \MH_else:
        \setlength \l_MT_multwidth_dim{#1}
      \MH_fi:
    }
  \MT_start_mult:N \MT_mult_default_pos:
}
\ifx\directlua\@undefined
  % THIS IS NORMAL
  \newcommand\MultlinedHook{
    \renewenvironment{subarray}[1]{%
      \vcenter\bgroup
      \Let@ \restore@math@cr \default@tag
      \let\math@cr@@\AMS@math@cr@@  % <--- the fix
      \baselineskip\fontdimen10 \scriptfont\tw@
      \advance\baselineskip\fontdimen12 \scriptfont\tw@
      \lineskip\thr@@\fontdimen8 \scriptfont\thr@@
      \lineskiplimit\lineskip
      \ialign\bgroup\ifx c##1\hfil\fi
      $\m@th\scriptstyle####$\hfil\crcr
    }{%
      \crcr\egroup\egroup
    }
    \renewenvironment{crampedsubarray}[1]{%
      \vcenter\bgroup
      \Let@ \restore@math@cr \default@tag
      \let\math@cr@@\AMS@math@cr@@  % <--- the fix
      \baselineskip\fontdimen10 \scriptfont\tw@
      \advance\baselineskip\fontdimen12 \scriptfont\tw@
      \lineskip\thr@@\fontdimen8 \scriptfont\thr@@
      \lineskiplimit\lineskip
      \ialign\bgroup\ifx c##1\hfil\fi
      \span\MT_cramped_internal:Nn \scriptstyle {####}%
      \hfil\crcr
    }{%
      \crcr\egroup\egroup
    }
    % from mathtools
    \def\MT_smallmatrix_begin:N ##1{%
      \Let@\restore@math@cr\default@tag
      \let\math@cr@@\AMS@math@cr@@  % <--- the fix
      \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
      \csname MT_smallmatrix_##1_begin:\endcsname
    }
    % from amsmath
    \renewenvironment{smallmatrix}{\null\,\vcenter\bgroup
      \Let@\restore@math@cr\default@tag
      \let\math@cr@@\AMS@math@cr@@  % <--- the fix
      \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
      \ialign\bgroup\hfil$\m@th\scriptstyle####$\hfil&&\thickspace\hfil
      $\m@th\scriptstyle####$\hfil\crcr
    }{%
      \crcr\egroup\egroup\,%
    }
  }
\else
  % THIS IS LUALATEX
  \newcommand\MultlinedHook{
    % from amsmath
    \renewenvironment{subarray}[1]{%
      \vcenter\bgroup
      \Let@ \restore@math@cr \default@tag
      \let\math@cr@@\AMS@math@cr@@  % <--- the fix
      \baselineskip \Umathstacknumup \scriptstyle
      \advance\baselineskip \Umathstackdenomdown \scriptstyle
      \lineskip \Umathstackvgap \scriptstyle
      \lineskiplimit \lineskip
      \ialign\bgroup\ifx c##1\hfil\fi
      \Ustartmath
      \m@th\scriptstyle####
      \Ustopmath
      \hfil\crcr
    }{%
      \crcr\egroup\egroup
    }
    % from mathtools
    \renewenvironment{crampedsubarray}[1]{%
      \vcenter\bgroup
      \Let@ \restore@math@cr \default@tag
      \let\math@cr@@\AMS@math@cr@@  % <--- the fix
      \baselineskip \Umathstacknumup \scriptstyle
      \advance\baselineskip \Umathstackdenomdown \scriptstyle
      \lineskip \Umathstackvgap \scriptstyle
      \lineskiplimit \lineskip
      \ialign\bgroup\ifx c##1\hfil\fi
      \Ustartmath
        \crampedscriptstyle{####}
      \Ustopmath
      \hfil\crcr
    }{%
      \crcr\egroup\egroup
    }
    % from mathtools
    \def\MT_smallmatrix_begin:N ##1{%
      \Let@\restore@math@cr\default@tag
      \let\math@cr@@\AMS@math@cr@@  % <--- the fix
      \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
      \csname MT_smallmatrix_##1_begin:\endcsname
    }
    % from amsmath
    \renewenvironment{smallmatrix}{\null\,\vcenter\bgroup
      \Let@\restore@math@cr\default@tag
      \let\math@cr@@\AMS@math@cr@@  % <--- the fix
      \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
      \ialign\bgroup\hfil$\m@th\scriptstyle####$\hfil&&\thickspace\hfil
      $\m@th\scriptstyle####$\hfil\crcr
    }{%
      \crcr\egroup\egroup\,%
    }
  }
\fi

\newenvironment{multlined}[1][]
  {\MH_group_align_safe_begin:
    \MultlinedHook
  \MT_test_for_tcb_other:nnnnn {#1}
    {\def\MT_mult_default_pos:{#1}}
    {\def\MT_mult_default_pos:{#1}}
    {\def\MT_mult_default_pos:{#1}}
    {
      \MH_if_meaning:NN \@empty#1\@empty
      \MH_else:
        \setlength \l_MT_multwidth_dim{#1}
      \MH_fi:
    }
    \MT_multlined_second_arg:w
  }
  {
    \hfilneg  \endaligned \MH_group_align_safe_end:
  }
\MHPrecedingSpacesOn
\define@key{\MT_options_name:}
  {firstline-afterskip}{\def\l_MT_mult_left_fdim{#1}}
\define@key{\MT_options_name:}
  {lastline-preskip}{\def\l_MT_mult_right_fdim{#1}}
\define@key{\MT_options_name:}
  {multlined-width}{\setlength \l_MT_multwidth_dim{#1}}
\define@key{\MT_options_name:}
  {multlined-pos}{\def\MT_mult_default_pos:{#1}}
\setkeys{\MT_options_name:}{
  firstline-afterskip=\multlinegap,
  lastline-preskip=\multlinegap,
  multlined-width=0pt,
  multlined-pos=c,
}
\def\MT_gobblelabel:w #1{}
\newcommand\MT_delim_default_inner_wrappers:n [1]{
   \@namedef{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}##1##2##3{
      \mathopen{}\mathclose\bgroup ##1 ##2 \aftergroup\egroup ##3
    }
    \@namedef{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}##1##2##3{
      \mathopen{##1}##2\mathclose{##3}
    }
    \@namedef{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}##1##2##3{
      \mathopen##1##2\mathclose##3
    }
  }

\newcommand\reDeclarePairedDelimiterInnerWrapper[3]{
  \@ifundefined{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}{
    \PackageError{mathtools}{
      Wrapper~not~found~for~\string#1~and~option~'#2'.\MessageBreak
      Either~\string#1~is~ not~ defined,~or~ you~ are~using~ the~
      \MessageBreak
      'nostar'~ option,~which~ is~ no~ longer~ supported.~
      \MessageBreak
      Please~ use~ 'nostarnonscaled'~ or~ 'nostarscaled~
      \MessageBreak instead.~
    }{See the manual}
  }{
    \@namedef{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}##1##2##3{
      #3
    }
  }
}

\def\MT_etb_ifdefempty_x:nnn #1{
  \expandafter\expandafter\expandafter
  \MT_etb_ifblank:nnn
  \expandafter\expandafter\expandafter{%
    \expandafter\strip@prefix\meaning#1}
}
\def\MT_etb_ifblank:nnn #1{
  \expandafter\ifx\expandafter\relax\detokenize\expandafter{\@gobble#1?}\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}

\newcommand*\DeclarePairedDelimiter[3]{%
  \@ifdefinable{#1}{
    \MT_delim_default_inner_wrappers:n{#1} % define the wrappers
    \@namedef{MT_delim_\MH_cs_to_str:N #1 _star:}##1
      { \@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}%
           {\left#2}{##1}{\right#3} }%
    \@xp\@xp\@xp
      \newcommand
        \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname
        [2][\\@gobble]
        {
          \def\@tempa{\\@gobble}
          \def\@tempb{##1}
          \ifx\@tempa\@tempb
            \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}%
               {#2}
               {##2}
               {#3}
          \else
            \MT_etb_ifblank:nnn {##1}{
              \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}%
                {#2}
                {##2}
                {#3}
            }{
              \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}%
                {\@nameuse {\MH_cs_to_str:N ##1 l} #2}
                {##2}
                {\@nameuse {\MH_cs_to_str:N ##1 r} #3}
            }
          \fi
        }
    \DeclareRobustCommand{#1}{
      \@ifstar
        {\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star:}}
        {\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar:}}
    }
  }
}
\def\MT_paired_delimx_arg_test:n #1{
  \ifnum#1>9\relax
    \PackageError{mathtools}{No~ more~ than~ 9~ arguments}{}
  \else
    \ifnum#1<1\relax
      \PackageError{mathtools}{Macro~ need~ 1~ or~ more~
        arguments.\MessageBreak Please~ change~ [#1]~ to~ [1]~ ... [9]}{}
    \fi
  \fi
 }

\def\@MHempty{}
\newcommand\MT_delim_inner_generator:nnnnnnn [7]{
    \@xp\@xp\@xp
      \newcommand
        \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar_inner:\endcsname
        [#2]
        {
          #3
          \def\@tempa{\@MHempty}
          \@xp\def\@xp\@tempb\@xp{\delimsize}
          \ifx\@tempa\@tempb
            \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}
              {#4}{#7}{#5}
          \else
            \MT_etb_ifdefempty_x:nnn {\delimsize}{
              \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}
                {#4}{#7}{#5}
            }{
              \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}
              {
                \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize l\endcsname #4
              }
              {#7}
              {
                \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize r\endcsname #5
              }
            }
          \fi
          #6
          \endgroup
        }
}

\def\DeclarePairedDelimiterXPP#1[#2]#3#4#5#6#7{%
  \@ifdefinable{#1}{
    \MT_paired_delimx_arg_test:n{#2}
    \MT_delim_default_inner_wrappers:n{#1}
    \@xp\@xp\@xp
      \newcommand
        \@xp\csname MT_delim_\MH_cs_to_str:N #1 _star:\endcsname
        [#2]
        {
          \begingroup
            \def\delimsize{\middle}
            #3
            \@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}
              {\left#4}{#7}{\right#5}
            #6
          \endgroup
        }
    \@xp\@xp\@xp
      \newcommand
        \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname
        [1][\@MHempty]
      {
        \begingroup
        \def\delimsize{##1}
        \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_inner:}
      }
      \MT_delim_inner_generator:nnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7}
    \DeclareRobustCommand{#1}{
      \@ifstar
        {\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star:}}
        {\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar:}}
    }
  }
}

\def\DeclarePairedDelimiterX#1[#2]#3#4#5{
  \DeclarePairedDelimiterXPP{#1}[#2]{}{#3}{#4}{}{#5}
}

\def\MT_start_cases:nnnn #1#2#3#4{ % #1=sep,#2=lpreamble,#3=rpreamble,#4=delim
 \RIfM@\else
   \nonmatherr@{\begin{\@currenvir}}
 \fi
 \MH_group_align_safe_begin:
 \left#4
 \vcenter \bgroup
     \Let@ \chardef\dspbrk@context\@ne \restore@math@cr
     \let  \math@cr@@\AMS@math@cr@@
     \spread@equation
     \ialign\bgroup
       \strut@#2 &#1\strut@
       #3
       \crcr
}
\def\MH_end_cases:{\crcr\egroup
 \restorecolumn@
 \egroup
 \MH_group_align_safe_end:
}
\newcommand*\newcases[6]{% #1=name, #2=sep, #3=preamble, #4=left, #5=right
 \newenvironment{#1}
   {\MT_start_cases:nnnn {#2}{#3}{#4}{#5}}
   {\MH_end_cases:\right#6}
}
\newcommand*\renewcases[6]{
 \renewenvironment{#1}
   {\MT_start_cases:nnnn {#2}{#3}{#4}{#5}}
   {\MH_end_cases:\right#6}
}
\newcases{dcases}{\quad}{%
  $\m@th\displaystyle##$\hfil}{$\m@th\displaystyle##$\hfil}{\lbrace}{.}
\newcases{dcases*}{\quad}{%
  $\m@th\displaystyle##$\hfil}{##\hfil}{\lbrace}{.}
\newcases{rcases}{\quad}{%
  $\m@th##$\hfil}{$\m@th##$\hfil}{.}{\rbrace}
\newcases{rcases*}{\quad}{%
  $\m@th##$\hfil}{##\hfil}{.}{\rbrace}
\newcases{drcases}{\quad}{%
  $\m@th\displaystyle##$\hfil}{$\m@th\displaystyle##$\hfil}{.}{\rbrace}
\newcases{drcases*}{\quad}{%
  $\m@th\displaystyle##$\hfil}{##\hfil}{.}{\rbrace}
\newcases{cases*}{\quad}{%
  $\m@th##$\hfil}{##\hfil}{\lbrace}{.}
\def\MT_matrix_begin:N #1{%
  \hskip -\arraycolsep
  \MH_let:NwN \@ifnextchar \MH_nospace_ifnextchar:Nnn
  \array{*\c@MaxMatrixCols #1}}
\def\MT_matrix_end:{\endarray \hskip -\arraycolsep}
\MaybeMHPrecedingSpacesOff
\newenvironment{matrix*}[1][c]
  {\MT_matrix_begin:N #1}
  {\MT_matrix_end:}
\newenvironment{pmatrix*}[1][c]
  {\left(\MT_matrix_begin:N #1}
  {\MT_matrix_end:\right)}
\newenvironment{bmatrix*}[1][c]
  {\left[\MT_matrix_begin:N #1}
  {\MT_matrix_end:\right]}
\newenvironment{Bmatrix*}[1][c]
  {\left\lbrace\MT_matrix_begin:N #1}
  {\MT_matrix_end:\right\rbrace}
\newenvironment{vmatrix*}[1][c]
  {\left\lvert\MT_matrix_begin:N #1}
  {\MT_matrix_end:\right\rvert}
\newenvironment{Vmatrix*}[1][c]
  {\left\lVert\MT_matrix_begin:N #1}
  {\MT_matrix_end:\right\lVert}
\def\MT_smallmatrix_begin:N #1{%
  \Let@\restore@math@cr\default@tag
  \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
  \csname MT_smallmatrix_#1_begin:\endcsname
}
\def\MT_smallmatrix_end:{\crcr\egroup\egroup\MT_smallmatrix_inner_space:}
\def\MT_smallmatrix_l_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup
  \ialign\bgroup$\m@th\scriptstyle##$\hfil&&\thickspace
  $\m@th\scriptstyle##$\hfil\crcr
}
\def\MT_smallmatrix_c_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup
  \ialign\bgroup\hfil$\m@th\scriptstyle##$\hfil&&\thickspace\hfil
  $\m@th\scriptstyle##$\hfil\crcr
}
\def\MT_smallmatrix_r_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup
  \ialign\bgroup\hfil$\m@th\scriptstyle##$&&\thickspace\hfil
  $\m@th\scriptstyle##$\crcr
}
\newenvironment{smallmatrix*}[1][\MT_smallmatrix_default_align:]
  {\MT_smallmatrix_begin:N #1}
  {\MT_smallmatrix_end:}
\def\MT_fenced_sm_generator:nnn #1#2#3{%
  \@ifundefined{#1}{%
    \newenvironment{#1}
    {\@nameuse{#1hook}\mathopen{}\mathclose\bgroup\left#2\MT_smallmatrix_begin:N c}%
      {\MT_smallmatrix_end:\aftergroup\egroup\right#3}%
  }{}%
  \@ifundefined{#1*}{%
    \newenvironment{#1*}[1][\MT_smallmatrix_default_align:]%
    {\@nameuse{#1hook}\mathopen{}\mathclose\bgroup\left#2\MT_smallmatrix_begin:N ##1}%
      {\MT_smallmatrix_end:\aftergroup\egroup\right#3}%
  }{}%
}
\MT_fenced_sm_generator:nnn{psmallmatrix}()
\MT_fenced_sm_generator:nnn{bsmallmatrix}[]
\MT_fenced_sm_generator:nnn{Bsmallmatrix}\lbrace\rbrace
\MT_fenced_sm_generator:nnn{vsmallmatrix}\lvert\rvert
\MT_fenced_sm_generator:nnn{Vsmallmatrix}\lVert\rVert
\define@key{\MT_options_name:}
  {smallmatrix-align}{\def\MT_smallmatrix_default_align:{#1}}
\define@key{\MT_options_name:}
  {smallmatrix-inner-space}{\def\MT_smallmatrix_inner_space:{#1}}
\setkeys{\MT_options_name:}{
  smallmatrix-align=c,
  smallmatrix-inner-space=\,
}

\MHPrecedingSpacesOn
\newcommand*\smashoperator[2][lr]{
  \@ifundefined{MT_smop_smash_#1:NNNNN}{
    \PackageError{mathtools}{Opt~ arg~ '#1'~ for~ \@backslashchar smashoperator~
      is~ not~ supported.\MessageBreak Use~ l,~r~or~lr~ (default)}{}
  }{
    \def\MT_smop_use:NNNNN {\@nameuse{MT_smop_smash_#1:NNNNN}}
    \toks@{#2}
    \expandafter\MT_smop_get_args:wwwNnNn
    \the\toks@\@nil\@nil\@nil\@nil\@nil\@nil\@@nil
  }
}
\def\MT_smop_remove_nil_vi:N #1\@nil\@nil\@nil\@nil\@nil\@nil{#1}
\def\MT_smop_mathop:n {\mathop}
\def\MT_smop_limits: {\limits}
\MH_new_boolean:n {smop_one}
\MH_new_boolean:n {smop_two}
\def\MT_smop_get_args:wwwNnNn #1#2#3#4#5#6#7\@@nil{%
  \begingroup
    \def\MT_smop_arg_A: {#1} \def\MT_smop_arg_B: {#2}
    \def\MT_smop_arg_C: {#3} \def\MT_smop_arg_D: {#4}
    \def\MT_smop_arg_E: {#5} \def\MT_smop_arg_F: {#6}
    \def\MT_smop_arg_G: {#7}
    \MH_if_meaning:NN \MT_smop_arg_A: \MT_smop_mathop:n
      \MH_if_meaning:NN \MT_smop_arg_C:\MT_smop_limits:
        \def\MT_smop_final_arg_A:{#1{#2}}%
        \MH_if_meaning:NN \MT_smop_arg_D: \@nnil
        \MH_else:
          \MH_set_boolean_T:n {smop_one}
          \MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_D:
          \MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_E:
          \MH_if_meaning:NN \MT_smop_arg_F: \@nnil
          \MH_else:
            \MH_set_boolean_T:n {smop_two}
            \MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_F:
            \edef\MT_smop_final_arg_E:
              {\expandafter\MT_smop_remove_nil_vi:N \MT_smop_arg_G: }
          \MH_fi:
        \MH_fi:
      \MH_else:
        \def\MT_smop_final_arg_A:{#1{#2}}%
        \MH_if_meaning:NN \MT_smop_arg_D: \@nnil
        \MH_else:
          \MH_set_boolean_T:n {smop_one}
          \MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_C:
          \MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_D:
          \MH_if_meaning:NN \MT_smop_arg_F: \@nnil
          \MH_else:
            \MH_set_boolean_T:n {smop_two}
            \MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_E:
            \MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_F:
          \MH_fi:
        \MH_fi:
      \MH_fi:
    \MH_else:
      \MH_if_meaning:NN \MT_smop_arg_B:\MT_smop_limits:
        \def\MT_smop_final_arg_A:{#1}%
        \MH_if_meaning:NN \MT_smop_arg_D: \@nnil
        \MH_else:
          \MH_set_boolean_T:n {smop_one}
          \MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_C:
          \MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_D:
          \MH_if_meaning:NN \MT_smop_arg_F: \@nnil
          \MH_else:
            \MH_set_boolean_T:n {smop_two}
            \MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_E:
            \MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_F:
          \MH_fi:
        \MH_fi:
      \MH_else:
        \def\MT_smop_final_arg_A:{#1}%
        \MH_if_meaning:NN \MT_smop_arg_C: \@nnil
        \MH_else:
          \MH_set_boolean_T:n {smop_one}
          \MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_B:
          \MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_C:
          \MH_if_meaning:NN \MT_smop_arg_D: \@nnil
          \MH_else:
            \MH_set_boolean_T:n {smop_two}
            \MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_D:
            \MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_E:
          \MH_fi:
        \MH_fi:
      \MH_fi:
    \MH_fi:
    \MH_if_boolean:nT {smop_one}{
      \MT_smop_measure:NNNNN
      \MT_smop_final_arg_A: \MT_smop_final_arg_B: \MT_smop_final_arg_C:
      \MT_smop_final_arg_D: \MT_smop_final_arg_E:
    }
    \MT_smop_use:NNNNN
      \MT_smop_final_arg_A: \MT_smop_final_arg_B: \MT_smop_final_arg_C:
      \MT_smop_final_arg_D: \MT_smop_final_arg_E:
  \endgroup
}
\def\MT_smop_needed_args:NNNNN #1#2#3#4#5{%
  \displaystyle #1
  \MH_if_boolean:nT {smop_one}{
    \limits#2{\MT_cramped_clap_internal:Nn \scriptstyle{#3}}
    \MH_if_boolean:nT {smop_two}{
      #4{\MT_cramped_clap_internal:Nn \scriptstyle{#5}}
    }
  }
}
\def\MT_smop_measure:NNNNN #1#2#3#4#5{%
  \MH_let:NwN \MT_saved_mathclap:Nn \MT_cramped_clap_internal:Nn
  \MH_let:NwN \MT_cramped_clap_internal:Nn \@secondoftwo
  \sbox\z@{$\m@th\MT_smop_needed_args:NNNNN #1#2#3#4#5$}
  \MH_let:NwN \MT_cramped_clap_internal:Nn \MT_saved_mathclap:Nn
  \sbox\tw@{$\m@th\displaystyle#1$}
  \@tempdima=.5\wd0
  \advance\@tempdima-.5\wd2
}
\def\MT_smop_smash_l:NNNNN #1#2#3#4#5{
  \MT_smop_needed_args:NNNNN #1#2#3#4#5\kern\@tempdima
}
\def\MT_smop_smash_r:NNNNN #1#2#3#4#5{
  \kern\@tempdima\MT_smop_needed_args:NNNNN #1#2#3#4#5
}
\def\MT_smop_smash_lr:NNNNN #1#2#3#4#5{
  \MT_smop_needed_args:NNNNN #1#2#3#4#5
}
\MH_let:NwN \MT_smop_smash_rl:NNNNN \MT_smop_smash_lr:NNNNN
\def\MT_vphantom:Nn {\v@true\h@false\MT_internal_phantom:N}
\def\MT_hphantom:Nn {\v@false\h@true\MT_internal_phantom:N}
\def\MT_phantom:Nn {\v@true\h@true\MT_internal_phantom:N}
\def\MT_internal_phantom:N #1{
  \ifmmode
    \expandafter\mathph@nt\expandafter#1
  \else
    \expandafter\makeph@nt
  \fi
}
\newcommand*\adjustlimits[6]{
  \sbox\z@{$\m@th \displaystyle #1$}
  \sbox\tw@{$\m@th \displaystyle #4$}
  \@tempdima=\dp\z@ \advance\@tempdima-\dp\tw@
  \MH_if_dim:w \@tempdima>\z@
    \mathop{#1}\limits#2{#3}
  \MH_else:
    \mathop{#1\MT_vphantom:Nn \displaystyle{#4}}\limits
    #2{
        \def\finsm@sh{\ht\z@\z@ \box\z@}
        \mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#3}}
        \MT_vphantom:Nn \scriptstyle
          {\MT_cramped_internal:Nn \scriptstyle{#6}}
    }
  \MH_fi:
  \MH_if_dim:w \@tempdima>\z@
    \mathop{#4\MT_vphantom:Nn \displaystyle{#1}}\limits
    #5
    {
      \MT_vphantom:Nn \scriptstyle
        {\MT_cramped_internal:Nn \scriptstyle{#3}}
      \def\finsm@sh{\ht\z@\z@ \box\z@}
      \mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#6}}
    }
  \MH_else:
    \mathop{#4}\limits#5{#6}
  \MH_fi:
}
\newcommand\SwapAboveDisplaySkip{%
  \noalign{\vskip-\abovedisplayskip\vskip\abovedisplayshortskip}
}

\newcommand\MoveEqLeft[1][2]{\kern #1em  &   \kern -#1em}
\newcommand\Aboxed[1]{\let\bgroup{\romannumeral-`}\@Aboxed#1&&\ENDDNE}
\def\@Aboxed#1&#2&#3\ENDDNE{%
  \ifnum0=`{}\fi \setbox \z@
    \hbox{$\displaystyle#1{}\m@th$\kern\fboxsep \kern\fboxrule }%
    \edef\@tempa {\kern  \wd\z@ &\kern -\the\wd\z@
     \fboxsep\the\fboxsep \fboxrule \the\fboxrule }\@tempa \boxed {#1#2}%
}
\newcommand\MakeAboxedCommand[2]{
  % #1: command to create
  % #2: box command to use
  \newcommand#1[1]{\let\bgroup{\romannumeral-`}%
    \@nameuse{@@\MH_cs_to_str:N #1}##1&&\ENDDNE}
  \@namedef{@@\MH_cs_to_str:N #1}##1&##2&##3\ENDDNE{%
    \settowidth\@tempdimc{#2{}}%
    \ifnum0=`{}\fi \setbox \z@
    \hbox{$\displaystyle##1{}\m@th$\kern0.5\@tempdimc}%
    \edef\@tempa{\kern\wd\z@&\kern-\the\wd\z@%
       \fboxsep\the\fboxsep \fboxrule \the\fboxrule}%
    \@tempa%
    #2{\m@th$\displaystyle ##1##2$}%
  }
}

\MHInternalSyntaxOff
\def\ArrowBetweenLines{\relax
  \iffalse{\fi\ifnum0=`}\fi
  \@ifstar{\ArrowBetweenLines@auxI{00}}{\ArrowBetweenLines@auxI{01}}}
\def\ArrowBetweenLines@auxI#1{%
  \@ifnextchar[%
  {\ArrowBetweenLines@auxII{#1}}%
  {\ArrowBetweenLines@auxII{#1}[\Updownarrow]}}
\def\ArrowBetweenLines@auxII#1[#2]{%
  \ifnum0=`{\fi \iffalse}\fi
    \expandafter\in@\expandafter{\@currenvir}%
      {alignedat,aligned,gathered}%
      \ifin@ \else
      \notag
      \fi%
   \\
  \noalign{\nobreak\vskip-\baselineskip\vskip-\lineskip}%
  \noalign{\expandafter\in@\expandafter{\@currenvir}%
      {alignedat,aligned,gathered}%
      \ifin@ \else\notag\fi%
  }%
  \if#1 &&\quad #2\else #2\quad\fi
  \\\noalign{\nobreak\vskip-\lineskip}}

\MHInternalSyntaxOn
\newcommand\vdotswithin[1]{%
  {\mathmakebox[\widthof{\ensuremath{{}#1{}}}][c]{{\vdots}}}}
\newlength\origjot
\setlength\origjot{\jot}
\newdimen\l_MT_shortvdotswithinadjustabove_dim
\newdimen\l_MT_shortvdotswithinadjustbelow_dim
\define@key{\MT_options_name:}
  {shortvdotsadjustabove}{\setlength\l_MT_shortvdotswithinadjustabove_dim{#1}}
\define@key{\MT_options_name:}
  {shortvdotsadjustbelow}{\setlength\l_MT_shortvdotswithinadjustbelow_dim{#1}}
\setkeys{\MT_options_name:}{
  shortvdotsadjustabove=2.15\origjot,
  shortvdotsadjustbelow=\origjot
}
\def\shortvdotswithin{\relax
  \@ifstar{\MT_svwi_aux:nn{00}}{\MT_svwi_aux:nn{01}}}
\def\MT_svwi_aux:nn #1#2{
  \MTFlushSpaceAbove
  \if#1 \vdotswithin{#2}& \else &\vdotswithin{#2}  \fi
  \MTFlushSpaceBelow
}
\def\MT_remove_tag_unless_inner:n #1{%
  \begingroup
  \def\etb@tempa##1|#1|##2\MT@END{\endgroup
    \ifx\@empty##2\@empty\notag\fi}%
  \expandafter\etb@tempa\expandafter|alignedat|aligned|split|#1|\MT@END}
  %| emacs
\newcommand\MTFlushSpaceAbove{
  \expandafter\MT_remove_tag_unless_inner:n\expandafter{\@currenvir}
  \\
  \noalign{%
    \nobreak\vskip-\baselineskip\vskip-\lineskip%
      \vskip-\l_MT_shortvdotswithinadjustabove_dim
      \vskip-\origjot
      \vskip\jot
  }%
  \noalign{
    \expandafter\MT_remove_tag_unless_inner:n\expandafter{\@currenvir}
  }
}
\newcommand\MTFlushSpaceBelow{
  \\\noalign{%
    \nobreak\vskip-\lineskip
    \vskip-\l_MT_shortvdotswithinadjustbelow_dim
    \vskip-\origjot
    \vskip\jot
  }
}

\def\MH_nrotarrow:NN #1#2{%
  \setbox0=\hbox{$\m@th#1\uparrow$}\dimen0=\dp0
  \setbox0=\hbox{%
    \reflectbox{\rotatebox[origin=c]{90}{$\m@th#1\mkern2.22mu #2$}}}%
  \dp0=\dimen0 \box0 \mkern2.3965mu
}
\def\MH_nuparrow: {%
  \mathrel{\mathpalette\MH_nrotarrow:NN\nrightarrow} }
\def\MH_ndownarrow: {%
  \mathrel{\mathpalette\MH_nrotarrow:NN\nleftarrow} }
\AtBeginDocument{%
  \RequirePackage{graphicx}%
  \@ifundefined{nrightarrow}{%
    \providecommand\nuparrow{%
      \PackageError{mathtools}{\string\nuparrow\space~ is~
        constructed~ from~ \string\nrightarrow,~ which~ is~ not~
        provided.~ Please~ load~ the~ amssymb~ package~ or~ similar}{}
    }}{ \providecommand\nuparrow{\MH_nuparrow:}}
  \@ifundefined{nleftarrow}{%
    \providecommand\ndownarrow{%
      \PackageError{mathtools}{\string\ndownarrow\space~ is~
        constructed~ from~ \string\nleftarrow,~ which~ is~ not~
        provided.~ Please~ load~ the~ amssymb~ package~ or~ similar}{}
    }}{ \providecommand\ndownarrow{\MH_ndownarrow:}} }
\def\MH_bigtimes_scaler:N #1{%
  \vcenter{\hbox{#1$\m@th\mkern-2mu\times\mkern-2mu$}}}
\def\MH_bigtimes_inner: {
  \mathchoice{\MH_bigtimes_scaler:N \huge}         % display style
             {\MH_bigtimes_scaler:N \LARGE}        % text style
             {\MH_bigtimes_scaler:N {}}            % script style
             {\MH_bigtimes_scaler:N \footnotesize} % script script style
}
\def\MH_csym_bigtimes: {\mathop{\MH_bigtimes_inner:}\displaylimits}
\AtBeginDocument{
  \providecommand\bigtimes{\MH_csym_bigtimes:}
}
\MH_let:NwN \MT_orig_intertext: \intertext@
\newdimen\l_MT_above_intertext_sep
\newdimen\l_MT_below_intertext_sep
\define@key{\MT_options_name:}
  {aboveintertextdim}{\setlength\l_MT_above_intertext_sep{#1}}
\define@key{\MT_options_name:}
  {belowintertextdim}{\setlength\l_MT_below_intertext_sep{#1}}
\define@key{\MT_options_name:}
  {above-intertext-dim}{\setlength\l_MT_above_intertext_sep{#1}}
\define@key{\MT_options_name:}
  {below-intertext-dim}{\setlength\l_MT_below_intertext_sep{#1}}
\define@key{\MT_options_name:}
  {above-intertext-sep}{\setlength\l_MT_above_intertext_sep{#1}}
\define@key{\MT_options_name:}
  {below-intertext-sep}{\setlength\l_MT_below_intertext_sep{#1}}
\def\MT_intertext: {%
  \def\intertext##1{%
    \ifvmode\else\\\@empty\fi
    \noalign{%
      \penalty\postdisplaypenalty\vskip\belowdisplayskip
      \vskip-\lineskiplimit      % CCS
      \vskip\normallineskiplimit % CCS
      \vskip\l_MT_above_intertext_sep
       \vbox{\normalbaselines
         \ifdim
           \ifdim\@totalleftmargin=\z@
             \linewidth
           \else
             -\maxdimen
           \fi
         =\columnwidth
        \else \parshape\@ne \@totalleftmargin \linewidth
        \fi
        \noindent\ignorespaces##1\par}%
      \penalty\predisplaypenalty\vskip\abovedisplayskip%
      \vskip-\lineskiplimit      % CCS
      \vskip\normallineskiplimit % CCS
      \vskip\l_MT_below_intertext_sep
   }%
 }%
 % also activate \shortintertext, such that is is only available when
 % \intertext is
 \MH_let:NwN \shortintertext \shortintertext@
}
\def\MT_orig_intertext_true:  {
  \MH_let:NwN \intertext@ \MT_orig_intertext:
  \MH_let:NwN \shortintertext \shortintertext@
}
\def\MT_orig_intertext_false: { \MH_let:NwN \intertext@ \MT_intertext: }
\define@key{\MT_options_name:}{original-intertext}[true]{
  \@nameuse{MT_orig_intertext_#1:}
}
\setkeys{\MT_options_name:}{
  original-intertext=false
}
\def\MT_orig_shortintertext:n #1{%
  \ifvmode\else\\\@empty\fi
  \noalign{%
    \penalty\postdisplaypenalty\vskip\abovedisplayshortskip
    \vbox{\normalbaselines
      \MH_if_dim:w
        \MH_if_dim:w \@totalleftmargin=\z@
          \linewidth
        \MH_else:
          -\maxdimen
        \MH_fi:
        =\columnwidth
      \MH_else:
        \parshape\@ne \@totalleftmargin \linewidth
      \MH_fi:
      \noindent\ignorespaces#1\par}%
    \penalty\predisplaypenalty\vskip\abovedisplayshortskip%
  }%
}
\newdimen\l_MT_above_shortintertext_sep
\newdimen\l_MT_below_shortintertext_sep
\define@key{\MT_options_name:}
  {aboveshortintertextdim}{\setlength \l_MT_above_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
  {belowshortintertextdim}{\setlength \l_MT_below_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
  {above-short-intertext-dim}{\setlength \l_MT_above_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
  {below-short-intertext-dim}{\setlength \l_MT_below_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
  {above-short-intertext-sep}{\setlength \l_MT_above_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
  {below-short-intertext-sep}{\setlength \l_MT_below_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
  {above-shortintertext-sep}{\setlength \l_MT_above_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
  {below-shortintertext-sep}{\setlength \l_MT_below_shortintertext_sep{#1}}
\setkeys{\MT_options_name:}{
  aboveshortintertextdim=3pt,
  belowshortintertextdim=3pt
}
\def\MT_shortintertext:n #1{%
  \ifvmode\else\\\@empty\fi
  \noalign{%
    \penalty\postdisplaypenalty\vskip\abovedisplayshortskip
    \vskip-\lineskiplimit
    \vskip\normallineskiplimit
    \vskip\l_MT_above_shortintertext_sep
    \vbox{\normalbaselines
      \MH_if_dim:w
        \MH_if_dim:w \@totalleftmargin=\z@
          \linewidth
        \MH_else:
          -\maxdimen
        \MH_fi:
        =\columnwidth
      \MH_else:
        \parshape\@ne \@totalleftmargin \linewidth
      \MH_fi:
      \noindent\ignorespaces#1\par}%
    \penalty\predisplaypenalty\vskip\abovedisplayshortskip%
    \vskip-\lineskiplimit
    \vskip\normallineskiplimit
    \vskip\l_MT_below_shortintertext_sep
  }%
}
\def\MT_orig_shortintertext_true:  { \MH_let:NwN \shortintertext@ \MT_orig_shortintertext:n }
\def\MT_orig_shortintertext_false: { \MH_let:NwN \shortintertext@ \MT_shortintertext:n }
\newcommand{\shortintertext}{\@amsmath@err{\Invalid@@\shortintertext}\@eha}
\define@key{\MT_options_name:}{original-shortintertext}[true]{
  \@nameuse{MT_orig_shortintertext_#1:}
}
\setkeys{\MT_options_name:}{
  original-shortintertext=false
}
\providecommand*\clap[1]{\hb@xt@\z@{\hss#1\hss}}
\providecommand*\mathllap[1][\@empty]{
  \relax\ifx\@empty#1\@empty
    \expandafter \mathpalette \expandafter \MT_mathllap:Nn
  \else
    \expandafter \MT_mathllap:Nn \expandafter #1
  \fi
}
\providecommand*\mathrlap[1][\@empty]{
  \relax\ifx\@empty#1\@empty
    \expandafter \mathpalette \expandafter \MT_mathrlap:Nn
  \else
    \expandafter \MT_mathrlap:Nn \expandafter #1
  \fi
}
\providecommand*\mathclap[1][\@empty]{
  \relax\ifx\@empty#1\@empty
    \expandafter \mathpalette \expandafter \MT_mathclap:Nn
  \else
    \expandafter \MT_mathclap:Nn \expandafter #1
  \fi
}
\def\MT_mathllap:Nn #1#2{{}\llap{$\m@th#1{#2}$}}
\def\MT_mathrlap:Nn #1#2{{}\rlap{$\m@th#1{#2}$}}
\def\MT_mathclap:Nn #1#2{{}\clap{$\m@th#1{#2}$}}
\providecommand*\mathmbox{\mathpalette\MT_mathmbox:nn}
\def\MT_mathmbox:nn #1#2{\mbox{$\m@th#1#2$}}
\providecommand*\mathmakebox{
  \@ifnextchar[  \MT_mathmakebox_I:w
                 \mathmbox}
\def\MT_mathmakebox_I:w[#1]{%
  \@ifnextchar[  {\MT_mathmakebox_II:w[#1]}
                 {\MT_mathmakebox_II:w[#1][c]}}
\def\MT_mathmakebox_II:w[#1][#2]{
  \mathpalette{\MT_mathmakebox_III:w[#1][#2]}}
\def\MT_mathmakebox_III:w[#1][#2]#3#4{%
  \@begin@tempboxa\hbox{$\m@th#3#4$}%
    \setlength\@tempdima{#1}%
    \hbox{\hb@xt@\@tempdima{\csname bm@#2\endcsname}}%
  \@end@tempboxa}
\def\mathsm@sh#1#2{%
  \setbox\z@\hbox{$\m@th#1{#2}$}{}\finsm@sh}
\providecommand*\cramped[1][\@empty]{
  \relax\ifx\@empty#1\@empty
    \expandafter \mathpalette \expandafter \MT_cramped_internal:Nn
  \else
    \expandafter \MT_cramped_internal:Nn \expandafter #1
  \fi
}
\def\MT_cramped_internal:Nn #1#2{
  %% \sbox\z@{$\m@th#1\kern-\nulldelimiterspace\radical\z@{#2}$}
  \setbox\z@\hbox{$\m@th#1\kern-\nulldelimiterspace\radical\z@{#2}$}
    \ifx#1\displaystyle
      \dimen@=\fontdimen8\textfont3
      \advance\dimen@ .25\fontdimen5\textfont2
    \else
      \dimen@=1.25\fontdimen8
      \ifx#1\textstyle\textfont
      \else
        \ifx#1\scriptstyle
          \scriptfont
        \else
          \scriptscriptfont
        \fi
      \fi
      3
    \fi
    \advance\dimen@-\ht\z@ \ht\z@=-\dimen@
    \ifvmode\leavevmode\fi
    {}\box\z@
}
\ifx\directlua\@undefined\else
  \def\MT_cramped_internal:Nn #1#2{
    {
      \ensuremath {
        \use:c { cramped \cs_to_str:N #1 } #2
      }
    }
  }
\fi

\providecommand*\crampedllap[1][\@empty]{
  \relax\ifx\@empty#1\@empty
    \expandafter \mathpalette \expandafter \MT_cramped_llap_internal:Nn
  \else
    \expandafter \MT_cramped_llap_internal:Nn \expandafter #1
  \fi
}
\def\MT_cramped_llap_internal:Nn #1#2{
  {}\llap{\MT_cramped_internal:Nn #1{#2}}
}
\providecommand*\crampedclap[1][\@empty]{
  \relax\ifx\@empty#1\@empty
    \expandafter \mathpalette \expandafter \MT_cramped_clap_internal:Nn
  \else
    \expandafter \MT_cramped_clap_internal:Nn \expandafter #1
  \fi
}
\def\MT_cramped_clap_internal:Nn #1#2{
  {}\clap{\MT_cramped_internal:Nn #1{#2}}
}
\providecommand*\crampedrlap[1][\@empty]{
  \relax\ifx\@empty#1\@empty
    \expandafter \mathpalette \expandafter \MT_cramped_rlap_internal:Nn
  \else
    \expandafter \MT_cramped_rlap_internal:Nn \expandafter #1
  \fi
}
\def\MT_cramped_rlap_internal:Nn #1#2{
  {}\rlap{\MT_cramped_internal:Nn #1{#2}}
}
\ifx\directlua\@undefined
\newenvironment{crampedsubarray}[1]{%
  \vcenter\bgroup
  \Let@ \restore@math@cr \default@tag
  \baselineskip\fontdimen10 \scriptfont\tw@
  \advance\baselineskip\fontdimen12 \scriptfont\tw@
  \lineskip\thr@@\fontdimen8 \scriptfont\thr@@
  \lineskiplimit\lineskip
  \ialign\bgroup\ifx c#1\hfil\fi
     %%$\m@th\scriptstyle\kern-\nulldelimiterspace\radical\z@{##}$% <-- changed line
    \span\MT_cramped_internal:Nn \scriptstyle {##}%
  \hfil\crcr
}{%
  \crcr\egroup\egroup
}
\else
\newenvironment{crampedsubarray}[1]{%
  \vcenter\bgroup
  \Let@ \restore@math@cr \default@tag
  \baselineskip \Umathstacknumup \scriptstyle
  \advance\baselineskip \Umathstackdenomdown \scriptstyle
  \lineskip \Umathstackvgap \scriptstyle
  \lineskiplimit \lineskip
  \ialign\bgroup\ifx c#1\hfil\fi
  \Ustartmath
    \crampedscriptstyle{##}
  \Ustopmath
  \hfil\crcr
}{%
  \crcr\egroup\egroup
}
\fi
\newcommand{\crampedsubstack}[1]{\crampedsubarray{c}#1\endcrampedsubarray}
\newcommand{\MT_prescript_inner:}[4]{
  \@mathmeasure\z@#4{\MT_prescript_sup:{#1}}
  \@mathmeasure\tw@#4{\MT_prescript_sub:{#2}}
  \MH_if_dim:w \wd\tw@>\wd\z@
    \setbox\z@\hbox to\wd\tw@{\hfil\unhbox\z@}
  \MH_else:
    \setbox\tw@\hbox to\wd\z@{\hfil\unhbox\tw@}
  \MH_fi:
  \mathop{}
  \mathopen{\vphantom{\MT_prescript_arg:{#3}}}^{\box\z@}\sb{\box\tw@}
  \MT_prescript_arg:{#3}
}
\DeclareRobustCommand{\prescript}[3]{
  \mathchoice
    {\MT_prescript_inner:{#1}{#2}{#3}{\scriptstyle}}
    {\MT_prescript_inner:{#1}{#2}{#3}{\scriptstyle}}
    {\MT_prescript_inner:{#1}{#2}{#3}{\scriptscriptstyle}}
    {\MT_prescript_inner:{#1}{#2}{#3}{\scriptscriptstyle}}
}
\define@key{\MT_options_name:}
  {prescript-sup-format}{\def\MT_prescript_sup:{#1}}
\define@key{\MT_options_name:}
  {prescript-sub-format}{\def\MT_prescript_sub:{#1}}
\define@key{\MT_options_name:}
  {prescript-arg-format}{\def\MT_prescript_arg:{#1}}
\setkeys{\MT_options_name:}{
  prescript-sup-format={},
  prescript-sub-format={},
  prescript-arg-format={},
}
\ifx\e@alloc\@undefined% kernel thus older than 2015
  \def\@DeclareMathSizes #1#2#3#4#5{%
    \@defaultunits\dimen@ #2pt\relax\@nnil
    \MH_if:w $#3$%
      \MH_let:cN {S@\strip@pt\dimen@}\math@fontsfalse
    \MH_else:
      \@defaultunits\dimen@ii #3pt\relax\@nnil
      \@defaultunits\@tempdima #4pt\relax\@nnil
      \@defaultunits\@tempdimb #5pt\relax\@nnil
      \toks@{#1}%
      \expandafter\xdef\csname S@\strip@pt\dimen@\endcsname{%
        \gdef\noexpand\tf@size{\strip@pt\dimen@ii}%
        \gdef\noexpand\sf@size{\strip@pt\@tempdima}%
        \gdef\noexpand\ssf@size{\strip@pt\@tempdimb}%
        \the\toks@
      }%
    \MH_fi:
  }
\fi
\def\MT_mathic_true: {
  \MH_if_boolean:nF {math_italic_corr}{
    \MH_set_boolean_T:n {math_italic_corr}
    \MH_if_boolean:nTF {robustify}{
      \MH_let:NwN \MT_mathic_redeffer: \DeclareRobustCommand
    }{
      \MH_let:NwN \MT_mathic_redeffer: \renewcommand
    }
    \MH_let:NwN \MT_begin_inlinemath: \(
    %\renewcommand*\({
    \MT_mathic_redeffer:*\({
      \relax\ifmmode\@badmath\else
      \ifhmode
        \MH_if_dim:w \fontdimen\@ne\font>\z@
          \MH_if_dim:w \lastskip>\z@
            \skip@\lastskip\unskip
            \MH_if_num:w \lastpenalty>\z@
              \count@\lastpenalty\unpenalty
            \MH_fi:
            \@@italiccorr
            \MH_if_num:w \count@>\z@
              \penalty\count@
            \MH_fi:
            \hskip\skip@
          \MH_else:
            \@@italiccorr
          \MH_fi:
        \MH_fi:
      \MH_fi:
      $\MH_fi:
    }
  }
}
\def\MT_mathic_false: {
  \MH_if_boolean:nT {math_italic_corr}{
    \MH_set_boolean_F:n {math_italic_corr}
    \MH_if_boolean:nTF {robustify}{
      \edef\({\MT_begin_inlinemath:}%
      \forced_EQ_MakeRobust\(%
    }{
      \MH_let:NwN \( \MT_begin_inlinemath:
    }
  }
}
\MH_new_boolean:n {math_italic_corr}
\define@key{\MT_options_name:}{mathic}[true]{
  \@ifundefined{MT_mathic_#1:}
    { \MT_true_false_error:
      \@nameuse{MT_mathic_false:}
    }
    { \@nameuse{MT_mathic_#1:} }
}
\newenvironment{spreadlines}[1]{
  \setlength{\jot}{#1}
  \ignorespaces
}{ \ignorespacesafterend }
\MaybeMHPrecedingSpacesOff
\newenvironment{MT_gathered_env}[1][c]{%
    \RIfM@\else
        \nonmatherr@{\begin{\@currenvir}}%
    \fi
    %\null\,%
    \alignedspace@left%
    \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup
        \Let@ \chardef\dspbrk@context\@ne \restore@math@cr
        \spread@equation
        \ialign\bgroup
            \MT_gathered_pre:
            \strut@$\m@th\displaystyle##$
            \MT_gathered_post:
            \crcr
}{%
  \endaligned
  \MT_gathered_env_end:
}
\MHPrecedingSpacesOn
\newcommand*\newgathered[4]{
  \newenvironment{#1}
    { \def\MT_gathered_pre:{#2}
      \def\MT_gathered_post:{#3}
      \def\MT_gathered_env_end:{#4}
      \MT_gathered_env
    }{\endMT_gathered_env}
}
\newcommand*\renewgathered[4]{
  \renewenvironment{#1}
    { \def\MT_gathered_pre:{#2}
      \def\MT_gathered_post:{#3}
      \def\MT_gathered_env_end:{#4}
      \MT_gathered_env
    }{\endMT_gathered_env}
}
\newgathered{lgathered}{}{\hfil}{}
\newgathered{rgathered}{\hfil}{}{}
\renewgathered{gathered}{\hfil}{\hfil}{}
\newcommand*\splitfrac[2]{%
  \genfrac{}{}{0pt}{1}%
    {\textstyle#1\quad\hfill}%
    {\textstyle\hfill\quad\mathstrut#2}%
}
\newcommand*\splitdfrac[2]{%
  \genfrac{}{}{0pt}{0}{#1\quad\hfill}{\hfill\quad\mathstrut #2}%
}
\MH_if_boolean:nT {fixamsmath}{
\def\place@tag{%
  \iftagsleft@
    \kern-\tagshift@
    \if@fleqn
      \MH_if_num:w \xatlevel@=\tw@
        \kern-\@mathmargin
      \MH_fi:
    \MH_fi:
    \MH_if:w 1\shift@tag\row@\relax
      \rlap{\vbox{%
        \normalbaselines
        \boxz@
        \vbox to\lineht@{}%
        \raise@tag
      }}%
    \MH_else:
      \rlap{\boxz@}%
    \MH_fi:
    \kern\displaywidth@
  \MH_else:
    \kern-\tagshift@
    \MH_if:w 1\shift@tag\row@\relax
      \llap{\vtop{%
        \raise@tag
        \normalbaselines
        \setbox\@ne\null
        \dp\@ne\lineht@
        \box\@ne
        \boxz@
      }}%
    \MH_else:
      \llap{\boxz@}%
    \MH_fi:
  \MH_fi:
}
\def\x@calc@shift@lf{%
  \MH_if_dim:w \eqnshift@=\z@
    \global\eqnshift@\@mathmargin\relax
      \alignsep@\displaywidth
      \advance\alignsep@-\totwidth@
      \MH_if_num:w \@tempcntb=0
      \MH_else:
        \global\divide\alignsep@\@tempcntb % original line
      \MH_fi:
      \MH_if_dim:w \alignsep@<\minalignsep\relax
        \global\alignsep@\minalignsep\relax
      \MH_fi:
  \MH_fi:
  \MH_if_dim:w \tag@width\row@>\@tempdima
    \saveshift@1%
  \MH_else:
    \saveshift@0%
  \MH_fi:}%
}
\MaybeMHPrecedingSpacesOff
\renewcommand\aligned@a[1][c]{\start@aligned{#1}\m@ne}
\MHPrecedingSpacesOn
\newbox\xmathstrut@box
\newdimen\xmathstrut@dim
\def\xmathstrut{\@dblarg\xmathstrut@}
\def\xmathstrut@[#1]#2{%
  \def\xmathstrut@dp{#1}%
  \vphantom{\mathpalette\xmathstrut@do{#2}}%
}
\def\xmathstrut@do#1#2{%
  \setbox\xmathstrut@box\hbox{$#1($}%)%emacs
   \xmathstrut@dim\dimexpr\ht\xmathstrut@box+\dp\xmathstrut@box\relax
   \ht\xmathstrut@box\dimexpr\ht\xmathstrut@box
           +#2\xmathstrut@dim
           \relax
   \dp\xmathstrut@box\dimexpr\dp\xmathstrut@box
         +\xmathstrut@dp\xmathstrut@dim
         \relax
   \box\xmathstrut@box}

\endinput
%%
%% End of file `mathtools.sty'.
