[LaTeX] Matrices
category: Writing  course: LaTeX Math  difficulty:There are other ways to create matrices, using the proper delimiters, but using a special type of matrix environment will always be the best way to do it. These environments all roughly do the same – create a matrix – but have subtle differences that might make your life easier. They all follow this general syntax:
\begin{matrixType}
row 1, number 1 & … & row 1, number n \\
…
row m, number 1 & … & row m, number n
\end{matrixType}
As you can see, each row is terminated by a newline (two backslashes), and each column by an ampersand.
Plain Matrix
The matrix
environment creates a matrix with everything lined up correctly, but nothing around it to signal it’s a matrix. This is useful, for instance, for creating a submatrix within a matrix.
\[ \begin{matrix} 0 & 1 & 2\\ 3 & 4 & 5\\ 6 & 7 & 8 \end{matrix} \]
Surrounded Matrices
One of the following environments can be used if you want a certain kind of delimiter surrounding your matrix:
Environment 
Description 

Brackets around the matrix (usual notation) 

Braces around the matrix 

Parentheses around the matrix 

Vertical bars around the matrix (used to represent the determinant) 

Double verticalbars around the matrix 
\[ \begin{bmatrix} 0 & 1 & 2\\ 3 & 4 & 5\\ 6 & 7 & 8 \end{bmatrix} \]
Inline Matrices
To use a matrix inline, so that the flow of text is not disrupted, use the smallmatrix
environment. This, however, only creates a smaller plain matrix, which means you need to add delimiters yourself, and the matrix can’t be too large to begin with.
This matrix, $\begin{smallmatrix} a & 0\\0 & b \end{smallmatrix}$, is inline.