I would like to: (a) have no equation numbers for non-referenced equations; (b) have hyperlinks on equations and other constructs (lemmas/theorems/etc.); (c) use autoref so that the string for the relevant reference (equation, lemma, etc.) is automatically added. the code below doesn't work, no "Equation 1/2" appears.
\documentclass[10pt]{article} % For LaTeX2e\usepackage{hyperref}\usepackage{mathtools}\mathtoolsset{showonlyrefs,showmanualtags}\makeatletter\newcommand\Autoref[1]{\@first@ref#1,@}\def\@throw@dot#1.#2@{#1}% discard everything after the dot\def\@set@refname#1{% % set \@refname to autoefname+s using \getrefbykeydefault \edef\@tmp{\getrefbykeydefault{#1}{anchor}{}}% \xdef\@tmp{\expandafter\@throw@dot\@tmp.@}% \ltx@IfUndefined{\@tmp autorefnameplural}% {\def\@refname{\@nameuse{\@tmp autorefname}}}% {\def\@refname{\@nameuse{\@tmp autorefnameplural}}}%}\def\@first@ref#1,#2{% \ifx#2@\autoref{#1}\let\@nextref\@gobble% only one ref, revert to normal \autoref \else% \@set@refname{#1}% set \@refname to autoref name \@refname~\ref{#1}% add autoefname and first reference \let\@nextref\@next@ref% push processing to \@next@ref \fi% \@nextref#2%}\def\@next@ref#1,#2{% \ifx#2@ and~\ref{#1}\let\@nextref\@gobble% at end: print and+\ref and stop \else, \ref{#1}% print ,+\ref and continue \fi% \@nextref#2%}\makeatother\providecommand*{\equationautorefname}{Equation}\begin{document}\begin{equation}referenced \label{eq:1}\end{equation}\begin{align}referenced too \label{eq:2}\end{align}\begin{equation}unreferenced\end{equation}Consider \autoref{eq:1} and \autoref{eq:2}. It is referenced.\end{document}EDIT: I read that the package autonum might help with, but the following doesn't work either (all I want is hyperlinked equations that are only labeled with numbers when they are referenced to):
\documentclass[10pt]{article} % For LaTeX2e\usepackage{amsmath}\usepackage{autonum}\usepackage{hyperref}\usepackage{cleveref}\makeatletter\newcommand\Autoref[1]{\@first@ref#1,@}\def\@throw@dot#1.#2@{#1}% discard everything after the dot\def\@set@refname#1{% % set \@refname to autoefname+s using \getrefbykeydefault \edef\@tmp{\getrefbykeydefault{#1}{anchor}{}}% \xdef\@tmp{\expandafter\@throw@dot\@tmp.@}% \ltx@IfUndefined{\@tmp autorefnameplural}% {\def\@refname{\@nameuse{\@tmp autorefname}}}% {\def\@refname{\@nameuse{\@tmp autorefnameplural}}}%}\def\@first@ref#1,#2{% \ifx#2@\autoref{#1}\let\@nextref\@gobble% only one ref, revert to normal \autoref \else% \@set@refname{#1}% set \@refname to autoref name \@refname~\ref{#1}% add autoefname and first reference \let\@nextref\@next@ref% push processing to \@next@ref \fi% \@nextref#2%}\def\@next@ref#1,#2{% \ifx#2@ and~\ref{#1}\let\@nextref\@gobble% at end: print and+\ref and stop \else, \ref{#1}% print ,+\ref and continue \fi% \@nextref#2%}\makeatother\providecommand*{\equationautorefname}{Equation}\begin{document}\begin{equation}referenced \label{eq:a}\end{equation}\begin{align}referenced too \label{eq:b}\end{align}\begin{equation}unreferenced \end{equation}Consider \autoref{eq:a} and \autoref{eq:b}. It is referenced.\ref{eq:a}\eqref{eq:a}\ref{eq:b}\eqref{eq:b}\ref{eq:a}\end{document}