# Placing a single algorithm in two columns

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!

\documentclass{article}

\usepackage{lipsum}
\usepackage{algorithm,algorithmic}
\usepackage{multicol}

\begin{document}
\lipsum[1]
\begin{algorithm}
\caption{Calculate $y = x^n$}
\label{alg1}
\begin{multicols}{2}
\begin{algorithmic}[1]
\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$
\ELSE
\STATE $X \Leftarrow x$
\STATE $N \Leftarrow n$
\ENDIF
\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$
\ENDIF
\ENDWHILE
\end{algorithmic}
\end{multicols}
\end{algorithm}
\lipsum[2]
\end{document}


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