I am preparing a presentation with beamer from a previous paper written in latex. I want to insert in a slide the pseudocode
\begin{algorithm}
\begin{algorithmic}[1]
\FOR{$i=1$ to $N$}
\FOR{$j=1$ to $JJJJ}
\STATE $energy[i*JJJ+j] =$ \\
$ interpolate(AAA[i*JJJ+j], ZZZ)$
\ENDFOR
\ENDFOR
\end{algorithmic}
\caption{pseudocode for the calculation of }
\label{alg:seq}
\end{algorithm}
but I get problems since the beamer document does not compile. I tried to use the same packages that in the latex document. I also tried to find examples through google but nothing. Could you tell me what is wron here or how could I add pseudocode in beamer )examples on the net, etc)?
Best Answer
The floating object
algorithm
doesn't behave well with beamer (which onviously disables floating objects). To prevent problems you can 1) use theH
placement specifier foralgorithm
, or 2) drop thealgorithm
environment and use the\captionof
command from thecaption
package if a caption is needed. The following example shows the first approach: