I'm looking for a LaTeX command, say \foo, which expands to the type of section I'm in. In the following, the first \foo should expand to "Section", the second to "Subsection", and the third one to "Figure":
\section{aaa}
Hello \foo
\subsection{bbb}
Hello \foo
\begin{figure}
whatever
\caption{bla \foo}
\end{figure}
I'd like to have this to build a labeling package which knows where the label comes from, i.e., a \label{R4wmVP} inside a figure would make \ref{R4wmVP} print "Figure \thefigure". The benefit is that after making a section a subsection (or chapter), all references change automatically.

namerefpackage directly – Seamus Aug 12 '11 at 15:32