# Horizontal alignment of long equations

I hope that the following question is not a duplicate but I could not find a definite answer.

I'm trying to obtain the the same result as Formula (1) in the picture next, but I feel that my approach is not optimal and somewhat dirty.

I produced the output with the following code:

\documentclass{scrartcl}

\usepackage{amsmath}

\begin{document}

\begin{aligned} X & = \{ x \mid \text{a very very very long condition} \} \cup \\ & \phantom{{}={}} \{ y \mid \text{another very very very long condition} \} \end{aligned}

$$\begin{split} X & = \{ x \mid \text{a very very very long condition} \} \cup \\ & \quad \{ y \mid \text{another very very very long condition} \} \end{split}$$

\begin{aligned} X = & \{ x \mid \text{a very very very long condition} \} \cup \\ & \{ y \mid \text{another very very very long condition} \} \end{aligned}

$$X = \begin{array}[t]{l} \{ x \mid \text{a very very very long condition} \} \cup \\ \{ y \mid \text{another very very very long condition} \} \end{array}$$

\end{document}

Formula (1) is the output I desire. However, I can't imagine that using \phantom is the right way to go.

Formula (2) is according to the examples in the amsmath package documentation. And it looks ugly.

Formula (3) is better, but the kerning is wrong. However, I somehow feel that using the alignment in this way is the right approach.

Finally, Formula (4) uses an array, but also here the kerning is screwed.

Can anyone hint me in the right direction? Thanx!

-
The right way to write it inside aligned is: \begin{aligned} X = {} & \{ x \mid \text{a very very very long condition} \} \cup \\ & \{ y \mid \text{another very very very long condition} \} \end{aligned} –  karlkoeller Aug 12 '13 at 20:19
I would agree that #3 is the idiomatic way, but I don't see the issue with kerning that you see, I suppose. At least in the picture, it's unnoticeable (to the point that I don't see it at all). –  Sean Allred Aug 12 '13 at 20:19
@SeanAllred -- take a closer look. in #3 there is no space between the equals sign and what follows. this is wrong. only #1 has the desired (proper) spacing. –  barbara beeton Aug 12 '13 at 20:28
@barbarabeeton oh goodness, how did I miss that? Well, using \phantom isn't all that hacky---this might be legitimate use. (For laziness' sake, something tells me you can add an empty group after = in #3 to achieve the effect---it's less typing.) –  Sean Allred Aug 12 '13 at 20:36
@karlkoeller perhaps an answer then? :-) –  Sean Allred Aug 12 '13 at 20:40

In these cases there is no need at all for \phantom commands.

To ensure the correct spacing when binary relations or operators are involved, it suffices to use an empty group {}.

Infact, the code

\documentclass{scrartcl}
\usepackage{amsmath}

\begin{document}

\begin{aligned} X = {} & \{ x \mid \text{a very very very long condition} \} \cup {} \\ & \{ y \mid \text{another very very very long condition} \} \end{aligned}

\end{document}

gives the desired spacing:

-
Thanks, this solution gives the right output and "feels right" ;) I guess that I should also use \cup {} \\ rather than just \cup \\ to get a proper spacing?! –  Dan Aug 12 '13 at 20:58
@Dan Sorry, I've been notified about your original comment, so I didn't see the edit. The answer is: yes, of course (I was going to bed and I didn't even notice that the first line ends with \cup...). I've added it in the answer, too. –  karlkoeller Aug 13 '13 at 6:34