GeneralCounters of procedures and algorithms

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
shay zakov
Posts: 2
Joined: Sun Aug 08, 2010 11:21 am

Counters of procedures and algorithms

Post by shay zakov »

I'm using the "algorithm2e" package, and the "algorithm" and "procedure" environments it defines. Whenever I add a new "procedure", it also increases the counter for the algorithms, so when I'm using:

Code: Select all

\begin{algorithm}
...
\end{algorithm}

\begin{procedure}
...
\end{procedure}

\begin{algorithm}
...
\end{algorithm}
I get something like:

Algorithm 1: first algorithm name
...

Procedure procedure name
...

Algorithm 3: second algorithm name
...


The question is: how do I enforce that procedures would not increase the counter of algorithms?

I've tried to use

Code: Select all

\addtocounter{algorithm}{-1}
after procedures and it did nothing, and I've tried

Code: Select all

\setcounter{algorithm}{<new value>}
before the algorithm, and it produced the error "No counter 'algorithm' defined."

Any ideas?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Counters of procedures and algorithms

Post by gmedina »

Hi,

we will need a minimal working example (MWE) allowing us to reproduce the undesired behaviour. I ask you for this MWE since the following simple example behaves well:

Code: Select all

\documentclass{article}
\usepackage{algorithm2e}

\begin{document}

\begin{algorithm}[H]
\caption{How to write algorithms}
\end{algorithm}
%
\begin{procedure}
\caption{How to write procedures()}
\end{procedure}
%
\begin{algorithm}
\caption{How to write algorithms}
\end{algorithm}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
shay zakov
Posts: 2
Joined: Sun Aug 08, 2010 11:21 am

Re: Counters of procedures and algorithms

Post by shay zakov »

Thanks gmedina,

As I run your example and it still produced wrong numbers, I understood that I have an old version of the algorithm2e package. I've replaced the installed 3.9 version with the 4.01 version, and now it is working.

Thanks again,

Shay
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Counters of procedures and algorithms

Post by localghost »

Now that the problem is solved please mark the topic accordingly as described in Section 3 of the Board Rules.


Best regards and welcome to the board
Thorsten
Post Reply