algorithms inside tabular ?

3,264 views
Skip to first unread message

Edu

unread,
Feb 1, 2009, 1:31:56 PM2/1/09
to LaTeX Users Group
Hi all,

In a one-column document, I would like to put two short algorithms in
two columns (one next to the other). I though the easiest way would be
to write the algorithms inside a tabular environment. The code:

\begin{table}[tb]
\begin{tabular}{ll}
\begin{algorithmic}
\REQUIRE a
\ENSURE b
\STATE hello
\end{algorithmic}

&

whatever

\end{tabular}
\end{table}

Produces the following error:

! LaTeX Error: Something's wrong--perhaps a missing \item.

Any suggestion on how to do it?

Thank you!

Luis Ernesto Carrera Retana

unread,
Feb 12, 2009, 7:29:11 PM2/12/09
to latexus...@googlegroups.com
I would prefer the package multicol instead of the tabular environment. You can see here the documentation:

http://www.ctan.org/tex-archive/macros/latex/required/tools/multicol.pdf

It could be something like:
\usepackage{multicol}

...

\begin{table}[tb]
\begin{multicols*}{2}

 \begin{algorithmic}
   \REQUIRE a
   \ENSURE b
   \STATE hello
 \end{algorithmic}

\columnbreak

 whatever

\end{multicols*}
\end{table}

Or if you are atached to the tabular environment, maybe you can use minipages:


\begin{table}[tb]
\begin{tabular}{ll}
\begin{minipage}{3in}

 \begin{algorithmic}
   \REQUIRE a
   \ENSURE b
   \STATE hello
 \end{algorithmic}
\end{minipage}

&

\begin{minipage}{3in}
 whatever
\end{minipage}
\end{tabular}
\end{table}

2009/2/1 Edu <edua...@gmail.com>
Reply all
Reply to author
Forward
0 new messages