# LaTeX & MathJax basic tutorial – Arrays

## Arrays

It is often easier to read tables formatted in MathJax rather than plain text or a fixed width font. Arrays and tables are created with the array environment. Just after \begin{array} the format of each column should be listed, use c for a center aligned column, r for right aligned, l for left aligned and a | for a vertical line. Just as with matrices, cells are separated with &  and rows are broken using \\. A horizontal line spanning the array can be placed before the current line with \hline.

For example,
$$\begin{array}{c|lcr} n & \text{Left} & \text{Center} & \text{Right} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \end{array}$$

Arrays can be nested to make an array of tables.

For example,
$$\begin{array}{c}\begin{array}{cc}\begin{array}{c|cccc} \text{min} & 0 & 1 & 2 & 3\\ \hline 0 & 0 & 0 & 0 & 0\\ 1 & 0 & 1 & 1 & 1\\ 2 & 0 & 1 & 2 & 2\\ 3 & 0 & 1 & 2 & 3 \end{array}& \begin{array}{c|cccc} \text{max}& 0& 1& 2& 3\\ \hline 0 & 0 & 1 & 2 & 3\\ 1 & 1 & 1 & 2 & 3\\ 2 & 2 & 2 & 2 & 3\\ 3 & 3 & 3 & 3 & 3 \end{array}\end{array} \\ \begin{array}{c|cccc} \Delta& 0& 1& 2& 3\\ \hline 0 & 0 & 1 & 2 & 3\\ 1 & 1 & 0 & 1 & 2\\ 2 & 2 & 1 & 0 & 1\\ 3 & 3 & 2 & 1 & 0 \end{array} \end{array}$$

As the source for the preceding array is long, please right-click on one of the tables and choose $\mathsf{Show\ Math\ As\ }\blacktriangleright\mathsf{\ TeX\ Commands}$.