Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.