problem in writing equation with one bigg bracket

I am writing the code for this equation

I tried this code

$$\left\{ \hat{y}_{i}^{k} = 0 if {S}_{i}^{k} < \tau \right\} \left\{ \hat{y}_{i}^{k} = 1 if {S}_{i}^{k} > \tau \right\}$$


I am unable to shift the second line \hat{y}_{i}^{k} = 1 if {S}_{i}^{k} > \tau to the next line by using big curly bracket, and I want to put a bracket on both sides.

How to also add space between each symbol?

• Use the cases environment. Commented Apr 18, 2022 at 9:27
• but it only puts bracket at right side .. how to put bracket at left side Commented Apr 18, 2022 at 9:35
• What do you mean by right side? The bracket is in the left side. Commented Apr 18, 2022 at 9:36
• @user12 - The screeenshot you show doesn't have a bracket on the right. If that's something you want, you should say so somewhere explicitly.
– Mico
Commented Apr 18, 2022 at 9:36
• see the question first i wrote in question ..then give suggestion thankyou Commented Apr 18, 2022 at 9:38

There are four usual ways to the problem of which anyone could be choosed as you like and are used very often. Of course, some unusual packages may also supply different ways which is not advised by me since they may be more complicated and used quite few.

1. By the normal cases environment in the amsmath package.
\documentclass{article}

\usepackage{amsmath}

\begin{document}
$$\begin{cases} \hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{cases}$$
\end{document}


1. By the \left\{ \right. codes and the array environment in the amsmath package. And you could add 1 to 3 \! to adjust the space after the left brace or before the right brace.
\documentclass{article}

\usepackage{amsmath}

\begin{document}
$$\left\{ \begin{array}{ll} \hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{array} \right.$$

$$\left. \begin{array}{ll} \hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{array} \right\}$$

$$\left\{ \begin{array}{ll} \hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{array} \right\}$$
\end{document}


1. By the \left\{ \right. codes and the aligned environment in the amsmath package.
\documentclass{article}

\usepackage{amsmath}

\begin{document}
\left\{ \begin{aligned} &\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ &\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{aligned} \right.

\left. \begin{aligned} &\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ &\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{aligned} \right\}

\left\{ \begin{aligned} &\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ &\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{aligned} \right\}

\end{document}


1. By the dcases or dcases* environment in the mathtools package
\documentclass{article}

\usepackage{mathtools}

\begin{document}
$$\begin{dcases} \hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{dcases}$$

$$\begin{dcases*} \hat{y}_{i}^{k} = 0 &if {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 &if {S}_{i}^{k} > \tau \end{dcases*}$$

$$\begin{rcases} \hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{rcases}$$

$$\begin{rcases*} \hat{y}_{i}^{k} = 0 &if {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 &if {S}_{i}^{k} > \tau \end{rcases*}$$
\end{document}


You need the cases environment as I commented.

\documentclass{article}

\usepackage{amsmath}

\begin{document}
$$\begin{cases} \hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{cases}$$
\end{document}


Edit: To put a bracket also on the right side, you may use the \Biggr\} (courtesy of @barbarabeeton) command.

\documentclass{article}

\usepackage{amsmath}

\begin{document}
$$\begin{cases} \hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\ \hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau \end{cases}\Biggr\}$$
\end{document}

• Using \Biggr\} might yield more symmetrical spacing. Commented Apr 20, 2022 at 16:15

Your question isn't clear. If you want a solution that mimics the screenshot you posted, use a cases environment, as is used, say, in @Imran's answer.

If, in contrast, you want to enclose a two-row expression in tall curly braces, I suggest you encase either a two-column array environment or a Bmatrix*[l] environment.

Both possibilities are illustrated in the following screenshot.

\documentclass{article}
\usepackage{mathtools} % for 'matrix*[l]' env.
\begin{document}

$$\begin{cases} \hat{\mathcal{Y}}_{k}^{i} = 0 & \text{if {\mathcal{S}}_{k}^{i} < \tau,} \\ \hat{\mathcal{Y}}_{k}^{i} = 1 & \text{if {\mathcal{S}}_{k}^{i} > \tau.} \end{cases}$$

$$\begin{Bmatrix*}[l] \hat{\mathcal{Y}}_{k}^{i} = 0 & \text{if {\mathcal{S}}_{k}^{i} < \tau} \\[0.75ex] \hat{\mathcal{Y}}_{k}^{i} = 1 & \text{if {\mathcal{S}}_{k}^{i} > \tau} \end{Bmatrix*}$$

\end{document}


Another possibility with alignedat and the empheq package:

    \documentclass{article}
\usepackage{empheq}

\begin{document}

\begin{empheq}[left=\empheqlbrace, right=\empheqrbrace]{equation}        \begin{alignedat}{2}
\hat{y}_{i}^{k} & = 0 &\quad & \text{ if } S_{i}^{k} < \tau \\
\hat{y}_{i}^{k} &= 1 & & \text{ if }S_{i}^{k} > \tau
\end{alignedat}
\end{empheq}

\end{document}
`

• @barbarabeeton: Thanks for warning me, Milady! I confess I often forget to check what I post. Commented Apr 21, 2022 at 14:40