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

  • Topic: LaTeX 
  • Thread starter basty
  • Start date
  • Tags Tags
    Latex Matrix
2 replies · 7K views · last reply
basty
Messages
94
Reaction score
0
How do you write a matrix such as below image in Latex, in this forum?

Two augmented matrices joined by a right arrow labelled R1 ↔ R2: left matrix rows (2 6 1 | 7), (1 2 -1 | -1), (5 7 -4 | 9); right matrix rows (1 2 -1 | -1), (2 6 1 | 7), (5 7 -4 | 9).
 
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