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.
Best Answer
I solved this problem for myself a few years ago without knowing about the
theoremref
orntheorem
packages, but those in themselves do not do what you want anyway.The problems that I had with the standard setup were the following:
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.
You have to write
\label
every time.You have to remember the name of the theorem type whenever you use
\ref
. This is the problem whichtheoremref
also solves, though I think they do it in a slightly different way than I did.The hyperlink produced by
ref
(when usinghyperref
) 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 syntaxthus solving the locality problem for the theorem type and also allowing me to omit
\label
. For 3, I used thefncylab
package to do the work thattheoremref
does (note that at the time, there was a bug inamsthm
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
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.)