How can I create matrices in general in LaTeX? As well as the one below?
Are there packages that are preferred over others?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityUse amsmath
: it defines 6 types of matrix environments: matrix
(without any delimiter), pmatrix
(delimiters: ( )
), bmatrix
([ ]
), Bmatrix
({ }
), vmatrix
(| |
), Vmatrix
(|| ||
). Columns are centred.
Still better: with mathtools
, an extension of amsmath
, you have starred variants which accept an optional argument for the columns alignment ([l]
, [r]
or [c]
, valid for all columns).
Here is a code for your image:
\[ \begin{pmatrix}x'\\y'\end{pmatrix}=
\begin{bmatrix}
\cos\theta & -\sin\theta\\
\sin\theta & \cos\theta
\end{bmatrix}
\begin{pmatrix}x \\y \end{pmatrix} \]
The use of \[ ... \]
can be substituted by the equation environment \begin{equation} ... \end{equation}
amsmath
package, and itspmatrix
andbmatrix
environments.