I am new to LaTeX. I am writing a paper for ACM Journal. I am using algorithm2e package for an algorithm which gives me "Missing number, treated as zero" error message for almost every line in the algorithm. See below for an example algorithm that I found online which is similar to what I have:

\documentclass[acmsmall, review, manuscript]{acmart}
\usepackage{amsmath} \usepackage{amssymb} \usepackage{amsfonts} \usepackage{subfigure}
\usepackage{mathptm} \usepackage{epsfig} \usepackage{latexsym} \usepackage{wrapfig}
\usepackage{placeins} \usepackage{epstopdf} \usepackage {algpseudocode}
\usepackage{mathtools} \usepackage{graphicx} \usepackage{enumerate}


\caption{Procedure For Algo testing}
\Procedure {BellmanKalaba}{$G$, $u$, $1$, $p$}\\
\ForAll {$v \in V(G)$}
\State $1(v) \leftarrow \infty$
\State $1(u) \leftarrow 0$
\For {$1 \leftarrow 1, n$}
\State $min \leftarrow 1(v_i)$
\For {$j \leftarrow 1, n$}
\If {$min > e(v_i, V_j) + 1(v_j)$}
\State $min \leftarrow e(v_i, v_j) + 1(v_j)$
\State $p(i) \leftarrow v_j$

\State $1’(i) \leftarrow min$
\State $changed \leftarrow 1 \not= 1’$
\State $1 \leftarrow 1’$
\Until{$\neg changed$}
\Procedure {FindPathBK}{$v$, $u$, $p$}\\
\If {$v = u$}
\State \textbf{Write} $v$
\State $w \leftarrow v$
\While {$w \not= u$}
\State \textbf{Write} $w$
\State $w \leftarrow p(w)$

When I compile this file, I have an error message for almost every line like in this image:


I want line number for each line in the algorithm. I really appreciate any help.

Thank you

  • 3
    Welcome to TeX.SE. Please don't post screenshots of code. You can copy the code in the editor and mark it as such! – user31729 Mar 13 '17 at 20:22
  • The example is also used in the algorithmicx manual (currently page 22, ctan.org/pkg/algorithmicx), however there the preamble (everything before \begin{document}) is different. Could you try using the full code from the manual? – Marijn Mar 13 '17 at 21:56
  • The example your are using is in algorithmicx syntax, but as you want to use the algorithm2e package, you have to use another syntax. Have a look at the manual (currently page 5/section 3) of the algorithm2e to update your code with the right format. – epR8GaYuh Mar 14 '17 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.