## LaTeX forum ⇒ Math & Science ⇒ Writing an algorithm in two columns

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
seeker
Posts: 2
Joined: Wed Jul 21, 2010 2:18 am

### Writing an algorithm in two columns

Hi there!
I appreciate this forum a lot and it has always been very useful to me. Here is a question I have:

- I am using a one column page.
- I need to write an algorithm (probably using algorithm and/or algorithmic packages) in "two" columns.
- I want only one caption and one label for the whole algorithm. (i.e., it is one algorithm, but written in two columns to save space).
It should look like the following:

--------------------------------------------------------
Algorithm 1 <algorithm caption>
--------------------------------------------------------
1: while(1) cond do 5: blah blah blah
2: blah blah blah 6: end if(2)
3: if(2) cond then 7: end while(1)
4: blah blah blah 8: return
--------------------------------------------------------

Would you help me do that please?
The purpose is to save space in one-column page.

Thank you and best regards!

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm
Try using the multicol package to switch from one to two columns. The second and third packages are just to provide text to show the different column layout
\documentclass{article} \usepackage{multicol}\usepackage[english]{babel}\usepackage{blindtext} \begin{document}\blindtext \begin{multicols}{2}\blindtext\end{multicols} \blindtext \end{document}

seeker
Posts: 2
Joined: Wed Jul 21, 2010 2:18 am
Wow!! That's exactly what I need. amazing!
Thanks php1ic!

-Seeker

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm
No problem, welcome to the board.

Once your problem is solved, the convention is to edit the subject of your initial post to include the green tick/check symbol.