The align environment is used for two or more equations when vertical alignment is desired; usually binary relations such as equal signs are aligned.
American Mathematical Society, User's Guide for the amsmath Package
Contents
Introduction to align[edit | edit source]
For all intents and purposes, the align environment is a replacement for the eqnarray environment and all its warts. Rather than
\begin{eqnarray*} x^2 + y^2 &=& 1 \\ y &=& \sqrt{1 - x^2}, \end{eqnarray*}
one can type
\begin{align*} x^2 + y^2 &= 1 \\ y &= \sqrt{1 - x^2}. \end{align*}
Benefits over eqnarray[edit | edit source]
Besides the slightly simpler syntax, you side-step bugs documented by Lars Madsen for The PracTeX Journal, such as
- inconsistent spacing around binary symbols,
- overwriting equation numbers, and
- silent label mismatch.
Multiple equations on one line[edit | edit source]
Besides being used for aligning binary symbols, the ampersand can also mark an invisible alignment for separating columns of equations. For example,
\begin{align}
u &= \arctan x & dv &= 1 \, dx \\
du &= \frac{1}{1 + x^2}dx & v &= x.
\end{align}
produces:
Preamble[edit | edit source]
To use align, import the amsmath package in your preamble.
.....
\usepackage{amsmath}
.....
\begin{align}
i_t & = \sigma(W_{xi}x_t+W_{hi}h_{t-1}+W_{ci}c_{t-1}+b_i)\\\\
f_t & = \sigma(W_{xf}x_t+W_{hf}h_{t-1}+W_{cf}c_{t-1}+b_f)\\\\
c_t & = f_t\odot c_{t-1}+i_t\odot tanh(W_{xc}x_t+W_{hc}h_{t-1}+b_c)\\\\
o_t & = \sigma(W_{xo}x_t+W_{ho}h_{t-1}+W_{co}c_{t}+b_o)\\\\
h_t & = o_t\odot tanh(c_t)\\\\
\end{align}
Community content is available under CC-BY-SA unless otherwise noted.