# Whitespace surrounding elements in a matrix

I was just wondering, when writing a matrix in the following way

\begin{pmatrix}
\begin{array}{cc}
-5 & 3 \\
6 & -4
\end{array}
\end{pmatrix}


I get quite a lot of unnecessary padding/white-space between the elements and the brackets. Is there any way of controlling this?

-

It's not necessary to have an array environment inside a pmatrix environment. The following should give you a reasonably good-looking 2x2 matrix:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\begin{pmatrix} -5 & 3 \\ 6 & -4 \end{pmatrix}$
\end{document}


If you want the elements of the columns to be right-aligned (rather than centered, which is the default), there are several ways to do this. In the present case, one way to achieve this objective is to place invisible minus signs before the upper-right and lower-left elements:

\begin{pmatrix}
-5           & \phantom{-}3 \\
\phantom{-}6 &           -4
\end{pmatrix}


A nearly identical result -- in terms of right-aligning the column entries -- may be achieved by using just the array environment (i.e., without the pmatrix environment entirely) if care is taken to avoid excessive space between the matrix's delimiters and its contents, say along the lines of the following example:

  \left( \begin{array}{@{} rr @{}} % note the "@{}" terms
-5 &  3 \\
6 & -4
\end{array} \right)


Relative to the pmatrix-based method, the array-based method doesn't require you to add various \phantom statements; on the other hand, you have to insert the \left( and \right) directives yourself, and you have to specify the array's structure explicitly: the number of columns, their alignment, and the suppression of the default whitespace between the parentheses and the matrix itself. Which of the two methods is preferable overall will depend on the size and contents of the actual matrix you need to typeset.

For completeness, here's how the matrices generated by the three examples look like:

-

Other option, not so elegant like the other is to use an array surrounded by two delimiters \left \right. I believe that it is not the best way to produce a matrix but when we start learning LaTeX we often see this kind of examples.

\left(
\begin{array}{cc}
-5 &  3 \\
6 & -4
\end{array}
\right)

-