[Tex/LaTex] How to remove the number from an algorithm caption

algorithmscaptionsnumbering

I want algorithm to NOT show the number in caption. How can i do that? Below is the code:

\begin{algorithm}
\begin{algorithmic}
\caption{ My Algorithm}
\IF
\ELSE
\end{algorithmic}
\end{algorithm}

Please let me know.

Best Answer

If this is for just one algorithm environment, you can locally redefine \thealgorithm:

\documentclass{article}
\usepackage{algorithmic,algorithm}

\begin{document}

\begin{algorithm}
\renewcommand\thealgorithm{}
\caption{A numberless algorithm}
\begin{algorithmic}
\STATE do something 
\end{algorithmic}
\addtocounter{algorithm}{-1}
\end{algorithm}

\end{document}

enter image description here

If you want this to be the global behaviour, you can add

\renewcommand\thealgorithm{}

to the preamble.

Another option is to use the caption package and declare a new label format for algorithms, suppressing the numbering:

\documentclass{article}
\usepackage{algorithmic,algorithm}
\usepackage{caption}

\makeatletter
\DeclareCaptionLabelFormat{numberless}{\ALG@name#1}
\captionsetup[algorithm]{labelformat=numberless} 
\makeatother

\begin{document}

\begin{algorithm}
\caption{A numberless algorithm}
\begin{algorithmic}
\STATE do something 
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here