[Tex/LaTex] Changing caption numbering for algorithm in algorithm2e

algorithm2enumbering

I am trying to define a new environment that uses the algorithm environment from algorithm2e. I want to use a separate caption counter for this new environment. As of now, this is what I have, but I don't know how to \def or \renewcommand the caption variable with the hdps counter?

\newcounter{hdps}
\newenvironment{asm}{%
\stepcounter{hdps}%
\renewcommand*{\algorithmcfname}{ASM Spec.}%
\begin{algorithm}}
{%
\def\thealgocf{}%
\end{algorithm}}

Help is much appreciated.

Best Answer

You could use something like this:

\newcounter{hdps}
\newenvironment{asm}
  {\refstepcounter{hdps}%
    \renewcommand*{\algorithmcfname}{ASM Spec.}%
    \begin{algorithm}\renewcommand\thealgocf{\arabic{hdps}}}
  {\end{algorithm}\addtocounter{algocf}{-1}}

EDIT: of course, this approach will only work as expected if \caption is used consistently in the algorithm and asm environments.