# \sfrac breaks vertical spacing in multlined enviroment

I have found that including a \sfrac from the package xfrac into a multlined environment from mathtools completely breaks the vertical spacing of the multlined. Actually, this affect the spacing between the first and second line, for all the multlined blocks in a gather.

This is particularly bad since it result in a negative spacing with overlapping text.

\documentclass{article}
\usepackage{mathtools}
\usepackage{xfrac}

\begin{document}
\texttt{multlined} (two copies inside \texttt{gather}) works fine
\begin{gather}
\begin{multlined}
\sin(x) = \sum_i \frac{(-1)^i x^{2i+1}}{(2i+1)!} \\
= x - \frac{x^3}{6} + \frac{x^5}{120} - \frac{x^7}{5040} \\
= x - \frac{x^3}{6} + \frac{x^5}{120} - \frac{x^7}{5040}
\end{multlined} \\
\begin{multlined}
\cos(x) = \sum_i \frac{(-1)^i x^{2i}}{(2i)!}  \\
= 1 - \frac{x^2}{2} + \frac{x^4}{24} - \frac{x^6}{720} \\
= 1 - \frac{x^2}{2} + \frac{x^4}{24} - \frac{x^6}{720}
\end{multlined}
\end{gather}
but with even a single \texttt{\textbackslash sfrac} breaks the spacing
\begin{gather}
\begin{multlined}
\sin(x) = \sum_i \frac{(-1)^i x^{2i+1}}{(2i+1)!} \\
= x - \frac{x^3}{6} + \frac{x^5}{120} - \frac{x^7}{5040} \\
= x - \frac{x^3}{6} + \sfrac{x^5}{120} - \frac{x^7}{5040}
\end{multlined} \\
\begin{multlined}
\cos(x) = \sum_i \frac{(-1)^i x^{2i}}{(2i)!}  \\
= 1 - \frac{x^2}{2} + \frac{x^4}{24} - \frac{x^6}{720} \\
= 1 - \frac{x^2}{2} + \frac{x^4}{24} - \frac{x^6}{720}
\end{multlined}
\end{gather}
\end{document}


This happens only with multlined. Nothing strange happens if I use split inside gather or a multline.

• It might be related to the \substack error, but I see no difference in the lengths being used. Also the \substack problem was due to \math@cr@@ and \sfrac does not seem to be messing with that (AFAICS) – daleif Nov 30 '16 at 15:29
• @daleif You are right, my question has to do with vertical spacings, differently from the \substack error. – Marco Jan 31 '17 at 16:44
• no idea why this happens – daleif Jan 31 '17 at 16:53
• In any case, I'm not a fan of multine or multlined, and prefer align, for example combined with \MoveEqLeft, I feel that gives a more consistent look than this moving left and right of the first and last line and the rest centered – daleif Jan 31 '17 at 17:07
• It is very strange that it affects both multlined. If you copy the last gather and paste it after the current one, and remove the \sfrac, the problem does not bleed into the extra gather. I – daleif Feb 1 '17 at 8:39

Not so much a fix as a workaround...put in in its own box prior to entering gather.

\documentclass{article}
\usepackage{mathtools}
\usepackage{xfrac}
\newsavebox\mybox
\begin{document}
\sbox\mybox{$\displaystyle\sfrac{x^5}{120}$}
\begin{gather}
\begin{multlined}
\sin(x) = \sum_i \frac{(-1)^i x^{2i+1}}{(2i+1)!} \\
= x - \frac{x^3}{6} + \frac{x^5}{120} - \frac{x^7}{5040} \\
= x - \frac{x^3}{6} + \usebox{\mybox} - \frac{x^7}{5040}
\end{multlined} \\
\begin{multlined}
\cos(x) = \sum_i \frac{(-1)^i x^{2i}}{(2i)!}  \\
= 1 - \frac{x^2}{2} + \frac{x^4}{24} - \frac{x^6}{720} \\
= 1 - \frac{x^2}{2} + \frac{x^4}{24} - \frac{x^6}{720}
\end{multlined}
\end{gather}
\end{document}