This site is supported by donations to The OEIS Foundation.

# Template:Align/doc

This documentation subpage contains instructions, categories, or other information for Template:Align. [<Edit> Template:Align]

[⧼Purge⧽ Template:Align/doc]

The {{align}} mathematical formatting template is used to either align operation symbols and/or relation symbols, e.g. equal signs, of equations on successive rows or to align decimal points of numbers on successive rows.

To get alignment you must use

• the "alignment mark" {{&}}, or {{&|htm}} (default), or {{&|tex}} (gives padding-left: 0.25em; in HTML+CSS);
• the "aligning equal sign" {{&=}}, or {{&=|htm}} (default), or {{&=|tex}} (gives padding-left: 0.25em; in HTML+CSS)
(this is for convenience, instead of using {{&}}{{=}});
• the "aligning decimal point" {{&.}}, or {{&.|htm}} (default), or {{&.|tex}} (no padding-left in HTML+CSS);

and as the "row separator" you must use

• {{\\}}, or {{\\|htm}} (default), or {{\\|tex}}. (Do not put any at the end of the last line!)

Note: for decimal point alignment, using {{&}}. will NOT do, since the {{&}} "alignment mark" gives padding-left: 0.25em; (which is suitable for operation symbols and for relation symbols).

## Usage

To align operation symbols and/or relation symbols

{{align|begin}}
lhs-1 {{&}}symbol rhs-1 {{\\}}<!-- No space before symbol! -->
lhs-2 {{&}}symbol rhs-2 {{\\}}<!-- No space before symbol! -->
...
lhs-k {{&}}symbol rhs-k <!-- Do NOT put {{\\}} at the end of the last line! -->
{{align|end}}


or

{{align|begin}}
lhs-1 {{&=}} rhs-1 {{\\}}
lhs-2 {{&=}} rhs-2 {{\\}}
...
lhs-k {{&=}} rhs-k <!-- Do NOT put {{\\}} at the end of the last line! -->
{{align|end}}


and to align decimal points

{{align|begin}}
integer part-1{{&.}}fractional part-1 {{\\}}<!-- No space before and after {{&.}}! -->
integer part-2{{&.}}fractional part-2 {{\\}}<!-- No space before and after {{&.}}! -->
...
integer part-k{{&.}}fractional part-k <!-- Do NOT put {{\\}} at the end of the last line! -->
{{align|end}}


### {{begin}} and {{end}} LaTeX style environment templates

You may also use the {{begin}} and {{end}} LaTeX style environment templates, e.g.

{{begin|align}}
integer part-1{{&.}}fractional part-1 {{\\}}<!-- No space before and after {{&.}}! -->
integer part-2{{&.}}fractional part-2 {{\\}}<!-- No space before and after {{&.}}! -->
...
integer part-k{{&.}}fractional part-k <!-- Do NOT put {{\\}} at the end of the last line! -->
{{end|align}}


## Examples

### Maxwell’s equations[1] (as differential equations)

The code

{{indent}}{{math|
{{align|begin}}
{{op|curl}}{{vec|B|b}} {{op|-}} {{frac|1|''c''|HTM}}{{sp|3}}{{partial|{{vec|E|b}}|''t''|HTM}} {{&=}} {{frac|4{{Gr|pi}}|''c''|HTM}}{{sp|3}}{{vec|J|b}} {{\\}}
{{op|divergence}}{{vec|E|b}} {{&=}} 4{{Gr|pi}}{{sp|3}}''{{Gr|rho}}'' {{\\}}
{{op|curl}}{{vec|E|b}} {{op|+}} {{frac|1|''c''|HTM}}{{sp|3}}{{partial|{{vec|B|b}}|''t''|HTM}} {{&=}} {{vec|0|b}} {{\\}}
{{op|divergence}}{{vec|B|b}} {{&=}} 0
{{align|end}}
|tex =
{{align|begin|tex}}
{{op|curl|tex}}{{vec|B|b|tex}} - {{frac|1|''c''|TEX}} {{partial|{{vec|E|b|tex}}|''t''|TEX}} {{&=|tex}} {{frac|4{{Gr|pi|tex}}|''c''|TEX}} {{vec|J|b|tex}} {{\\|tex}}
{{op|divergence|tex}}{{vec|E|b|tex}} {{&=|tex}} 4{{Gr|pi|tex}} ''{{Gr|rho|tex}}'' {{\\|tex}}
{{op|curl|tex}}{{vec|E|b|tex}} + {{frac|1|''c''|TEX}} {{partial|{{vec|B|b|tex}}|''t''|TEX}} {{&=|tex}} {{vec|0|b|tex}} {{\\|tex}}
{{op|divergence|tex}}{{vec|B|b|tex}} {{&=|tex}} 0
{{align|end|tex}}
|&&}}


yields the display style HTML+CSS (with the && option):

∇ × B
 1 c
 ∂E ∂t
=
 4π c
J
∇ ∙ E  =  4π ρ
∇ × E +
 1 c
 ∂B ∂t
=  0
∇ ∙ B  =  0

or yields the display style LaTeX (with the  option): {\displaystyle {\begin{array}{l}\displaystyle {\begin{aligned}{\nabla }\,{\times }\,\mathbf {B} -{\frac {1}{c}}{\dfrac {{\partial }^{}\mathbf {E} }{{\partial }{t}^{}}}&={\frac {4\pi }{c}}\mathbf {J} \\{\nabla }\,\mathbf {\cdot } \,\mathbf {E} &=4\pi \rho \\{\nabla }\,{\times }\,\mathbf {E} +{\frac {1}{c}}{\dfrac {{\partial }^{}\mathbf {B} }{{\partial }{t}^{}}}&=\mathbf {0} \\{\nabla }\,\mathbf {\cdot } \,\mathbf {B} &=0\end{aligned}}\end{array}}} ### Maxwell’s equations (integral form) The code {{indent}}{{math| {{align|begin}} {{oiint|{{sym|partial}}''V''||{{vec|E|b}}{{op|sdot}}{{d|{{vec|S|b}}}}|HTM}} {{&=}} <!-- -->{{frac|1|''{{Gr|epsilon}}''{{sub|0}}|HTM}} {{iiint|''V''||''{{Gr|rho}}''{{sp|3}}{{d|''V''}}|HTM}} {{\\}} {{oiint|{{sym|partial}}''V''||{{vec|B|b}}{{op|sdot}}{{d|{{vec|S|b}}}}|HTM}} {{&=}} 0 {{\\}} {{oint|{{sym|partial}}''S''||{{vec|E|b}}{{op|sdot}}{{d|{{vec|x|b}}}}|HTM}} {{&=}} {{op|-}}{{iint|''S''||{{partial|{{vec|B|b}}|''t''|HTM}}{{op|sdot}}{{d|{{vec|S|b}}}}|HTM}} {{\\}} {{oint|{{sym|partial}}''S''||{{vec|B|b}}{{op|sdot}}{{d|{{vec|x|b}}}}|HTM}} {{&=}} <!-- -->{{iint|''S''||{{(|''{{Gr|mu}}''{{sub|0}}{{sp|1}}{{vec|J|b}} + {{frac|1|''c''{{^|2}}|HTM}} {{partial|{{vec|E|b}}|''t''|HTM}}|)|Big}}{{op|sdot}}{{d|{{vec|S|b}}}}|HTM}} {{align|end}} |&&}}  yields the display style HTML+CSS  Error: String exceeds 10,000 character limit. The code (broken in three calls to {{math}} to avoid the pesky 10,000 character limit for template arguments) {{indent}}{{math| {{align|begin}} {{oiint|{{sym|partial}}''V''||{{vec|E|b}}{{op|sdot}}{{d|{{vec|S|b}}}}|HTM}} {{&=}} <!-- -->{{frac|1|''{{Gr|epsilon}}''{{sub|0}}|HTM}} {{iiint|''V''||''{{Gr|rho}}''{{sp|3}}{{d|''V''}}|HTM}} {{\\}} {{oiint|{{sym|partial}}''V''||{{vec|B|b}}{{op|sdot}}{{d|{{vec|S|b}}}}|HTM}} {{&=}} 0 {{\\}} {{align|end}} |&&}}{{clear}} {{indent}}{{nbsp|3}}{{math| {{oint|{{sym|partial}}''S''||{{vec|E|b}}{{op|sdot}}{{d|{{vec|x|b}}}}|HTM}} {{&=}} {{op|-}}{{iint|''S''||{{partial|{{vec|B|b}}|''t''|HTM}}{{op|sdot}}{{d|{{vec|S|b}}}}|HTM}} |&&}}{{clear}} {{indent}}{{nbsp|3}}{{math| {{oint|{{sym|partial}}''S''||{{vec|B|b}}{{op|sdot}}{{d|{{vec|x|b}}}}|HTM}} {{&=}} <!-- -->{{iint|''S''||{{(|''{{Gr|mu}}''{{sub|0}}{{sp|1}}{{vec|J|b}} + {{frac|1|''c''{{^|2}}|HTM}} {{partial|{{vec|E|b}}|''t''|HTM}}|)|Big}}{{op|sdot}}{{d|{{vec|S|b}}}}|HTM}} |&&}}  yields the display style HTML+CSS  ∂V ∂V E ⋅ dS =  1 ϵ0  V V ρdV  ∂V ∂V B ⋅ dS = 0  ∂S ∂S E ⋅ dx = −  S S  ∂B ∂t ⋅ dS  ∂S ∂S B ⋅ dx =  S S  ⎛ ⎝ μ0J +  1 c 2  ∂E ∂t  ⎞ ⎠ ⋅ dS The code {{indent}}{{math| {{align|begin|tex}} {{oiint|{{sym|partial|tex}}''V''||{{vec|E|b|tex}}{{op|sdot|tex}}{{d|{{vec|S|b|tex}}|tex}}|TEX}} {{&=|tex}} <!-- -->{{frac|1|''{{Gr|epsilon|tex}}''{{sub|0|tex}}|tex}} {{iiint|''V''||''{{Gr|rho|tex}}''{{sp|3|tex}}{{d|''V''|tex}}|TEX}} {{\\|tex}} {{oiint|{{sym|partial|tex}}''V''||{{vec|B|b|tex}}{{op|sdot|tex}}{{d|{{vec|S|b|tex}}|tex}}|TEX}} {{&=|tex}} 0 {{\\|tex}} {{oint|{{sym|partial|tex}}''S''||{{vec|E|b|tex}}{{op|sdot|tex}}{{d|{{vec|x|b|tex}}|tex}}|TEX}} {{&=|tex}} <!-- -->{{op|-}}{{iint|''S''||{{partial|{{vec|B|b|tex}}|''t''|TEX}}{{op|sdot|tex}}{{d|{{vec|S|b|tex}}|tex}}|TEX}} {{\\|tex}} {{oint|{{sym|partial|tex}}''S''||{{vec|B|b|tex}}{{op|sdot|tex}}{{d|{{vec|x|b|tex}}|tex}}|TEX}} {{&=|tex}} <!-- -->{{iint|''S''||{{(|''{{Gr|mu|tex}}''{{sub|0|tex}}{{sp|1|tex}}{{vec|J|b|tex}} + {{frac|1|''c''{{^|2|tex}}|tex}} <!-- -->{{partial|{{vec|E|b|tex}}|''t''|TEX}}|)|Big|tex}}{{op|sdot|tex}}{{d|{{vec|S|b|tex}}|tex}}|TEX}} {{align|end|tex}} |}}


yields the display style LaTeX

{\displaystyle {\begin{array}{l}\displaystyle {\begin{aligned}{\mathit {\oiint }}\!_{{\partial }V}^{}\;{\mathbf {E} {\;\!}{\cdot }{\;\!}d^{}\mathbf {S} }&={\frac {1}{\epsilon _{0}{\!\,\!}}}\iiint _{V}^{}\;{\rho {\,}d^{}V}\\{\mathit {\oiint }}\!_{{\partial }V}^{}\;{\mathbf {B} {\;\!}{\cdot }{\;\!}d^{}\mathbf {S} }&=0\\\oint _{{\partial }S}^{}\;{\mathbf {E} {\;\!}{\cdot }{\;\!}d^{}\mathbf {x} }&=-\iint _{S}^{}\;{{\dfrac {{\partial }^{}\mathbf {B} }{{\partial }{t}^{}}}{\;\!}{\cdot }{\;\!}d^{}\mathbf {S} }\\\oint _{{\partial }S}^{}\;{\mathbf {B} {\;\!}{\cdot }{\;\!}d^{}\mathbf {x} }&=\iint _{S}^{}\;{{\Big (}\mu _{0}{\!\,\!}{\;\;\!\!\!}\mathbf {J} +{\frac {1}{c^{2}}}{\dfrac {{\partial }^{}\mathbf {E} }{{\partial }{t}^{}}}{\Big )}{\;\!}{\cdot }{\;\!}d^{}\mathbf {S} }\end{aligned}}\end{array}}}

### Decimal point alignment

The code

{{indent}}{{math|
{{align|begin}}
123{{&.}}45678 {{\\}}
1{{&.}}2345678 {{\\}}
123456{{&.}}78
{{align|end}}
|&&}}


yields the display style HTML+CSS

 123 0.45678 1 0.234568 123456 0.78

The code

{{indent}}{{math|
{{align|begin|tex}}
123{{&.|tex}}45678 \\
1{{&.|tex}}2345678 \\
123456{{&.|tex}}78
{{align|end|tex}}
|}}


yields the display style LaTeX

{\displaystyle {\begin{array}{l}\displaystyle {\begin{aligned}123&.45678\\1&.2345678\\123456&.78\end{aligned}}\end{array}}}