I would like to be able to align the minus sign in a matrix so that the minus is to the left of the numerical column. I have written my matrix as the following:
\begin{eqnarray}
\left(
\begin{array}{llll}
1 & 0 & 0 & 0 \\
0 & 2 & 2i & 0 \\
0 & -2i & 2 & 0 \\
0 & 0 & 0 & 1
\end{array}
\right),
\label{eq:rhot}
\end{eqnarray}
An extracted form of that is as:
But the desired shape should be as a format in which the [3,2] element (-2i) must be written as though: 2 below 2 of the [2,2] element, and the minus sign be at the left of the second column as:
Albeit I made it by paint.
Best Answer
Using the
mathtools
package you can make use of enhanced versions of thematrix
environments. In this example I use the starred version ofpmatrix
which accepts an optional argument which is the alignment of the cells. To reserve the space for the minus sign, I simply put\phantom{-}
before the entries to be spaced out.To align at the
i
, just apply the above trick in reverse, i.e. add\phantom{i}
where needed.Using David's
dcolumn
package you can also achieve alignment at thei
. This has the disadvantage, that it reserves space for thei
even in columns where there is noi
(like the first and last columns in the example).