##### Child pages
• One-counter theorems with autoref
Go to start of banner

# One-counter theorems with autoref

I like to have my theorems, lemmas, definitions and so on numbered with the same counter. This is easy to do with amsthm - you just declare, say,

and so on, and amsthm will do its magic.

On the other hand, I also like the macro \autoref provided by the package hyperref – this lets you write, say \autoref{sec:symm} or \autoref{Fermat's last} and get out "section 2" or "Theorem 3.6" (appropriately hyperlinked), if the first label was a section and the second label a theorem. However, if you try to use this with the above one-counter theorems, you'll get an error, because autoref doesn't understand how differently named environments can share one counter. My solution is as follows. It requires the aliascnt package, and works by defining extra counters aliased to the dummy counter. Create a new command for declaring theorems:

Now you can declare new theorem environments with \mynewtheorem instead of \newtheorem:

So here is a complete example.

The example is too complex for the wiki to typeset, but it will produce "We will use Lemma 1 to prove Theorem 2." and then print the lemma and theorem.

This is based on the hyperref manual.

• No labels