# How do I left-align entries in a matrix with \begin{matrix}?

I'd like to left align -1 entry in the following matrix so that the 1s line up. Is there a way to get matrices to ignore signs in that way?

\begin{matrix}
1 & 1  \\
1 & -1 \\
\end{matrix}


Using \flushright{-1} doesn't seem to work.

-
mathtools allows you to l/r align entries in matrices. In your example, putting an \hfill before the upper 1 should also work. –  anon Feb 19 '12 at 5:38

A quick way to do this is by adding phantom characters:

\begin{matrix}
1 & \phantom{-}1  \\
1 & -1 \\
\end{matrix}


Although for simple arrays like this it's probably simpler just to use a standard array environment

\begin{array}{rr}
1 & 1  \\
1 & -1 \\
\end{array}


for the same result. Note that if you need control over alignment, then array is the preferred way to typeset matrices (you can simply wrap in \left( ... \right) etc. for brackets and lines).

-
Perfect, thank you. –  Will Feb 19 '12 at 5:09
You're welcome! For extra information on mathematics environments, the documentation of the amsmath package is an excellent resource. –  Mark S. Everitt Feb 19 '12 at 5:11
If you using LaTeX2e out of the box, you can use the array environment, which is similar to a tabular:
\documentclass{article}
$\begin{array}{rr} 1 & 1 \\ 1 & -1 \\ \end{array}$