1

I am writing a beamer presentation and I keep trying to add an algorithm to it with no success.

I have:

\begin{frame}{Proposed Solutions}{Curve Projection}
\begin{block}{}
    Ellipses are implicit surfaces, we can use their gradient to our advantage!
\end{block}

\begin{minipage}{0.45\textwidth}
    \begin{algorithmic}[1]

    \end{algorithmic}
\end{minipage}
\end{frame}  

Which fails to compile with error

Something's wrong, perhaps a mising \item. \end{frame}

Removing the algorithm environment lets it compile,

Adding anything to the algorithm environment. eg:

\begin{frame}{Proposed Solutions}{Curve Projection}
\begin{block}{}
    Ellipses are implicit surfaces, we can use their gradient to our advantage!
\end{block}

\begin{minipage}{0.45\textwidth}
    \begin{algorithmic}[1]
    \Procedure{Find\_distance}{$p_1, p_2$}
    \end{algorithmic}
\end{minipage}
\end{frame} 

Does not fix the problem

2
  • 2
    Try with [fragile] frame option. If this does not help, please add a MWE Apr 15, 2018 at 21:06
  • Did you load any algorithm-related packages? If so, which ones?
    – Mico
    Apr 15, 2018 at 21:15

1 Answer 1

2

If you have fragile content within the frame, you need the fragile frame option.

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{algpseudocode}

\begin{document}

\begin{frame}[fragile]{Proposed Solutions}{Curve Projection}
\begin{block}{}
    Ellipses are implicit surfaces, we can use their gradient to our advantage!
\end{block}

\begin{minipage}{0.45\textwidth}
    \begin{algorithmic}[1]
    \Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
   \State $r\gets a\bmod b$
   \While{$r\not=0$}\Comment{We have the answer if r is 0}
      \State $a\gets b$
      \State $b\gets r$
      \State $r\gets a\bmod b$
   \EndWhile\label{euclidendwhile}
   \State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
    \end{algorithmic}
\end{minipage}
\end{frame} 


\end{document}

enter image description here

You must log in to answer this question.

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