I know how to use \label and \ref to get a reference to a result(or whatever else really) that I have made previously in the document. But this is tedious and requires me to create a label name every time.

What I am wondering, is if there is a more systematic/powerful way to accomplish this. I suppose there are many ways to skin a cat, so I will word the question like this;

How do you reference theorem-like environments in your LaTeX documents, and why do you do so in this way?

Since I am asking the question in a way that suggest multiple answers with some opinions, I am marking this CW and putting the Big-list tag. If this is wrong, feel free to change.

  • What is a "theorem style"?
    – TH.
    Aug 28, 2010 at 7:06
  • 2
    I think this question shouldn’t be big-list and cw. (but cw can’t be undone)
    – Caramdir
    Aug 28, 2010 at 9:24
  • 2
    So you want an autogenerated label or something? How would you know what to use? It seems like the best you could get is saving yourself typing \label for each theorem.
    – TH.
    Aug 28, 2010 at 12:35
  • 2
    Or is the question "How do you label your theorems?" i.e. What conventions are good for naming your labels?
    – Seamus
    Aug 28, 2010 at 13:56
  • 2
    It seems to me not to be the question, but in response to Seamus: I used to use the laconic style \label{thm:z_lemma} or some such, but then I realized you can use spaces in the label. Now I'll write \label{zorn's lemma} or even something crazy like \label{bounded chains imply maximal elements} (which, if I were Zorn, I probably would have used in the original paper). Then I can be sure (on checking) that I have referenced the right theorem.
    – Ryan Reich
    Aug 28, 2010 at 18:53

4 Answers 4


I solved this problem for myself a few years ago without knowing about the theoremref or ntheorem packages, but those in themselves do not do what you want anyway.

The problems that I had with the standard setup were the following:

  1. You have to give each theorem type a different environment, which has both a "begin" and "end" tag containing the name of the theorem. If you want to make a change, you have to change two words not near each other.

  2. You have to write \label every time.

  3. You have to remember the name of the theorem type whenever you use \ref. This is the problem which theoremref also solves, though I think they do it in a slightly different way than I did.

  4. The hyperlink produced by ref (when using hyperref) only encompasses the number and not the name ("Theorem 2", etc.), which is a small target but to change it is awkward.

I dealt with 1 and 2 by overwriting the theorem environment with one that has the syntax

\begin{theorem}{theorem type}{name of label} ... \end{theorem}

thus solving the locality problem for the theorem type and also allowing me to omit \label. For 3, I used the fncylab package to do the work that theoremref does (note that at the time, there was a bug in amsthm which makes this impossible without some work. It may be fixed now). This also takes care of 4, since now the word "Theorem" is part of the text produced by \ref, which is all wrapped in a hyperlink without my needing to do anything.

I like this solution very much. I write things like

\begin{theorem}{lem}{little lemma} This is a small lemma. \end{theorem}
It follows from \ref{little lemma} that we have
\begin{theorem*}{thm} The main result. \end{theorem*}

You can guess the effect of a theorem* environment, of course. You can see the .sty file on my website if you are interested.

Later: I just found out about the thmtools package. Man, that thing is awesome. I wish I had known about it. It does everything above (and more) and uses a keyval syntax for setting parameters, which is far better than having multiple arguments. Read p. 8 of its manual to see my hack done right. (It's not quite the same: it doesn't address point 1. However, I can imagine writing a wrapper environment taking a key "type" that would duplicate the above example.)

  • 1
    Thank you! This is PERFECT! Also I appreciate you explaining why you wanted this hack yourself, I was having difficulty expressing myself in my question, but you captured it perfectly. Thanks so much.
    – BBischof
    Aug 28, 2010 at 21:31
  • @RyanReich what was your solution?
    – juanuni
    Jun 10, 2017 at 3:20
  • Hello Ryan, I'm trying to find the source code for your overwritten theorem and theorem* environments; however, I'm having difficulty finding your website. Do you have a hyperlink or, if you have the time, could you post the code here?
    – user45054
    Mar 9, 2019 at 21:39

If you use ntheorem package, this allows you to use \thref to reference theorem environments in a smart way. So it will reference a theorem as "Theorem 1" and a lemma as "Lemma 2" automatically.

hyperref will also automatically do the same sort of thing with its \autoref command.


Check out the coolthms package (admitedly, I am one of its authors). We were facing similar problems, especially regarding labeling lists nested in theorem environments (cf this related question) and used ntheorem for the formating and cleveref for the references, allowing for a single (!) reference to have the form (e.g.) "Theorem 1 (a)". We're still looking for people to test it and give feedback :)

The idea is to create a new \Label command for a list nested in a "theorem-like" environment that includes the theorem name and number in its formating.

  • @downvoter: care to explain your reasoning?! Did you actually test the package and figure it was that bad? How about some constructive criticism then? I was faced with exactly the same problem some years ago and my solution was to write a package that fixed it for me and post it on CTAN. Why is it incorrect to mention that in answer to this question?
    – Jonathan
    Aug 3, 2013 at 8:10
  • up-voting you because I feel the down-vote here without an explanation was inappropriate. Jan 29, 2014 at 4:49

How would the auto-labelling work? If there were a way of generating, say, \label{thm1}, \label{thm2}, and so on, then you couldn't rearrange the theorems or insert new ones without the labels automatically changing. And if you're willing to forswear such edits, then you might as well write Theorem 1 in the source, and skip the \label business entirely.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .