4

I have been trying to get

S0    = 0
Si+1  =   { .... }
        U { ........}
        U { ... }

definition layout in LaTeX, but have been unsuccessful for hours.

My main problem is that the unions have to be aligned differently than the =.

I hope there is anyone that can help me.

cmhughes
  • 100,947
codd
  • 1,239
  • Hi codd, welcome to tex exchange! I inserted the code snippet for you using the {}. I also removed the thanks- it seems strange, but it helps to keep the forum in a 'Question and Answer' format :) Have you tried the various environments from the amsmath package? It seems your problem could be solved using one of align, aligned, etc – cmhughes Apr 02 '12 at 20:05

3 Answers3

6

This is another case where (as an exception to the general rule) putting the relation symbol before the & can help:

\begin{align}
S_{0}={}  & 0\\
\begin{split}
S_{i+1}={}& \mathbin{\hphantom{\cup}}\{...\}\\
          & \cup\{...\}\\
          & \cup\{...\}
\end{split}
\end{align}

If you don't need to number the formulas, you can omit the \begin{split} and \end{split} and change align into align*.

The reason why this is needed is to ensure correct spacing after the \cup symbols.

enter image description here

David Carlisle
  • 757,742
egreg
  • 1,121,712
  • I like the combined alignand split. Also, less code clutter. – Christoph Apr 02 '12 at 20:30
  • 2
    does the OP want the Ss aligned? if so, the following will do it (it's a kludge): S_{0\hphantom{+i}} – barbara beeton Apr 02 '12 at 20:33
  • \mathbin was new to me, so I searched and found this: http://tex.stackexchange.com/questions/38982/what-is-the-difference-between-mathbin-vs-mathrel I think it might be useful to others reading the answers given here. – Christoph Apr 02 '12 at 20:55
  • @barbarabeeton thanks! I did want that as well. – codd Apr 03 '12 at 12:46
1

I used amsmath's split environment and a phantom for the missing U in the second equation:

\documentclass[varwidth,fleqn]{standalone}
\usepackage{amsmath}
\begin{document}
  \noindent
  \begin{equation}
    \begin{split}
     S_0 = & 0 \\
     S_{i+1} = & \phantom{U} \left\{ \ldots \right\}\\
     & U \left\{ \ldots \right\}
    \end{split}
  \end{equation}
\end{document}

enter image description here

You can leave out the subscripts if you wish.

I just noticed that this is a possible duplicate of Multi horizontal alignment in mathmode


Updated - after applying the recommendations from the comments, here's my second take:

\documentclass[varwidth,fleqn]{standalone}
\usepackage{amsmath}
\begin{document}
  \noindent
  \begin{equation}
    \begin{split}
     S_{0\phantom{+1}} & = 0 \\
     S_{i+1} & = \phantom{\cup} \left\{ \ldots \right\}\\
     & \mathrel{\phantom{=}} \cup \left\{ \ldots \right\}
    \end{split}
  \end{equation}
\end{document}

enter image description here

Christoph
  • 2,913
  • Please note: first the separator than the relation: http://tex.stackexchange.com/questions/50445/about-alignment-of-mathematics-formulas/50458#50458 – Marco Daniel Apr 02 '12 at 20:14
  • I'd recommend moving the alignment character to the left of the equal, adding the appropriate \phantom to get the S terms aligned left as desired by the OP, and using an appropriate symbol for union. In which case I can delete my answer. – Peter Grill Apr 02 '12 at 20:15
  • @Peter: Your answer is closer to what the OP wants, isn't it? Anyway, I'll edit my answer according to the recommendations - they're good, after all. – Christoph Apr 02 '12 at 20:17
  • Christoph, thanks for the (quick) answer. I will upvote your answer, but I am accepting egreg's because I am using it (because I find it more comprehensive). – codd Apr 02 '12 at 20:28
  • two problems: (1) in the first line, the spacing after the = is too tight (add an empty group {} as a kludge; (2) it's not a U, but a union \cup. better would be to put the & before the = and adjust spacing manually. not straightforward. – barbara beeton Apr 02 '12 at 20:30
  • I think I was just happy to see an unanswered question I thought I could answer more or less correctly. I was wrong, sort of ;) – Christoph Apr 02 '12 at 20:33
  • @barbara: Is your comment related to my first or to my second example? – Christoph Apr 02 '12 at 20:39
  • @Christoph -- to the first example; the second example wasn't there yet when i posted the comment. – barbara beeton Apr 02 '12 at 20:43
0

You current ASCII alignment suggests both "columns" to be left-aligned. As such, here's an array approach to achieve your output:

enter image description here

\documentclass{article}
%\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\[
  \begin{array}{l@{\;}c@{\;}l}
    S_0      &=& 0 \\
    S_{i+1}  &=& \phantom{\cup}\:\{\ldots\} \\
             & & \cup\:\{\ldots\} \\
             & & \cup\:\{\ldots\}
  \end{array}
\]
\end{document}

Instead of using U for set union, use \cup. The spacing adjustments (using \; and \: corrects any problems introduced by array due to column spacing.

You'll notice that the vertical alignment is slightly different (tighter) to that of the other solutions using align from amsmath. To obtain a similar alignment, use \\[\jot] for line endings rather than just \\.

Werner
  • 603,163