22

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

| 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
18

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.

To get custom names with hyperref you need to add \newcommand{\xxxautorefname}{Xxx}, e.g.:

\newcommand{\definitionautorefname}{Definition}
\newcommand{\lemmaautorefname}{Lemma}
\newcommand{\remarkautorefname}{Remark}
\newcommand{\propositionautorefname}{Proposition}
\newcommand{\exampleautorefname}{Example}
| improve this answer | | | | |
  • 3
    \autoref doesn't work out of the box on custom defined theorems. theoremref doesn't seem to work on figures. – Turion Jul 22 '16 at 9:56

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.
https://tex.stackexchange.com/questions/33226/how-to-cross-reference-theorems-with-theorem
tex.stackexchange.com
crawl=CC-MAIN-2020-24
146593
application/http; msgtype=response
sha1:S6MZ37KFDQUUMZUROE4ZV3CPXPYW6RFT
<urn:uuid:c47c893c-ae51-45d2-bbf3-b6b60726f829>
2020-05-26T00:04:04Z
151.101.1.69
text/html
sha1:INB7I7YRLKEC336F4MVQQ6QS5KIF7JF2
<urn:uuid:d66c0a82-ff11-4c7c-9fea-665cd01f9465>
https://tex.stackexchange.com/questions/33226/how-to-cross-reference-theorems-with-theorem
response
<urn:uuid:f5b16cbb-5c62-4a86-aa7d-c4e88ab967cc>
isPartOf: CC-MAIN-2020-24
publisher: Common Crawl
description: Wide crawl of the web for May/June 2020
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-88.ec2.internal
software: Apache Nutch 1.16 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.1-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/