I use
\begin{lemma} \label{aaa} ... \end{lemma}
\begin{theorem} \label{bbb} ... \end{theorem}
and many other similar kinds in the same document.
When I cross-reference those lemmas and theorems somewhere in the manuscript, I don't remember if I named it a lemma or a theorem, but I perhaps remember the label name. When I just \ref{aaa}
, it only gives the number; so I have to put something like Lemma \ref{aaa}
or Theorem \ref{bbb}
. How can I print "Lemma 1" when it is a lemma, and "Theorem 2", when it is a theorem, without explicitly typing "Lemma" and "Theorem"?
Best Answer
hyperref
's\autoref
function does this for you. It's neat. I believe there's alsontheorem
's\thref
and thetheoremref
package. And finally, there is thecleveref
package.To get custom names with hyperref you need to add
\newcommand{\xxxautorefname}{Xxx}
, e.g.: