Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
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

2 Answers

up vote 11 down vote accepted

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

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

enter image description here

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).

share|improve this answer
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{document}
\[
\begin{array}{rr}
    1 &  1  \\
    1 & -1 \\
\end{array}
\]
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.