Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

enter image description here

I produced the output with the following code:

\documentclass{scrartcl}

\usepackage{amsmath}

\begin{document}

\begin{equation}
\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}
\end{equation}

\begin{equation}
\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}
\end{equation}

\begin{equation}
\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{equation}

\begin{equation}
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{equation}

\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!

share|improve this question
1  
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
1  
@karlkoeller perhaps an answer then? :-) –  Sean Allred Aug 12 '13 at 20:40

1 Answer 1

up vote 6 down vote accepted

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{equation}
\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{equation}

\end{document} 

gives the desired spacing:

enter image description here

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.