5

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

0

3 Answers 3

7

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.

1
  • Ah, thanks. I didn't know about alignedat*.
    – Geremia
    Oct 13, 2013 at 2:03
2

If you want to align parenthesis, this does it.

   \documentclass{article}
    \usepackage{mathtools}
    \usepackage[T1]{fontenc}
    \begin{document}
    \begin{equation}
    \begin{dcases}
    \label{eq:115}
    \begin{split}
       U(x,y,z,t)=\int\frac{x'-x}{r^3}[\hphantom{{}+{}} &(x'-x)u(x',y',z',t)\\[-2\jot]
                                        {}+{}&(y'-y)v(x',y',z',t)\\
                                        {}+{}&(z'-z)w(x',y',z',t)]d\omega',
      \end{split}\\
    V(x,y,z,t)=\ldots\ldots,\quad W(x,y,z,t)=\ldots\ldots
   \end{dcases}
   \end{equation}
    \end{document}

enter image description here

You may prefer to remove \hphantom{{}+{}} if you wish.

2
  • 2
    since the + signs continue an existing formula, you should put empty groups around them to get the correct spacing: {}+{}. Oct 12, 2013 at 17:30
  • @barbarabeeton Thanks for the official confirmation.
    – user11232
    Oct 12, 2013 at 21:44
1

A few ideas on how to typeset your formulas.

Code

\documentclass{article}
\usepackage{mathtools} % loads amsmath
\begin{document}

\begin{align}
  U(x,y,z,t) & = \int\frac{x'-x}{r^3} (x',y',z',t)
    \bigl[ (x'-x)u + (y'-y)v + (z'-z)w \bigr] d\omega' \\
  V(x,y,z,t) & = \ldots \\
  W(x,y,z,t) & = \ldots
\end{align}

\begin{equation}\left\{\begin{aligned}
  U(x,y,z,t) & = \int\frac{x'-x}{r^3} (x',y',z',t)
    \bigl[ (x'-x)u + (y'-y)v + (z'-z)w \bigr] d\omega' \\
  V(x,y,z,t) & = \ldots \\
  W(x,y,z,t) & = \ldots
\end{aligned}\right.\end{equation}

\begin{equation}\left\{\begin{gathered}
  \begin{multlined}
  U(x,y,z,t) = \int\frac{x'-x}{r^3}  \\
    \bigl[ (x'-x)u(x',y',z',t) + (y'-y)v(x',y',z',t) + (z'-z)w(x',y',z',t) \bigr] \\
    d\omega'
  \end{multlined} \\
  V(x,y,z,t) = \ldots \hfill\\
  W(x,y,z,t) = \ldots \hfill
\end{gathered}\right.\end{equation}
\end{document}

Output

enter image description here

1
  • I do want the 2nd and 3rd equations on one line, though.
    – Geremia
    Oct 13, 2013 at 2:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .