Problem in writing equation with one bigg bracket

equations

I am writing the code for this equation

enter image description here

I tried this code

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

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?

Best Answer

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{equation}    
    \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{equation}
\end{document}

enter image description here

  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}
    \begin{equation}
    \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{equation}
    
       \begin{equation}
    \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{equation}
    
       \begin{equation}
    \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{equation}
\end{document}

enter image description here

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

\usepackage{amsmath}

\begin{document}
\begin{equation}
\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{equation}

\begin{equation}
\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{equation}

\begin{equation}
\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{equation}

\end{document}

enter image description here

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

\usepackage{mathtools}

\begin{document}
    \begin{equation}    
    \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}
    \end{equation}
    
    \begin{equation}    
    \begin{dcases*}
        \hat{y}_{i}^{k}  = 0  &if  ${S}_{i}^{k}  <  \tau$ \\
        \hat{y}_{i}^{k}  = 1  &if ${S}_{i}^{k}  >  \tau$
    \end{dcases*}
    \end{equation}
    
    \begin{equation}    
    \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}
    \end{equation}
    
    \begin{equation}    
    \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{equation}
\end{document}

enter image description here