6

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}
\begin{equation}
  -x = -x
\end{equation}
\end{document}

gives an equation with wrong spacing, 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
6

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.

Workaround:

\begin{equation}
  {-}x = -x
\end{equation}
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.