I am currently using the \autoref
command from the hyperref
package to refer to my theorems etc. However, I want to be able to (easily) refer to two or more theorems/lemmas/…, e.g. by calling something like \autoref{lemma1,lemma2,lemma5}
— where of course lemmas 1, 2 and 5 are labeled lemma1
, lemma2
and lemma5
respectively — so that the reference shows: "Lemmas 1, 2 and 5".
Can anyone help me with this? It doesn't seem to me like the hyperref
package provides this functionality.
Minimal example
\documentclass{memoir}
\usepackage{amsmath,amssymb}
\usepackage{mathtools}
\usepackage{cleveref}
\mathtoolsset{showonlyrefs,showmanualtags}
\begin{document}
This is the first equation
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
and this is the second equation
\begin{equation}
\label{test}
\alpha^2 + \beta^2 = \gamma^2
\end{equation}
Referring to second equation here: \eqref{test}.
\end{document}
Best Answer
EDIT added a way to set the plural names, which in effect gives foreign language support
I decided that I needed this feature of
\autoref
today and then I was surprised that I was unable to find it...so here is one way to define an\Autoref
command that will do it. Specifically,will expand into the plural of the first reference followed by hyperlinks for all of the references. Here's the sample output from the MWE below:
There are a few minor(?) limitations in that the macro assumes that:
all of the references are of the same "type" (so all lemmas, or all theorems etc)
doesn't handle the optional argument to
\autoref
or the*
-form (would be easy to fix...)it probably does not play well with equation references
by default the plural form is obtained simply by adding an
s
to the "singular" name (so it is English centric). This can be overridden by defining a plural version of the autorefname, for example\providecommand*{\lemmaautorefnameplural}{Lots of lemmas}
. A more realistic application would be to define plurals for other languages. The...autorefnameplural
form is optionalThe
\Autoref
macro behaves like\autoref
when it is given one reference.Anyway, here's the code:
If you uncomment the line
then the output is:
A more realistic use of this feature would be to add foreign language support.