# Is subequations known to introduce vertical white space? [duplicate]

In this MWE, there is additional white space between the line of text and the following subequations environment. It disappears when I unload hyperref, when I remove the wrapping subequations environment, when I shorten the line of text, or when I append % to the line of text.

\documentclass{IEEEtran}
\usepackage{amsmath,hyperref}
\begin{document}
mmmmmmmmmmmmmmmi
mmmmmmmmmmmmmmmi
\begin{subequations}
$$X$$
\end{subequations}
\end{document}

But why does it appear in the first place, and can this be fixed?

Place \begin{subequations} before starting the paragraph, which is the position it should go to begin with.

\documentclass{IEEEtran}
\usepackage{amsmath,hyperref}
\begin{document}

mmmmmmmmmmmmmmmi
mmmmmmmmmmmmmmmi
\begin{subequations}
$$X$$
\end{subequations}

\begin{subequations}
mmmmmmmmmmmmmmmi
mmmmmmmmmmmmmmmi
$$X$$
\end{subequations}

mmmmmmmmmmmmmmmi
mmmmmmmmmmmmmmmi
$$X$$

\end{document}

• This looks like a good fix. Do you happen to have some documentation that explains that this is "the position it should go to begin with"? Because in the only official example that I can find, it is not in that position: ftp.fu-berlin.de/tex/CTAN/macros/latex/required/amslatex/math/… – bers Feb 7 '17 at 17:53
• @bers Well, it ought to work even in that position, but hyperref adds some hooks that make the break between the “paragraph-so-far” and the equation into something different as usual. It's my opinion that subequation should encompass full paragraphs anyway. – egreg Feb 7 '17 at 18:07

Thanks to @pluton's comment, referring me to fleqn document class option, long text lines, and hyperref package, I found @Faekynn's comment referring me futher to Too much space between full paragraph and subequations env and the accepted answer there. So this one also solves my problem without messing with the order of environments:

\documentclass{IEEEtran}
\usepackage{amsmath,hyperref}

\usepackage{etoolbox}
\preto\subequations{\ifhmode\unskip\fi}

\begin{document}
mmmmmmmmmmmmmmmi
mmmmmmmmmmmmmmmi
\begin{subequations}
$$X$$
\end{subequations}
\end{document}