[Tex/LaTex] ref to subsection number only

cross-referencing

is there a way to reference the subsection part only?
Example:

\documentclass{article}
\begin{document}

\section{This is my section}
For further information see subsection \ref{subsecthree} within this section.
\subsection{One}
\subsection{Two}
\subsection{Three}\label{subsecthree}

\end{document}

Usually gives (without the stars):

1 This is my section
For further information see subsection **1.3** within this section.

But I want:

1 This is my section
For further information see subsection **3** within this section.

Is that possible?

[Edit] To make it more clear: I am looking for a command that works like \ref, but prints (the arabic number of) the value of the subsection counter at the position of the \label.

=======================
== Solution in LaTeX ==

There is another solution below. This is a different solution I came up with
(I cannot post an answer to my own question, so I put it here):

\documentclass{article}

\newcommand{\labelsubseccounter}[1]{
    \renewcommand\thesubsection{\arabic{subsection}}
    \addtocounter{subsection}{-1}
    \refstepcounter{subsection}
    \label{#1}
    \renewcommand\thesubsection{\thesection.\arabic{subsection}}
}

\begin{document}

\section{This is my section}
For further information see subsection \ref{subsecthree} within this section, 
which is called \ref{onepointthree}, not \ref{onepointfour}.
\subsection{One}
\subsection{Two}
\subsection{Three}\label{onepointthree}\labelsubseccounter{subsecthree}
\subsection{Four}\label{onepointfour}

\end{document}

(I would like to insert the compiled code, but don't know how, sorry)

Best Answer

Related to your MWE you can use the following:

\documentclass{article}
\makeatletter
\def\@firstoftwo@second#1#2{%
  \def\temp##1.##2\@nil{##2}%
   \temp#1\@nil}
\newcommand\sref[1]{%
   \expandafter\@setref\csname r@#1\endcsname\@firstoftwo@second{#1}%
}

\makeatother
\begin{document}
\section{This is my section}
For further information see
\begin{tabular}{ll}
 \verb+\sref{subsecone}+   & \sref{subsecone} \\
 \verb+\sref{subsectwo}+   & \sref{subsectwo} \\
 \verb+\sref{subsecthree}+ & \sref{subsecthree} \\
\end{tabular}  within this section.
\subsection{One}\label{subsecone}
\subsection{Two}\label{subsectwo}
\subsection{Three}\label{subsecthree}
\end{document}

enter image description here


Some explanation.

The standard reference are saved in the aux-file in the following form:

\newlabel{subsectwo}{{1.2}{1}}

You can see that \newlabel is a command with two mandatory argument. The first argument is the label name and the second argument has two other groups inside. The first group is the numbering scheme and the second group shows the page.

So you want to extract the first group of the second mandatory argument and then you want to extract the second part of the number.

With the command \@firstoftwo@second you take the first group of the second argument of \newlabel and due to it's defintion you extract your requested number.

Related Question