[Tex/LaTex] Putting multiple algorithm2e procedures in figure

algorithm2e

I want to put some algorithm2e procedures into a figure like:

\begin{figure}
\begin{procedure}
some code \;
\caption{abc (n).}
\end{procedure}

\begin{procedure}
some code \;
\caption{abc (n).}
\end{procedure}

\caption{some procedures.}
\end{figure}

Please, how to do it?

Best Answer

The procedure environment like algorithm is already a float so you cannot place it inside figure or table directly. See this discussion for more details.

You can place your procedures in minipage environment and add caption using captionof command from caption package. and then enclose them in figure environment as follows,

\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
\begin{figure}
    \begin{minipage}{\linewidth}
    \begin{procedure}[H]
        some code \;
         \caption{abc (n).}
    \end{procedure}
    \end{minipage}
    \begin{minipage}{\linewidth}
    \begin{procedure}[H]
        some code \;
        \caption{abc (n).}
    \end{procedure}
    \end{minipage}
\caption{some procedures.}
\end{figure}
\end{document}

code output

You may also want to look at the answers for this question.