# align+multicolumn sometimes produces misaligned equation labels

Here is a short document demonstrating the problem:

\documentclass[twocolumn]{article}
\makeatletter
\renewcommand{\rmdefault}{ptm}
\renewcommand{\normalsize}{\@setfontsize{\normalsize}{9pt}{10pt}}
\makeatother
\usepackage[table]{xcolor}
\usepackage{amsmath}

\begin{document}
\begin{itemize} \item
\begin{align}
longfoo &\in foo \\
foo &= longlonglongfoo \\
foo &= foo && longlonglongfoo \\
\multicolumn{2}{c}{foo}
\end{align}
\end{itemize}
\end{document}


This produces a document that looks like this:

As you can see, the (4) label does not line up with the others. I tried to minimize the document as much as possible, so the visual problem is not so serious in this small example, but you can see in my actual document that the alignment is quite far off indeed.

Why is the alignment off, and what can I do to fix it?

-

\multicolumn shouldn't be used here.

Here's how to place the last line centered around the = in the line above:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath

\newsavebox{\equalbox}
\savebox{\equalbox}{${}={}$}
\begin{document}

\begin{align}
c_a &= (\mathit{swap}(c_b),()) \\
(x,c_a,y) &\in a.K \\
(x,c_b,y) &\in b.K \\
x &= \mathsf{inl}(x_k) \quad \text{for some $x_k\in X_k$} \\
&\hspace*{.5\wd\equalbox}
\makebox[0pt]{$\mathrm{d}x; \mathit{init}_{X_i}\downarrow$}
\end{align}
\end{document}


We store the relation = in a box and use it to measure exactly halfway from the alignment character &. Then we place the construction in a zero-width box (which is centered by default).

-

Using \multicolumn in align is not really allowed, as the environment doesn't use the same mechanism as tabular or array.

In this particular case, alignment at the relation symbol is not the best way to manage the display, because those symbols are not related to each other.

\documentclass[twocolumn]{article}
\usepackage{amsmath}

\begin{document}
\begin{align}
& c_a=(\mathit{swap}(c_b),()) \\
& (x,c_a,y)\in a.K \\
& (x,c_b,y)\in b.K \\
& x=\mathsf{inl}(x_k)\quad \text{for some $x_k\in X_k$} \\
& \mathrm{d}x; \mathit{init}_{X_i}\downarrow
\end{align}
\end{document}


-

Did you try to put & \text{foo} instead of the multicolumn?

Also where exactly do you want to line up?

You can also use the \phantom{} command to hide parts of the equation, for instance

\phantom{foo} & \phantom{{} = } \text{foo}


would then align on the invisible =

\documentclass[twocolumn]{article}
\makeatletter
\renewcommand{\rmdefault}{ptm}
\renewcommand{\normalsize}{\@setfontsize{\normalsize}{9pt}{10pt}}
\makeatother
\usepackage[table]{xcolor}
\usepackage{amsmath}

\begin{document}
\begin{itemize} \item
\begin{align}
longfoo &\in foo \\
foo &= longlonglongfoo \\
foo &= foo && longlonglongfoo \\
\phantom{foo} & \phantom{{} = } \, foo
\end{align}
\end{itemize}
\end{document}


Edit: Changed the phantom line to

\phantom{foo} \phantom{{} = } & \! \! foo


giving

-
The alignment of the non-label parts of my real document is essentially ideal, as far as I'm concerned: dx;init_X is centered compared to the remaining equations. I don't see how to do this without spanning, as you seem to be suggesting. –  Daniel Wagner Apr 29 at 22:00
Did you see my update? –  Trefex Apr 29 at 22:02
Yes, I saw the update; your proposal aligns the lone non-equation with the left-most parts of the right-hand sides of the equations, which doesn't look very good compared to centering the non-equation compared to the equations. –  Daniel Wagner Apr 29 at 22:04
like this ? --> update –  Trefex Apr 29 at 22:07
Okay, that seems like it could work with a bit of manual effort. Thanks! –  Daniel Wagner Apr 29 at 22:08