1

I want to make an algorithm float and I use the algorithm2e package.

However, I can only use H for the algorithm. If I use htbp, I will get a Missing number, treated as zero error at \begin{algorithm}.

Here is the example.

\documentclass[twoside]{article}
\usepackage{multicol}
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}

\begin{document} \begin{multicols}{2} Test floating. \begin{center} \begin{minipage}{\columnwidth} \begin{algorithm}[htbp] \DontPrintSemicolon \caption{Test Algorithm} \KwIn{An Integer} \KwOut{Hash Value} \SetKwFunction{FFoo}{Foo} \SetKwProg{Fn}{Function}{:}{} \Fn{\FFoo{$i$}}{ \uIf{$i = 0$}{ \Return 0; } \Else{ \Return 1; } } \end{algorithm} \end{minipage} \end{center} \end{multicols} \end{document}

  • 3
    You can't put a floating object in a minipage. And I also think that multicols doesn't like floats. – campa Nov 26 '20 at 09:42
  • The multicols is from a template so I cannot modify it, while minipage can be removed. Hence, is there any solution to this problem? – Lesterth Nov 26 '20 at 10:46
  • 2
    The usual approach is to \end{multicols} add the filoat then start up multicols again. OTOH, the only real difference between multicol and twocolumn is on the last page (see https://tex.stackexchange.com/questions/477188/removing-the-space-in-the-page-before-appendix/477197?r=SearchResults&s=5|15.5037#477197). – John Kormylo Nov 26 '20 at 17:13

0 Answers0