5

I would like the first two pieces in align look as though they are the only two items in the align environment and the rest to align at the equals signs and separated by some space for the different equality.

Right now it compiles looking like:

enter image description here

So the first two I would like to align as such:

enter image description here

and the last equalities I would like to align as

enter image description here

\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\begin{document}
\begin{alignat*}{2}
    \vec{x}_1(t) &=
    \begin{pmatrix}
      x_1^{(1)}(t)\\
      x_2^{(1)}(t)
    \end{pmatrix} &&{}=
    \begin{pmatrix}
      X_1^{(1)}\cos(\omega_1t + \phi_1)\\
      r_1X_1^{(1)}\cos(\omega_1t + \phi_1)
    \end{pmatrix}\\
    \vec{x}_2(t) &=
    \begin{pmatrix}
      x_1^{(2)}(t)\\
      x_2^{(2)}(t)
    \end{pmatrix} &&{}=
    \begin{pmatrix}
      X_1^{(2)}\cos(\omega_2t + \phi_2)\\
      r_2X_1^{(2)}\cos(\omega_2t + \phi_2)
    \end{pmatrix}\\
    r_1 &=
    \begin{aligned}
      \frac{3k - m\omega_1^2}{2k} && \qquad
      X_1^{(1)} &&{}= \frac{1}{r_2 - r_1}\bigg[(r_2x_1(0) - x_2(0))^2 +
      \frac{(-r_2\dot{x}_1(0) + \dot{x}_2(0))^2}{\omega_1^2}\bigg]^{1/2}
    \end{aligned}\\
    r_2 &=
    \begin{aligned}
      \frac{3k - m\omega_2^2}{2k} && \qquad
      X_1^{(2)} &&{}= \frac{1}{r_2 - r_1}\bigg[(-r_1x_1(0) + x_2(0))^2 +
      \frac{(r_1\dot{x}_1(0) - \dot{x}_2(0))^2}{\omega_2^2}\bigg]^{1/2}
    \end{aligned}\\
    \phi_1 &=
    \begin{aligned}
      \arctan\bigg[\frac{-r_2\dot{x}_1(0) + \dot{x}_2(0)}
      {\omega_1^2(r_2x_1(0) - x_2(0))}\bigg] && \qquad
      \phi_2 &&{}= \arctan\bigg[\frac{r_1\dot{x}_1(0) - \dot{x}_2(0)}
      {\omega_2^2(-r_1x_1(0) + x_2(0))}\bigg]
    \end{aligned}
  \end{alignat*}
\end{document}
dustin
  • 18,617
  • 23
  • 99
  • 204

2 Answers2

6

enter image description here

\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\begin{document}
\begin{alignat*}{2}
    \vec{x}_1(t) &=
    \begin{pmatrix}
      x_1^{(1)}(t)\\
      x_2^{(1)}(t)
    \end{pmatrix} =
    \mathrlap{\begin{pmatrix}
      X_1^{(1)}\cos(\omega_1t + \phi_1)\\
      r_1X_1^{(1)}\cos(\omega_1t + \phi_1)
    \end{pmatrix}}\\
    \vec{x}_2(t) &=
    \begin{pmatrix}
      x_1^{(2)}(t)\\
      x_2^{(2)}(t)
    \end{pmatrix} =
    \mathrlap{\begin{pmatrix}
      X_1^{(2)}\cos(\omega_2t + \phi_2)\\
      r_2X_1^{(2)}\cos(\omega_2t + \phi_2)
    \end{pmatrix}}\\
    r_1 &=
      \frac{3k - m\omega_1^2}{2k} &
      X_1^{(1)} &= \frac{1}{r_2 - r_1}\bigg[(r_2x_1(0) - x_2(0))^2 +
      \frac{(-r_2\dot{x}_1(0) + \dot{x}_2(0))^2}{\omega_1^2}\bigg]^{1/2}
\\
    r_2 &=
      \frac{3k - m\omega_2^2}{2k} &
      X_1^{(2)} &= \frac{1}{r_2 - r_1}\bigg[(-r_1x_1(0) + x_2(0))^2 +
      \frac{(r_1\dot{x}_1(0) - \dot{x}_2(0))^2}{\omega_2^2}\bigg]^{1/2}
\\
    \phi_1 &=
      \arctan\bigg[\frac{-r_2\dot{x}_1(0) + \dot{x}_2(0)}
      {\omega_1^2(r_2x_1(0) - x_2(0))}\bigg] &
\phi_2 &= \arctan\bigg[\frac{r_1\dot{x}_1(0) - \dot{x}_2(0)}
      {\omega_2^2(-r_1x_1(0) + x_2(0))}\bigg]
  \end{alignat*}
\end{document}
David Carlisle
  • 757,742
  • 2
    I'd be inclined to leave a tad more space between the two formulas on the last line. a \quad before the \phi should fix that. – barbara beeton Nov 07 '14 at 19:25
  • @barbarabeeton yes I thought same after posting the image, but I had to leave the house to collect a boy:-) – David Carlisle Nov 07 '14 at 21:38
  • 1
    Here's a case where it makes a considerable difference in the output if one writes \arctan\bigg[ or \arctan\biggl[. The former code tells TeX to insert a thinspace (inappropriately, I believe) between arctan and the opening square bracket; this doesn't happen if you write \arctan\biggl[. See http://tex.stackexchange.com/a/144439/5001 for further examples of why it pays to use \biggl[ and \biggr] instead of \bigg[ and \bigg]. Shameless self-citation alert!! – Mico Nov 07 '14 at 23:12
3

I don't understand what's supposed to be achieved by the proposed layout and the attendant alignment of various = symbols. Rather than create the impression that various equations are related in ways that are probably not intended, I'd simplify the layout and get by with a single align* environment and use \qquad statements to insert some horizontal whitespace where needed. Observe that it's important to use \biggl[ instead of just \bigg[ following the two \arctan statements; if you omit the l (mathopen) specifiers, LaTeX will insert an inappropriate whitespace.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "align*" and "pmatrix" environments
\usepackage{newpxtext}             % Palatino text font
\usepackage[euler-digits]{eulervm} % Euler math font
\begin{document}
\begin{align*}
    \vec{x}_1(t) &=
    \begin{pmatrix}
      x_1^{(1)}(t)\\
      x_2^{(1)}(t)
    \end{pmatrix} =
    \begin{pmatrix}
      X_1^{(1)}\cos(\omega_1t + \phi_1)\\
      r_1X_1^{(1)}\cos(\omega_1t + \phi_1)
    \end{pmatrix}\\
    \vec{x}_2(t) &=
    \begin{pmatrix}
      x_1^{(2)}(t)\\
      x_2^{(2)}(t)
    \end{pmatrix} =
    \begin{pmatrix}
      X_1^{(2)}\cos(\omega_2t + \phi_2)\\
      r_2X_1^{(2)}\cos(\omega_2t + \phi_2)
    \end{pmatrix}\\[2ex]  % additional vertical space
    r_1 &=
      \frac{3k - m\omega_1^2}{2k} \qquad
      X_1^{(1)} = \frac{1}{r_2 - r_1}\biggl[(r_2x_1(0) - x_2(0))^2 +
      \frac{(-r_2\dot{x}_1(0) + \dot{x}_2(0))^2}{\omega_1^2}\biggr]^{1/2}\\
    r_2 &=
      \frac{3k - m\omega_2^2}{2k}  \qquad
      X_1^{(2)} = \frac{1}{r_2 - r_1}\biggl[(-r_1x_1(0) + x_2(0))^2 +
      \frac{(r_1\dot{x}_1(0) - \dot{x}_2(0))^2}{\omega_2^2}\biggr]^{1/2}\\[2ex] % additional vertical space
    \phi_1 &=
      \arctan\biggl[\frac{-r_2\dot{x}_1(0) + \dot{x}_2(0)}
      {\omega_1^2(r_2x_1(0) - x_2(0))}\biggr] \qquad
      \phi_2 = \arctan\biggl[\frac{r_1\dot{x}_1(0) - \dot{x}_2(0)}
      {\omega_2^2(-r_1x_1(0) + x_2(0))}\biggr]
  \end{align*}
\end{document}
Mico
  • 506,678
  • Just look at @davidcarisle answer to understand what was supposed to be achieved. – dustin Nov 08 '14 at 01:37
  • @dustin - I know what you said you wanted, and I understand that David's answer provides what you say you want. However, I honestly don't think that the requested alignments are particularly effective in enhancing an understanding of the material. That's why I proposed an alternative and simpler layout. You are, naturally, free to disregard my opinion. – Mico Nov 08 '14 at 01:41