# Aligning of equations within derivations

Okay, so I have the following derivation so far in my latex document:

\documentclass[a4paper,oneside,11pt]{report}

\usepackage[english]{babel} %francais, polish, spanish, ...
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage[cm]{fullpage}
\usepackage{float}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{a4wide}
\setlength{\marginparwidth}{3cm}
\setlength{\topmargin}{0cm}
\setlength{\voffset}{0cm}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother

\makeatletter
\vspace*{10\p@}%
{\parindent \z@ \raggedright \normalfont
%\ifnum \c@secnumdepth >\m@ne
%    \huge\bfseries \@chapapp\space \thechapter
%    \par\nobreak
%    \vskip 20\p@
%\fi
\interlinepenalty\@M
\Huge \thechapter \space \space \space \bfseries #1\par\nobreak
\vskip 10\p@
}}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% DOCUMENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\begin{align}
F_{x_t}(h-h_3) + (F_{z_t} + mgcos\phi - 2F_{z_1})a_2 - 2h(F_{x_1} + F_{x_2}) - 2F_{z_1}a_1 - F_{z_t}(a_2 + b_1) = 0 \nonumber
\end{align}         \begin{align}
2F_{z_1}(a_1 + a_2) &= F_{x_t}(h - h_3) + (F_{z_t} + mgcos\phi)a_2 -2h(F_{x_1} + F_{x_2}) - F_{z_t}(a_2 + b_1) \nonumber \\
&= A_2sin\phi(h - h_3) + mga_2cos\phi - 2hA_1sin\phi - b_1(A_3sin\phi + B_3cos\phi) \nonumber \\
&= sin\phi\big(A_2(h - h_3) -2hA_1 -b_1A_3 \big) + cos\phi \big(mga_2 - b_1B_3 \big) \nonumber
\end{align}         \begin{align}
\therefore F_{z_1} = A_4sin\phi + B_4cos\phi
\end{align}
\end{document}


As you can see, there are 5 lines in the derivation (i.e between \begin{align} and \end{align} statements. However, the middle 3 need to be aligned w.r.t to the equals sign, and the top and bottom line should be centred. I've sort of managed to achieve it this way, but I want a way of doing it without 3 align blocks, is this possible?

-
The a4wide package is deprecated. Use geometry for setting the page parameters. –  egreg Sep 23 '13 at 15:53

You could use ordinary equation and/or equation* environments for the first and last equation. Also, if every single line in an align environment gets a \notag statement to suppress an equation number, it's much better to use an align* environment and drop all those \notag statements.

\documentclass[a4paper,oneside,11pt]{report}
\usepackage[cm]{fullpage}
\usepackage{lmodern,amsmath,amssymb}
\usepackage{a4wide}
\setlength{\marginparwidth}{3cm}
\setlength{\topmargin}{0cm}
\setlength{\voffset}{0cm}

\begin{document}

\begin{equation*}
F_{x_t}(h-h_3) + (F_{z_t} + mg\cos\phi - 2F_{z_1})a_2 - 2h(F_{x_1} + F_{x_2}) - 2F_{z_1}a_1 - F_{z_t}(a_2 + b_1) = 0
\end{equation*}
\begin{align*}
2F_{z_1}(a_1 + a_2) &= F_{x_t}(h - h_3) + (F_{z_t} + mg\cos\phi)a_2 -2h(F_{x_1} + F_{x_2}) - F_{z_t}(a_2 + b_1) \\
&= A_2\sin\phi(h - h_3) + mga_2\cos\phi - 2hA_1\sin\phi - b_1(A_3\sin\phi + B_3\cos\phi) \\
&= \sin\phi\big(A_2(h - h_3) -2hA_1 -b_1A_3 \big) + \cos\phi \big(mga_2 - b_1B_3 \big)
\end{align*}
$$\therefore F_{z_1} = A_4\sin\phi + B_4\cos\phi$$
\end{document}


Addendum If you want to eliminate the extra whitespace between the groups of equations, you could proceed by using a split environment inside a gather environment (with \notag directives for all but the final expression):

\documentclass[a4paper,oneside,11pt]{report}
\usepackage[cm]{fullpage}
\usepackage{lmodern,amsmath,amssymb}
\usepackage{a4wide}
\setlength{\marginparwidth}{3cm}
\setlength{\topmargin}{0cm}
\setlength{\voffset}{0cm}
\begin{document}
\begin{gather}
F_{x_t}(h-h_3) + (F_{z_t} + mg\cos\phi - 2F_{z_1})a_2 - 2h(F_{x_1} + F_{x_2}) - 2F_{z_1}a_1 - F_{z_t}(a_2 + b_1) = 0\notag\\
\begin{split}
2F_{z_1}(a_1 + a_2) &= F_{x_t}(h - h_3) + (F_{z_t} + mg\cos\phi)a_2 -2h(F_{x_1} + F_{x_2}) - F_{z_t}(a_2 + b_1) \notag\\
&= A_2\sin\phi(h - h_3) + mga_2\cos\phi - 2hA_1\sin\phi - b_1(A_3\sin\phi + B_3\cos\phi) \notag\\
&= \sin\phi\big(A_2(h - h_3) -2hA_1 -b_1A_3 \big) + \cos\phi \big(mga_2 - b_1B_3 \big) \end{split} \notag\\
\therefore F_{z_1} = A_4\sin\phi + B_4\cos\phi
\end{gather}
\end{document}

-
Yes I wondered about that too, it depends on the style of reference to (1) whether you want to just refer to the final step as here or if you want (1) to label the entire derivation. +1 anyway, see which the OP picks:-) –  David Carlisle Sep 23 '13 at 15:59

Perhaps

Note you should always use \cos not cos and similar multi-letter identifiers The default math italic font is not designed for multi-letter words.

\documentclass[a4paper,oneside,11pt]{report}

\usepackage[english]{babel} %francais, polish, spanish, ...
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage[cm]{fullpage}
\usepackage{float}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{a4wide}
\setlength{\marginparwidth}{3cm}
\setlength{\topmargin}{0cm}
\setlength{\voffset}{0cm}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother

\makeatletter
\vspace*{10\p@}%
{\parindent \z@ \raggedright \normalfont
%\ifnum \c@secnumdepth >\m@ne
%    \huge\bfseries \@chapapp\space \thechapter
%    \par\nobreak
%    \vskip 20\p@
%\fi
\interlinepenalty\@M
\Huge \thechapter \space \space \space \bfseries #1\par\nobreak
\vskip 10\p@
}}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% DOCUMENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\begin{gather}
\begin{aligned}
F_{x_t}(h-h_3) + (F_{z_t} + mg\cos\phi - 2F_{z_1})a_2 - 2h(F_{x_1} + F_{x_2}) - 2F_{z_1}a_1 - F_{z_t}(a_2 + b_1) = 0\\[\jot]
\begin{aligned}
2F_{z_1}(a_1 + a_2) &= F_{x_t}(h - h_3) + (F_{z_t} + mg\cos\phi)a_2 -2h(F_{x_1} + F_{x_2}) - F_{z_t}(a_2 + b_1)  \\
&= A_2\sin\phi(h - h_3) + mga_2\cos\phi - 2hA_1\sin\phi - b_1(A_3\sin\phi + B_3\cos\phi)  \\
&= \sin\phi\big(A_2(h - h_3) -2hA_1 -b_1A_3 \big) + \cos\phi \big(mga_2 - b_1B_3 \big)
\end{aligned}\\[\jot]
\therefore F_{z_1} = A_4\sin \phi + B_4\cos\phi
\end{aligned}
\end{gather}
\end{document}

-
I prefer this answer as it removes the whitespace between the blocks. However, is there any way to make the last line aligned to the left or centred rather than the right? –  Keir Simmons Sep 23 '13 at 18:39
@KeirSimmons simplest is to put an & before each of the lines of the outer aligned so before F before the second \begin{aligned} and before \therefore –  David Carlisle Sep 23 '13 at 19:27

i suggest wrapping the whole thing in a single gather, use aligned to group the middle three lines, and use \nonumber on the first line and just before the (explicit) line break after \end{aligned} so that only one number appears for the whole structure.

\begin{gather}
F_{x_t}(h-h_3) + (F_{z_t} + mgcos\phi - 2F_{z_1})a_2 - 2h(F_{x_1} + F_{x_2}) - 2F_{z_1}a_1 - F_{z_t}(a_2 + b_1) = 0 \nonumber \\
\begin{aligned}
2F_{z_1}(a_1 + a_2) &= F_{x_t}(h - h_3) + (F_{z_t} + mgcos\phi)a_2 -2h(F_{x_1} + F_{x_2}) - F_{z_t}(a_2 + b_1) \\
&= A_2sin\phi(h - h_3) + mga_2cos\phi - 2hA_1sin\phi - b_1(A_3sin\phi + B_3cos\phi) \\
&= sin\phi\big(A_2(h - h_3) -2hA_1 -b_1A_3 \big) + cos\phi \big(mga_2 - b_1B_3 \big)
\end{aligned} \nonumber \\
\therefore F_{z_1} = A_4sin\phi + B_4cos\phi
\end{gather}


any "line" within the scope of gather will be centered; the aligned block will be treated as a single "line" for this purpose.

-

You can do it without align environment, instead using stackengine

\documentclass[a4paper,oneside,11pt]{report}
\usepackage[english]{babel} %francais, polish, spanish, ...
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{a4wide}
\setlength{\marginparwidth}{3cm}
\setlength{\topmargin}{0cm}
\setlength{\voffset}{0cm}
$$\savestack{\temp}{\Longunderstack[l]{% = F_{x_t}(h - h_3) + (F_{z_t} + mg\cos\phi)a_2 -2h(F_{x_1} + F_{x_2}) - F_{z_t}(a_2 + b_1)\\ = A_2\sin\phi(h - h_3) + mga_2\cos\phi - 2hA_1\sin\phi - b_1(A_3\sin\phi + B_3\cos\phi)\\ = \sin\phi\big(A_2(h - h_3) -2hA_1 -b_1A_3 \big) + \cos\phi \big(mga_2 - b_1B_3 \big)}% } \Shortstack{% F_{x_t}(h-h_3) + (F_{z_t} + mg\cos\phi - 2F_{z_1})a_2 - 2h(F_{x_1} + F_{x_2}) - 2F_{z_1}a_1 - F_{z_t}(a_2 + b_1) = 0\\ 2F_{z_1}(a_2 + b_1)\mathrel{\temp}\\% \therefore F_{z_1} = A_4\sin\phi + B_4\cos\phi% }$$