I'd like to put a list of pages, hyperlinked to the position of the \eqref or \cref that point to it in the margin of each \labeled equation, like backref does for bibliographies and \cite.

Both this answer for \ref and this one for a figure list don't support hyperref links, deduplication and ranges like backref. (Edit: see below and first comment, turns out to not be that hard).

Edit: so my main problem is displaying text in the margin next to an equation's tag.

Edit 2: posted my current solution as an answer

Edit 3: It doesn't work with cleveref because that patches \label{X} in a way that \df@label now contains {X} instead of just X as before which breaks \refsto. No idea how that happens, or how I could remove the {}. Edit 4: actually it's when amsmath is loaded before cleverref. But it must be loaded before, because \cref can't be used to refer to equations otherwise.

Edit 5: found a way to remove {} if present, is there a builtin command for this?

\def\maybeWithBraces{foo} % this
\def\maybeWithBraces{{foo}} % or this
% \withoutBraces→foo in both cases.
  • Something like this: tex.stackexchange.com/questions/14981/… May 25, 2013 at 7:58
  • Ah yes, turns out getting the backreferences isn't the main problem but putting them next to the equation. Didn't expect that when writing the question, I'll edit it
    – pascal
    May 26, 2013 at 14:01

1 Answer 1


Found I had to patch \make@display@tag, before calling, the current label is in \df@label, it's written out and reset there. By storing the label, calling the original and using the label with my \refsto I can put backreferences in the margin.

There's no support for ranges like “see p. 2—4” though.

\ProvidesPackage{eqbackref}[2013/05/26 v0.1 Backreferences for equations]

% dump both reference ends

% patch amsmath's eqref

% make a list of refering pages

\newcommand{\refsto@prefix}{see p. }
\newcommand{\refsto@delim}{, }
% print list of refering pages

% patch tag display, show refsto in margin.
% sometimes \df@label expands to `{name}` instead of `name`
    \ifdefempty{\df@label}{% can happen with package `autonum`.
    }{% not empty, show refs
        \edef\orig@label{\expandafter\@@removebrace\df@label}% save label
        \ams@make@display@tag% resets label
        \rlap{\mbox{\refsto@marginstyle\refsto\orig@label}}% show

Example use:

\usepackage{hyperref} % optional
\usepackage{amsmath} % load before cleveref    
\usepackage{cleveref} % optional
\ussepackage{autonum} % optional
    E_1 \label{eA} \\
    E_2 \label{eB} \\
    E_3 \label{eC}
\newpage\section{page two}\eqref{eA}
\newpage\section{page three}\eqref{eA}\eqref{eB}\eqref{eB}
\newpage\section{page four}\eqref{eA}


backrefs in margin

  • This only works for equations defined in align environments but not in equation environments.
    – Paul Wintz
    Aug 2 at 0:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .