# How To Write Matrix In Latex?

1. Dec 13, 2015

### basty

How do you write a matrix such as below image in Latex, in this forum?

2. Dec 13, 2015

### gsal

3. Dec 14, 2015

### Staff: Mentor

Normally, the easiest way to write a matrix is to use the pmatrix environment:
Code (LaTeX):

\begin{pmatrix}
2 & 6 & 1 \\ 1 & 2 & -1 \\ 5 & 7 & -4
\end{pmatrix
}

$$\begin{pmatrix} 2 & 6 & 1 \\ 1 & 2 & -1 \\ 5 & 7 & -4 \end{pmatrix}$$

If you need the vertical line, you have to do the matrix "by hand," and it requires a bit more work:
Code (LaTeX):

\left(
\begin{array}{rrr|r}
2 & 6 & 1 & 7 \\ 1 & 2 & -1 & -1 \\ 5 & 7 & -4 & 9
\end{array
}
\right)

$$\left( \begin{array}{rrr|r} 2 & 6 & 1 & 7 \\ 1 & 2 & -1 & -1 \\ 5 & 7 & -4 & 9 \end{array} \right)$$