We can create a matrix in LaTeX using the array environment, or simplematrix, matrix, pmatrix, bmatrix, vmatrix, and Vmatrix environments via amsmath package. This article provides some examples on how to create a matrix in LaTeX.
Creating a matrix with array
Here are some examples.
- unbracketed matrix

\[ M = \begin{array}{cc} x & y \\ z & w \\ \end{array} \] - matrix surrounded by square brackets

\[ M = \left[ {\begin{array}{cc} x & y \\ z & w \\ \end{array} } \right] \] - matrix surrounded by parentheses

\[ M = \left( {\begin{array}{cc} x & y \\ z & w \\ \end{array} } \right) \] - matrix surrounded by single vertical lines

\[ M = \left| {\begin{array}{cc} x & y \\ z & w \\ \end{array} } \right| \]
Using amsmath package
Call \usepackage{amsmath} in the preamble, after \documentclass{}.
The amsmath package environment for matrix:
- smallmatrix: inline matrix

$M = \begin{smallmatrix} x&y\\ z&w \end{smallmatrix}$ $M = \left( \begin{smallmatrix} x&y\\ z&w \end{smallmatrix}\right)$ - matrix: unbracketed matrix

$M = \begin{matrix} x&y\\ z&w \end{matrix}$ - pmatrix: matrix surrounded by parentheses

$M = \begin{pmatrix} x&y\\ z&w \end{pmatrix}$ - bmatrix: matrix surrounded by square brackets

$M = \begin{bmatrix} x&y\\ z&w \end{bmatrix}$ - vmatrix: matrix surrounded by single vertical lines

$M = \begin{vmatrix} x&y\\ z&w \end{vmatrix}$ - Vmatrix: matrix surrounded by double vertical lines

$M = \begin{Vmatrix} x&y\\ z&w \end{Vmatrix}$

Awesome, thanks a lot!
gracias me ha servido de mucho… thanks
How about a border matrix? How can I write a circle around a letter, like in “copyright” or “registered trademark”? Is it possible to have a circle around all letters (not only C and R)? Thanks.
@jeanounou: You can use TikZ (http://en.wikipedia.org/wiki/PGF/TikZ) to put a letter in a circle.
For example (adapted from here):
That’s very helpful, thank you.