TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"?

share|improve this question
1  
I find RefTeX mightily useful, with some combination of keys it will bring a list of choices to choose from, and it will produce the \ref{aaa} automatically. Too bad not many other software provides this function. – Jiangwei Xue Mar 2 '12 at 6:54
    
I would advise you to name your labels using prefixes like \label{lem:lemma} or \label{theo:theorem} or similar. – basseur Nov 30 '13 at 11:47
up vote 17 down vote accepted

hyperref's \autoref function does this for you. It's neat. I believe there's also ntheorem's \thref and the theoremref package. And finally, there is the cleveref package.

share|improve this answer
    
\autoref doesn't work out of the box on custom defined theorems. theoremref doesn't seem to work on figures. – Turion Jul 22 at 9:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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