The IEEEtran documentation suggests that I should not use the floating algorithm environment of algorithm2e.sty.
B. Algorithms
IEEE publications use the
figureenvironment to contain algorithms that are not to be a part of the main text flow. Peter Williams’ and Rogerio Brito’salgorithmic.stypackage or Szász János’algorithmicx.stypackage (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 floatingalgorithmenvironment ofalgorithm.sty(also by Williams and Brito) oralgorithm2e.sty(by Christophe Fiorio) as the only floating structures IEEE uses are figures and tables. Furthermore,IEEEtranwill not be in control of the (non-IEEE) caption style produced by thealgorithm.styoralgorithm2e.styfloat environments.
I tried using the suggested packages algorithmic and algorithmicx but I am not satisfied with the results and I would rather use the algorithm2e package.
A colleague told me that the suggestion of IEEE applies only to the floating algorithm environment of the package and not to the package itself. She suggested that I wrap the algorithm in a figure environment.
I tried to simply wrap the entire algorithm in a figure:
\documentclass[journal, a4paper]{IEEEtran}
\usepackage[ruled,norelsize]{algorithm2e}
\begin{document}
%\begin{figure}[!t]
\begin{algorithm}[h]
\caption{multiobjective DE}
initialize population $P = \left \{ X_{1}, ... , X_{N} \right \} $\;
\For( \emph{Evolutionary loop}){$g := 1$ to $G_{max}$}
{
Do things \;
Trim the population to size $N$ using nondominated sorting and diversity estimation \;
}
\end{algorithm}
%\end{figure}
\end{document}
But I get a
Not in outer par mode. \begin{algorithm}[h]
error. Obviously I cannot do it like this. How can I fix this?


algorithmto do all of this error removal andfigureplacement automatically, so you can just use\begin{algorithm}[t]...\end{algorithm}. – Werner Nov 29 '13 at 20:25\captionto thefigure, too. – karlkoeller Nov 29 '13 at 20:40\caption{...}command must be placed at the bottom, near\end{figure}. – gaborous Jan 05 '15 at 23:32