\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{hyperref}
\makeatletter
% Helper macro to extract the type (section,subsection...) or the type name
% out of the label reference. Works with hyperref only.
% Argument #1 is a macro of form \def\...#1...\@nil{...}
% Argument #2 is the label reference, e.g. "sect:test"
\newcommand*\@myautoref[2]{% \HyPsd@@@autoref from hyperref, modified
\expandafter\ifx\csname r@#2\endcsname\relax
??%
\else
\expandafter\expandafter\expandafter\@@myautoref
\csname r@#2\endcsname{}{}{}{}\@nil#1\@nil
\fi
}
\def\@@myautoref#1#2#3#4#5\@nil#6\@nil{% \HyPsd@autorefname, modified
#6#4.\@nil}% Argument #4 = type and number, e.g. "section.1" or "subsection.1.2"
% \myreftype results in the type name, e.g. "section" or "figure".
% The starred variant will remove a star, if existent, i.e. "section*" will become "section"
\newcommand\myreftype{%
\@ifstar
{\@myautoref\@@myreftype}%
{\@myautoref\@myreftype}}
\def\@myreftype#1.#2\@nil{#1}
\def\@@myreftype#1.#2\@nil{\@@@myreftype#1*\@nil}
\def\@@@myreftype#1*#2\@nil{#1}
% \myautorefname results in the type prose name (plus space character),
% e.g. "section" in English or "Abschnitt" in German
% (like \autoref, but without number).
% \HyPsd@@autorefname is defined in the hyperref package.
\newcommand*\myautorefname[1]{\@myautoref\HyPsd@@autorefname{#1}}
% An alternative version of \myautorefname without space at the end.
% Since the \space is hard coded inside \HyPsd@@autorefname we use our
% own version called \@myautorefname instead.
% Furthermore we offer a starred variant which will work with labels to
% \section* etc., too.
\renewcommand*\myautorefname{%
\@ifstar
{\@myautoref\@@myautorefname}%
{\@myautoref\@myautorefname}}
\def\@myautorefname#1.#2\@nil{% = \HyPsd@@autorefname without \space
\ltx@IfUndefined{#1autorefname}%
{\ltx@IfUndefined{#1name}%
{}%
{\csname#1name\endcsname}}%
{\csname#1autorefname\endcsname}}
\def\@@myautorefname#1.#2\@nil{%
\expandafter\@myautorefname\@@@myreftype#1*\@nil.\@nil}
\makeatother
\begin{document}
\myreftype{section:one}
\myreftype{subsection:one}
\myreftype{figure:one}
\myreftype{section:two}
\myreftype*{section:one}
\myreftype*{subsection:one}
\myreftype*{figure:one}
\myreftype*{section:two}
\myautorefname{section:one}
\myautorefname{subsection:one}
\myautorefname{figure:one}
\myautorefname{section:two}
\myautorefname*{section:one}
\myautorefname*{subsection:one}
\myautorefname*{figure:one}
\myautorefname*{section:two}
\section{Section One}
\label{section:one}
\subsection{Subsection One}
\label{subsection:one}
\begin{figure}
\caption{Figure One}
\label{figure:one}
\end{figure}
\section*{Section Two}
\label{section:two}
\end{document}
The code above is an extract of a solution I once wrote for a German LaTeX forum, see: http://www.mrunix.de/forums/showthread.php?t=71566
Please note that this one uses the facilities of hyperref alone. I'm not familiar with packages like varioref or cleverref, so there may be a better solution using one of those packages.
cleverefpackage? – cmhughes Nov 05 '11 at 21:07\lcnamecrefcould be of any use... but lack the skill to turn it into something usefull I'm afraid :S... could you provide an example? – mpr Nov 05 '11 at 21:28