LaTeX forum ⇒ Math & ScienceWriting 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

Postby seeker » Wed Jul 21, 2010 2:31 am

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

Postby php1ic » Wed Jul 21, 2010 3:34 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
  1. \documentclass{article}
  2.  
  3. \usepackage{multicol}
  4. \usepackage[english]{babel}
  5. \usepackage{blindtext}
  6.  
  7. \begin{document}
  8. \blindtext
  9.  
  10. \begin{multicols}{2}
  11. \blindtext
  12. \end{multicols}
  13.  
  14. \blindtext
  15.  
  16. \end{document}

seeker
Posts: 2
Joined: Wed Jul 21, 2010 2:18 am

Postby seeker » Thu Jul 22, 2010 6:37 am

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

-Seeker

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

Postby php1ic » Thu Jul 22, 2010 12:23 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.


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 4 guests