I'm having trouble getting the desired alignment behavior in a set of "sets" that I'm typesetting. I have a bunch of set definitions of the form
$$U = \{\text{$x$ $|$ $x$ satisfies some condition}\}$$
Of course, I want the equals signs to line up, which is easy enough to do with an align*
environment.
The problem is that for some of the sets, the "some condition" takes a couple of lines to state. I'd like like those lines to align after the |
symbol.
Of course, if I only had one set to define, then I could do the previous thing with the align*
environment.
However, I want to achieve both of the above behaviors in the same set of equations. How do I do this?
EDIT: After seeing frabjous's answer below, I realized that I didn't emphasize (or even mention) one of the key difficulties. The U
's and x
's in my set definition are actually expressions with different lengths, so the second align point in each set definition is different. This prevents me from using an array environment. For instance, I could have something like the following:
X = {(p,q) | p=q+7 and something else very long that doesn't fit
on one line}Y(1) = {x | x is prime}
Z' = {(a,b,c) | the variables a, b, and c satisfy a condition that
is too long for one line}.
Sorry for not using tex in the above, but I think it makes it clear what is happening.
Thanks for any help.
EDIT 2: Thanks to Antal S-Z's nice answer, I was able to create a macro that does exactly what I wanted. In case anyone desires the same behavior, here it is.
\newcommand\Set[3]{\ensuremath{\{\text{#1 $|$ \parbox[t]{\widthof{#3}}{#2\}}}}}
You call it with 3 arguments. To get a set {x|P}, the first argument should be x, the second P (with newlines in it) and the third the longest line in your condition P. This is compatible with align*
, so you can then do things like
\begin{align*}
A &= \Set{x}{P}{Q}\\
B &= \Set{y}{R}{S}
\end{align*}
and it typesets things correctly.