Math-Linux.com

Knowledge base dedicated to Linux and applied mathematics.

Home > Latex > FAQ > Latex - FAQ > How to write matrices in Latex ? matrix, pmatrix, bmatrix, vmatrix, (...)

How to write matrices in Latex ? matrix, pmatrix, bmatrix, vmatrix, Vmatrix

Here are few examples to write quickly matrices.


First of all, modify your preamble adding*

\usepackage{amsmath}

*Thanks to Miss Paola Estrada for the fix.

LateX pmatrix, bmatrix, vmatrix, Vmatrix

pmatrix, bmatrix, vmatrix, Vmatrix are Latex environments:

  • p for parens
  • b for brackets
  • v for verts
  • B for braces
  • V for double verts.

How to write an m x n matrix in LaTeX

\begin{equation*}
A_{m,n} =
\begin{pmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots  & \vdots  & \ddots & \vdots  \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{pmatrix}
\end{equation*}

$$ \begin{equation*} A_{m,n} = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix} \end{equation*} $$

Examples matrix 3 x 3 in LaTeX

\begin{equation*}
A =
\begin{pmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{pmatrix}
\end{equation*}

$$ \begin{equation*} A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} \end{equation*} $$

\begin{equation*}
B =
\begin{bmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{bmatrix}
\end{equation*}

$$ \begin{equation*} B = \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix} \end{equation*} $$

LateX matrix with no bracket

\begin{equation}
  \begin{matrix}
  a_{11} & a_{12} & a_{13}  \\
  a_{21} & a_{22} & a_{23}  \\
  a_{31} & a_{32} & a_{33}  \\
  \end{matrix}
\end{equation}

$$ \begin{equation} \begin{matrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \\ \end{matrix} \end{equation} $$

LateX matrix determinant / vertical bar bracket

\begin{equation}
  \begin{vmatrix}
  a_{11} & a_{12} & a_{13}  \\
  a_{21} & a_{22} & a_{23}  \\
  a_{31} & a_{32} & a_{33}  \\
  \end{vmatrix}
\end{equation}

$$ \begin{equation} \begin{vmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \\ \end{vmatrix} \end{equation} $$

Latex matrix with curly brackets

\begin{equation}
  \begin{Bmatrix}
  a_{11} & a_{12} & a_{13}  \\
  a_{21} & a_{22} & a_{23}  \\
  a_{31} & a_{32} & a_{33}  \\
  \end{Bmatrix}
\end{equation}

$$ \begin{equation} \begin{Bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \\ \end{Bmatrix} \end{equation} $$

Latex matrix with double vertical bar brackets

\begin{equation}
  \begin{Vmatrix}
  a_{11} & a_{12} & a_{13}  \\
  a_{21} & a_{22} & a_{23}  \\
  a_{31} & a_{32} & a_{33}  \\
  \end{Vmatrix}
\end{equation}

$$ \begin{equation} \begin{Vmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \\ \end{Vmatrix} \end{equation} $$

Latex small inline matrix

Use smallmatrix environment

I love small matrice such $\big(\begin{smallmatrix} a & b\\ c & d \end{smallmatrix}\big)$

I love small matrice such $\big(\begin{smallmatrix} a & b\\ c & d \end{smallmatrix}\big)$

Examples matrix 2 x 2 in LaTeX

Here are examples with matrix 2x2 with pmatrix, bmatrix, vmatrix, Vmatrix environments:

\begin{matrix} 
a & b \\
c & d
\end{matrix}
\quad
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
\quad
\begin{bmatrix}
a & b \\
c & d
\end{bmatrix}
\quad
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}
\quad
\begin{Vmatrix}
a & b \\
c & d
\end{Vmatrix}

$$ \begin{matrix} a & b \\ c & d \end{matrix} \quad \begin{pmatrix} a & b \\ c & d \end{pmatrix} \quad \begin{bmatrix} a & b \\ c & d \end{bmatrix} \quad \begin{vmatrix} a & b \\ c & d \end{vmatrix} \quad \begin{Vmatrix} a & b \\ c & d \end{Vmatrix} $$

Also in this section

  1. How to write number sets N Z D Q R C with Latex: \mathbb, amsfonts and \mathbf
  2. How to write angle in latex langle, rangle, wedge, angle, measuredangle, sphericalangle
  3. Latex numbering equations: leqno et fleqn, left,right
  4. How to write a vector in Latex ? \vec,\overrightarrow
  5. Latex how to insert a blank or empty page with or without numbering \thispagestyle,\newpage,\usepackage{afterpage}
  6. Latex arrows
  7. Latex natural numbers
  8. Latex real numbers
  9. Latex binomial coefficient
  10. Latex overset and underset
  11. LateX Derivatives, Limits, Sums, Products and Integrals
  12. Latex absolute value
  13. Latex piecewise function
  14. Latex how to hide page number
  15. How to get dots in Latex \ldots,\cdots,\vdots and \ddots
  16. How to write algorithm and pseudocode in Latex ?\usepackage{algorithm},\usepackage{algorithmic}
  17. How to display formulas inside a box or frame in Latex ? \boxed
  18. Latex how to write underscore
  19. How to write table in Latex ? begin{tabular}...end{tabular}
  20. Latex norm for vector and sum
  21. Latex infinity symbol
  22. Latex how to write percent
  23. Latex how to write a fraction
  24. Latex how to write bar
  25. Latex how to write text in math mode
  26. Latex rational numbers
  27. Latex quaternion numbers
  28. Latex complex numbers
  29. Latex indicator function
  30. Latex plus or minus symbol
  31. Latex symbol for all x
  32. Latex symbol exists
  33. Latex symbol not exists
  34. How to write matrices in Latex ? matrix, pmatrix, bmatrix, vmatrix, Vmatrix
  35. Latex horizontal space: qquad,hspace, thinspace,enspace
  36. Horizontal and vertical curly Latex braces: \left\{,\right\},\underbrace{} and \overbrace{}