Possible Duplicate:
Placing figures inside a two-column document

Here is my MWE:



\title{How to insert algorithm inside multicols environment}



\caption{Euclid’s algorithm}\label{euclid}
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
   \State $r\gets a\bmod b$
   \While{$r\not=0$}\Comment{We have the answer if r is 0}
      \State $a\gets b$
      \State $b\gets r$
      \State $r\gets a\bmod b$
   \State \textbf{return} $b$\Comment{The gcd is b}



It output the warning message when I compile this:

Package multicol Warning: Floats and marginpars not allowed inside `multicols' 

And the pseudocode is missing.

Can you tell me how to insert single column float algorithm environment. I don't want algorithm* style.

  • Are you okay with a non-floating algorithm?
    – Werner
    Jul 1, 2012 at 2:18
  • @Werner basically, I really want floating algorithm. As I have tried to add [H] parameter into algorithm. but there leave much blank space
    – pythonee
    Jul 1, 2012 at 2:31
  • This problem can be generalized in terms of placing a float inside the multicols environment. For that, Frank's answer in Placing figures inside a two-column document should provide a solution, however minimal, and one could consider this question a duplicate.
    – Werner
    Jul 1, 2012 at 2:58

1 Answer 1


The multicols environment doesn't support floats that are column wide, for the simple reason that this would conflict with balancing and with the fact that you could alter the number of columns on a single page.

Given that your example uses multicols* for the whole document the first thing you need to decide for yourself is: do you need to use multicol at all or would it be better to use LaTeX's standard twocolumnpossibilities.

See the discussion in this answer for details.

However, as Werner remarked I actually recently implemented a unsupported extension to multicol that offers placing column figures within the scope of the environment. They do not automatically "float" but you can specify that they should appear on a certain page in a certain column position. See here for details.

  • I prefer to use standard towcolumn option. But I don't know how to switch to onecolumn for certain part of document
    – pythonee
    Jul 1, 2012 at 11:46
  • \onecolumn ends the current page and restarts with a single column page. \twocolumn ends the current page and restarts with two columns. \twocolumn[some single column text] does the same but keeps the material in brackets in single column at the top of the page. Jul 1, 2012 at 12:29
  • thank you for your reply. I have tried this method. But I got some break line issue. so I switch to multicol package. It breaks well. so finally I decide to use package multicol. and It is very convenient switch column.
    – pythonee
    Jul 1, 2012 at 13:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.