# Extra vertical space when using align and no numbering

I think I've found a small bug in the way the showonlyrefs=true option in mathtools works. Consider this semi-minimal example:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc} % UFT8 - danske bogstaver og andet godt fra havet
\usepackage[T1]{fontenc}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{mhchem}

\mathtoolsset{showonlyrefs=true} % ingen numerering af equations

\begin{document}
%
Seems fine
\begin{align*}
\Delta S &= \sum(S^{\ominus}(\text{produkter})) - \sum(S^{\ominus}    (\text{reaktanter})) \\
\Delta S &= (\SI{214}{\joule\per\kelvin\per\mole} + 2\cdot \SI{33}{\joule\per\kelvin\per\mole}) - (2\cdot \SI{27}{\joule\per\kelvin\per\mole} + \SI{6}{\joule\per\kelvin\per\mole}) \\
\Delta S &= \SI{247}{\joule\per\kelvin\per\mole}
\end{align*}
%
Not so fine
\begin{align}
\Delta S &= \sum(S^{\ominus}(\text{produkter})) - \sum(S^{\ominus}(\text{reaktanter})) \\
\Delta S &= (\SI{214}{\joule\per\kelvin\per\mole} + 2\cdot \SI{33}{\joule\per\kelvin\per\mole}) - (2\cdot \SI{27}{\joule\per\kelvin\per\mole} + \SI{6}{\joule\per\kelvin\per\mole}) \\
\Delta S &= \SI{247}{\joule\per\kelvin\per\mole}
\end{align}
\end{document}


Which gives the following:

In the first set of equations, I've removed the numbering with the * sign, while in the second set I have not. However, I have the showonlyrefs=true option set in mathtools package, which usually removes all numbering of equations, unless it's being refered to. I would guess, that the long equations move the number to the next line, but somehow mathtools can't remove that space.

Is this a bug or am I missing something here? I rather like the way I can remove numbering when it's not needed, so I'd rather not go back to manually managing which equations I'd like to be numbered.

• It's a problem with the length of the second equation: it's almost \textwidth, as you can check with the showframe option of geometry. If you set, say, hmargin=3cm, it's OK. Sep 25 '14 at 18:54
• i haven't run this through latex, but given the width of the second line, i think that your conclusion that a number for that line would require a line of its own is sound. i'd send the example to the mathtools maintainer, lars madsen. Sep 25 '14 at 18:57
• @Bernard Exactly, but the option given to mathtools should, in my opinion, work as \begin{align*}, aka remove the line where the number "should" be.
– Argo
Sep 25 '14 at 18:59
• @ Argo: I agree with you, I was just suggesting a workaround. Such cases must be relatively rare. Sep 25 '14 at 19:08
• I haven't seen that "feature" before. Something this wide really should be rewritten for readability. Mathtools take over the rendering of the eqn number. But not the measuring. Thus it fails. Sep 25 '14 at 20:47

The autonum package seems not to suffer from the problem:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc} % UFT8 - danske bogstaver og andet godt fra havet
\usepackage[T1]{fontenc}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage[version=3]{mhchem}
\usepackage{autonum}

\begin{document}
%
Seems fine
\begin{align}
\Delta S &= \sum(S^{\ominus}(\text{produkter})) - \sum(S^{\ominus}    (\text{reaktanter})) \\
\Delta S &= (\SI{214}{\joule\per\kelvin\per\mole} + 2\cdot \SI{33}{\joule\per\kelvin\per\mole}) - (2\cdot \SI{27}{\joule\per\kelvin\per\mole} + \SI{6}{\joule\per\kelvin\per\mole}) \\
\Delta S &= \SI{247}{\joule\per\kelvin\per\mole}
\end{align}
%
Not so fine
\begin{align}
\Delta S &= \sum(S^{\ominus}(\text{produkter})) - \sum(S^{\ominus}(\text{reaktanter})) \\
\Delta S &= (\SI{214}{\joule\per\kelvin\per\mole} + 2\cdot \SI{33}{\joule\per\kelvin\per\mole}) - (2\cdot \SI{27}{\joule\per\kelvin\per\mole} + \SI{6}{\joule\per\kelvin\per\mole}) \\
\Delta S &= \SI{247}{\joule\per\kelvin\per\mole}
\end{align}
\end{document}


Note that with the autonum package you should not use the *-variant of environments, just adding no \label` is sufficient.