# Matrix in LaTeX

A matrix can be described as a rectangular array of numbers, symbols or expressions that are arranged in rows and columns. A matrix in LaTeX can be generated with the help of a math environment for typesetting matrices. In this tutorial, we will discuss how to generate a matrix and make amendments with regard to the brackets.

## How to create matrix in LaTeX?

For generating matrix in LaTeX we have to use the package amsmath by giving the command \usepackage{amsmath}.


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
$$\begin{bmatrix} a & b & c \\ c & d & d\\ e & f & g \\ \end{bmatrix} \quad$$
\end{document}


### Output of the code above There can be various types of brackets to use in a matrix. Some of them are discussed below
• \begin{matrix}: This command creates a matrix without brackets or boundaries.
• \begin{pmatrix}: This command creates a matrix with brackets or parenthesis.
• \begin{bmatrix}: This command creates a matrix with square brackets or boundaries.
• \begin{Bmatrix}: This command creates a matrix with curly brackets or boundaries.
• \begin{vmatrix}: This command creates a matrix with a rectangular line boundary.
• \begin{Vmatrix}: This command creates a matrix with double vertical bar brackets or boundaries.

## Spacing in a matrix :

A matrix can face alterations in spacing as we can give more distance between elements. The following code can demonstrate how


\documentclass{article}
\usepackage{amsmath}
\begin{document}
Default:
$\left[ \begin{array}{ccc} \dfrac{5}{6} & \dfrac{1}{6} & 0 \\ \dfrac{5}{6} & 0 & \dfrac{1}{6} \\ 0 & \dfrac{5}{6} & \dfrac{1}{6} \end{array} \right]$
\renewcommand{\arraystretch}{2.5}
Stretched:
$\left[ \begin{array}{ccc} \dfrac{5}{6} & \dfrac{1}{6} & 0 \\ \dfrac{5}{6} & 0 & \dfrac{1}{6} \\ 0 & \dfrac{5}{6} & \dfrac{1}{6} \end{array} \right]$
\end{document}



### Output of the code above 