How can matrices be written in Latex with or without vertical lines?

  • Context: LaTeX 
  • Thread starter Thread starter basty
  • Start date Start date
  • Tags Tags
    Latex Matrix
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 6K views
basty
Messages
94
Reaction score
0
How do you write a matrix such as below image in Latex, in this forum?

Matrix.png
 
Physics news on Phys.org
Normally, the easiest way to write a matrix is to use the pmatrix environment:
Code:
\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:
\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)
$$
 
  • Like
Likes   Reactions: Greg Bernhardt