Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is what i tried, but i can get the algorithms to display side by side.

\begin{minipage}{\textwidth}
\centering
\begin{minipage}{0.48\textwidth}
\centering
%\begin{algorithm}
\captionof{algorithm}{alg1}
\label{alg:case3}
\begin{algorithmic}
\REQUIRE $\F$, $O''$,
\ENSURE $I''$
\STATE $P_O \leftarrow$  $O''$
\STATE I $\leftarrow$ \{$I_1,I_2,..., I_n$\};


\end{algorithmic}
\end{minipage}

\begin{minipage}[c]{0.48\textwidth}
 \centering
%\begin{algorithm}
\captionof{algorithm}{alg2}
\label{alg:case2_2}
\begin{algorithmic}
\REQUIRE $T$,  $O''$, $I$,
\ENSURE $I''$
\STATE $P_O \leftarrow$  $O''$
\STATE $W'_O \leftarrow \O$

\end{algorithmic}
\end{minipage}
\captionof{figure}{Both alg}
\label{xxxxx}
\end{minipage}

Where could i be going wrong?

share|improve this question
    
Does removing the empty lines at the end of the environments help? –  Seamus Aug 12 '11 at 11:23
    
Ah: remove the first \centering might fix it –  Seamus Aug 12 '11 at 11:23
    
fixed, thanks. How do i add a frame around each algorithms? –  user739807 Aug 12 '11 at 11:32
add comment

1 Answer

The \centering of the "outer" minipage causes the two "inner" minipages to be centered. Without this, LaTeX will put the first minipage flushed left, and then see if there's room for the next one: there is, so it will be put next to it, as desired. You might want to add a \hfill between the two inner minipages so that the second one is flushed right and thus the page will be more balanced.

If you enclose the minipage in an \fbox this will put a frame around it:

\fbox{\begin{minipage...
...
\end{minipage}}

But depending on what package you're using to set your algorithms, it might include its own resources for adding frames. The framed and mdframed packages provide further options for customising frames.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.