I am trying to put two algorithms side-by-side on a page so it is easy
to compare their differences. I am using the acm template, algorithm2e package and minipage environment. but I get this error:
! LaTeX Error: [H] in two columns mode is not allowed for algorithms.
I have followed these steps in this post, but it dose not work out for me. multiple algorithm2e algorithms in two column documents
Does anyone know how I can put two algorithms side-by-side?
This is my sample code it us work fine in one column page but it does not work in two column page.
\begin{minipage}[t]{8cm}
\null
\begin{algorithm}[H]
% \caption{Algo 1}
\SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up}
\SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress}
\SetKwInOut{Input}{Generation step}\SetKwInOut{Output}{Initialization step}
\Input{\color{blue} Generate }
\Output{ $K$}
\BlankLine
\Output{\color{blue}***,**}
\emph{\bf{\color{blue} 444}}\;
\emph{\color{blue} 2222}\;
\emph{\color{blue}11111\;}
\emph{\color{blue}111\;}
\emph{###\;
}
\BlankLine
\emph{\bf{\color{blue} Received $ID$}}\;
\For{\color {blue} each node that receives a ID}{
\If{\color {blue} ##}{\color {blue} Add value to the list
}
\BlankLine
\For{Each $received ID$}{
Find *,$s$\;
\eIf{$s$ $>$ ID$}{do nothing}{Replace #}
}
}
\BlankLine
Find the smallest element on the list, $s$\;
\eIf{$s$ $=$ $0$}{###}{*** }\BlankLine
\BlankLine
\caption{DNE Algorithm}\label{DNE Algorithm}
\end{algorithm}
\end{minipage}%
\removelatexerror
\begin{minipage}[t]{8cm}
\null
\begin{algorithm}[H]
\emph{**}\;
% \Output{***}
\emph{**}\;
\emph{** size to 1}\;
\BlankLine
\emph{\bf{Broadcast}}\;
\emph{broadcast it}\;
\BlankLine
\emph{\bf{Estimation}}\;
\For{each ID$}{
Find the smallest ,$s$\;
\eIf{$s$ $>$ $received ID$}{do nothing}{Replace $s$ }
}
\BlankLine
Find the smallest element on the list, $s$\;
\eIf{$s$ $=$ $0$}{1111}{ab}\BlankLine
\caption{Algorithm}\label{DNE-Algorithm}
\end{algorithm}
\end{minipage}
\documentclass{...}and ending with\end{document}. – Sep 26 '14 at 10:41