IEEEtrans template requires not to use algorithm package?

During the IEEEtrans.tex, there is a comment below package algorithmic saying that

Do NOT use the algorithm floating environment provided by algorithm.sty (by the same authors) or algorithm2e.sty (by Christophe Fiorio) as IEEE does not use dedicated algorithm float types and packages that provide these will not provide correct IEEE style captions.

How can I make a beautiful box to show the pseudo code while using only the algorithmic package?

-
You can download the algorithmic package from here: ctan.org/tex-archive/macros/latex/contrib/algorithms It contains a .pdf with instructions on how to do what you are looking for. – latex fan Jun 22 '12 at 0:03

You can try something like this:

\documentclass{IEEEtran}
\pagestyle{empty}
\usepackage{algorithmic}

\newsavebox{\ieeealgbox}
\newenvironment{boxedalgorithmic}
{\begin{lrbox}{\ieeealgbox}
\begin{minipage}{\dimexpr\columnwidth-2\fboxsep-2\fboxrule}
\begin{algorithmic}}
{\end{algorithmic}
\end{minipage}
\end{lrbox}\noindent\fbox{\usebox{\ieeealgbox}}}

\begin{document}

\begin{boxedalgorithmic}
\REQUIRE $n \geq 0 \vee x \neq 0$
\ENSURE $y = x^n$
...
\ENDIF
\ENDWHILE
\end{boxedalgorithmic}

\end{document}


-
Many thanks for sharing! I still have a problem about the caption. Which part should I modify if I want to reference this box? Could I write the box part into a Table? – datcn Jan 6 '12 at 13:05
Update: I find the way of adding the title and caption. Move the box part into a '\begin{table}' and '\end{table}' is OK. Thanks again for your help. – datcn Jan 6 '12 at 13:20

Instead of Table, you can use a Figure, in which you can add caption and label.

\begin{figure}
\begin{boxedalgorithmic}
\REQUIRE $n \geq 0 \vee x \neq 0$
\ENSURE $y = x^n$
\STATE $y \leftarrow 1$
\IF{$n < 0$}
\STATE $X \leftarrow 1 / x$
\STATE $N \leftarrow -n$
\ELSE
\STATE $X \leftarrow x$
\STATE $N \leftarrow n$
\ENDIF
\WHILE{$N \neq 0$}
\IF{$N$ is even}
\STATE $X \leftarrow X \times X$
\STATE $N \leftarrow N / 2$
\ELSE[$N$ is odd]
\STATE $y \leftarrow y \times X$
\STATE $N \leftarrow N - 1$
\ENDIF
\ENDWHILE
\end{boxedalgorithmic}
\caption{My algorithm}
\label{myalgo}
\end{figure}

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). – doncherry Jun 22 '12 at 15:59