Tell me more ×
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 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.

share|improve this question

1 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

share|improve this answer

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.