I tried this example Place four algorithms (algorithm2e) in a subfigure and arrange them in two rows and two columns on two column documents. It doesn't work. The error message is
! LaTeX Error: [H] in two columns mode is not allowed for algorithms.
Is there anyway to go?
The code example is:
\documentclass[twocolumn]{article}
\usepackage{algorithm2e}
\usepackage{caption}
\usepackage{subcaption}
\newcommand{\myalgorithm}{%
\begin{algorithm*}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\end{algorithm*}}
\begin{document}
\begin{figure}
\begin{subfigure}{.5\textwidth}
\myalgorithm
\caption{How to write algorithms}
\end{subfigure}% need this comment symbol to avoid overfull hbox
\begin{subfigure}{.5\textwidth}
\myalgorithm
\caption{How to write algorithms}
\end{subfigure}\\
\begin{subfigure}{.5\textwidth}
\myalgorithm
\caption{How to write algorithms}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\myalgorithm
\caption{How to write algorithms}
\end{subfigure}
\caption{Main caption}
\end{figure}
\end{document}