# Center a column in align

I have the following type of code in my document:

\begin{align*}
(-m)+m & \stackrel{\mathrm{Ax 1.1 (i)}}{=}  m+(-m)\\
&\stackrel{\mathrm{Ax 1.4}}{=}  0 \\


I want to align on the = but that is complicated by the fact that there is something hovering over it.

It would seem to be easier to align their centers (no matter what, that is where the = will be).

How can I center a column in align (or align* to be honest, I am not that clear on the difference)

-
I currently don't have access to latex, but maybe adding the \mathclap{} command to the stuff you put over the '=' helps? You can find it in the mathtools package – Jakob van Bethlehem Sep 6 '12 at 6:53

Since you don't need to number each row, use an array:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{array}{@{}r@{{}\mathrel{}}c@{\mathrel{}{}}l@{}}
(-m)+m & \overset{\text{Ax 1.1 (i)}}{=} & m+(-m)\\
& \overset{\text{Ax 1.4}}{=}     & 0
\end{array}
\end{equation*}
\end{document}


Notice that \overset is preferable to \stackrel and that \text will preserve spaces. Between the first and the second column I put the space normally used for a relation symbol (produced by {}\mathrel{}) and similarly for the other intercolumn space. If you want that the text is upright whatever is the context the formula is in (perhaps embedded in something in italics), use \textup instead of \text.

Here's the result:

However, this seems not particularly legible; usually I prefer setting the justification on the right:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
(-m)+m &= m+(-m) && \text{by Ax 1.1 (i)} \\
&= 0  && \text{by Ax 1.4}
\end{align*}
\end{document}


-
 actually, even with \overset, in this case \text is as good as \textrm, and maybe better, as it is designed to work in math. like \textrm it observes spaces and produces the correct size. (it does require amsmath.) – barbara beeton Sep 6 '12 at 12:50 @barbarabeeton Thanks, I changed the answer accordingly. – egreg Sep 6 '12 at 12:57 I still would not write too much like that, I think it is much more readable to add something like this into the text. I have some lectures here how do something like the above for almost every larger calculation. Very annoying to read, and not something that encourage the student to understand the steps in the calculation. – daleif Sep 6 '12 at 13:17

This might be one of those cases where using eqnarray (or eqnarray* if you do not want a numbered equation) might be appropriate (in general eqnarray is deprecated).

\begin{eqnarray*}
(-m)+m & \stackrel{\mathrm{Ax 1.1 (i)}}{=}&   m+(-m)\\
& \stackrel{\mathrm{Ax 1.4}}{=}&  0 \\
& \stackrel{\mathrm{Ax 1.4 (iiii)}}{=}&  0
\end{eqnarray*}


Eventually, it is possible to use \mathclap{} from the mathtools package to improve the spacing around =.

\begin{eqnarray*}
(-m)+m & \stackrel{\mathclap{\mathrm{Ax 1.1 (i)}}}{=}&   m+(-m)\\
& \stackrel{\mathclap{\mathrm{Ax 1.4}}}{=}&  0
\end{eqnarray*}


Alternatively it is possible to change the space around = with

\bgroup\arraycolsep=1.4pt
\begin{eqnarray*}
(-m)+m & \stackrel{\mathrm{Ax 1.1 (i)}}{=}&   m+(-m)\\
& \stackrel{\mathrm{Ax 1.4}}{=}&  0
\end{eqnarray*}
\egroup

-
 Please, do not use eqnarray! – tohecz Sep 6 '12 at 12:51 @tohecz if you look at the opening of the answer I wrote that eqnarray is deprecated but under the special circumstances of the question it might be right to use it. – Guido Sep 6 '12 at 13:23 Guido, I know. I only wanted to stress it again: Do not use eqnarray! – tohecz Sep 6 '12 at 13:36