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,

\theoremstyle{plain} \newtheorem{dummy}{***}[section] \newtheorem{thm}[dummy]{Theorem} \newtheorem{prop}[dummy]{Proposition} \newtheorem{cor}[dummy]{Corollary}

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:

\newtheorem{dummy}{***} % add [section] for numbering within sections \newcommand{\mynewtheorem}[2]{ \newaliascnt{#1}{dummy} \newtheorem{#1}[#1]{#2} \aliascntresetthe{#1} % maybe we will squish some autoref defaults, but who cares? \expandafter\def\csname #1autorefname\endcsname{#2} }

Now you can declare new theorem environments with `\mynewtheorem`

instead of `\newtheorem`

:

\theoremstyle{plain} \mynewtheorem{thm}{Theorem} \mynewtheorem{cor}{Corollary} \theoremstyle{definition} \mynewtheorem{defn}{Definition}

So here is a complete example.

\documentclass[a4paper]{article} \usepackage{amsthm,aliascnt,hyperref} % Declare theorem-style environments with \mynewtheorem to maintain just one % counter for numbering, and make them work with \autoref. \newtheorem{dummy}{***} % add [section] for numbering within sections \newcommand{\mynewtheorem}[2]{ \newaliascnt{#1}{dummy} \newtheorem{#1}[#1]{#2} \aliascntresetthe{#1} % maybe we will squish some autoref defaults, but who cares? \expandafter\def\csname #1autorefname\endcsname{#2} } \theoremstyle{plain} \mynewtheorem{thm}{Theorem} \mynewtheorem{prop}{Proposition} \mynewtheorem{cor}{Corollary} \mynewtheorem{lem}{Lemma} \theoremstyle{definition} \mynewtheorem{defn}{Definition} \mynewtheorem{expl}{Example} \theoremstyle{remark} \mynewtheorem{rem}{Remark} \begin{document} We will use \autoref{a} to prove \autoref{b}. \begin{lem}\label{a} Nobody knows. \end{lem} \begin{thm}\label{b} Nobody is right. \end{thm} \end{document}

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.