LaTeX Wiki
Register
Advertisement

The array environment is used to make a table in math mode, with column alignment (left, center, or right) and optional vertical lines separating the columns.

Syntax[]

The syntax resembles the tabular environment. Columns are separated by &, and each row ends with a double backslash \\:

\begin{array}{col₁col₂…colₙ}
  item₁₁ & item₁₂ … & item₁ₙ \\
  item₂₁ & item₂₂ … & item₂ₙ \\
             ⋮
  itemₘ₁ & itemₘ₂ … & itemₘₙ
\end{array}

Each of col₁, col₂, etc. is a single letter,

c – for centred
l – for flush left
r – for flush right
The column format letters can be interspersed with vertical bars (|), which result in rendering vertical bars as needed in the formatted matrix.

If a horizontal line is needed in the matrix, \hline can be used.

Examples[]

Markup
\begin{array}{lc|r|}
  left1 & center1 & right1 \\
  \hline
  d & e & f
\end{array}
Renders as
Markup
\begin{array}{lcl}
  z & = & a \\
  & = & a \\
  f(x,y,z) & = & x + y + z
\end{array}
Renders as

See also[]

Advertisement