I am trying to insert the caption on an algorithm in beamer presentation. The algorithm syntax is correct and it is working while using \documentclass{article} but it shows following error when \documentclass[11pt]{beamer} is used:
! LaTeX Error: Not in outer par mode.
See the LaTeX manual or LaTeX Companion for explanation.
Below is the sample code:
%\documentclass{article}
\documentclass[11pt]{beamer}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%
\begin{document}
\begin{frame} %comment \begin{frame} and \end{frame} while using article
\begin{algorithm}
\caption{This is comment}
\begin{algorithmic}[1]
\ForAll{$point$ ~in $trajectory$}
\State {$i\gets maxval$}
\Do
\State $success \gets dist(a,b)$
\doWhile{$success \le 0$}
\EndFor
\end{algorithmic}
\end{algorithm}
\end{frame}
\end{document}
Below are the TeX compiler details:
pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex 2016.5.18)

algpseudocodetwice. – naphaneal Jul 10 '16 at 08:07