2

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?

5
  • 4
    Use the cases environment.
    – Imran
    Commented Apr 18, 2022 at 9:27
  • but it only puts bracket at right side .. how to put bracket at left side
    – user12
    Commented Apr 18, 2022 at 9:35
  • What do you mean by right side? The bracket is in the left side.
    – Imran
    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
    – user12
    Commented Apr 18, 2022 at 9:38

4 Answers 4

5

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

3

You need the cases environment as I commented.

enter image description here

\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}

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

enter image description here

\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}\Biggr\}
\end{equation}
\end{document}
1
  • 2
    Using `\Biggr\} might yield more symmetrical spacing. Commented Apr 20, 2022 at 16:15
3

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.

enter image description here

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

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

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

\end{document}
0
1

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} 

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .