I'm using the algpseudocode package and I want to write a pseudocode. This is my code
\documentclass[conference]{IEEEtran}
\usepackage[spanish, es-tabla]{babel}
\usepackage{graphicx, times, amsmath, colortbl, psfrag}
\usepackage[ruled, vlined, english, boxed, linesnumbered, lined]{algorithm2e}
\usepackage{algpseudocode}
\usepackage{multirow}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{float}
\begin{document}
...
\begin{algorithm}
\caption{Buscar elemento en una lista}
\KwData{$lista[1,...,x_n]$: lista en la que se va a buscar, $elem$: elemento que se va a buscar}
\KwResult{$encontrado$: booleano que indica si se encontr\'o el elemento}
\begin{algorithmic}[1]
\Procedure{Buscar}{$lista$, $elem$}
\State $encontrado \gets False$
\For{i}{1}{n}
\If{$lista[i]=elem$}
\State $encontrado \gets True$
\EndIf
\EndFor
\Return $encontrado$
\EndProcedure
\end{algorithmic}
\end{algorithm}
...
\end{document}
but I get the following errors when I try to compile it
! Missing number, treated as zero.
<to be read again>
\ALG@b@2@EndIf@0
l.113 \EndIf
?
! Missing number, treated as zero.
<to be read again>
\ALG@b@2@EndFor@0
l.114 \EndFor
?
Does anyone know how can I compile it?
Thanks for answering.
Best Answer
You are using incompatible commands from the packages
algorithm2e
andalgpseudocode
; you can use onlyalgpseudocode
and replace\KwData
,\KwResult
with\Require
,\Ensure
:Notice, however, that the
IEEEtran HowTo
document recommends not to usealgorithm
from thealgorithm
package:In this case, as recommended by the class, you can enclose your algorithm inside a
figure
environment: