Vertical spacing in mathtools

This is probably a `feature' of the problematic equation environment (see various posts on this site). It disappears in the following example.

\documentclass{minimal}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
\begin{document}
\begin{gather}
\label{eq}
a=b
\end{gather}
This is an equation %\refeq{eq}
\end{document}

The autonum package seems to be better at it:

\documentclass{article}
\usepackage{amsmath}
\usepackage{autonum}

\usepackage{lipsum} % for mock text

\begin{document}

\lipsum*[2]
\begin{equation}
\label{eq1}
a=b
\end{equation}
This is an equation \eqref{eq1}.
\lipsum*[2]
\begin{equation}
\label{eq2}
a=b
\end{equation}
\lipsum[2]

\end{document}

enter image description here