Matrices are where people lose an hour to a missing brace. The good news is that LaTeX has one mechanism with several dressings.
The environment decides the delimiter
pmatrix— parentheses, the standard for a matrix in running text.bmatrix— square brackets, what most linear algebra textbooks use.vmatrix— vertical bars, i.e. a determinant.Vmatrix— double vertical bars, used for permanents.Bmatrix— curly braces, common in set theory and some statistics.
All of them take the same body: rows separated by \\, cells by &.
\begin{bmatrix}\n a & b \\\n c & d\n\end{bmatrix}
The alignment argument
array is the primitive underneath, and unlike the matrix environments it needs an alignment spec: {cc} for two centred columns. Use it when you need a custom rule or an augmented matrix with a vertical line.
\left(\begin{array}{cc|c}\n 1 & 2 & 3 \\\n 4 & 5 & 6\n\end{array}\right)
Two mistakes worth memorising
First, a trailing & or an extra \\ at the end of the last row throws "Extra alignment tab". Second, \\ inside a \frac does not start a new row — maths mode treats the fraction as one cell. Use \genfrac or restructure.
latexmatrixlinear algebra
Keep reading
Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.