3

I would like the lines of "procedure" and "end procedure", "function", and "end function" etc to not be numbered.

For example, the default behavior produces this:

1 procedure hasNext(v,V,s)
2  solution <-- findSolution()
3 end procedure

but I would like to have this:

  procedure hasNext(v,V,s)
1    solution <-- findSolution()
  end procedure

Is this possible?

3

The following is a workaround, since this package does not seem to provide any option to show this behavior.

The \Procedure and \EndProedure control sequences are replaced by \Statex, which results in a line not being numbered. The drawback is that the procedure markup needs to be inserted by hand.

\documentclass{article}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithmic}[1]
\Statex{{\bf procedure} Euclid ($a,b$)}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\Statex{\bf end procedure}
\end{algorithmic}

\end{document}

Your Answer

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

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