I'm using a custom counter with a newenvironment for the first time and don't quite understand the nuances. The only problem I have so far is that when I use \ref
it gets the number I want but not the format I want. I want the reference to have the same format as the original numbering. In this MWE the commented out line has what I want the format to be. What's the right way to get that?
\documentclass[12pt]{article}
% problem numbering
\newcounter{pcntr} % count the problems
\newenvironment{Problems}{
\begin{list}{\textbf{\alph{pcntr})~}}{\usecounter{pcntr}}
}{
\end{list}
}
% problem referencing
%\newcommand{\qref}[1]{part~\textbf{\alph{\ref{#1}})}}
\newcommand{\qref}[1]{part~\textbf{\ref{#1})}}
\begin{document}
\begin{Problems}
\item \label{prb:test1} Blah blah blah
\item \label{prb:test2} As we saw in \qref{prb:test1}, \dots
\item \label{prb:test3} Also, \qref{prb:test2} is quite interesting.
\end{Problems}
\end{document}
Best Answer
Use
\thepcntr
after defining it properly.