TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
\While{not at end of this document}{
read current\;
go to next section\;
current section becomes this one\;
go back to the beginning of current section\;

        \caption{How to write algorithms}
    \end{subfigure}% need this comment symbol to avoid overfull hbox
        \caption{How to write algorithms}
        \caption{How to write algorithms}
        \caption{How to write algorithms}
\caption{Main caption}

share|improve this question
up vote 8 down vote accepted

algorithm2e provides its own [H] float parameter, which sidesteps setting its contents as a float. However, in twocolumn mode, it produces an error. I'm not sure why. You can avoid this by setting \@latex@error to \@gobble temporarily. Using your example, I've added a \removelatexerror macro inside a \begingroup...\endgroup. More specifically, the definition


is placed inside a group, inside \myalgorithm:

\removelatexerror% Nullify \@latex@error

Also, since you're spreading the 4 algorithms across both columns, it's best to use figure* rather than figure:

enter image description here

Obviously you won't be using \myalgorithm in your actual document. You could just place \removelatexerror inside each of the subfigure environments.

share|improve this answer

I had similar issues...

I simply removed [H] from the code as below.




Then the issue solved.

share|improve this answer
Welcome to TeX.SX! – mafp Sep 8 '13 at 19:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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