1

I want to add a caption below algorithm environment that spans over two column page in \documentclass[10pt, conference, compsocconf]{IEEEtran}. I use the following:

\usepackage[Algorithm,ruled]{algorithm}
\usepackage{float}

\begin{figure*}
    \begin{algorithm*}[H]
            This is algorithm
    \end{algorithm*}
\caption{Caption here}
\end{figure*}

But I get error ./main.tex:164: LaTeX Error: Float(s) lost. How can I fix that?

Thank you very much.

0

You can have a caption below an algorithm using the algorithm2e package

\documentclass{article}
\usepackage[]{algorithm2e}

\begin{document}
    \begin{algorithm}
            This is algorithm
            \caption{Algorithm caption}
    \end{algorithm}
\end{document}
1

The issue here is that you're placing a starred float environment (algorithm*) inside another starred float environment (figure*). You can get away with it by using figure* and the algorithm with the [H]ere float specifier:

\documentclass[conference]{IEEEtran}

\usepackage[ruled]{algorithm}
%\usepackage{float} % Already loaded by the algorithm package

\begin{document}

\begin{figure*}
  \begin{algorithm}[H]
    This is algorithm
  \end{algorithm}
  \caption{Caption here}
\end{figure*}

\end{document}

Note that your algorithm captions will be printed as a figure caption. However, that might be what you're after.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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