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 am using the algorithm2e package to write algorithms. However, when i write three algorithms one after another, the algorithms are automatically numbered 1,2 and 3 in the caption. I am using following code:

\begin{algorithm}[H]
 \SetAlgoLined
 \KwData{this text}
 \KwResult{how to write algorithm with \LaTeX2e }
 initialization\;
 \While{not at end of this document}{
  read current\;
 \eIf{understand}{
  go to next section\;
 current section becomes this one\;
 }{
 go back to the beginning of current section\;
 }
}
\caption{How to write algorithms}
\end{algorithm}

I am getting the resulting algorithm to be enter image description here

The caption of algorithm mentions "Algorithm 3" if this package is used three times. I want that for every caption it just mentions "Algorithm" and not "Algorithm 3". How can it be done?

share|improve this question
add comment

2 Answers

If you're willing to use \TitleOfAlgo instead (which, for algorithms, is more flexible than \caption in many ways), then see John Wickerson's answer.

Otherwise, if you really want to use \caption but remove algorithm numbering, simply insert \renewcommand{\thealgocf}{} in your preamble.

enter image description here

\documentclass[10pt]{report} 
\usepackage{algorithm2e}

\renewcommand{\thealgocf}{}

\begin{document}

\begin{algorithm}[H]
 \SetAlgoLined
 \KwData{this text}
 \KwResult{how to write algorithm with \LaTeX2e }
 initialization\;
 \While{not at end of this document}{
  read current\;
 \eIf{understand}{
  go to next section\;
 current section becomes this one\;
 }{
 go back to the beginning of current section\;
 }
}
\caption{How to write algorithms}
\end{algorithm}

\end{document}
share|improve this answer
    
if answered, then DO accept it as an answer please. –  doctorate Feb 11 at 16:20
add comment

As texenthusiast has pointed out in a comment below, you should use

\TitleOfAlgo{How to write algorithms}

rather than

\caption{How to write algorithms}

This makes algorithms not numbered by default. If you change your mind and want the algorithms to be numbered again, you should set the option titlenumbered option when you load the algorithm2e package. (titlenotnumbered is the default.) That is,

\usepackage[titlenumbered]{algorithm2e}

For more details, see page 20 of the package documentation.

share|improve this answer
2  
titlenotnumbered is (default) hence not needed to mention but should use \TitleOfAlgo{How to write algorithms} instead of \caption{How to write algorithms} to remove numbering. –  texenthusiast May 18 '13 at 8:04
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.