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'm trying to write an algorithm in a IEEEtran LaTeX template and it doesn't work in any way.


\caption{ASGP Merge and Pruning Step}
\REQUIRE {$stuff$}
\STATE $stuff$
\RETURN $stuff$

but this is what I get:

! LaTeX Error: \begin{ALC@g} on input line 31 ended by \end{algorithmic}.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

l.47 \end{algorithmic}

I already tried use \begin{figure*} instead of \begin{algorithm*} but that also doesn't work.

I saw a post about using \begin{algpseudocode}, but that isn't working either, If I also \include{algorithmic}:

! LaTeX Error: Command \algorithmicindent already defined. Or name \end... illegal, see p.192 of the manual.

If not, I get:

\REQUIRE undefined control sequence.

Can anybody help me with that?

share|improve this question
It may just be a typo while posting, or it may be correct, but should the second line be \usepackage{algorithmic} rather than \usepackage{algorithmc}? – Scott H. May 15 '12 at 8:24
up vote 18 down vote accepted

The IEEEtran's documentation suggests:

B. Algorithms

IEEE publications use the figure environment to contain algorithms that are not to be a part of the main text flow. Peter Williams’ and Rogerio Brito’s algorithmic.sty package [24] or Szász János’ algorithmicx.sty package [25] (the latter is designed to be more customizable than the former) may be of help in producing algorithm-like structures (although authors are of course free to use whatever LaTeX commands they are most comfortable with in this regard). However, do not use the floating algorithm environment of algorithm.sty (also by Williams and Brito) or algorithm2e.sty (by Christophe Fiorio) as the only floating structures IEEE uses are figures and tables. Furthermore, IEEEtran will not be in control of the (non-IEEE) caption style produced by the algorithm.sty or algorithm2e.sty float environments.

So, as suggested, do not use the algorithm floating environment; you can wrap your algorithm inside a figure (or figure*) environment (if a caption is required and the captions are to be IEEEtran compliant) and use the algorithmicx package ; something like this:



\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$
\State \textbf{return} $b$\Comment{The gcd is b}
\caption{Euclid's algorithm}\label{euclid}


enter image description here

If no caption is required, then simply don't use the figure environment.

share|improve this answer
Unfortunately this is so ugly compared to the algorithm environment – Martin Drozdik Nov 8 '13 at 8:59

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.