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.

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?

share|improve this question
    
Welcome to TeX.SE. –  Peter Grill Nov 3 '12 at 6:14
    
Thanks for the editing! –  wei wang Nov 3 '12 at 6:18
    
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. –  Peter Grill Nov 3 '12 at 6:34
add comment

1 Answer 1

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.

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.