# Why do I get the error “\caption outside float” with the algorithm / algorithmic package? [closed]

I have an algorithm in my document

It looks like this:

\begin{algorithm}
\caption{Merge Digest: Insert\label{mergeDigestInsert}}
\begin{algorithmic}[1]
[....algorithm is here]
\end{algorithmic}
\end{algorithm}


When I compile the document I get this error:

Package caption Error: \caption outside float.


I tried putting the caption inside of the algorithmic block, and I tried to put it at the end. I also read somewhere that I need to declare algorithm as a caption type like this:

\DeclareCaptionType{algorithm}


but when I do that I get this error:

LaTeX Error: ./doc.tex:21 LaTeX Error: Command \algorithm already defined.


I appreciate any help that can be given on this.

-

## migrated from stackoverflow.comDec 17 '11 at 0:39

This question came from our site for professional and enthusiast programmers.

## closed as too localized by Marco Daniel, egreg, Stefan Kottwitz♦Feb 4 '12 at 21:34

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Welcome to TeX.sx! Please add a complete and minimal version of your code (in the sense of a minimal working example (MWE)) that illustrates your problem. – Gonzalo Medina Dec 17 '11 at 0:49
Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Werner Dec 17 '11 at 0:50
It should work this way, no need for \DeclareCaptionType since this defines a new floating environment. So I second what Gonzalo wrote, please give us a MWE so we can examine the problem. – Axel Sommerfeldt Dec 17 '11 at 8:08