Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

error of using {algorithm} in beamer

1,922 views
Skip to first unread message

Cecily

unread,
Jul 13, 2009, 11:53:02 AM7/13/09
to
Hi, I have a problem in beamer when I use
\begin{algorithm}
\begin{algorithmic}
....
\end{algorithmic}
\end{algorithm}

but there is no error if I only have
\begin{algorithmic}
....
\end{algorithmic}

Below is a minimal example I have, can some one help me? I really want
to use
\begin{algorithm}
\begin{algorithmic}
....
\end{algorithmic}
\end{algorithm}
to include the caption. Thanks a lot!

BTW, the error message is
! LaTeX Error: Not in outer par mode.
! Undefined control sequence.
! Missing number, treated as zero.

The example:
\documentclass[compress]{beamer}

\usepackage{amsmath,amssymb,amsthm,algorithmic,algorithm}
\usepackage{graphicx}
\usepackage{color}
\usetheme{Frankfurt}
\mode<presentation>
\setbeamertemplate{blocks}[rounded][shadow=true]
\title{title}

\date{\today}

\newcommand{\bs}{$\mathtt{\backslash}$}
\newcommand{\ra}{\rightarrow}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
\renewcommand{\tt}{\ttfamily}
\newtheorem{proposition}{Proposition}
%\usepackage{natbib} %citep and citet


\setbeamertemplate{footline}[frame number]
\begin{document}
\def\newblock{\hskip .11em plus .33em minus .07em}


\begin{frame}
\titlepage
\end{frame}

\begin{frame}{Forward Mode}
\begin{columns}[t] % the "c" option specifies center vertical
alignment
\column{.5\textwidth} % column designated by a command
\begin{algorithmic}
\FOR {$i=1$ to $n$}
\STATE $x_i=\varphi_i(x_i)=\xi_i$
\ENDFOR
\FOR{ $i=n+1$ to $K$}
\STATE $x_i=\varphi_i(x_1,\cdots,x_{i-1})$
\ENDFOR
\STATE $f=x_K$
\end{algorithmic}

\column{.5\textwidth}

\begin{algorithm}
\caption{Augmented program using the forward mode }
\label{alg2}
\begin{algorithmic}
\FOR {$i=1$ to $n$}
\STATE $x_i=\varphi_i(x_i)=\xi_i$
\STATE $\nabla x_i=e^{(i)}$
\ENDFOR
\FOR{ $i=n+1$ to $K$}
\STATE $x_i=\varphi_i(x_1,\cdots,x_{i-1})$
\STATE $\nabla x_i=\displaystyle \sum_{j=1}^{i-1}\frac{\partial
\varphi_i}{\partial x_j} \nabla x_j$
\ENDFOR
\STATE $f=x_K$
\STATE $\nabla f=\nabla x_K$
\end{algorithmic}
\end{algorithm}

\end{columns}

\end{frame}

\end{document}

zappathustra

unread,
Jul 14, 2009, 5:18:26 AM7/14/09
to
There's a problem with the processing of floats.
Using

\begin{algorithm}[H]

solves it. You use "H" instead of "h" because of the implementation of
algorithm.sty, based on David Carlisle's here package.

Paul

0 new messages