0

I had the following pseudocode that work perfect on \documentclass[conference]{IEEEtran}. Now, I want same pseudocode on Bearmer class, it did not work well, and code missed up.

My original code in conference class

\documentclass{article}

\usepackage[ruled]{algorithm2e}
\usepackage{amsmath}

\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\DontPrintSemicolon

\begin{document}

\begin{algorithm}
  \caption{Some algorithm caption}

  \Input{Info}
  \Output{SCORE}

  \If{$r < R$}{
    $n \gets \text{function}(\text{DataX}, \text{DataX1}, \text{DataX2}, \text{Type}, \text{Type2})$\;
    $S \gets \text{function}(S)$\;
  }
  $\text{SCORE} \gets \text{Trained ANN}(\text{InfoInput})$\;
\end{algorithm}

\end{document}

My trying code:

\documentclass{beamer}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{sansmathaccent}
\pdfmapfile{+sansmathaccent.map}
\usepackage[ruled]{algorithm2e}
\usepackage{amsmath}
\usepackage{varwidth}
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\DontPrintSemicolon

\begin{document}

\subsection{Blocks}
\begin{frame}{Blocks}   
    \begin{algorithm}
  \caption{Some algorithm caption}
  \Input{Info}
  \Output{SCORE}
  \If{$r < R$}{
    $n \gets \text{function}(\text{DataX}, \text{DataX1}, \text{DataX2}, \text{Type}, \text{Type2})$\;
    $S \gets \text{function}(S)$\;
  }
  $\text{SCORE} \gets \text{Trained ANN}(\text{InfoInput})$\;
\end{algorithm}

\end{document}

1 Answer 1

3

You forgot an \end{frame} and, for some reason, the code seems to require (?) to add [H] (or some other placement) in the beamer code. The following snippet compiles.

\documentclass{beamer}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{sansmathaccent}
\pdfmapfile{+sansmathaccent.map}
\usepackage[ruled]{algorithm2e}
\usepackage{varwidth}
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\DontPrintSemicolon

\begin{document}

\subsection{Blocks}
\begin{frame}{Blocks}   
\begin{algorithm}[H]
\caption{Some algorithm caption}
  \Input{Info}
  \Output{SCORE}
  \If{$r < R$}{
    $n \gets \text{function}(\text{DataX}, \text{DataX1}, \text{DataX2}, \text{Type}, \text{Type2})$\;
    $S \gets \text{function}(S)$\;
  }
  $\text{SCORE} \gets \text{Trained ANN}(\text{InfoInput})$\;
\end{algorithm}
\end{frame}
\end{document}
1
  • I really appreciate your help, Works PERFECT
    – jou
    Dec 9, 2017 at 20:19

You must log in to answer this question.

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