Why does the hyperref documentation suggest using gather instead of equation?

It's all a bit lost in history, but when using hyperref many things that are labeled need to have some kind of whatsit to make a destination in the final pdf that you can jump to.

It is a perennial problem in TeX that these invisible nodes can affect spacing in some cases. In particular, they prevent one macro looking back and "seeing" the last added vertical space. You see similar issues with \color affecting spacing (often addressed by using \textcolor instead).

equation is a very thin wrapper around the TeX primitive $$ construct, and so there is very little provided control over where the vertical space is added above the equation in relation to any whatsit nodes that hyperref wants to inject.

Conversely the amsmath environments already grab the whole environment, measure widths and alignment points then build up the display to insert on the main page by tex macros, so hyperref has a lot more control about where it injects the hyperref nodes.

That said, the comment is old and may or may not mean there is actually a problem with the current hyperref code and equation.


I do not recommend this solution either, I happily use equation with hyperref

The only one I can come up with is this little strange one

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage[colorlinks]{hyperref}
%\let\equation\gather
%\let\endequation\endgather
\begin{document}

\begin{equation}
  test \nonumber
\end{equation}


\begin{gather}
  test 
\end{gather}
\end{document}

without changing equation you'll get this warning:

pdfTeX warning (ext4): destination with the same identifier (name{eq
uation.0.1}) has been already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                                  \fi \fi 
l.19 \end{document}

Which is a pain to debug if you do not know that the combination of equation + \nonumber is problematic under hyperref

If you know they are problematic, it is just a matter of finding them and removing \nonumber and replacing equation with equation*

I'd like to know if there are others reasons

Tags:

Hyperref