2

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?

2
  • Welcome to TeX.SE. Nov 3, 2012 at 6:14
  • Your welcome. You can use select the code and then hit the {} to format the code -- refer to Markdown help for more detauls. And keep in mind that while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and all the appropriate packages. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving problem. Nov 3, 2012 at 6:34

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .