Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 ?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
add comment

enter image description here

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.