I'm using IEEEtran
with \usepackage[boxed,linesnumbered]{algorithm2e}
. I have one pseudocode/algorithm. My caption inside the algorithm
environment appears as "Algorithm 1". Since I only have one algorithm, I think I should be using the figure
caption instead. What do you think and how can I force my caption to appear as a figure
caption?
To provide information needed for the comments here is a snippet of my code:
\IncMargin{1em}
\begin{algorithm}
\DontPrintSemicolon
\Indm
\KwInputs{\hspace*{0.3em}sth}
\KwOutput{sth}
\Indp
this is the body of my algo.
\caption{this is my caption.}
\end{algorithm}
\DecMargin{1em}
Best Answer
The simplest solution is to use the
figure
option foralgorithm2e
; in this way, algorithms are put infigure
environments and so are numbered as figures and included in the\listoffigures
:An image of the result:
Update
According to comments to the original answer,
algorithm2e
is loaded with optionsboxed
andlinesnumbered
; in this case, adding thefigure
option, as inhas the undesired effect that the caption is moved inside the frame boxing the algorithm. To prevent this, some additional work is needed, but since it is just for one algorithm, I think the effort is worthy.
The idea is to load the package only with the
figure
optionand then manually box and frame the algorithm also using
\LinesNumbered
to get the numbers:The result: