The command \autoref{some-label-goes-here} from the hyperref package would print "Figure X", or "Table Y", etc. depending on the type of the referenced float.

How can I print "Figure" / "Table" (without the number) given the label? Something like \floattype{some-label-goes-here}.

This is useful if one wants to say, for example,

The \floattype{some-figure-label} shows the expansion rules

which would expand to "The figure shows the expansion rules."

  • 1
    The cleveref package has \namecref that does this.
    – Marijn
    Dec 16 '17 at 21:40

It's straightforward to achieve your objective by employing the cleveref package and its \namecref macro.

enter image description here

If you need to upppercase the first letters in figure and table, load the cleveref package with the option capitalise. (capitalize works too.)


\Cref{fig:h} shows that \dots

The \namecref{fig:h} shows that \dots

\Cref{tab:g} show that \dots

The \namecref{tab:g} demonstrates that \dots

The following inserts the reference type as the fifth, unused element in the components written with every \label:

enter image description here



    {\csname type@name@#5\endcsname}%
  % \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}


  \caption{A figure caption}

See \autoref{fig:figure}. It is a \typeref{fig:figure}.


See \autoref{fig:figure}. It is a \typeref{fig:figure}.


\settyperef{<type>}{<output>} allows you to format what the output should look like.

  • 2
    What is the advantage of this solution vs using the cleveref package? EDIT: Seems like a good source of information for some of the inner workings of hyperref.
    – dow
    Dec 17 '17 at 2:18
  • 1
    @dow: Using an existing package is always a good idea, since it's probably undergone some scrutiny by the community and may be updated to support different features. However, using such an encompassing package would seem to suggest changing your user interface (\cref instead of \ref). Mine allows you to stick to your format of using \autoref, but it really depends on the end-user.
    – Werner
    Dec 17 '17 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.