# Alignment problem using align environement and \phantom

The following code

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

\begin{document}
\begin{align*}
A &\leq B \cdot C \cdot \int D
\\&
\phantom{{} \leq B \cdot {}}
C \cdot \int D
\\&
\phantom{{} \leq B \cdot C {}}
\cdot \int D
\\&
\phantom{{} \leq B \cdot C \cdot \int {}}
D
\end{align*}

\begin{align*}
A &\leq \fbox{aaaaaaaaaaaaaaaaaaaaaaaaa}
\\&
\phantom{{} \leq {}}
\cdot \int \fbox{bbbbbbbbbbbbbbbb}
\\&
\phantom{{} \leq \cdot \int {}}
\fbox{ccccccccccccccccccc}
\end{align*}
\end{document}


gives

In the first case the alignments work exactly as I would expect. But why in the second case the boxes of b's and c's are not aligned?

In the second align you're forgetting the empty atom after \leq:

\begin{align*}
A &\leq \fbox{aaaaaaaaaaaaaaaaaaaaaaaaa}
\\&
\phantom{{} \leq {}}
\cdot \int \fbox{bbbbbbbbbbbbbbbb}
\\&
\phantom{{} \leq {}\cdot \int {}}
\fbox{ccccccccccccccccccc}
\end{align*}


When you have Rel Bin Op, the Bin atom is changed into Ord (think to $a \leq -\log b$), so the spacing changes.

Why don't you align it directly to the point where you want it, and then adjust the first row accordingly?

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

\begin{document}
\begin{align*}
A \leq B \cdot C \cdot \int &D
\\
C \cdot \int &D
\\
\cdot \int &D
\\
&D
\end{align*}

\begin{align*}
A \leq \hspace{2.2em} &\hspace{-2em}\fbox{aaaaaaaaaaaaaaaaaaaaaaaaa}
\\
\cdot \int &\fbox{bbbbbbbbbbbbbbbb}
\\
&\fbox{ccccccccccccccccccc}
\end{align*}
\end{document}


Please not that I added 2.2em before the &, instead of 2em, because it gives a space between the \leq and the box, and it looks a bit better, at least to me.

• Thanks for your advice. I guess I could do that in this specific example. But that does not answer my question. Why is the alignment working in the first example but not the second? Commented Jul 15, 2016 at 9:18
• And the environment align is designed such that you put the alignment before the relation symbol. It gives then the right spacing around it. It looks weird to me to write & any where else. Commented Jul 15, 2016 at 9:18