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'm trying to write a set notation in multiple lines, for example:

enter image description here

This is my code to get it.

\usepackage{amsmath}

\begin{document}
...  
\begin{align*}
Lookup &= \{\, \langle C, A.m, B.m \rangle   \mid & \textrm{class $A$ contains virtual method $m$, $C \le^{*} B \le^{*} A$}, \\
            &      & \textrm{class $B$ contains virtual method $m$}, \\
            &      & \textrm{there is no class $B^{'}$ tht contains method $m$ such that $C \le^{*} B^{'} <^{*} B$}
\, \}\\
LC &= \{\, \langle a, b \rangle \mid \langle a, b, c \rangle \in ...\, \}
\end{align*}

However, I can't make the second & aligned correctly.

enter image description here

What might be wrong?

ADDED

enter image description here I replaced the second & with && to get the lines aligned correctly. However, I see too much space between the $\mid$ and $class A$. Is there a way to control the gap between them?

ADDED2

With Barbara's help, this is my working code.

\usepackage{amsmath}

\begin{align*}
 \textit{Lookup} &= \{\, \langle C, A.m, B.m \rangle   \mid {}
   \begin{aligned}[t] &\text{class $A$ contains ...}, \\
            & \text{class $B$ contains ...}, \\
            & \text{there is no class $B'$ that contains ...} \, \}
   \end{aligned}\\
\rlap{LC}\hphantom{\textit{Lookup}}
       &= \{\, \langle a, b \rangle \mid \langle a, b, c \rangle \in ...\, \}
\end{align*}

enter image description here

share|improve this question
1  
Use a double && for the second alignment point, so that becomes left aligned instead of right aligned. –  Peter Grill Nov 14 '12 at 21:31
1  
The spacing you show in your updated example is due to the second line. To eliminate that, you could enclose the right hand side of the second line within a \rlap{$\displaystyle ... $}. –  Peter Grill Nov 14 '12 at 21:41
    
Note that B^{'} is wrong; the correct way to input it is simply B'. –  egreg Nov 14 '12 at 22:31

2 Answers 2

up vote 5 down vote accepted

i suggest using the sub-environment aligned to handle the three conditions. also, since the apostrophe is automatically treated as a prime (in the desired location), i'd omit the explicit superscript code -- that is what is causing the interline spacing to be irregular.

here's my suggestion:

\begin{align*}
 \textit{Lookup} &= \{\, \langle C, A.m, B.m \rangle   \mid {}
   \begin{aligned}[t] &\text{class $A$ contains ...}, \\
            & \text{class $B$ contains ...}, \\
            & \text{there is no class $B'$ that contains ...}
   \end{aligned}\\
\rlap{LC}\hphantom{\textit{Lookup}}
       &= \{\, \langle a, b \rangle \mid \langle a, b, c \rangle \in ...\, \}
\end{align*}

with the result

output of code example

it's also not necessary to use \textrm; just \text will do in most situations (unless you happen to be in a theorem, for example). i've left-aligned the pre-equal-sign elements since that is what was in your first example -- this required the use of an artificially widened component to match the "Lookup" in the first line.

share|improve this answer
    
Thanks for the nice answer, the issue with this approach is that the closing bracket } is at the first line not the last line that I expected. In your code example, the enclosing } is missing. –  prosseek Nov 15 '12 at 18:52
    
@prosseek -- ah, i thought it looked like something was missing. what i'd do is put the \} that completes the "lookup" condition at the end of the last line within the aligned block. since it's not being sized, there are no constraints on where it can go. (admittedly, a computer algebra system would almost certainly not accept this approach.) –  barbara beeton Nov 15 '12 at 18:58

Thanks to Peter's help, I could make it work.

This is the modified code:

\begin{align*}
Lookup &= \{\, \langle C, A.m, B.m \rangle   \mid && \textrm{class $A$ contains virtual method $m$, $C \le^{*} B \le^{*} A$}, \\
            & && \textrm{class $B$ contains virtual method $m$}, \\
            & && \textrm{there is no class $B^{'}$ tht contains method $m$ such that $C \le^{*} B^{'} <^{*} B$}
\, \}\\
LC &= \rlap{$\{\, \langle a, b \rangle \mid \langle a, b, c \rangle \in \textrm{there is no class $B^{'}$ tht contains method $m$ such that $C \le^{*} B^{'} <^{*} B$}\, \}$}
\end{align*}

This is the result: enter image description here

share|improve this answer

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.