Center a column in align
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}
One can still use the align
environment,. in two ways:
- For a casual use, the
makebox
package introduces a\makebox*
command that takes two arguments: the first one is the text that defines the width of the box that contains the second argument. I used it to define an\oversetto
with 3 arguments, the first (optional) defining the width of the\overset
box. - A more systematic use requires the
eqparbox
package: its\eqmakebox
command has the same arguments as\makebox
(unstarred), plus a 3rd (optional) argument which is a tag. All \eqparboxes of the document sharing the same tag will have width equal to that of the widest one.
Here is an example of both ways:
\documentclass[12pt]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{mathtools,amssymb}
\usepackage{eqparbox}
\usepackage{makebox}
\newcommand\textoverset[3][]{\mathrel{\overset{\scriptsize{\eqmakebox[#1]{#2}}}{#3}}}
\newcommand\oversetto[3][]{\overset{\text{\makebox*{#1}{#2}}}{#3}}
\thispagestyle{empty}
\begin{document}
{\bfseries With \verb+\overset+: }
\begin{align*}
x_1 + x_2
&\overset{\text{some text}}= 2y³ \leq\\
&\overset{\text{some longer text}}\leq 3z
\end{align*}
{\bfseries With \verb+\textoverset+:}
\begin{align*}%over
x_1 + x_2 & \textoverset[O]{some text}{=} 2y³ \leq\\
y_i + y_2 & \textoverset[O]{some longer text}{\leq} 3z
\end{align*}
{\bfseries With \verb+\oversetto+ :}
\begin{align*}
x_1 + x_2 & \oversetto[Some longer text]{some text}{=}2y³ \leq \\
y_i + y_2 & \overset{\text{some longer text}}{\leq} 3z
\end{align*}
\end{document}