I am renaming the "line" label for lines in the algorithmic
environment, since I am using the default label for lstlisting
environment. As soon as I add define \crefname
for it, the counter does not increase.
It's a simple problem, so an example will illustrate it best.
\documentclass{article}
\usepackage{algorithm}
\usepackage{hyperref}
\usepackage{algpseudocode}
\usepackage{cleveref}
\crefname{opC}{operation}{operations}
\Crefname{opC}{Operation}{Operations}
\begin{document}
\begin{algorithm}[bt]
\begin{algorithmic}[1]
\State First line
\label[opC]{line:1}
\State Second line
\label[opC]{line:2}
\end{algorithmic}
\end{algorithm}
Refer here to \cref{line:1} and to \cref{line:2}.
These two work just fine: \cref{line:4} and \cref{line:3}.
\begin{algorithm}[bt]
\begin{algorithmic}[1]
\State Another first line
\label{line:3}
\State Another second line
\label{line:4}
\end{algorithmic}
\end{algorithm}
\end{document}
I tried with \newcounter{opC}
and \crefalias{opC}{line}
to no avail.
Incidentally, \ref
returns numbers as it should, as shown for the second algorithm. Also, the hyperref
links point to the right location (though hard to check in this MWE), so only the actual label is wrong.