latex Typesetting mathematics Matrices


Example

Matrices

You must always use the amsmath package if you are going to use the following commands. There are four main types of matrix, as shown in the code below:

\begin{matrix} 
    a & b \\
    c & d 
\end{matrix}
\quad
\begin{pmatrix} 
   a & b \\
   c & d 
\end{pmatrix}
\quad
\begin{bmatrix} 
    a & b \\
    c & d 
\end{bmatrix}
\quad
\begin{vmatrix} 
    a & b \\
    c & d 
\end{vmatrix}
\quad
\begin{Vmatrix} 
    a & b \\
    c & d 
\end{Vmatrix}

This code produces

enter image description here

There are a couple important things to note about this:

  1. It is important you put your matrix within the equation, equation*, or $...$ environment - the bmatrix command is not a math environment on its own.
  2. The construction of the matrix is actually fairly simple. For each row, you create each element (say x_{11}), then put a &, and then write the next element. For multiple rows, at the end of each row put \\ (you do not have to do this for the last row). It is fairly similar to a table in this.