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
figure
s 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:
\documentclass{IEEEtran}
\usepackage{algpseudocode}
\begin{document}
\begin{figure}
\begin{algorithmic}[1]
\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}
\EndProcedure
\end{algorithmic}
\caption{Euclid's algorithm}\label{euclid}
\end{figure}
\end{document}
If no caption is required, then simply don't use the figure
environment.
As egreg has mentioned in a comment, one option would be to use
\addtocounter{algorithm}{-1}
before \caption{Part 2}
. Another option, not requiring manually changing counters and that additionally gives you the possibility to use a customized formatting for the continued algorithm, would be to use \ContinuedFloat
from the caption
package. An example with the default caption format for \ContinuedFloat
:
\documentclass{article}
\usepackage{caption}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Part 1}
\begin{algorithmic}[1]
\Procedure {BellmanKalaba}{$G$, $u$, $l$, $p$}
\ForAll {$v \in V(G)$}
\State $l(v) \leftarrow \infty$
\EndFor
\State $l(u) \leftarrow 0$
\Repeat
\For {$i \leftarrow 1, n$}
\State $min \leftarrow l(v_i)$
\For {$j \leftarrow 1, n$}
\If {$min > e(v_i, v_j) + l(v_j)$}
\State $min \leftarrow e(v_i, v_j) + l(v_j)$
\State \Comment For some reason we need to break here!
\algstore{bkbreak}
\end{algorithmic}
\end{algorithm}
And we need to put some additional text between\dots
\begin{algorithm}[h]
\ContinuedFloat
\caption{Part 2}
\begin{algorithmic}[1]
\algrestore{bkbreak}
\State $p(i) \leftarrow v_j$
\EndIf
\EndFor
\State $l’(i) \leftarrow min$
\EndFor
\State $changed \leftarrow l \not= l’$
\State $l \leftarrow l’$
\Until{$\neg changed$}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}
An an example with a modified format for the caption of continued floats:
\documentclass{article}
\usepackage{caption}
\usepackage{algorithm}
\usepackage{algpseudocode}
\makeatletter
\DeclareCaptionLabelFormat{algcontinued}{\ALG@name~#2 (Continued)}
\makeatother
\captionsetup[ContinuedFloat]{labelformat=algcontinued}
\begin{document}
\begin{algorithm}
\caption{Part 1}
\begin{algorithmic}[1]
\Procedure {BellmanKalaba}{$G$, $u$, $l$, $p$}
\ForAll {$v \in V(G)$}
\State $l(v) \leftarrow \infty$
\EndFor
\State $l(u) \leftarrow 0$
\Repeat
\For {$i \leftarrow 1, n$}
\State $min \leftarrow l(v_i)$
\For {$j \leftarrow 1, n$}
\If {$min > e(v_i, v_j) + l(v_j)$}
\State $min \leftarrow e(v_i, v_j) + l(v_j)$
\State \Comment For some reason we need to break here!
\algstore{bkbreak}
\end{algorithmic}
\end{algorithm}
And we need to put some additional text between\dots
\begin{algorithm}[h]
\ContinuedFloat
\caption{Part 2}
\begin{algorithmic}[1]
\algrestore{bkbreak}
\State $p(i) \leftarrow v_j$
\EndIf
\EndFor
\State $l’(i) \leftarrow min$
\EndFor
\State $changed \leftarrow l \not= l’$
\State $l \leftarrow l’$
\Until{$\neg changed$}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}
Best Answer
You have to modify
\ALG@name
in order to get the appropriate translation:You may also consider using the more advanced
algorithmicx
bundle.