Getting inspired by this Have reference in section with custom counter, I've developed the following new environment. All is fine except when I call \prettyref{dog:1}
output is just showing 1 instead of DOG1. After some amount of debugging, it looks like \newrefformat
inside the definition of the environment is not being executed.
\newenvironment{animals}[1][dog]%
{
\newrefformat{#1}{\hyperref[{##1}]{\uppercase{#1} \ref*{##1}}}
\newcount\IndexNum
\IndexNum = 1
\newcounter{count#1}%
\setcounter{count#1}{0}%
\let\olditem\item%
\begin{enumerate}[label={\texttt{\uppercase{#1}\arabic*}}, ref={\arabic*}]%
\setcounter{enumi}{\value{count#1}}%
\renewcommand{\item}[1][]{%
\refstepcounter{count#1}\olditem%
\label{#1:\the\IndexNum} \global\advance\IndexNum by 1
}%
}%
{\end{enumerate}}
I've also attached an MWE for your reference.
\documentclass{article}
\usepackage{prettyref}
\usepackage{hyperref}
\usepackage{enumitem}
\newenvironment{animals}[1][dog]%
{
\newrefformat{#1}{\hyperref[{##1}]{\uppercase{#1} \ref*{##1}}}
\newcount\IndexNum
\IndexNum = 1
\newcounter{count#1}%
\setcounter{count#1}{0}%
\let\olditem\item%
\begin{enumerate}[label={\texttt{\uppercase{#1}\arabic*}}, ref={\arabic*}]%
\setcounter{enumi}{\value{count#1}}%
\renewcommand{\item}[1][]{%
\refstepcounter{count#1}\olditem%
\label{#1:\the\IndexNum} \global\advance\IndexNum by 1
}%
}%
{\end{enumerate}}
\begin{document}
\begin{animals}
\item Pitbull
\item Boxer
\end{animals}
\prettyref{dog:1} is Pitbull.
\end{document}
Current output is
while the expected output is