4

I use Typora. I have obtained the following, using an array and multiple quads :

enter image description here

$\begin{array}{lcl} P_4 & = & P_1 & \cup & \\ 
& \cup & P_2 & \cup & \\ 
& \cup & \left \{ S \xrightarrow[(1)]{} b \quad 
    \mid \quad S_1 \rightarrow b \in P_1, 
         \quad b \in X \cup \left \{ \lambda \right \} 
         \quad \right \} &\cup & \\ 
&\cup & \left \{ S \xrightarrow[(2)]{} bC \quad 
   \mid \quad S_1 \rightarrow bC \in P_1, 
        \quad b \in X, \quad b \ne \lambda, 
        \quad C \in V_1 \quad \right \} 
\end{array}$

instead, I would want to obtain the following:

enter image description here

I have tried, but, I obtain an error if I use parenthesis within array. Please, can you tell me, how can I obtain that tabular positioning? Thanks! :)

5
  • 1
    I think you can adapt codes from answers to this post. They used a lot of alignments. tex.stackexchange.com/q/416555/14757
    – Sigur
    Commented Feb 24, 2018 at 19:38
  • @Sigur in the cases listed, there aren't rows of parethesis within the same array.
    – JB-Franco
    Commented Feb 24, 2018 at 19:42
  • No problem. Just read your formula as a system of formulas and align the symbols, including the bars and braces, and unions.
    – Sigur
    Commented Feb 24, 2018 at 19:44
  • Please, can you explain it better or can you post a simple example?
    – JB-Franco
    Commented Feb 24, 2018 at 19:55
  • Done. You can control the space between cols.
    – Sigur
    Commented Feb 24, 2018 at 20:27

5 Answers 5

3

Here's a deliberately differently-styled answer, which uses a single align* environment and no array environments. Observe that the \cup symbols at the starts of rows 2, 3, and 4 are shifted to the right of the = symbol in row 1, to emphasize that p (at the start of row 1) is the union of the remaining stuff on all four lines. With such a layout, it's also not necessary to provide \cup symbols at the ends of rows 1, 2, and 3.

Observe also that I use \Bigm| instead of \mid in rows 3 and 4, to provide some more visual support for what the main things in those two rows are. I also use simple spaces instead of \quad, as I believe the latter inserts too much horizontal displacement.

enter image description here

\documentclass{article} 
\usepackage{amsmath} % for 'align*' env.
\begin{document}
\begin{align*}
P_4 &= P_1 \\
    &\quad \cup P_2 \\
    &\quad \cup\Bigl\{ S\xrightarrow[(1)]{} b\phantom{C} 
               \Bigm|  S_1\to b\phantom{C}\in P_1,\  
                       b\in X\cup\{\lambda\} 
               \Bigr\} \\
    &\quad \cup\Bigl\{ S\xrightarrow[(2)]{}bC 
               \Bigm|  S_1\to bC\in P_1,\ 
                       b\in X,\ 
                       b\notin\lambda,\ C\in V_1
               \Bigr\}
\end{align*}
\end{document}
5

I would exploit having a short second term:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{aligned}
P_4 = P_1
& \cup P_2 \\
& \cup \Bigl\{ S \xrightarrow[(1)]{} b\hphantom{C} \Bigm|
         S_1 \rightarrow b \in P_1, b \in X \cup \{\lambda\}
       \Bigr\} \\
& \cup \Bigl\{ S \xrightarrow[(2)]{} bC \Bigm|
         S_1 \rightarrow bC \in P_1,
          b \in X,  b \ne \lambda,
          C \in V_1
       \Bigr\}
\end{aligned}
\end{equation*}

\end{document}

The trailing \cup symbols do nothing and appear as hanging from nowhere. I see no real reason for artificially aligning unconnected bits, except for the vertical bar. To the contrary, the asymmetry between the terms will help the reader in spotting the differences.

enter image description here

4

One way to accomplish this is using a \hphantom.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\begin{array}{lcll} P_4 & = & P_1 & \cup  \\ 
& \cup & P_2 & \cup  \\ 
& \cup & \left \{ 
\makebox[0pt][l]{$S \xrightarrow[(1)]{} b \quad$}
\hphantom{S \xrightarrow[(2)]{} bC \quad}
 \mid \makebox[0pt][l]{$\quad S_1 \rightarrow b \in
P_1, \quad b \in X \cup \left \{ \lambda \right \} \quad$}
\hphantom{\quad S_1 \rightarrow bC \in P_1, \quad b \in X, \quad b \ne \lambda, \quad C \in V_1 \quad} \right \} &\cup  \\
&\cup& \left \{ S \xrightarrow[(2)]{} bC \quad \mid \quad S_1 \rightarrow bC \in P_1, \quad b \in X, \quad b \ne \lambda, \quad C \in V_1 \quad \right \} 
\end{array}$
\end{document}

enter image description here

Alternative: \vphantoms

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\begin{array}{lclclll} P_4 & = & P_1 & & & & \cup  \\ 
& \cup & P_2 & & & & \cup  \\ 
& \cup & \left \{ 
S \xrightarrow[(1)]{} b \right.&  \mid &  S_1 \rightarrow b \in
P_1, \quad b \in X \cup \left \{ \lambda \right \}& 
\left.\vphantom{S \xrightarrow[(1)]{} b}\right\} &\cup  \\
&\cup& \left\{ S \xrightarrow[(2)]{} bC \right.& \mid 
& S_1 \rightarrow bC \in P_1, \quad b \in X, \quad b \ne \lambda, \quad C \in V_1 
& \left.\vphantom{S \xrightarrow[(1)]{} b}\right\}
\end{array}$
\end{document}

But do you really like the outcome? (To me it looks almost as terrible as a pineapple on a pizza ;-)

2
  • thanks, but, also the contents of the parenthesis must be aligned as tabular.
    – JB-Franco
    Commented Feb 24, 2018 at 19:45
  • 3
    Nothing can be terrible like 🍍 on 🍕, +1
    – egreg
    Commented Feb 25, 2018 at 6:07
4

It's as simple to do that with alignat, and you have full control on the spacing between the element of the formula:

 \documentclass{article}

\usepackage{mathtools}
\usepackage{makebox} 

\begin{document}

\begin{alignat*}{6}
  P_4 & \makebox*{${}\cup{}$}{$ = $} P_1\\
  &\cup P_2 & & & & & & & & & & \cup\\
 & \cup \Bigl\{S \xrightarrow[(1)]{} b & & \mid S \xrightarrow{} b\in P_1, & \enspace & b\in X\cup\{\lambda\} & \enspace & & & \Bigr\} &\enspace & \cup\\
 & \cup \Bigl\{S \xrightarrow[(2)]{} b C& & \mid S \xrightarrow{} b\in P_1, &\enspace & b\in X ,& \enspace & b\ne\lambda, & \enspace C\in V_1&\Bigr\} & &\cup
\end{alignat*}

\end{document} 

enter image description here

1
  • @Mico: Forgot this! I'll complete in a moment.
    – Bernard
    Commented Feb 24, 2018 at 20:14
3

Adapting this answer by Mico, we can produce the following:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\setlength{\arraycolsep}{3pt}
\begin{array}{rcl c l c l c r c r c }
P_4 & = &    P_1  &&&&&&&&& \cup \\
    & \cup & P_2  &&&&&&&&& \cup \\
    & \cup & \Bigl\{ S \xrightarrow[(1)]{} b & \mid & S_1 \to b  \in P_1, && b \in X \cup  \{ \lambda \} &&                  && \Bigr\}            & \cup \\
    & \cup & \Bigl\{ S \xrightarrow[(2)]{} bC & \mid & S_1 \to bC \in P_1, && b \in X,                    &&   b\neq \lambda, && C\in V_1   \Bigr\} & \cup 
\end{array}
\]
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .