3

I don't want any newline character after case statement. How can I do that?

This is my code:

\begin{algorithm}[t]

 \SetInd{0.5em}{0.5em}
 \KwIn{Data $\mathsf{D}$}
 \KwOut{List of Simple Hints}

 \Begin{

     \Switch{$\mathsf{dist}$}{
       \uCase{0}{
    $\mathsf{skip}$\;
       }
       \uCase{1}{
         $\mathsf{H_S \leftarrow H_S \cup \{(H_Se}$\;

       }
       \Other{
          $\mathsf{H_S \leftarrow H_S \cup \{(replace(H_Se')}$\;
       }
     }

   }
 \caption{Algorithm to simple hints}
\end{algorithm}

This is the output:

enter image description here

1 Answer 1

3

Use the \lCase definition:

enter image description here

\documentclass{article}
\usepackage[ruled,vlined]{algorithm2e}% http://ctan.org/pkg/algorithm2e
\begin{document}
\begin{algorithm}[t]
 \SetInd{0.5em}{0.5em}
 \KwIn{Data $\mathsf{D}$}
 \KwOut{List of Simple Hints}
 \Begin{
    \Switch{$\mathsf{dist}$}{
      \uCase{0}{
        $\mathsf{skip}$\;
      }
      \uCase{1}{
        $\mathsf{H_S \leftarrow H_S \cup \{(H_Se\}}$\;
      }
      \Other{
        $\mathsf{H_S \leftarrow H_S \cup \{(replace(H_Se')\}}$\;
      }
    }
  }
 \Begin{
    \Switch{$\mathsf{dist}$}{
      \lCase{0}{
        $\mathsf{skip}$
      }
      \lCase{1}{
        $\mathsf{H_S \leftarrow H_S \cup \{(H_Se\}}$
      }
      \lOther{
        $\mathsf{H_S \leftarrow H_S \cup \{(replace(H_Se')\}}$
      }
    }
  }
  \caption{Algorithm to simple hints}
\end{algorithm}
\end{document}

You must log in to answer this question.

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