TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a way to have a number for every line in algorithmic:

        \caption{Some alg}
            \REQUIRE a,b, c
            \STATE d = a + b + c
            \STATE d = d/2
            \STATE d = d/3
            \RETURN d

I would like to have:

 Require: a,b,c
1 d = a + b + c
2 d = a + b + c
3 d = d/2
4 d = d/3
  return d
share|improve this question
up vote 32 down vote accepted

According to the manual you can do this the following way:

An optional argument to the \begin{algorithmic} statement can be used to turn on line numbering by giving a positive integer indicating the required frequency of line numbering. For example, \begin{algorithmic}[5] would cause every fifth line to be numbered.

Obviously, \begin{algorithmic}[1] causes a number for every line.

share|improve this answer

Your Answer


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.