# Hyperref, amsmath, and horizontal spacing at start of a numbered equation

When amsmath is loaded before hyperref (which I thought was the preferred order), spacing within the equation environment is altered:

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
$$-x = -x$$
\end{document}


gives , where the first minus sign seems to be taken as a binary operator, rather than a unary sign. When hyperref is loaded before amsmath, the spacing is identical on both sides of the equation. What is going on? Is the fix simply to load the packages in the opposite order?

(In fact, I set \pagestyle{empty}\hsize=70pt to get the number close enough to get a good-loooking cropped output.)

• This is most likely due to hyperref inserting an anchor, which is seen as an operand to -. Loading amsmath after hyperref removes this insertion. A simple fix would just be to force the first element to be a unary operator {-}. – Werner Aug 3 '13 at 6:07

Package hyperref sets an anchor at the start of the math display and raises the anchor position using \Hy@raisedlink (default: \baselineskip). Raising is done via boxes in TeX and that causes the trouble with the minus sign.
$${-}x = -x$$

• It seems, from a table in TeX by Topics which I may be misreading, that TeX never puts any space after an Open noad. Also, there is no space between an Ord and an Open. Could the problem be fixed by adding \mathopen{} just after the anchor in the hyperref code? – Bruno Le Floch Aug 3 '13 at 6:41