I am trying to come up with the absolute best way to replicate an matrix alignment style that my textbook has (Linear Algebra with Applications by Steven J. Leon).
I first found this MOSTLY helpful answer here.

The only problem is that looking at peoples responses, although they are able to get the positive integers aligned when some entries have negative signs, what will happen is that there is additional space. Take a look at the top rated answer there. See that, although everything is aligned nicely, the spacing between the first column and the second column is larger than the spacing between any other two consecutive columns.

Leon's book doesn't have this issue. Is there any way to make positive integers aligned despite negative signs and without offsetting the column spacing?


1 Answer 1


For this problem, mathtools defines useful commands: \mathrlap, \mathllap and \mathclap, which make their arguments have 0 width, while being left, right or center-aligned. Combined with \phantom, and used in the example you refer to,this results in a better result with a simple code:

\usepackage{mathtools} % loads amsmath


    1 & 0 & 0 & 0 \\
    0\phantom{i} & 2 & 2i & 0 \\
    0 & \mathllap{-}2 i & 2 & 0 \\
    0 & 0 & 0 & 1


enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .