\ref should use enumerate label name
You can use the enumitem
package:
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=\textbf{S.\arabic*}]
\item a
\item \label{l} b
\item c. goto \ref{l}
\end{enumerate}
\end{document}
or
\begin{enumerate}[label=\textbf{S.\arabic*},ref=S.\arabic*]
\item a
\item \label{l} b
\item c. goto \ref{l}
\end{enumerate}
if you don't want the reference to be boldfaced.
For your attempt properly work, you need redefine the counter representation (\theenumi
) as well as the label associated with it (\labelenumi
). This separates the formatting from the counter when you're using \ref
:
\documentclass{article}
\begin{document}
\begin{enumerate}
\renewcommand{\labelenumi}{\textbf{\theenumi}}
\renewcommand{\theenumi}{S.\arabic{enumi}}
\item a
\makeatletter
\show\@currentlabel
\makeatother
\item \label{l} b
\item c. goto \ref{l}
\end{enumerate}
\end{document}
This also works nicely with hyperref
. However, in general, it is much easier to use enumitem
since it can be used in a global or localized setting using a key-value approach; very convenient.