Math & ScienceWriting an algorithm in two columns

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

Writing an algorithm in two columns

Post by seeker »

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!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Writing an algorithm in two columns

Post by php1ic »

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

Code: Select all

\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

Re: Writing an algorithm in two columns

Post by seeker »

Wow!! That's exactly what I need. amazing!
Thanks php1ic!

-Seeker
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Re: Writing an algorithm in two columns

Post by php1ic »

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.
Post Reply