Complicated alignment within multiline equation
I'd do this with an alignat*
environment, but just put the text inside a parbox. That way, you can just align every equals sign and vertical bar; the line breaking will leave the text after the bar in ever case. This works, but is unfortunately slightly complicated. The best way to typeset a set comprehension (using etex) is with something like \left\{ x \;\middle|\; \phi \right\}
1,2, but apparently you can't put an &
between a \left
and a \right
. Manual scaling works, though, which gives this solution:
\newcommand{\pctext}[2]{\text{\parbox{#1}{\centering #2}}}
\begin{alignat*}{2}
X &= \biggl\{(p,q) &&\;\bigg|\; \pctext{1.5in}{$p=q+7$ and something else
very long}\biggr\} \\
Y(1) &= \{x &&\;|\; \pctext{1.5in}{$x$ is prime}\} \\
Z' &= \Biggl\{(a,b,c) &&\;\Bigg|\; \pctext{1.5in}{the variables $a$, $b$,
and $c$ satisfy a
condition that is too long
for one line}\Biggr\} \\
\end{alignat*}
This gives the following output:
As you can see, this does work, though I think it's not ideal. There are some spacing issues (which I'm not sure how to fix, or even what best to do) stemming from the differing sizes of the braces. And the code's a bit cluttered; one could probably write a macro to abstract some of the boilerplate, but enclosing &
in macros with align
and friends tends to be problematic.
1: Actually, I typically use the braket package to write \Set{x | \phi}
, but it uses \left
and \right
(and \middle
if it can) under the hood.
2: Since it's assumed that |
is a delimiter here, it's not spaced out, and so we use \;
s to get the spacing right. If we use a relation such as \mid
, we get the same (I think) spacing, but we can't \middle
it.