Curly Bracket over multiple equation

I have a question regarding the curvy brackets in tex. Didn't find a good solution for the problem yet:

I have the following formulas:

\begin{aligned} f(x) &= x + 1 \\ g(x) &= x + 2 \\ h(x) &= x + 3 \\ k(x) &= x + 4 \\ l(x) &= x + 5 \end{aligned}


Now I want to have a curly bracket around f(x) and g(x) on the right side and want to write some stuff behind the curly bracket. And I also want a curly bracket behind h(x), k(x) and l(x). How can I manage that and also make sure, that all five equations are aligned on the "="-sign?

I just tried to put the formulas in a \begin{rcases} ... \end{rcases}, but then the formulas are no longer aligned.

Thank you very much in advance!

Best regards!

• Do you really want a single number for the equation? Nov 21, 2021 at 16:15

You can use nicematrix and its powerful methods.

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}

\AtBeginEnvironment{NiceArray}{\tracinglostchars=0 }

\begin{document}

$\renewcommand{\arraystretch}{1.2} \begin{NiceArray}{ @{} r @{} >{{}}c<{{}} @{} l l} f(x) &=& x + 1 & \Block{2-1}{\text{whatever}}\\ g(x) &=& x + 2 \\ h(x) &=& x + 3 & \Block{3-1}{\text{something else}}\\ k(x) &=& x + 4 \\ l(x) &=& x + 5 \\ \CodeAfter \SubMatrix.{1-3}{2-3}\} \SubMatrix.{3-3}{5-3}\} \end{NiceArray}$

\end{document}


The strange setting to \tracinglostchars is to avoid spurious warnings (but they deserve some investigation).

The specifications for the columns are the usual ones to mimic aligned, including the setting to \arraystretch. We build two “submatrices”, with empty delimiter on the left and braces on the right, plus two blocks spanning two and three rows respectively.

A couple of LaTeX runs are necessary for the output to stabilize, because ornamentations are set in successive steps after the object has been measured.

• Just a curiosità. Is It possibile to create two same curly brackets? Nov 22, 2021 at 20:19
• @Sebastiano No, if you mean with the same thickness; maybe with other fonts. Nov 22, 2021 at 21:11

One neat way is to define a new column type for the alignment at = as follows

\newcolumntype{e}{@{{$\mspace{\thinmuskip}$}}c@{{}}}


NiceArray from nicematrix works well for such for such purpose

\documentclass[11pt, a4paper]{article}

\usepackage{nicematrix}
\newcolumntype{e}{@{{$\mspace{\thinmuskip}$}}c@{{}}}

\begin{document}

\begin{equation*}
\everymath{\displaystyle}
f(x) &= x + 1 & \Block[l]{2-1}{\text{Text for $f(x)$} \\ \text{and $g(x)$}}
\\
g(x) &= x + 2 &
\\
h(x) &= x + 3 & \Block[l]{3-1}{\text{Text for $h(x)$,} \\ \text{$k(x)$, and $k(x)$}}
\\
k(x) &= x + 4 &
\\
l(x) &= x + 5 &
\CodeAfter
\SubMatrix{.}{1-1}{2-2}{\}}[extra-height=-1.1pt]
\SubMatrix{.}{3-2}{5-2}{\}}[extra-height=-1.1pt]
\end{NiceArray}
\end{equation*}

\end{document}


I am not sure if I understood correctly your question. For my understanding, the following should do the trick

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{aligned} &\left.\begin{aligned} f(x) &= x + 1 \\ g(x) &= x + 2 \\ \end{aligned}\right\}\hspace{0.5cm}\text{some stuff}\\ &\left.\begin{aligned} h(x) &= x + 3 \\ k(x) &= x + 4 \\ l(x) &= x + 5 \end{aligned}\right\} \end{aligned}

\end{document}


Producing

If the RHS of all the equation has the same length, the inner alignments & will luckily produce the desired alignment. However, if you really want to force the alignment the solution is less straightforward and I suggest you to have a look at the following question: HERE