[Tex/LaTex] What’s the difference between \ref and \autoref


I've always used \ref for referring to labelled items, but a LaTeX template I downloaded uses \autoref instead. What is the difference?

Best Answer

\autoref is a command from the hyperref package which is used to have some automatic prefix added to the reference. For instance if you used \label{sec:intro} just after your command for the introduction section the \autoref{sec:intro} command will output "section X" with X being the good number.

Of course you can imagine that the prefix depends on the type of the object to which the label is linked. If it is a figure, it will output "figure" and so on.

Note that you can redefine the prefix for the autoref command associated to a given type of object. For instance for the sections use:

\def\sectionautorefname{New prefix for the sections}

More generally,

\def\<type>autorefname{<new name>}