[Tex/LaTex] Where is the \matrix command

mathjaxmatrices

From what I can see, \matrix was a TeX command, but I cannot seem to find documentation on it.

It works in MathJax, so I wonder if it can be used in LaTeX.

ie this is valid MathJax:

$$
\left[
\matrix
{
newx.x&newy.x&newz.x \\
newx.y&newy.y&newz.y \\
newx.z&newy.z&newz.z    
}
\right]
$$

As can be seen on math.stackexchange.

In my LaTeX editor (which uses MiKTeX underneath), I have to use \begin{matrix} .. \end{matrix}, so I'm wondering what happened to the \matrix command.

Best Answer

In addition to some already provided, here are a number of ways of creating matrices in LaTeX. Using

  • an array structure to place items in a rigid row/column environment;
  • \begin{matrix}...\end{matrix} from the amsmath package, which allows you to specify the matrix delimiters yourself (using \left and \right);
  • pmatrix, bmatrix, Bmatrix, vmatrix and Vmatrix variations to the above (also from amsmath) to fix the delimiters to ( ), [ ], { }, | |, and || ||, respectively;
  • \bordermatrix{...} which is a TeX command and will specify row and column indicies;
  • \kbordermatrix{...} which is similar to the above, but provides more flexibility;
  • the blkarray package and the associated blockarray and block environments to construct your matrix.

Here is an example file showing some of the different styles:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{kbordermatrix}% http://www.hss.caltech.edu/~kcb/TeX/kbordermatrix.sty
\usepackage{blkarray}% http://ctan.org/pkg/blkarray
\begin{document}

\[
\begin{array}{lc}
  \verb|array| & \left(\begin{array}{@{}ccc@{}}
                    a & b & c \\
                    d & e & f \\
                    g & h & i
                  \end{array}\right) \\[15pt]
  \verb|matrix| & \left(\begin{matrix}
                    a & b & c \\
                    d & e & f \\
                    g & h & i
                  \end{matrix}\right) \\[15pt]
  \verb|pmatrix| & \begin{pmatrix}
                    a & b & c \\
                    d & e & f \\
                    g & h & i
                  \end{pmatrix} \\[15pt]
  \verb|bmatrix| & \begin{bmatrix}
                    a & b & c \\
                    d & e & f \\
                    g & h & i
                  \end{bmatrix} \\[15pt]
  \verb|Bmatrix| & \begin{Bmatrix}
                    a & b & c \\
                    d & e & f \\
                    g & h & i
                  \end{Bmatrix} \\[15pt]
  \verb|vmatrix| & \begin{vmatrix}
                    a & b & c \\
                    d & e & f \\
                    g & h & i
                  \end{vmatrix} \\[15pt]
  \verb|Vmatrix| & \begin{Vmatrix}
                    a & b & c \\
                    d & e & f \\
                    g & h & i
                  \end{Vmatrix} \\[15pt]
  \verb|bordermatrix| & \bordermatrix{\text{corner}&c_1&c_2&\ldots &c_n\cr
                r_1&a_{11} &  0  & \ldots & a_{1n}\cr
                r_2& 0  &  a_{22} & \ldots & a_{2n}\cr
                r_3& \vdots & \vdots & \ddots & \vdots\cr
                r_4& 0  &   0       &\ldots & a_{nn}} \\[15pt]
  \verb|kbordermatrix| & \kbordermatrix{\text{corner}&c_1&c_2&\ldots &c_n\cr
                r_1&a_{11} &  0  & \ldots & a_{1n}\cr
                r_2& 0  &  a_{22} & \ldots & a_{2n}\cr
                r_3& \vdots & \vdots & \ddots & \vdots\cr
                r_4& 0  &   0       &\ldots & a_{nn}} \\[25pt]
  \verb|blkarray| & \begin{blockarray}{[cc]c\}}
                11 & 22 & 33 \\
                1 & 2 & 3 \\
                \begin{block}{(ll)l\}}
                  11 & 22 & 33 \\
                  1 & 2 & 3 \\
                \end{block}
                1 & 2 & 3
                \end{blockarray}
\end{array}
\]
\end{document}

Matrices

Related Question