1

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 weird alignments

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?

2 Answers 2

3

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*}

enter image description here

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

0

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.

2
  • 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

You must log in to answer this question.

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