# Aligning marginal notes with center of line rather than baseline

I would like to have all references in my document (to equations, figures, lemmas, random locations in text, etc.) be numbered in the same series, and I would like these numbers to appear in the margin. See here for examples: p. 30 (equation and paragraph labels), p. 31 (theorem label and figure label), p. 26 (\item label).

I've managed to cobble together macros which do most of what I want, but two problems remain:

• The marginal label aligns according to the baseline, but for displayed equations I would like it to be more centered (see p. 4 of above document).

• I can't get labels for figures into the margin.

Is there a package which does something like this?

Is there a way for TeX to know the height of the current displayed equation, so that I can adjust the vertical position of the marginal note accordingly?