LaTeX Wiki
No edit summary
Tags: Visual edit apiedit
No edit summary
Tag: rte-wysiwyg
Line 1: Line 1:
 
{{Quotation|The <tt>align</tt> 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 <tt>amsmath</tt> Package}}
 
{{Quotation|The <tt>align</tt> 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 <tt>amsmath</tt> Package}}
   
== Introduction to align ==
+
== Introduction to <tt>align</tt> ==
For all intents and purposes, the align environment is a replacement for the [[eqnarray]] environment and all its warts. Rather than
+
For all intents and purposes, the <tt>align</tt> environment is a replacement for the <tt>[[eqnarray]]</tt> environment and all its warts. Rather than
   
 
\begin{eqnarray*}
 
\begin{eqnarray*}
Line 18: Line 18:
 
Besides the slightly simpler syntax, you side-step [http://www.tug.org/pracjourn/2006-4/madsen/madsen.pdf bugs documented by Lars Madsen for ''The PracTeX Journal'']:
 
Besides the slightly simpler syntax, you side-step [http://www.tug.org/pracjourn/2006-4/madsen/madsen.pdf bugs documented by Lars Madsen for ''The PracTeX Journal'']:
   
* Inconsistent spacing around binary symbols like =</code> and <code>+</code>;<code>
+
* Inconsistent spacing around binary symbols like <code> </code>
  +
<code>
 
  +
=</code> and <code>+</code>;
 
* Overwriting equation numbers; and
 
* Overwriting equation numbers; and
 
* Silent label mismatch.
 
* Silent label mismatch.
   
== Multiple equations on one line ==
+
== Multiple equations on one line ==
 
Besides being used for aligning binary symbols, the ampersand can also mark an invisible alignment for separating columns of equations. For example,
 
Besides being used for aligning binary symbols, the ampersand can also mark an invisible alignment for separating columns of equations. For example,
   
\begin{align}
+
<code>\begin{align}
 
u &= \arctan x & dv &= 1 \, dx \\
 
u &= \arctan x & dv &= 1 \, dx \\
 
du &= \frac{1}{1 + x^2} dx & v &= x.
 
du &= \frac{1}{1 + x^2} dx & v &= x.
 
\end{align}
 
\end{align}
  +
</code>
   
produces:
+
<code>produces: </code>
   
<math>
+
<code><math>
 
\begin{align}
 
\begin{align}
 
u &= \arctan x & dv &= 1 \, dx
 
u &= \arctan x & dv &= 1 \, dx
 
\\ du &= \frac{1}{1 + x^2} dx & v &= x.
 
\\ du &= \frac{1}{1 + x^2} dx & v &= x.
 
\end{align}
 
\end{align}
</math>
+
</math> </code>
   
 
== Preamble ==
 
== Preamble ==
 
To use align, import the [[amsmath]] package in your preamble.
 
To use align, import the [[amsmath]] package in your preamble.
.....
+
<code>.....
 
\{{Lcmd|usepackage}}{amsmath}
 
\{{Lcmd|usepackage}}{amsmath}
 
.....
 
.....
Line 51: Line 53:
 
du &= \frac{1}{1 + x^2} dx & v &= x.
 
du &= \frac{1}{1 + x^2} dx & v &= x.
 
\end{align*}
 
\end{align*}
\end{document}
+
\end{document}</code>
 
 
[[Category:AMS-LaTeX]]
 
[[Category:AMS-LaTeX]]
 
[[Category:Environment]]
 
[[Category:Environment]]

Revision as of 14:13, 10 April 2017

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

Introduction to align

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

Besides the slightly simpler syntax, you side-step bugs documented by Lars Madsen for The PracTeX Journal:

  • Inconsistent spacing around binary symbols like

= and +;

  • Overwriting equation numbers; and
  • Silent label mismatch.

Multiple equations on one line

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

To use align, import the amsmath package in your preamble.

.....
\usepackage{amsmath}
.....

\begin{document}
\begin{align*}
    u  &= \arctan x             &  dv &= 1 \, dx  \\ 
    du &= \frac{1}{1 + x^2} dx  &  v  &= x.
\end{align*}
\end{document}