With the style file gSCS2e.cls, found at http://www.tandf.co.uk/journals/authors/gscslatex.zip as well as the algorithm package, if I compile the following LaTeX document, the Algorithm counter seems to be broken. It is stuck at 1 and does not increment. Specifically, the final words in my example document are "This is Algorithm 1" repeated twice. The Algorithm counter increments within a section, however. I get the expected results with other style files, so there is probably something wrong with the style file. I was not successful in obtaining a solution from the journal. I am sure this is well beyond my knowledge, hence I'm asking for help here.

The journal proofs do not show this problem. I initially thought they had fixed the problem in a more recent version of the class file, but after repeated requests and much confusion, I think it is possible that someone hand-edited the output. At any rate, I have never seen a version of this class file more recent than the version I have been using all along, namely, 2.4 ("First released 2008/05/02"). Unfortunately this is a real problem for me because I cannot circulate preprints with this brokenness.

\usepackage{algorithm, algpseudocode}

\section{First section}
\caption{First algorithm}
\State some stuff

\section{Second section}
\caption{Second algorithm}
\State some more stuff

This is Algorithm~\ref{first}. This is Algorithm~\ref{second}.
  • Including section numbers in counters is a better solution for journal papers (at least in IEEE journals). There is a package option for it: \usepackage[section]{algorithm} – Aydin Dec 7 '12 at 12:26

The algorithm counter is reset at each section. That's because the gSCS2e class defines an algorithm environment. This uses a counter with the same name algorithm which is bound to the section counter. From gSCS2e.cls:


You could remove that dependency, for example using the chngcntr package. This package provides commands for setting and removing relationships of counters, i.e. it allows to customize if a counter is reset when another counter is incremented, or not.

  • @Stefan: Can you give more details, please? For example, why is there no problem with other class files? What is resetting the counter? If this is the style file, it seems unlikely it would have special code for the algorithm package. – Faheem Mitha Mar 19 '11 at 21:14
  • @Faheem: I added an explanation. – Stefan Kottwitz Mar 19 '11 at 21:21
  • I was just writing the same answer. Alternatively, if you want the algorithms numbered within a section, you can use \counterwithin{algorithm}{section} This will give Sec.Alg numbering. – Alan Munn Mar 19 '11 at 21:22
  • @Alan: That would look like Algorithm 1.1, Algorithm 1.2 etc? – Faheem Mitha Mar 19 '11 at 21:26
  • @Stefan: I see. LaTeX has no namespaces, so one algorithm counter interferes with the other? – Faheem Mitha Mar 19 '11 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.