[Tex/LaTex] Algorithm counter is broken with journal style file

algorithmsnumberingtemplates

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.

\documentclass{gSCS2e}
\usepackage{algorithm, algpseudocode}
\begin{document}
\title{Title}
\maketitle

\section{First section}
\begin{algorithm}
\caption{First algorithm}
\label{first}
\begin{algorithmic}[1]
\State some stuff
\end{algorithmic}
\end{algorithm}

\section{Second section}
\begin{algorithm}
\caption{Second algorithm}
\label{second}
\begin{algorithmic}[1]
\State some more stuff
\end{algorithmic}
\end{algorithm}

This is Algorithm~\ref{first}. This is Algorithm~\ref{second}.
\end{document}

Best Answer

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:

\newtheorem{algorithm}{\global\algorithmtrue{\bf\algorithmname}}[section]

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.

\usepackage{chngcntr}
\counterwithout{algorithm}{section}