# Algorithm with Latex ( Package algorithmicx)

This is my algorithm:

 \usepackage{graphicx}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
%\usepackage{algorithmic}
\usepackage{float}
\begin{document}
\begin{algorithm}
\caption{Euclid's algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}
\State $r\gets a\bmod b$
\While{$r\not=0$}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile
\State \textbf{return} $b$\Comment{The gcd is b}
%\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}


i have this error:

./llncs1.dem: 102: Missing number, treated as zero /EndWhile


Have you an idea please ?

-

You could simply do this:

\documentclass{article}
\usepackage{algorithm} %ctan.org\pkg\algorithms
\usepackage{algpseudocode}
\begin{document}

\begin{algorithm}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}
\State $r\gets a\bmod b$
\While{$r\not=0$}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile
\State \textbf{return} $b$ \Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\caption{Euclid's algorithm}
\label{euclid}
\end{algorithm}

\end{document}


Some packages define these kinds of floating environments, like alg, but that conflicted also.

-

There are several packages for this type of layout, but you need to choose which to use, if you load them all you get conflicts, as you see. For example if you just used an algorithmicx based layout you could use:

 \documentclass{article}
\usepackage{graphicx}
%\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
%\usepackage{algorithmicx}
\usepackage{algpseudocode}
%\usepackage{algorithmic}
\usepackage{float}
\newfloat{algorithm}{tp}{toa}
\begin{document}
\begin{algorithm}
\caption{Euclid's algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}
\State $r\gets a\bmod b$
\While{$r\not=0$}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}

-