Having two right brackets with alignat

alignbeamerequationshorizontal alignmentmath-mode

Considering the following MWE:

\documentclass[fleqn,xcolor={dvipsnames,table}]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools, nccmath, textcomp} % https://tex.stackexchange.com/questions/155534/how-to-reduce-the-size-of-fractions-typed-in-align-environment
\usepackage{booktabs} %https://tex.stackexchange.com/a/112514/166831
\usepackage{array}

\let\tc\textcolor

\definecolor{darkgreen}{rgb}{0.09, 0.45, 0.27}
\definecolor{dauphineblue}{rgb}{0.19,0.267,0.5176}

\newcommand{\tdb}[1]{\tc{dauphineblue}{#1}}
\newcommand{\tdr}[1]{\tc{darkred}{#1}}

% Thème CambridgeUS
\usetheme{CambridgeUS}
\usepackage{amsmath}

  \makeatletter
  \newcommand{\srcsize}{\@setfontsize{\srcsize}{7pt}{7pt}}
  \makeatother

\begin{document}


      \begingroup
      \srcsize %https://tex.stackexchange.com/a/207655/166831
      \begin{frame}
        Min $\sum_{i\in V} \text{some minimizing function with terms} + x + y$
      \begin{alignat*}{2}
        \displaystyle\sum_{\substack{i\in V\\j\dots}} \tdr{x_{ij}} + \sum_{\substack{i\in V\\j\dots}} \tdr{x_{ij}} &= c \tdr{x_{ij}}  ,&\quad\tdr{\forall i \in V}\\
        \dots \text{some more constraints}\\
        \displaystyle\sum_{\substack{i\in V\\j\dots}}\sum_{\substack{i\in V\\j\dots}} \tdr{x_{ij}}  &\ge 3 + \tc{darkgreen}{\sigma} &\\
        \tc{darkgreen}{\sigma}~ & \ge \tdr{x_{ij}} ,&\quad \tdr{\forall i \in V} \\
       \displaystyle\sum_{\substack{i\in V\\j\dots}} \tdb{y_{ij}} + \displaystyle\sum_{\substack{i\in V\\j\dots}} \tdb{y_{ij}} &= (1-\tdr{x_{ij}}),&\quad  \tdb{\forall i \in V}\\
       \tdb{y_{ij}}&\le \tdr{y_{jj}}, &\quad \tdb{\forall (i,j) \in V}\\
       \tc{darkgreen}{\sigma}~ & \in \mathbb N &\\
       \tdr{y_{11}} &= 1&\\
       \tdr{x_{ij}} &\in \mathbb B ,\quad&\tc{darkgreen}{\forall (i,j) \in V^2, i < j}\\
       \tdb{y_{ij}} &\in \mathbb B ,\quad&\tc{darkgreen}{\forall (i,j) \in V^2}\\
       \tdb{z_{ij}} &\in \mathbb B ,\quad&\tc{darkgreen}{\forall (i,j) \in V^2, i < j}
      \end{alignat*}
      \end{frame}
      \endgroup

      \begingroup
      \srcsize %https://tex.stackexchange.com/a/207655/166831
      \begin{frame}
        Min $\sum_{i\in V} \text{some minimizing function with terms} + x + y$
        \[\left.\begin{array}{rrr}
        \displaystyle\sum_{\substack{i\in V\\j\dots}} \tdr{x_{ij}} + \sum_{\substack{i\in V\\j\dots}} \tdr{x_{ij}} &= c \tdr{x_{ij}}  ,&\quad\tdr{\forall i \in V}\\
        \dots \text{some more constraints}\\
        \displaystyle\sum_{\substack{i\in V\\j\dots}}\sum_{\substack{i\in V\\j\dots}} \tdr{x_{ij}}  &\ge 3 + \tc{darkgreen}{\sigma} &\\
        \tc{darkgreen}{\sigma}~ & \ge \tdr{x_{ij}} ,&\quad \tdr{\forall i \in V} \\
       \displaystyle\sum_{\substack{i\in V\\j\dots}} \tdb{y_{ij}} + \displaystyle\sum_{\substack{i\in V\\j\dots}} \tdb{y_{ij}} &= (1-\tdr{x_{ij}}),&\quad  \tdb{\forall i \in V}
        \end{array}\color{darkred}\right\}\text{\tdr{Ring constraints}}\]

        \[\left.\begin{array}{rrr}
        \displaystyle\sum_{\substack{i\in V\\j\dots}} \tdb{y_{ij}} + \displaystyle\sum_{\substack{i\in V\\j\dots}} \tdb{y_{ij}} &= (1-\tdr{x_{ij}}),&\quad  \tdb{\forall i \in V}\\
        \tdb{y_{ij}}&\le \tdr{y_{jj}}, &\quad \tdb{\forall (i,j) \in V}\\
        \tc{darkgreen}{\sigma}~ & \in \mathbb N &\\
        \tdr{y_{11}} &= 1&
        \end{array}\color{dauphineblue}\right\}\text{\tdb{Star constraints}}\]

        \begin{alignat*}{2}
        \tc{darkgreen}{\sigma}~ & \in \mathbb N &\\
         \tdr{x_{ij}} &\in \mathbb B ,\quad&\tc{darkgreen}{\forall (i,j) \in V^2, i < j}\\
         \tdb{y_{ij}} &\in \mathbb B ,\quad&\tc{darkgreen}{\forall (i,j) \in V^2}\\
         \tdb{z_{ij}} &\in \mathbb B ,\quad&\tc{darkgreen}{\forall (i,j) \in V^, i < j}
        \end{alignat*}
      \end{frame}
      \endgroup



\end{document}

It produces:

enter image description here

Then I want to add two right brackets as follows on the next frame:

enter image description here

My problem is that I didn't succeed to have the same alignment thanks to & for the equations. The \le, \ge, =, \in signs are not aligned anymore nor the indices domains \forall. I also want that my two brackets to be vertically exactly one above each other and not having the red one on the right. Thank you for your help 😀

Best Answer

Here is an approach (in plain TeX) that first typesets the equations with breaks only allowed after the first group of three lines. This group is then split off and put into a box while the rest remains in another box. These two boxes (there could be more if more than one group is split off) are then typeset together with the right braces.

\setbox0=\vbox{\tabskip=.5em\halign{\hfil$#$&\hfil$#$\hfil&$#$\hfil\cr
  \noalign{\penalty0} %first \vsplit here
  1+2&=&3\cr\noalign{\nobreak}
  1-2&=&-1\cr\noalign{\nobreak}
  3\cdot2&=&6\cr %second \vsplit here
  1\cdot2&=&2\cr\noalign{\nobreak}
  1/2&=&0.5\cr}}
\setbox1=\vsplit0 to0pt %insert \splittopskip at the top of \box0
\setbox1=\vsplit0 to12pt %split off first group
\setbox1=\vbox{\unvbox1} %give \box1 its natural height
\halign{$\left.\vcenter{\box#}\right\}$\hfil&#\hfil\cr
  1&Ring constraints\cr
  \noalign{\vskip 2pt}
  0&Star constraints\cr}

enter image description here

LaTeX experts in this forum can perhaps translate this approach for use with the alignat package.

Related Question