2

I would like to specify two very similar equations underneath each other, and align them at some points using the alignat environment. My code so far:

\begin{alignat}{3} 
D_s &= \{ (s_1, s_2)\quad & \forall\ &s_1, s_2\neq s_1 \quad && 
\begin{array}{|l}
 G_{s_1} \cap G_{s_2} \neq \{\} \\
 s_1 \notin \mathbb{D}(s_2) \wedge s_2 \notin \mathbb{D}(s_1)
 \end{array} \}\\
D_p &= \{ (p_1, p_2) & \forall\ &p_1, p_2\neq p_1 && 
\begin{array}{|l}
 G_{p_1} \cap G_{p_2} \neq \{\} \\
 p_1 \notin \mathbb{D}(p_2) \wedge p_2 \notin \mathbb{D}(p_1)
 \end{array}\}
\end{alignat}

gives me the following equations:

enter image description here

The alignment works perfectly. I would just like to increase the size of the outer braces, to make it look more like:

enter image description here

However, it seems that \left\{ and \right\} cannot span over multiple alignat columns.. How to change the above code to get the alignment of the first picture with the big braces from the second one?

TorbenB
  • 21

2 Answers2

2

A solution with the \DeclarePairedDelimiter command from mathtools and the eqparbox package:

\documentclass{article}
\usepackage{mathtools,amssymb}
\usepackage{eqparbox} 
\newcommand{\eqmathbox}[2][M]{\eqmakebox[#1]{$\displaystyle#2$}}

\DeclarePairedDelimiterX{\set}[1]{}{\setargs{#1}} \NewDocumentCommand{\setargs}{>{\SplitArgument{1}{;}}m} {\setargsaux#1} \NewDocumentCommand{\setargsaux}{mm} {\IfNoValueTF{#2}{#1}{\nonscript,#1\nonscript;\delimsize\vert\nonscript:\allowbreak #2\nonscript,}}

\begin{document}

\begin{align} D_s &= \set[\bigg]{\eqmathbox{(s_1, s_2)\quad \forall s_1, s_2\neq s_1}; \begin{aligned} &G_{s_1} \cap G_{s_2} \neq {} \ &s_1 \notin \mathbb{D}(s_2) \wedge s_2 \notin \mathbb{D}(s_1) \end{aligned}} \[1.5ex] D_p &= \set*{\eqmathbox{(p_1, p_2) \forall p_1, p_2\neq p_1} ; \begin{aligned} & G_{p_1} \cap G_{p_2} \neq {} \ & p_1 \notin \mathbb{D}(p_2) \wedge p_2 \notin \mathbb{D}(p_1) \end{aligned}} \end{align}

\end{document}

enter image description here

Bernard
  • 271,350
  • +1. The fences produced by \set* seem needlessy tall, though; \set[\bigg] might be preferable. – Mico Dec 08 '20 at 14:32
  • 1
    @Mico: you're probably right, albeit one may wonder whether it's an optical effect, due to the single-lined left side of the sets. I posted the version with [\bigg] for the first equation, so anyone interested in this solution may compare. Thanks! – Bernard Dec 08 '20 at 14:52
1

I would employ a plain align environment and use \biggl\lbrace, \biggm\vert, and \biggr\rbrace to create the "fence" symbols. Observe that \biggm\vert automatically inserts a bit of whitespace -- appropriate for a relational operator -- on both sides of the vertical bar.

You could replace the array environment with an aligned environment if you want the contents to be typeset in \displaystyle rather than in \textstyle math. For the case at hand, it won't make a difference, though.

enter image description here

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{align}
D_s &= \biggl\lbrace 
       (s_1, s_2)\quad \forall\ s_1, s_2\neq s_1 \,
       \biggm\vert
       \begin{array}{@{}l@{}}
          G_{s_1} \cap G_{s_2} \neq \emptyset \\
          s_1 \notin \mathbb{D}(s_2) \wedge s_2 \notin \mathbb{D}(s_1)
       \end{array} 
       \biggr\rbrace \\[1ex]
D_p &= \biggl\lbrace 
       (p_1, p_2) \quad\forall\ p_1, p_2\neq p_1 
       \biggm\vert
       \begin{array}{@{}l@{}}
          G_{p_1} \cap G_{p_2} \neq \emptyset \\
          p_1 \notin \mathbb{D}(p_2) \wedge p_2 \notin \mathbb{D}(p_1)
       \end{array}
       \biggr\rbrace
\end{align}
\end{document} 

Addendum to address the OP's follow-up comment: Since the suggested solution uses \biggl, \biggm, and \biggr rather than \left, \middle, and \right to resize the fence symbols, it is indeed possible to combine the approach with an alignat environment, along the following lines (no screenshot posted since the outcome looks very similar to the one above):

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{alignat}{4}
D_s &= \biggl\lbrace (s_1, s_2)\quad 
    &&\forall\ s_1, s_2\neq s_1 
    &&\biggm\vert
      \begin{array}{@{}l@{}}
          G_{s_1} \cap G_{s_2} \neq \emptyset \\
          s_1 \notin \mathbb{D}(s_2) \wedge s_2 \notin \mathbb{D}(s_1)
      \end{array} 
    &&\biggr\rbrace \\[1ex]
D_p &= \biggl\lbrace (p_1, p_2)  
    &&\forall\ p_1, p_2\neq p_1 
    &&\biggm\vert
      \begin{array}{@{}l@{}}
          G_{p_1} \cap G_{p_2} \neq \emptyset \\
          p_1 \notin \mathbb{D}(p_2) \wedge p_2 \notin \mathbb{D}(p_1)
      \end{array}
    &&\biggr\rbrace
\end{alignat}
\end{document}
Mico
  • 506,678
  • Thank you for your quick response! I copied the code, but the \vert were shifted horizontally (unlike your picture). So I ended up with the second picture from my original answer. However, because you avoided using \left and \right, I was able to get the correct result by using alignat after all. The code looks a bit messy, but the result is exactly how I like it, many thanks! – TorbenB Dec 08 '20 at 16:03
  • @TorbenB - I've gone ahead and posted an addendum to the address, to show how I would implement the suggested solution via an alignat{4} environment. Presumably, it's similar to what you've come up with. – Mico Dec 08 '20 at 17:33