%%
%% This is file `empheq.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% empheq.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2002-2007 by Morten Hoegholm
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 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.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is
%% Lars Madsen, Will Robertson and Joseph Wright.
%% 
%% This work consists of the main source file empheq.dtx
%% and the derived files
%%    empheq.sty, empheq.pdf, empheq.ins, empheq.drv.
%% 
\ProvidesPackage{empheq}%
  [2007/12/03 v2.12 Emphasizing equations (MH)]
\RequirePackage{mhsetup}[2004/10/10]
\MHInternalSyntaxOn
\MH_new_boolean:n {overload_ams}
\DeclareOption{overload}{
  \MH_set_boolean_T:n {overload_ams}
}
\MH_new_boolean:n {overload_amsII}
\DeclareOption{overload2}{
  \MH_set_boolean_T:n {overload_ams}
  \MH_set_boolean_T:n {overload_amsII}
}
\MH_new_boolean:n {good_mult}
\DeclareOption{oldmultline}{\MH_set_boolean_F:n {good_mult}}
\DeclareOption{newmultline}{\MH_set_boolean_T:n {good_mult}}
\gdef\g@EQ@ntheorem@support@bool{01}
\DeclareOption{ntheorem}{\gdef\g@EQ@ntheorem@support@bool{00}}
\DeclareOption*{
  \PassOptionsToPackage{\CurrentOption}{mathtools}
}
\ExecuteOptions{newmultline}
\ProcessOptions\relax
\MHInternalSyntaxOff
\RequirePackage{mathtools}[2004/10/10]
\MHInternalSyntaxOn
\AtEndOfPackage{\MHInternalSyntaxOff}
\newcount\l_EQ_equationtype_int
\newcount\l_EQ_alignmentmode_int
\if@fleqn
  \iftagsleft@
    \l_EQ_alignmentmode_int=4
  \else:
    \l_EQ_alignmentmode_int=\thr@@
  \fi:
\else:
  \iftagsleft@
    \l_EQ_alignmentmode_int=\tw@
  \else:
    \l_EQ_alignmentmode_int=\@ne
  \fi:
\fi:
\newdimen\l_EQ_totalwidth_dim
\newdimen\l_EQ_displaywidth_dim
\def\EmphEqdisplaywidth{\l_EQ_displaywidth_dim}
\newdimen\l_EQ_temp_linewidth_dim
\newdimen\EmphEqdelimitershortfall
\newcount\EmphEqdelimiterfactor
\EmphEqdelimiterfactor950
\EmphEqdelimitershortfall\p@
\newdimen\g_EQ_toptag_height_dim
\newdimen\g_EQ_bottomtag_depth_dim
\newdimen\g_EQ_toprow_height_dim
\newdimen\g_EQ_bottomrow_depth_dim
\newdimen\g_EQ_widesttag_dim
\def\EmphEqtagwidth{\g_EQ_widesttag_dim}
\def\EQ_outerbox:{}
\def\EQ_innerbox:{}
\def\EQ_left_side:{}
\def\EQ_right_side:{}
\newsavebox\EQ_mathdisplay_box
\def\EmphEqdisplayheight{\ht\EQ_mathdisplay_box}
\def\EmphEqdisplaydepth{\dp\EQ_mathdisplay_box}
\newsavebox\EQ_tag_box
\def\EQ_complete_mathdisplay:{}
\def\EQ_getbody:n #1{%
  \def\EQ_complete_mathdisplay:{}\def\EQ_mathbody:{#1}}
\newenvironment{EmphEqMainEnv}{\collect@body\EQ_getbody:n}{%
  \if_num:w \l_EQ_equationtype_int=\z@ %ZeroCheckpoint
    \EQ_upgrade_error:
  \else:
    \EQ_post_process:
    \ignorespacesafterend
  \fi:}
\def\EQ_post_process:{%
  \EQ_initialize:
  \EQ_begin_equation:
  \MH_if_boolean:nT {outer_mult}{
    \setkeys{\MT_options_name:}{
      firstline-afterskip=0pt,
      lastline-preskip=0pt,
      multlined-width=0pt,
    }
    \ifodd \l_EQ_alignmentmode_int
      \setkeys{\MT_options_name:}{multlined-pos=b}
    \else:
      \setkeys{\MT_options_name:}{multlined-pos=t}
    \fi:
      \g@addto@macro\EQ_complete_mathdisplay:{
        \begin{MTmultlined}\relax}
  }
  \g@addto@macro\EQ_complete_mathdisplay:\EQ_mathbody:
  \MH_if_boolean:nT {outer_mult}{
    \g@addto@macro\EQ_complete_mathdisplay:{\end{MTmultlined}}
  }
  \EQ_end_equation:
  \edef\EQ_hyperref_link_fint{\number\Hy@linkcounter}
  \savecounters@
  \EQ_typeset_tags:
  \edef\l_EQ_equation_fint{\number\c@equation}
  \restorecounters@
  \Hy@linkcounter=\EQ_hyperref_link_fint
  \settowidth\l_EQ_totalwidth_dim{%
    $\EQ_left_side:\EQ_innerbox:{}\EQ_right_side:$}%
  \MH_if_boolean:nTF {outer_mult}
    { \def\EQ_next:{_mult} }
    { \def\EQ_next:{} }
  \@nameuse{EQ_modify_linewidth_
            \romannumeral\l_EQ_equationtype_int\EQ_next: :}%
  \EQ_typeset_display:
  \@nameuse{find_displaywidth_
           \romannumeral\l_EQ_equationtype_int\EQ_next: :}
  \MH_addtolength:dn
    \l_EQ_totalwidth_dim{\l_EQ_displaywidth_dim}
  \savebox\EQ_mathdisplay_box[\l_EQ_totalwidth_dim][c]{%
    $\EQ_left_side:
    \EQ_innerbox:{%
      \if_case:w \l_EQ_alignmentmode_int\or:
        \makebox[\l_EQ_displaywidth_dim][c]
          {\usebox{\EQ_mathdisplay_box}}%
      \or:
        \makebox[\l_EQ_displaywidth_dim][c]
          {\usebox{\EQ_mathdisplay_box}}%
      \or:
        \makebox[\l_EQ_displaywidth_dim][l]{%
          \if_num:w \l_EQ_equationtype_int=5 \else:
            \if_num:w \l_EQ_equationtype_int=6 \else:
              \kern-\@mathmargin
            \fi:
          \fi:
          \usebox{\EQ_mathdisplay_box}}%
      \or:
        \makebox[\l_EQ_displaywidth_dim][l]{%
          \if_num:w \l_EQ_equationtype_int=5 \else:
            \if_num:w \l_EQ_equationtype_int=6 \else:
              \kern-\@mathmargin
            \fi:
          \fi:
          \usebox{\EQ_mathdisplay_box}}%
      \fi:}%
    \EQ_right_side:$}%
  \begin{AmSequation*}
  \@nameuse{EQ_place_display_
           \romannumeral\l_EQ_equationtype_int\EQ_next: :}
  \if_dim:w \g_EQ_widesttag_dim>\z@
  \MH_set_boolean_T:n {show_manual_tags}
    \if_case:w \l_EQ_alignmentmode_int
    \or: \EQ_place_tag:N r %#1
    \or: \EQ_place_tag:N l %#2
    \or: \EQ_place_tag:N r %#3
    \or: \EQ_place_tag:N l %#4
    \fi:
  \fi:
  \end{AmSequation*}
  \global\c@equation=\l_EQ_equation_fint\relax
}
\def\EQ_initialize:{%
  \m@th
  \MH_let:NwN\SetTagPlusEndMark\EQ_tag_plus_endmark:
  \MH_let:NwN\SetOnlyEndMark\EQ_only_endmark:
  \l_EQ_temp_linewidth_dim\linewidth
  \g_EQ_toprow_height_dim\z@
  \g_EQ_bottomrow_depth_dim\z@
  \g_EQ_toptag_height_dim\z@
  \g_EQ_bottomtag_depth_dim\z@
  \g_EQ_widesttag_dim\z@
  \xdef\g_EQ_latest_nonzerodepth_row_fint{\z@}
  \edef\EQ_restore_tex_delimiter:{%
    \delimiterfactor\the\delimiterfactor
    \delimitershortfall\the\delimitershortfall\relax}%
  \g@addto@macro\EQ_complete_mathdisplay:
                \EQ_restore_tex_delimiter:
  \delimitershortfall\EmphEqdelimitershortfall
  \delimiterfactor\EmphEqdelimiterfactor
  \MH_let:NwN\intertext@\EQ_intertext:
  \EQ_displaybreak:}
\def\EQ_intertext:{%
  \def\intertext##1{\PackageError{empheq}{%
    You~cannot~use~\string\intertext\space inside~the~`empheq'
    \MessageBreak
    environment,~as~`empheq'~creates~an~unbreakable~box}\@eha}}
\def\EQ_displaybreak:{%
  \def\dspbrk@[##1]{\PackageWarning{empheq}{%
    You~cannot~use~\string\displaybreak\space inside~the~`empheq'%
    \MessageBreak
    environment,~as~`empheq'~creates~an~unbreakable~box.}}}
\def\EQ_new_equationtype:nnn #1#2#3{%
  \define@key{#1}{#2}[true]{%
    \l_EQ_equationtype_int=#3\relax
    \def\EQ_begin_equation:
      {\g@addto@macro{\EQ_complete_mathdisplay:}{\begin{#2}}}%
    \def\EQ_end_equation:
      {\g@addto@macro{\EQ_complete_mathdisplay:}{\end{#2}}}}}
\def\EQ_new_equationtype_arg:nnn #1#2#3{%
  \define@key{#1}{#2}{%
    \l_EQ_equationtype_int=#3\relax
    \def\EQ_begin_equation:
      {\g@addto@macro{\EQ_complete_mathdisplay:}{\begin{#2}{##1}}}%
    \def\EQ_end_equation:
      {\g@addto@macro{\EQ_complete_mathdisplay:}{\end{#2}}}}}
\def\EQ_typeset_tags:{%
  \sbox\EQ_tag_box{%
    \parbox{.5\maxdimen}{%
      \hbadness\@M
      \EQ_prevent_vertical_space:
      \EQ_typeset_tags_hook:
      \MH_let:NwN\set@gather@field\EQ_set_gather_field:
      \MH_let:NwN\set@field\EQ_set_align_field:
      \MH_set_boolean_T:n {continue_measuring}
      \global\g_EQ_temprow_int\m@ne
      \MH_let:NwN \EQ_saved_maketag:n \maketag@@@
      \def\maketag@@@##1{
        \EQ_maketag:Nn \EQ_saved_maketag:n {##1}}
      \EQ_complete_mathdisplay:}}}
\def\EQ_predisplay_adjustment:{%
  \if_dim:w \g_EQ_toprow_height_dim<\baselineskip
    \vskip\g_EQ_toprow_height_dim
    \vskip-\baselineskip
  \else:
    \vskip-\normallineskip
  \fi:
  \if_dim:w \g_EQ_toptag_height_dim>\g_EQ_toprow_height_dim
    \if_dim:w \g_EQ_toptag_height_dim>\baselineskip
      \vskip-\g_EQ_toptag_height_dim
      \vskip\baselineskip
      \vskip-\normallineskip
    \fi:
  \fi:}
\def\EQ_postdisplay_adjustment:{%
  \if_dim:w \g_EQ_bottomrow_depth_dim<\dp\strutbox
    \vskip\g_EQ_bottomrow_depth_dim
    \vskip-\dp\strutbox
  \fi:
  \if_dim:w \g_EQ_bottomtag_depth_dim>\g_EQ_bottomrow_depth_dim
    \if_dim:w \g_EQ_bottomtag_depth_dim>\dp\strutbox
      \vskip-\g_EQ_bottomtag_depth_dim
      \vskip\dp\strutbox
    \fi:
  \fi:}
\def\EQ_typeset_display:{%
  \sbox\EQ_mathdisplay_box{%
    \parbox{\l_EQ_temp_linewidth_dim}{%
      \EQ_predisplay_adjustment:
      \EQ_prevent_vertical_space:
      \EQ_typeset_display_hook:
      \def\maketag@@@##1{\EQ_maketag:Nn \vphantom{##1}}%
      \EQ_complete_mathdisplay:
      \EQ_postdisplay_adjustment:}}}
\def\EQ_prevent_vertical_space:{%
  \nointerlineskip
  \abovedisplayskip\z@  \belowdisplayskip\z@\relax}
\def\EQ_maketag:Nn #1#2{%
  \setboxz@h{#2}%
  \if_num:w \row@=\@ne
    \global \g_EQ_toptag_height_dim = \ht\z@
  \fi:
  \global \g_EQ_bottomtag_depth_dim=\dp\z@
  \xdef\g_EQ_latest_nonzerodepth_row_fint{\number\row@}
  \@tempdima=\wd\z@
  \if_dim:w \@tempdima > \g_EQ_widesttag_dim
    \global \g_EQ_widesttag_dim = \@tempdima
  \fi:
  #1{#2}%
}
\def\EQ_set_gather_field:{%
  \iftagsleft@
    \global\lineht@\ht\z@
  \else:
    \global\lineht@\dp\z@
  \fi:
  \kern\eqnshift@
  %\boxz@ % Original amsmath version
  \EQ_measure_gather:
  \phantom{\boxz@}%
  \hfil}
\def\EQ_measure_gather:{%
  \if_num:w \row@=\@ne
    \g_EQ_toprow_height_dim=\ht\z@
  \fi:
  \g_EQ_bottomrow_depth_dim=\dp\z@
  \global\g_EQ_toprow_height_dim\g_EQ_toprow_height_dim
  \global\g_EQ_bottomrow_depth_dim\g_EQ_bottomrow_depth_dim}
\def\EQ_set_align_field:{%
  \column@plus
  \iftagsleft@
    \if_dim:w \ht\z@>\lineht@
      \global\lineht@\ht\z@
    \fi:
  \else:
    \if_dim:w \dp\z@>\lineht@
      \global\lineht@\dp\z@
    \fi:
  \fi:
  %\boxz@ % Original amsmath version
  \MH_if_boolean:nT {continue_measuring}{ \EQ_measure_align: }
  \phantom{\boxz@}}
\newcount\g_EQ_temprow_int
\MH_new_boolean:n {still_in_samerow}
\MH_new_boolean:n {continue_measuring}
\def\EQ_measure_align:{%
  \if_num:w \g_EQ_temprow_int=\row@
    \MH_set_boolean_T:n {still_in_samerow}
  \else:
    \if_num:w \g_EQ_temprow_int>\row@
      \global\MH_set_boolean_F:n {continue_measuring}
    \fi:
    \MH_set_boolean_F:n {still_in_samerow}
    \global\@tempdimc=\@tempdimb
    \global\@tempdimb=\g_EQ_bottomrow_depth_dim
  \fi:
  \MH_if_boolean:nTF {continue_measuring}{
    \global\g_EQ_temprow_int=\row@
    \@tempcnta=\row@
    \if_num:w \@tempcnta=\z@
      \@tempdima=\g_EQ_toprow_height_dim
      \g_EQ_toprow_height_dim=\ht\z@\relax
      \if_dim:w \g_EQ_toprow_height_dim<\@tempdima
        \g_EQ_toprow_height_dim\@tempdima
      \fi:
    \fi:
    \MH_if_boolean:nTF {still_in_samerow}{
      \@tempdima=\g_EQ_bottomrow_depth_dim
      \g_EQ_bottomrow_depth_dim=\dp\z@\relax
      \if_dim:w \g_EQ_bottomrow_depth_dim<\@tempdima
        \g_EQ_bottomrow_depth_dim\@tempdima
      \fi:
    }{
      \g_EQ_bottomrow_depth_dim\dp\z@\relax
    }
  }{
    \global\g_EQ_bottomrow_depth_dim=\@tempdimc
  }
  \global\g_EQ_toprow_height_dim\g_EQ_toprow_height_dim
  \global\g_EQ_bottomrow_depth_dim\g_EQ_bottomrow_depth_dim}
\def\EQ_place_tag:N #1{%
  \tag*{\makebox[\g_EQ_widesttag_dim][#1]{%
    \EQ_vertical_tag_adjustment:n {\usebox{\EQ_tag_box}}}}}
\def\EQ_vertical_tag_adjustment:n #1{{%
  \@tempdima\z@\@tempdimb\z@
  \@tempdimc=\dp\strutbox
  \if_dim:w \g_EQ_toprow_height_dim<\baselineskip
    \MH_setlength:dn
      \@tempdima{\g_EQ_toprow_height_dim-\baselineskip}
  \else:
    \MH_setlength:dn \@tempdima{-\normallineskip}
  \fi:
  \if_dim:w \g_EQ_toptag_height_dim>\g_EQ_toprow_height_dim
    \if_dim:w \g_EQ_toptag_height_dim>\baselineskip
      \MH_addtolength:dn \@tempdima
        {-\g_EQ_toptag_height_dim+\baselineskip-\normallineskip}
    \fi:
  \fi:
  \if_dim:w \g_EQ_bottomrow_depth_dim<\@tempdimc
    \MH_setlength:dn \@tempdimb
      {\g_EQ_bottomrow_depth_dim-\@tempdimc}
  \fi:
  \if_dim:w \g_EQ_bottomtag_depth_dim>\g_EQ_bottomrow_depth_dim
    \if_dim:w \g_EQ_bottomtag_depth_dim<\@tempdimc
    \else:
      \MH_addtolength:dn \@tempdimb
        {-\g_EQ_bottomtag_depth_dim+\@tempdimc}
    \fi:
  \fi:
  \raisebox{-0.5\@tempdima+0.5\@tempdimb}{#1}}}%
\def\EQ_use_mathdisplay:{%
  \EQ_outerbox:{\usebox{\EQ_mathdisplay_box}}}
\def\EQ_options_name:{EmphEqOpt}
\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{equation}{gather}
  {\EQ_disable_linebreak:}
\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{equation*}{gather*}
  {\EQ_disable_linebreak:}
\def\EQ_disable_linebreak:{%
  \MH_let:NwN \EQ_saved_Let: \Let@
  \def\Let@{\def\\{%
    \PackageError{empheq}{You~ cannot~ use~ \string\\~ in~ equation!}
      {\@eha}}
    \MH_let:NwN \Let@ \EQ_saved_Let:
  }%
}
\EQ_new_equationtype:nnn {EmphEqEnv}{align}{1}
\EQ_new_equationtype:nnn {EmphEqEnv}{align*}{2}
\def\EQ_modify_linewidth_i:{%
  \if_num:w \maxfields@=\tw@
  \else:
    \setlength{\l_EQ_temp_linewidth_dim}{%
      \linewidth-\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
  \fi:}
\def\EQ_modify_linewidth_ii:{\EQ_modify_linewidth_i:}
\def\find_displaywidth_i:{%
  \MH_setlength:dn \l_EQ_displaywidth_dim
    {\l_EQ_temp_linewidth_dim-\alignsep@}
  \if_case:w \l_EQ_alignmentmode_int
  \or: % #1:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\alignsep@}%
  \or: % #2:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\alignsep@}%
  \or: % #3:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
  \or: % #4:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
  \fi:}
\def\find_displaywidth_ii:{\find_displaywidth_i:}
\def\EQ_place_display_i: {\EQ_use_mathdisplay:}
\def\EQ_place_display_ii:{\EQ_place_display_i:}
\EQ_new_equationtype:nnn {EmphEqEnv}{gather}{3}
\EQ_new_equationtype:nnn {EmphEqEnv}{gather*}{4}
\def\EQ_modify_linewidth_iii:{}
\def\EQ_modify_linewidth_iv:{\EQ_modify_linewidth_iii:}
\def\find_displaywidth_iii:{%
  \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
  \if_case:w \l_EQ_alignmentmode_int \or: \or: % #1 & #2:
  \or: % #3:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
  \or: % #4:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
  \fi:}
\def\find_displaywidth_iv:{\find_displaywidth_iii:}
\def\EQ_place_display_iii:{\EQ_use_mathdisplay:}
\def\EQ_place_display_iv: {\EQ_place_display_iii:}
\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}
  {flalign}{\MH_set_boolean_T:n {multline}}
\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline*}
  {flalign*}{\MH_set_boolean_T:n {multline}}
\MH_new_boolean:n {multline}
\def\EQ_multline_modify_linewidth_tag:{%
  \if_case:w \l_EQ_alignmentmode_int
  \or: % #1:
    \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
      -\g_EQ_widesttag_dim-\multlinetaggap-\multlinegap}%
  \or:
    \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
      -\g_EQ_widesttag_dim-\multlinetaggap-\multlinegap}%
  \or:
    \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
      -\@mathmargin-\g_EQ_widesttag_dim-\multlinetaggap}%
  \or:
    \MH_addtolength:dn
      \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
  \fi:
}
\def\EQ_multline_modify_linewidth_notag:{%
  \if_case:w \l_EQ_alignmentmode_int\or:
    \MH_addtolength:dn \l_EQ_temp_linewidth_dim{-2\multlinegap}
  \or:
    \MH_addtolength:dn \l_EQ_temp_linewidth_dim{-2\multlinegap}
  \or:
    \MH_addtolength:dn
      \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
  \or:
    \MH_addtolength:dn
      \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
  \fi:
}
\MH_let:NwN \MTmultlined \multlined
\MH_let:NwN \endMTmultlined \endmultlined
\MH_if_boolean:nTF {good_mult}{
\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}{gather}
  {\MH_set_boolean_T:n {outer_mult}}
\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline*}{gather*}
  {\MH_set_boolean_T:n {outer_mult}}
\def\EQ_modify_linewidth_iii_mult:{
  \setlength{\l_EQ_temp_linewidth_dim}{%
    \linewidth-\widthof{\EQ_outerbox:{}}}%
  \if_dim:w \g_EQ_widesttag_dim>\z@
    \EQ_multline_modify_linewidth_tag:
  \else:
    \EQ_multline_modify_linewidth_notag:
  \fi:
  \MH_setlength:dn \l_MT_multwidth_dim{\l_EQ_temp_linewidth_dim}
}
\def\EQ_modify_linewidth_iv_mult:{\EQ_modify_linewidth_iii_mult:}
\def\find_displaywidth_iii_mult:{%
  \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
  \if_case:w \l_EQ_alignmentmode_int \or: \or: % #1 & #2:
  \or: % #3:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
  \or: % #4:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
  \fi:}
\def\find_displaywidth_iv_mult:{\find_displaywidth_iii_mult:}
\def\EQ_place_display_iii_mult:{
  \if_case:w \l_EQ_alignmentmode_int
  \or: % #1:
    \if_dim:w \g_EQ_widesttag_dim>\z@
      \abovedisplayshortskip=\abovedisplayskip
      \rlap{
        \kern-.5\linewidth
        \kern\multlinegap
        \EQ_use_mathdisplay:
      }
    \else:
      \EQ_use_mathdisplay:
    \fi:
  \or: % #2:
    \if_dim:w \g_EQ_widesttag_dim>\z@
      \llap{
        \EQ_use_mathdisplay:
        \kern-.5\linewidth
        \kern\multlinegap
      }%
    \else:
      \EQ_use_mathdisplay:
    \fi:
  \or: % #3:
    \EQ_use_mathdisplay:
  \or: % #4:
    \EQ_use_mathdisplay:
  \fi:
}
\def\EQ_place_display_iv_mult: {\EQ_place_display_iii_mult:}
}{
\def\EQ_generic_multline:nnnnn #1#2#3#4#5{%
  \hskip1sp#2#3{{}#5}#4%
  \if:w *#1\relax\else:\notag\fi:}
\def\multleft{\@ifstar{%
  \MH_if_boolean:nTF {multlined}{
    \def\EQ_next:{\EQ_multlined_left:n}
  }{
    \def\EQ_next:{
      \EQ_generic_multline:nnnnn {*}{}{\mathrlap}{&&&&&}}
  }
  \EQ_next:}{%
  \MH_if_boolean:nTF {multlined}{
    \def\EQ_next:{\EQ_multlined_left:n}%
  }{
    \def\EQ_next:{
      \EQ_generic_multline:nnnnn {}{}{\mathrlap}{&&&&&}}
  }
  \EQ_next:}}%
\def\multcenter{\@ifstar{%
  \MH_if_boolean:nTF {multlined}{
    \def\EQ_next:{\EQ_multlined_center:n}%
  }{
    \def\EQ_next:{
      \EQ_generic_multline:nnnnn {*}{&&}{\mathclap}{&&&}}
  }
  \EQ_next:}{%
  \MH_if_boolean:nTF {multlined}{
    \def\EQ_next:{\EQ_multlined_center:n }%
  }{
    \def\EQ_next:{
      \EQ_generic_multline:nnnnn {}{&&}{\mathclap}{&&&}}
  }
  \EQ_next:}}%
\def\multright{\@ifstar{%
  \MH_if_boolean:nTF {multlined}{
    \def\EQ_next:{\EQ_multlined_right:n }%
  }{
    \def\EQ_next:{
      \EQ_generic_multline:nnnnn {*}{&&&&&}{\mathllap}{}}
  }
  \EQ_next:}{%
  \MH_if_boolean:nTF {multlined}{
    \def\EQ_next:{\EQ_multlined_right:n }%
  }{
    \def\EQ_next:{
      \EQ_generic_multline:nnnnn {}{&&&&&}{\mathllap}{}}
  }
  \EQ_next:}}
\def\multfirst{%
  \MH_if_boolean:nTF {multlined}{
     \def\EQ_next:{\EQ_multlined_left:n }%
  }{
    \if_case:w \l_EQ_alignmentmode_int
    \or: % #1:
      \def\EQ_next:{\multleft}%
    \or: % #2:
      \def\EQ_next:{\multleft*}%
    \or: % #3:
      \def\EQ_next:{\multleft}%
    \or: % #4:
      \def\EQ_next:{\multleft*}%
    \fi:
  }
  \EQ_next:}
\def\multmiddle{%
  \def\EQ_next:{%
    \MH_if_boolean:nTF {multlined}{
      \expandafter\EQ_multlined_center:n
    }{
      \expandafter\multcenter
    }
  }%
  \@ifstar{\EQ_next:}{\EQ_next:}}
\def\multlast{%
  \MH_if_boolean:nTF {multlined}{
     \def\EQ_next:{\EQ_multlined_right:n }%
  }{
    \if_case:w \l_EQ_alignmentmode_int
    \or: % #1:
      \def\EQ_next:{\multright*}%
    \or: % #2:
      \def\EQ_next:{\multright}%
    \or: % #3:
      \def\EQ_next:{\multright*}%
    \or: % #4:
      \def\EQ_next:{\multright}%
    \fi:
  }
  \EQ_next:}
\MH_new_boolean:n {multlined}
\newdimen\multlinedwidth
\MH_setlength:dn \multlinedwidth{.7\linewidth}
\renewenvironment{multlined}%
  {\MH_nospace_ifnextchar:Nnn [  {\EQ_multlined_I:w}
                                 {\EQ_multlined_I:w[c]}
  }
  { \endaligned }
\def\EQ_multlined_I:w[#1]{%
  \MH_nospace_ifnextchar:Nnn[  {\EQ_multlined_II:w[#1]}
                               {\EQ_multlined_II:w[#1][\multlinedwidth]}}
\def\EQ_multlined_II:w[#1][#2]{%
  \MH_set_boolean_T:n {multlined}
  \MH_let:NwN \Let@\MT_saved_Let:
  \if:w t#1\relax \EQ_multlined_III:nn {#1}{#2}%
  \else:
    \if:w b#1\relax \EQ_multlined_III:nn {#1}{#2}%
    \else:
      \if:w c#1\relax \EQ_multlined_III:nn {#1}{#2}%
      \else:
        \EQ_multlined_III:nn {#2}{#1}%
      \fi:
    \fi:
  \fi:
  \mkern-\thinmuskip
  \EQ_next:}
\def\EQ_multlined_III:nn #1#2{%
  \def\EQ_next:{\setlength\multlinedwidth{#2}%
                          \start@aligned{#1}{\thr@@}}}
\def\EQ_multlined_left:n #1{%
  \mathrlap{#1}&\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&}
\def\EQ_multlined_center:n #1{%
  &\hskip.5\multlinedwidth&&\mathclap{#1}\hskip.5\multlinedwidth&&}
\def\EQ_multlined_right:n #1{%
  &\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&\mathllap{#1}}
}
\EQ_new_equationtype:nnn {EmphEqEnv}{flalign}{5}
\EQ_new_equationtype:nnn {EmphEqEnv}{flalign*}{6}
\def\EQ_modify_linewidth_v:{%
  \setlength{\l_EQ_temp_linewidth_dim}{%
    \linewidth-\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
  \if_dim:w \g_EQ_widesttag_dim>\z@
    \MH_if_boolean:nTF {multline}{
      \EQ_multline_modify_linewidth_tag:
    }{
      \if_case:w \l_EQ_alignmentmode_int
      \or: % #1:
        \MH_addtolength:dn  \l_EQ_temp_linewidth_dim
          {-\g_EQ_widesttag_dim-\mintagsep}
      \or: % #2:
        \MH_addtolength:dn \l_EQ_temp_linewidth_dim
          {-\g_EQ_widesttag_dim-\mintagsep}%
      \or: % #3:
        \MH_addtolength:dn \l_EQ_temp_linewidth_dim
          {-\g_EQ_widesttag_dim-\mintagsep}
      \or: % #4:
        \MH_addtolength:dn \l_EQ_temp_linewidth_dim
          {-\@mathmargin}
      \fi:
    }
  \else:
    \MH_if_boolean:nT {multline}{
      \EQ_multline_modify_linewidth_notag:
    }
  \fi:}
\def\EQ_modify_linewidth_vi:{\EQ_modify_linewidth_v:}
\def\find_displaywidth_v:{%
  \MH_setlength:dn
    \l_EQ_displaywidth_dim{\l_EQ_temp_linewidth_dim}}
\def\find_displaywidth_vi:{\find_displaywidth_v:}
\def\EQ_place_display_v:{%
  \if_case:w \l_EQ_alignmentmode_int
  \or: % #1:
    \if_dim:w \g_EQ_widesttag_dim>\z@
      \MH_if_boolean:nTF {multline}{
        \rlap{\kern\multlinegap  \kern-.5\linewidth
          \EQ_use_mathdisplay:
          \kern-\mintagsep  \kern\multlinetaggap}%
      }{
        \rlap{\kern-.5\linewidth\EQ_use_mathdisplay:}%
      }
    \else:
      \EQ_use_mathdisplay:
    \fi:
  \or: % #2:
    \if_dim:w \g_EQ_widesttag_dim>\z@
      \MH_if_boolean:nTF {multline}{
        \llap{\kern-\mintagsep \kern\multlinetaggap
          \EQ_use_mathdisplay:
          \kern\multlinegap  \kern-.5\linewidth}%
      }{
        \llap{\EQ_use_mathdisplay:\kern-.5\linewidth}%
      }
    \else:
      \EQ_use_mathdisplay:
    \fi:
  \or: % #3:
    \MH_if_boolean:nF {multline}{ \kern-\multlinetaggap }
    \EQ_use_mathdisplay:
  \or: % #4:
    \if_dim:w \g_EQ_widesttag_dim>\z@
    \else:
      \MH_if_boolean:nF {multline}{ \kern-\@mathmargin }
    \fi:
    \EQ_use_mathdisplay:
  \fi:
  \MH_set_boolean_F:n {multline}}
\def\EQ_place_display_vi:{\EQ_place_display_v:}
\EQ_new_equationtype_arg:nnn {EmphEqEnv}{alignat}{7}
\EQ_new_equationtype_arg:nnn {EmphEqEnv}{alignat*}{8}
\def\EQ_modify_linewidth_vii:{}
\def\EQ_modify_linewidth_viii:{\EQ_modify_linewidth_vii:}
\def\find_displaywidth_vii:{%
  \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
  \if_case:w \l_EQ_alignmentmode_int
  \or: % #1:
  \or: % #2:
  \or: % #3:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\eqnshift@}%
  \or: % #4:
    \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
  \fi:}
\def\find_displaywidth_viii:{\find_displaywidth_vii:}
\def\EQ_place_display_vii:{\EQ_use_mathdisplay:}
\def\EQ_place_display_viii:{\EQ_place_display_vii:}
\define@key{\EQ_options_name:}{box}{\def\EQ_outerbox:{#1}}
\MH_keyval_alias:nnn {\EQ_options_name:}{outerbox}{box}
\def\EQ_marginbox:nn #1#2{%
  \settowidth{\@tempdima}{#2}%
  \makebox[\z@]{\hspace{\@tempdima}#1{#2}}}
\define@key{\EQ_options_name:}{marginbox}{%
  \def\EQ_outerbox:{\EQ_marginbox:nn {#1}}}
\define@key{\EQ_options_name:}{innerbox}{\def\EQ_innerbox:{#1}}
\define@key{\EQ_options_name:}{left}{\def\EQ_left_side:{#1}}
\define@key{\EQ_options_name:}{right}{\def\EQ_right_side:{#1}}
\newcommand*\empheqset[1]{\setkeys{\EQ_options_name:}{#1}}
\def\EQ_upgrade_error:{%
  \PackageError{empheq}
    {You~ are~ using~ the~ old~ syntax!\MessageBreak
    The~ `empheq'~ environment~ takes~ a~ mandatory~
    argument~ now.\MessageBreak
    You~ need~ to~ exit~ and~ change~ your~ source~ file.}
    {It~ won't~ work,~ trust me.~ Press~ `X'~ now.}}
\define@key{\EQ_options_name:}{boxtype}{\EQ_upgrade_error:}
\define@key{\EQ_options_name:}{Left}{\EQ_upgrade_error:}
\define@key{\EQ_options_name:}{Right}{\EQ_upgrade_error:}
\newenvironment{empheq}[2][]{%
  \setkeys{EmphEqEnv}{#2}\setkeys{\EQ_options_name:}{#1}%
  \EmphEqMainEnv}{\endEmphEqMainEnv}
\newcommand*\DeclareLeftDelimiter[2][]{%
  \EQ_declare_left_delimiter:nnnn {#1}{#2}{}{}%
  \EQ_declare_left_delimiter:nnnn {#1}{#2}{big}{\EQ_innerbox:}}
\def\EQ_declare_left_delimiter:nnnn #1#2#3#4{%
  \@namedef{empheq#3\expandafter\@gobble\string#2}{%
    \left#2%
    \mkern-\thinmuskip
    \vphantom{#4{\parbox{.5\maxdimen}{%
      \EQ_predisplay_adjustment:
      \EQ_prevent_vertical_space:
      \usebox{\EQ_tag_box}%
      \EQ_postdisplay_adjustment:}}}%
    \right.%
    \kern-\nulldelimiterspace #1}}
\newcommand*\DeclareRightDelimiter[2][]{%
  \EQ_declare_right_delimiter:nnnn {#1}{#2}{}{}%
  \EQ_declare_right_delimiter:nnnn {#1}{#2}{big}{\EQ_innerbox:}}
\def\EQ_declare_right_delimiter:nnnn #1#2#3#4{%
  \@namedef{empheq#3\expandafter\@gobble\string#2}{%
    \kern-\nulldelimiterspace
    #1%
    \left.%
    \vphantom{#4{\parbox{.5\maxdimen}{%
      \EQ_predisplay_adjustment:
      \EQ_prevent_vertical_space:
      \usebox{\EQ_tag_box}%
      \EQ_postdisplay_adjustment:}}}%
    \mkern-\thinmuskip
    \right#2}}
\DeclareLeftDelimiter{\lbrace}
\DeclareRightDelimiter{\rbrace}
\DeclareLeftDelimiter{\lbrack}
\DeclareRightDelimiter{\rbrack}
\DeclareLeftDelimiter{\langle}
\DeclareRightDelimiter{\rangle}
\DeclareLeftDelimiter{\lvert}
\DeclareRightDelimiter{\rvert}
\DeclareLeftDelimiter{\lVert}
\DeclareRightDelimiter{\rVert}
\DeclareLeftDelimiter{\lfloor}
\DeclareRightDelimiter{\rfloor}
\DeclareLeftDelimiter{\lceil}
\DeclareRightDelimiter{\rceil}
\DeclareLeftDelimiter{\lparen}
\DeclareRightDelimiter{\rparen}
\def\EQ_typeset_tags_hook:{}
\def\EQ_typeset_display_hook:{}
\g@addto@macro\EQ_typeset_display_hook:{
  \def\SK@@label#1>#2\SK@{}
}
\@namedef{SK@AmSequation}  {\SK@equationtrue}
\@namedef{SK@AmSequation*} {\SK@equationtrue}
\@namedef{SK@AmSalign}     {\SK@equationtrue}
\@namedef{SK@AmSalign*}    {\SK@equationtrue}
\@namedef{SK@AmSalignat}   {\SK@equationtrue}
\@namedef{SK@AmSalignat*}  {\SK@equationtrue}
\@namedef{SK@AmSgather}    {\SK@equationtrue}
\@namedef{SK@AmSgather*}   {\SK@equationtrue}
\@namedef{SK@AmSmultline}  {\SK@equationtrue}
\@namedef{SK@AmSmultline*} {\SK@equationtrue}
\@namedef{SK@AmSflalign}   {\SK@equationtrue}
\@namedef{SK@AmSflalign*}  {\SK@equationtrue}
\AtBeginDocument{
  \@ifundefined{Hy@linkcounter}{\newcount\Hy@linkcounter}{}
}
\g@addto@macro\EQ_typeset_display_hook:{
  \MH_let:NwN \hyper@refstepcounter\@gobble
}
 \g@addto@macro\EQ_typeset_display_hook:{
   \let\NCC@ignorepar\relax
 }
 \g@addto@macro\EQ_typeset_tags_hook:{
   \let\NCC@ignorepar\relax
 }
\g@addto@macro\EQ_typeset_tags_hook:{
  \MH_let:NwN\TagsPlusEndmarks\relax
  \MH_let:NwN\RestoreTags\relax
}
\g@addto@macro\EQ_typeset_display_hook:{
  \MH_let:NwN\TagsPlusEndmarks\relax
  \MH_let:NwN\RestoreTags\relax
}
\g@addto@macro\EQ_typeset_display_hook:{
  \MH_let:NwN\ltx@label\MT_gobblelabel:w
  \MH_let:NwN \GenericError \@gobblefour
}
\AtBeginDocument{%
  \@ifpackageloaded{fancybox}{%
    \@ifpackageloaded{color}{\definecolor{shadowcolor}{rgb}{0,0,0}}%
    {\newcommand*\textcolor[2]{\normalcolor{#2}}}%
    \MH_new_boolean:n {shadowbox_star}
    \renewcommand*\shadowbox{%
      \@ifstar{\MH_set_boolean_T:n {shadowbox_star}
               \VerbBox\EQ_shadowbox:n}
              {\MH_set_boolean_F:n {shadowbox_star}
               \VerbBox\EQ_shadowbox:n}}
    \def\EQ_shadowbox:n #1{%
      \sbox{\z@}{\fbox{#1}}%
      \MH_if_boolean:nTF {shadowbox_star}{
        \MH_setlength:dn \@tempdima{\z@}%
      }{
        \MH_setlength:dn \@tempdima{\dp\z@+\shadowsize}%
      }
      \raisebox{\@tempdima}{%
        \makebox[\z@][l]{%
          \kern\shadowsize \textcolor{shadowcolor}{%
            \rule[-\dp\z@-\shadowsize]{\wd\z@}{\shadowsize}}%
        }%
        \usebox\z@\textcolor{shadowcolor}{%
          \rule[-\dp\z@-\shadowsize]{\shadowsize}{\ht\z@+\dp\z@}}}}%
  }{}%
}
\def\EQ_overload_ams_begin:n #1{%
  \MH_let:cc {AmS#1}{#1}%
  \MH_let:cc {AmS#1*}{#1*}
}
\def\EQ_overload_ams_end:n #1{%
  \MH_let:cc {endAmS#1}{endAmSalign}
}
\AtBeginDocument{
  \EQ_overload_ams_begin:n {equation}
  \MH_let:cc {endAmSequation}{endequation}
  \MH_let:cc {endAmSequation*}{endequation*}
  \MH_if_boolean:nT {overload_ams}{
    \def\EQ_renew_ams_environment:n #1{%
      \MaybeMHPrecedingSpacesOff
      \renewenvironment{#1}[1][]{%
        \setkeys{\EQ_options_name:}{##1}%
        \setkeys{EmphEqEnv}{AmS#1}%
        \EmphEqMainEnv
      }{\endEmphEqMainEnv}
      \MHPrecedingSpacesOn
    }
    \EQ_new_equationtype:nnn     {EmphEqEnv}{AmSalign}   {1}
    \EQ_new_equationtype:nnn     {EmphEqEnv}{AmSalign*}  {2}
    \EQ_new_equationtype:nnn     {EmphEqEnv}{AmSgather}  {3}
    \EQ_new_equationtype:nnn     {EmphEqEnv}{AmSgather*} {4}
    \EQ_new_equationtype:nnn     {EmphEqEnv}{AmSflalign} {5}
    \EQ_new_equationtype:nnn     {EmphEqEnv}{AmSflalign*}{6}
    \EQ_new_equationtype_arg:nnn {EmphEqEnv}{AmSalignat} {7}
    \EQ_new_equationtype_arg:nnn {EmphEqEnv}{AmSalignat*}{8}
    \EQ_overload_ams_begin:n {gather}
    \MH_let:cc {endAmSgather}{endgather}
    \MH_let:cc {endAmSgather*}{endAmSgather}
    \EQ_renew_ams_environment:n {gather}
    \EQ_renew_ams_environment:n {gather*}
    \EQ_overload_ams_begin:n {equation}
    \MH_keyval_alias_with_addon:nnnn {EmphEqEnv} {AmSequation}
      {AmSgather}{\EQ_disable_linebreak:}
    \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSequation*}
      {AmSgather*}{\EQ_disable_linebreak:}
    \EQ_renew_ams_environment:n {equation}
    \EQ_renew_ams_environment:n {equation*}
    \EQ_overload_ams_begin:n {align}
    \MH_let:cc {endAmSalign}{endalign}
    \EQ_overload_ams_end:n {align*}
    \EQ_renew_ams_environment:n {align}
    \EQ_renew_ams_environment:n {align*}
    \EQ_overload_ams_begin:n {flalign}
    \EQ_overload_ams_end:n {flalign}
    \EQ_overload_ams_end:n {flalign*}
    \EQ_renew_ams_environment:n {flalign}
    \EQ_renew_ams_environment:n {flalign*}
    \EQ_overload_ams_begin:n {alignat}
    \EQ_overload_ams_end:n {alignat}
    \EQ_overload_ams_end:n {alignat*}
    \MaybeMHPrecedingSpacesOff
    \newcommand*\EQ_alignat_optional:w [1][]{
      \setkeys{\EQ_options_name:}{#1}
      \EmphEqMainEnv}
    \MHPrecedingSpacesOn
    \renewenvironment{alignat}[1]{
      \setkeys{EmphEqEnv}{AmSalignat=#1}
      \EQ_alignat_optional:w}
      {\endEmphEqMainEnv}
    \renewenvironment{alignat*}[1]{%
      \setkeys{EmphEqEnv}{AmSalignat*=#1}%
      \EQ_alignat_optional:w}%
      {\endEmphEqMainEnv}
    \DeclareRobustCommand{\[}{\begin{AmSequation*}}
    \DeclareRobustCommand{\]}{\end{AmSequation*}}
    \MH_keyval_alias:nnn {EmphEqEnv}{gather}  {AmSgather}
    \MH_keyval_alias:nnn {EmphEqEnv}{gather*} {AmSgather*}
    \MH_keyval_alias:nnn {EmphEqEnv}{align}   {AmSalign}
    \MH_keyval_alias:nnn {EmphEqEnv}{align*}  {AmSalign*}
    \MH_keyval_alias:nnn {EmphEqEnv}{flalign} {AmSflalign}
    \MH_keyval_alias:nnn {EmphEqEnv}{flalign*}{AmSflalign*}
    \MH_keyval_alias:nnn {EmphEqEnv}{alignat} {AmSalignat}
    \MH_keyval_alias:nnn {EmphEqEnv}{alignat*}{AmSalignat*}
    \MH_if_boolean:nT {good_mult}{
      \EQ_overload_ams_begin:n {multline}
      \MH_let:cc {endAmSmultline}{endmultline}
      \MH_let:cc {endAmSmultline*}{endAmSmultline}
      \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline}
        {AmSgather}{\MH_set_boolean_T:n {outer_mult}}
      \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline*}
        {AmSgather*}{\MH_set_boolean_T:n {outer_mult}}
      \EQ_renew_ams_environment:n {multline}
      \EQ_renew_ams_environment:n {multline*}
    }
    \MH_if_boolean:nT {overload_amsII}{
      \MH_protected:\def\[#1\]{\begin{equation*} #1\end{equation*}}
      \MH_if_boolean:nF {good_mult}{
        \EQ_overload_ams_begin:n {multline}
        \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline}
          {AmSflalign}{\MH_set_boolean_T:n {multline}}
        \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline*}
          {AmSflalign*}{\MH_set_boolean_T:n {multline}}
        \EQ_renew_ams_environment:n {multline}
        \EQ_renew_ams_environment:n {multline*}
      }
    }
  }
}
\if\g@EQ@ntheorem@support@bool
\else
  \expandafter\endinput
\fi
\def\default_raisetag:{\nobreak}
\def\raisetag#1{
  \skip@#1\relax
  \xdef\raise@tag{\default_raisetag:
                  \vskip\iftagsleft@\else:-\fi:\the\skip@\relax}}
\MH_let:NwN\raise@tag\default_raisetag:
\def\displ@y@{\@display@init{%
  \global\column@\z@ \global\dspbrk@lvl\m@ne
  \global\tag@false \global\MH_let:NwN\raise@tag\default_raisetag:
}}
\def\MT_gobblelabel:w #1{\@ifnextchar[{\EQ_gobbleoptional:w}{}}
\def\EQ_gobbleoptional:w [#1]{}
\def\gmeasure@#1{%
  \begingroup
    \measuring@true
    \totwidth@\z@
    \global\MH_let:NwN\tag@lengths\@empty
    \savecounters@
    \setbox\@ne\vbox{%
      \everycr{\noalign{\global\tag@false
        \global\MH_let:NwN\raise@tag\default_raisetag:
        \global\column@\z@}}%
      \MH_let:NwN\label\MT_gobblelabel:w
      \halign{%
        \setboxz@h{$\m@th\displaystyle{##}$}%
        \if_dim:w \wdz@>\totwidth@
          \global\totwidth@\wdz@
        \fi:
        &\setboxz@h{\strut@{##}}%
        \savetaglength@
        \crcr
        #1%
        \math@cr@@@
      }%
    }%
    \restorecounters@
    \if@fleqn
        \global\advance\totwidth@\@mathmargin
    \fi:
    \iftagsleft@
        \if_dim:w \totwidth@>\displaywidth
            \global\MH_let:NwN\gdisplaywidth@\totwidth@
        \else:
            \global\MH_let:NwN\gdisplaywidth@\displaywidth
        \fi:
    \fi:
  \endgroup
}
\def\measure@#1{%
  \begingroup
    \measuring@true
    \global\eqnshift@\z@
    \global\alignsep@\z@
    \global\MH_let:NwN\tag@lengths\@empty
    \global\MH_let:NwN\field@lengths\@empty
    \savecounters@
    \global\setbox0\vbox{%
      \MH_let:NwN\math@cr@@@\math@cr@@@align@measure
      \everycr{\noalign{\global\tag@false
        \global\MH_let:NwN\raise@tag\default_raisetag:
        \global\column@\z@}}%
      \MH_let:NwN\label\MT_gobblelabel:w
      \global\row@\z@
      \tabskip\z@
      \halign{\span\align@preamble\crcr
        #1%
        \math@cr@@@
        \global\column@\z@
        \add@amps\maxfields@\cr
      }%
    }%
    \restorecounters@
    \ifodd\maxfields@
      \global\advance\maxfields@\@ne
    \fi:
    \if_num:w \xatlevel@=\tw@
      \if_num:w \maxfields@<\thr@@
        \MH_let:NwN\xatlevel@\z@
      \fi:
    \fi:
    \setbox\z@\vbox{%
      \unvbox\z@ \unpenalty \global\setbox\@ne\lastbox
    }%
    \global\totwidth@\wd\@ne
    \if@fleqn \global\advance\totwidth@\@mathmargin \fi:
    \global\MH_let:NwN\maxcolumn@widths\@empty
    \begingroup
      \MH_let:NwN\or:\relax
      \loop
        \global\setbox\@ne\hbox{%
          \unhbox\@ne \unskip \global\setbox\thr@@\lastbox
        }%
      \ifhbox\thr@@
        \xdef\maxcolumn@widths{ \or: \the\wd\thr@@ \maxcolumn@widths}%
      \repeat
    \endgroup
    \dimen@\displaywidth
    \advance\dimen@-\totwidth@
    \if_case:w \xatlevel@
      \global\alignsep@\z@
      \MH_let:NwN\minalignsep\z@
      \@tempcntb\z@
      \if@fleqn
        \@tempcnta\@ne
        \global\eqnshift@\@mathmargin
      \else:
        \@tempcnta\tw@
        \global\eqnshift@\dimen@
        \global\divide\eqnshift@\@tempcnta
      \fi:
    \or:
      \@tempcntb\maxfields@
      \divide\@tempcntb\tw@
      \@tempcnta\@tempcntb
      \advance\@tempcntb\m@ne
      \if@fleqn
        \global\eqnshift@\@mathmargin
        \global\alignsep@\dimen@
        \global\divide\alignsep@\@tempcnta
      \else:
        \global\advance\@tempcnta\@ne
        \global\eqnshift@\dimen@
        \global\divide\eqnshift@\@tempcnta
        \global\alignsep@\eqnshift@
      \fi:
    \or:
      \@tempcntb\maxfields@
      \divide\@tempcntb\tw@
      \global\advance\@tempcntb\m@ne
      \global\@tempcnta\@tempcntb
      \global\eqnshift@\z@
      \global\alignsep@\dimen@
      \if@fleqn
        \global\advance\alignsep@\@mathmargin\relax
      \fi:
      \global\divide\alignsep@\@tempcntb
    \fi:
    \if_dim:w \alignsep@<\minalignsep\relax
      \global\alignsep@\minalignsep\relax
      \if_dim:w \eqnshift@>\z@
        \if@fleqn\else:
          \global\eqnshift@\displaywidth
          \global\advance\eqnshift@-\totwidth@
          \global\advance\eqnshift@-\@tempcntb\alignsep@
          \global\divide\eqnshift@\tw@
        \fi:
      \fi:
    \fi:
    \if_dim:w \eqnshift@<\z@
      \global\eqnshift@\z@
    \fi:
    \calc@shift@align
    \global\tagshift@\totwidth@
    \global\advance\tagshift@\@tempcntb\alignsep@
    \if@fleqn
      \if_num:w \xatlevel@=\tw@
        \global\advance\tagshift@-\@mathmargin\relax
      \fi:
    \else:
      \global\advance\tagshift@\eqnshift@
    \fi:
    \iftagsleft@ \else:
      \global\advance\tagshift@-\displaywidth
    \fi:
    \dimen@\minalignsep\relax
    \global\advance\totwidth@\@tempcntb\dimen@
    \if_dim:w \totwidth@>\displaywidth
      \global\MH_let:NwN\displaywidth@\totwidth@
    \else:
      \global\MH_let:NwN\displaywidth@\displaywidth
    \fi:
  \endgroup
}
\def\EQ_multline_labelhack:n #1{%
  \begingroup\measuring@false\label@in@display{#1}\endgroup}
\def\EQ_multline_labelhack_opt:nw #1[#2]{%
  \begingroup\measuring@false\label@in@display{#1}[#2]\endgroup}
\def\multline@#1{%
  \Let@
  \@display@init{\global\advance\row@\@ne \global\dspbrk@lvl\m@ne}%
  \chardef\dspbrk@context\z@
  \restore@math@cr
  \MH_let:NwN\tag\tag@in@align
  \global\tag@false \global\MH_let:NwN\raise@tag\default_raisetag:
  \mmeasure@{#1}%
  \MH_let:NwN\tag\gobble@tag
  \MH_let:NwN\label\MT_gobblelabel:w
  \tabskip \if@fleqn \@mathmargin \else: \z@skip \fi:
  \totwidth@\displaywidth
  \if@fleqn
    \advance\totwidth@-\@mathmargin
  \fi:
  \halign\bgroup
    \hbox to\totwidth@{%
      \if@fleqn
        \hskip \@centering \relax
      \else:
        \hfil
      \fi:
      \strut@
      $\m@th\displaystyle{}##\endmultline@math%$
      \hfil
    }%
    \crcr
    \if@fleqn
      \hskip-\@mathmargin
      \def\multline@indent{\hskip\@mathmargin}% put it back
    \else:
      \hfilneg
      \def\multline@indent{\hskip\multlinegap}%
    \fi:
    \iftagsleft@
      \iftag@
        \begingroup
          \ifshifttag@
            \rlap{\vbox{%
              \normalbaselines
              \hbox{%
                \strut@
                \make@display@tag
              }%
              \vbox to\lineht@{}%
              \raise@tag
            }}%
              \multline@indent
          \else:
            \setbox\z@\hbox{\make@display@tag}%
            \dimen@\@mathmargin \advance\dimen@-\wd\z@
            \if_dim:w \dimen@<\multlinetaggap
              \dimen@\multlinetaggap
            \fi:
            \box\z@ \hskip\dimen@\relax
          \fi:
        \endgroup
      \else:
        \multline@indent
      \fi:
    \else:
      \multline@indent
    \fi:
  #1%
}
\def\mmeasure@#1{%
  \begingroup
    \measuring@true
    \def\label##1{%
      \@ifnextchar[
        {\EQ_multline_labelhack_opt:nw {##1}}
        {\EQ_multline_labelhack:n {##1}}
    }
    \def\math@cr@@@{\cr}%
    \MH_let:NwN\shoveleft\@iden \MH_let:NwN\shoveright\@iden
    \savecounters@
    \global\row@\z@
    \setbox\@ne\vbox{%
      \global\MH_let:NwN\df@tag\@empty
      \halign{%
        \setboxz@h{\@lign$\m@th\displaystyle{}##$}%
        \iftagsleft@
          \if_num:w \row@=\@ne
            \global\totwidth@\wdz@
            \global\lineht@\ht\z@
          \fi:
        \else:
          \global\totwidth@\wdz@
          \global\lineht@\dp\z@
        \fi:
        \crcr
        #1%
        \crcr
      }%
    }%
    \if_meaning:NN
      \df@tag\@empty
    \else:
      \global\tag@true
    \fi:
    \if@eqnsw\global\tag@true\fi:
    \iftag@
      \setboxz@h{%
        \if@eqnsw
          \stepcounter{equation}%
          \tagform@\theequation
        \else:
          \df@tag
        \fi:
      }%
      \global\tagwidth@\wdz@
      \dimen@\totwidth@
      \advance\dimen@\tagwidth@
      \advance\dimen@\multlinetaggap
      \iftagsleft@\else:
        \if@fleqn
          \advance\dimen@\@mathmargin
        \fi:
      \fi:
      \if_dim:w \dimen@>\displaywidth
        \global\shifttag@true
      \else:
        \global\shifttag@false
      \fi:
    \fi:
    \restorecounters@
  \endgroup
}
\newlength\mintagvsep
\mintagvsep5pt
\def\EQ_only_endmark:{%
  \MH_set_boolean_T:n {show_manual_tags}
  \global\tag@true
  \iftagsleft@
    \gdef\df@tag{%
      \hbox to \displaywidth{%
        \hss
        \raisebox{-\normallineskip
                  -\depthof{\EQ_outerbox:{}}
                  -\heightof{\EQ_outerbox:{}}
                  -\dp\EQ_mathdisplay_box
                  -\ht\EQ_mathdisplay_box}
                 [0pt][0pt]{\PotEndMark{\maketag@@@}}}}
  \else:
    \gdef\df@tag{%
      \raisebox{-\dp\EQ_mathdisplay_box
                -\depthof{\EQ_outerbox:{}}}
               {\PotEndMark{\maketag@@@}}}%
  \fi:}
\def\EQ_tag_plus_endmark:{%
  \iftagsleft@
    \gdef\maketag@@@##1{%
      \hfuzz\displaywidth
      \makebox[\widthof{##1}][l]{%
        \hbox to \displaywidth{\m@th\normalfont##1\hss
          \raisebox{-\dp\EQ_mathdisplay_box
                    -\depthof{\EQ_outerbox:{}}}
                   {\PotEndMark{\hss}}}}}%
  \else:
    \gdef\maketag@@@##1{%
      \hbox{\m@th\normalfont##1\llap{\hss\PotEndMark{%
        \settoheight{\@tempdima}{\@nameuse{\InTheoType Symbol}}%
        \MH_addtolength:dn \@tempdima
          {\g_EQ_bottomtag_depth_dim+\mintagvsep}
        \setlength{\@tempdimb}
          {\g_EQ_bottomrow_depth_dim+\depthof{\EQ_outerbox:{}}
            +\depthof{\EQ_innerbox:{}}}
        \if_dim:w \@tempdima>\@tempdimb
          \MH_setlength:dn \@tempdima{-\dp\EQ_mathdisplay_box
            -\@tempdima+\g_EQ_bottomrow_depth_dim}
          \addtolength{\@tempdima}{\depthof{\EQ_innerbox:{}}}%
          \def\EQ_next:{\raisebox{\@tempdima}}%
        \else:
          \def\EQ_next:{
            \raisebox{-\dp\EQ_mathdisplay_box
                      -\depthof{\EQ_outerbox:{}}}}%
        \fi:\EQ_next:}}}}%
  \fi:}
\MH_let:NwN \MT_nonumber: \nonumber
\def\g_EQ_latest_nonzerodepth_row_fint{\z@}
\renewcommand*\nonumber{
  \@tempcnta=\row@
  \if_num:w \l_EQ_equationtype_int=\thr@@
    \advance\@tempcnta\m@ne
  \else:
    \if_num:w \l_EQ_equationtype_int=4\relax
      \advance\@tempcnta\m@ne
    \fi:
  \fi:
  \if_num:w \g_EQ_latest_nonzerodepth_row_fint=\@tempcnta
  \else:
    \global\g_EQ_bottomtag_depth_dim=-\baselineskip
  \fi:
  \MT_nonumber:
}
\endinput
%%
%% End of file `empheq.sty'.
