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.

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?

share|improve this question
    
Welcome to TeX.sx! –  Andrew Uzzell Nov 9 '12 at 11:48

1 Answer 1

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}
share|improve this answer
    
Thanks @guillem, it seems that there is no other way to do it. –  Asterios Nov 9 '12 at 15:56
    
You're welcome. –  guillem Nov 12 '12 at 6:33

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.