I have a single-column document and to save space I would like to make a long algorithm (produced using packages algorithm and algorithmic) to be double-column. That is, I would like the float content to start on the left column and continue on the right column, where the rest of the document is single column. I can place two algorithms side by side within a figure environment, but I am not sure if partitioning a single algorithm into columns can be done.


The multicol package to the rescue!



\caption{Calculate $y = x^n$}
  \REQUIRE $n \geq 0 \vee x \neq 0$
  \ENSURE $y = x^n$
  \STATE $y \Leftarrow 1$
  \IF{$n < 0$}
  \STATE $X \Leftarrow 1 / x$
  \STATE $N \Leftarrow -n$
  \STATE $X \Leftarrow x$
  \STATE $N \Leftarrow n$
  \WHILE{$N \neq 0$}
  \IF{$N$ is even}
  \STATE $X \Leftarrow X \times X$
  \STATE $N \Leftarrow N / 2$
  \ELSE[$N$ is odd]
  \STATE $y \Leftarrow y \times X$
  \STATE $N \Leftarrow N - 1$

sample output

  • 2
    @Marina Welcome! If this is the answer you were looking for, please consider accepting it.
    – mafp
    Jun 16 '13 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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