[Tex/LaTex] alignat inside align environment

alignamsmathequationshorizontal alignmentmultline

Why can't I nest an alignat environment in an align environment?

\begin{equation}
  \label{eq:115}
  \left\{
    \begin{aligned}
      \begin{alignat*}{2}
        &U(x,y,z,t)=\int\frac{x'-x}{r^3}[& &(x'-x)u(x',y',z',t)\\
        &                                &+&(y'-y)v(x',y',z',t)\\
        &                                &+&(z'-z)w(x',y',z',t)]d\omega',
      \end{alignat*}\\
        V(x,y,z,t)=.....,\quad W(x,y,z,t)=..... .
    \end{aligned}
  \right.
\end{equation}

The following compiles, but the first "+" sign of the second equation line doesn't align up very well with the phantom "+" of the first equation:

\begin{equation}
  \begin{dcases}
    \label{eq:115}
    {\begin{aligned}
        U(x,y,z,t)=\int\frac{x'-x}{r^3}[&\phantom{+}(x'-x)u(x',y',z',t)\\
                                        &+(y'-y)v(x',y',z',t)\\
                                        &+(z'-z)w(x',y',z',t)]d\omega',
      \end{aligned}}\\
    V(x,y,z,t)=\ldots\ldots,\quad W(x,y,z,t)=\ldots\ldots
  \end{dcases}
\end{equation}

thanks

Best Answer

the easiest fix is to use your second attempt, but instead of just \phantom{+}, surround the plus sign by empty groups to force the correct spacing:

\begin{equation}
  \begin{dcases}
    \label{eq:115}
    {\begin{aligned}
        U(x,y,z,t)=\int\frac{x'-x}{r^3}[&\phantom{{}+{}}(x'-x)u(x',y',z',t)\\
                                        &+(y'-y)v(x',y',z',t)\\
                                        &+(z'-z)w(x',y',z',t)]d\omega',
      \end{aligned}}\\
    V(x,y,z,t)=\ldots\ldots,\quad W(x,y,z,t)=\ldots\ldots
  \end{dcases}
\end{equation}

for your first attempt, alignat* isn't meant to be embedded. instead, alignedat (defined by mathtools) is appropriate. but you will still need to add empty groups around plus signs, in this case, the two that are between the ampersands:

\begin{equation}
  \label{eq:115}
  \left\{
    \begin{aligned}
      \begin{alignedat}{2}
        &U(x,y,z,t)=\int\frac{x'-x}{r^3}[& &(x'-x)u(x',y',z',t)\\
        &                                &{}+{}&(y'-y)v(x',y',z',t)\\
        &                                &{}+{}&(z'-z)w(x',y',z',t)]d\omega',
      \end{alignedat}\\
        V(x,y,z,t)=.....,\quad W(x,y,z,t)=..... .
    \end{aligned}
  \right.
\end{equation}

output of code input

i'm also not sure why you didn't use cases, but that's a niggle.