I am trying to write three equations, second with two equal signs. I would like the first two to be aligned by the first equal sign, and the second and third by the second equal sign. I have the following code:
\documentclass[a4paper]{article}
\usepackage{mathtools}
\usepackage{amssymb}
\newcommand{\ddn}[2]{\frac{\mathrm{d}}{\mathrm{d} #1 } #2 }
\newcommand{\ddt}{\frac{\mathrm{d}}{\mathrm{d} t } }
\begin{document}
\begin{eqnarray}
x'(t)&=&\ddt\left(\left[-\frac{M}{\omega^2}\cos{(\omega t)}+B_1\sin{(\omega t)}\right]+
\left[\frac{M}{\omega^2}-\frac{M}{T\omega^2}t\right]\right)\\
{}&=&\frac{M}{\omega}\sin{(\omega t)}+B_1\omega\cos{(\omega t)}-\frac{M}{T \omega^2}\\
\therefore x'(0) &=&
\frac{M}{\omega}\sin{(\omega 0)}+B_1\omega\cos{(\omega 0)}-\frac{M}{T \omega^2}=0\\
\therefore B_1\omega-\frac{M}{T\omega^2}&=& 0
\end{eqnarray}
\end{document}
which produces following output:
Equations (1), (2), and (3) are aligned as desired, but I wish (4) to be aligned with the second equal sign in (3). Is that feasible?
Best Answer
To achieve this alignment, I would use
\mathllap
and\mathrlap
, but I would use these in conjunction with thealignat
environment, to ensure the proper alignment of=
symbols on each line.Example code:
Example output: