array
¶Synopsis:
\begin{array}{cols} column 1 entry &column 2 entry ... &column n entry \\ ... \end{array}
or:
\begin{array}[pos]{cols} column 1 entry &column 2 entry ... &column n entry \\ ... \end{array}
Produce a mathematical array. This environment can only be used in math
mode (see Modes), and normally appears within a displayed
mathematics environment such as equation
(see equation
).
Inside of each row the column entries are separated by an ampersand,
(&
). Rows are terminated with double-backslashes (see \\
).
This example shows a three by three array.
\begin{displaymath} \chi(x) = \left| % vertical bar fence \begin{array}{ccc} x-a &-b &-c \\ -d &x-e &-f \\ -g &-h &x-i \end{array} \right| \end{displaymath}
The required argument cols describes the number of columns, their
alignment, and the formatting of the intercolumn regions. For instance,
\begin{array}{rcl}...\end{array}
gives three columns: the
first flush right, the second centered, and the third flush left. See
tabular
for the complete description of cols and of the
other common features of the two environments, including the optional
pos argument.
There are two ways that array
diverges from tabular
. The
first is that array
entries are typeset in math mode, in
textstyle (see Math styles) except if the cols definition specifies
the column with p{...}
, which causes the entry to be typeset in
text mode. The second is that, instead of tabular
’s parameter
\tabcolsep
, LaTeX’s intercolumn space in an array
is
governed by
\arraycolsep
, which gives half the width between columns. The
default for this is ‘5pt’ so that between two columns comes
10pt of space.
To obtain arrays with braces the standard is to use the amsmath
package. It comes with environments pmatrix
for an array
surrounded by parentheses (...)
, bmatrix
for an array
surrounded by square brackets [...]
, Bmatrix
for an
array surrounded by curly braces {...}
, vmatrix
for
an array surrounded by vertical bars |...|
, and
Vmatrix
for an array surrounded by double vertical
bars ||...||
, along with a number of other array constructs.
The next example uses the amsmath
package.
\usepackage{amsmath} % in preamble \begin{equation} \begin{vmatrix}{cc} % array with vert lines a &b \\ c &d \end{vmatrix}=ad-bc \end{equation}
There are many packages concerning arrays. The array
package has
many useful extensions, including more column types. The dcolumn
package adds a column type to center on a decimal point. For both see
the documentation on CTAN.