[texhax] aligned nested in a multlined nested in an align

Morten Høgholm morten.hoegholm at gmail.com
Fri Jun 22 16:08:43 CEST 2007

On 6/21/07, Ignacy Gawedzki <texhax at qult.net> wrote:

Hi Ignacy,

> It's been already a few times when I wanted to nest an aligned environment in
> a multlined environment (from mathtools), itself being nested in an align
> environment.  As soon as there are '&' in the aligned environment, LaTeX
> complains:
>
>   ERROR: Argument of \multlined has an extra }.

Ah yes, I see. Best thing to do is to contact the author... Oh wait,
that's me. :-)

Fixing the problem is relatively simple given that one knows which
dirty trick to use. Place the following in your preamble and it'll fix
the problem.

\MHInternalSyntaxOn

\renewenvironment{multlined}[1][]{
\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}}
{
\if_meaning:NN \@empty#1\@empty
\else:
\setlength \l_MT_multwidth_dim{#1}
\fi:
}
\MT_multlined_second_arg:w
}
{
\hfilneg  \endaligned
\ifnum0={\fi\iffalse}\fi % added
}

\MHInternalSyntaxOff

The latter \iffalse ... \fi can be shortened even more but this way
there is at least a small chance you will keep your sanity. See
Appendix D of The TeXbook for more on this.

I will fix this in the source.

Cheers,
--
Morten