# Diego’s CS research blog

## August 13, 2008

### Side-by-Side Algorithms in LaTex

Filed under: Uncategorized — Diego @ 9:35 am

Here is the code of how to put two (or more) algorithms side by side in latex using algorithmic and algorithm packages. (The principle is the same used to put figures side-by-side).
NB: remeber to put [H] as a parameter for \begin{algorithm} (I lost a lot of time trying to understand this very simple thing)

\begin{figure*}[ttt!]

\begin{minipage}[t]{3.15in}

\begin{algorithm}[H]

\caption{Mission-side Greedy}

\label{alg1}

\begin{algorithmic}[1]

\FOR{each mission $M_{j}$ in sorted order}

\STATE do something

\ENDFOR

\end{algorithmic}

\end{algorithm}

\end{minipage}

\hfill

\begin{minipage}[t]{3.15in}

\begin{algorithm}[H]

\caption{Mission-side2 Greedy}

\label{alg2}

\begin{algorithmic}[1]

\FOR{each mission $M_{j}$ in sorted order}

\STATE do something

\ENDFOR

\end{algorithmic}

\end{algorithm}

\end{minipage}

\hfill

\end{figure*}

1. Good stuff man, I’ve been searching for a way to wrap text around an algorithm float. When I read this post it clicked, put the algorithm environments into the minipage and use that in the wrapfigure environment.

Comment by Ted R. — January 14, 2011 @ 9:25 am

2. Thank you very much. I lost one day to resolve this problem. I use this solution and i don’t care why it works 🙂

Comment by Alex — December 31, 2011 @ 2:52 pm

3. I tried this but it doesn’t work in an IEEEtran.cls environment. Any idea why?

Comment by Dimitris — January 14, 2013 @ 3:35 pm

Create a free website or blog at WordPress.com.