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

  • Thread starter Thread starter basty
  • Start date Start date
  • Tags Tags
    Latex Matrix
Click For Summary
To write a matrix in LaTeX, the simplest method is to use the pmatrix environment, as demonstrated with the code \begin{pmatrix} 2 & 6 & 1 \\ 1 & 2 & -1 \\ 5 & 7 & -4 \end{pmatrix}. For matrices that require vertical lines, a more manual approach is necessary, using the array environment with specific formatting. An example provided shows how to include a vertical line: \left( \begin{array}{rrr|r} 2 & 6 & 1 & 7 \\ 1 & 2 & -1 & -1 \\ 5 & 7 & -4 & 9 \end{array} \right). This method allows for greater customization in matrix presentation.
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 Greg Bernhardt

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K