I found this question explaining how to use algorithm2e package with IEEEtran class. However I would like to be able also to use the algorithmic package.
For the following code:
\begin{figure}[!t]
\removelatexerror
\begin{algorithm}[H]
\begin{algorithmic}
\For( \emph{Evolutionary loop}){$g := 1$ to $G_{max}$}
{
\State Do things \;
\State Trim the population to size $N$ using nondominated sorting and diversity estimation \;
}
\end{algorithmic}
\end{algorithm}
\end{figure}
I am getting an error:
ERROR: You can't use `\prevdepth' in horizontal mode.
--- TeX said ---
\nointerlineskip ->\prevdepth
-\@m \p@
I am reusing preamble from the original question:
\usepackage[ruled,norelsize]{algorithm2e}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother
\usepackage{algpseudocode,algorithmicx}
I would highly appreciate if you could help me to fix the problem.
UPD Full minimal example:
\documentclass[journal, a4paper]{IEEEtran}
\usepackage[ruled,norelsize]{algorithm2e}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother
\usepackage{algpseudocode,algorithmicx}
\begin{document}
\begin{figure}[!t]
\removelatexerror
\begin{algorithm}[H]
\begin{algorithmic}
\For{\texttt{<some condition>}}
\State \texttt{<do stuff>}
\EndFor
\end{algorithmic}
\end{algorithm}
\end{figure}
\end{document}
\documentclassup to\end{document}. – egreg Mar 25 '17 at 21:59algorithmicenvironment. – desa Mar 25 '17 at 22:10algorithm2etogether withalgpseudocode. – egreg Mar 25 '17 at 22:22