# Why smashing a sum change an horizontal spacing?

I need to smash a sum because its indices take too much vertical space. But then, it also change the horizontal spacing before it, as shown with the following MWE :

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}

\begin{document}

Blablabla blabla bla bla:
$$x = \frac{1}{2} \sum_{n=1}^N x = \frac{1}{2} \smash{\sum_{n=1}^N x}.$$
Blablabla bla bla blabla blaaaa.

\end{document}


Here's a preview:*

How can I smash the sum without changing the horizontal spacings around it?

(* The small red cow in the picture is a signature to this very nice piece of primitive art. The picture is copyrighted and could be sold to MOMA!)

• Try \mathop{\smash{...}} – Phelype Oleinik Feb 13 at 18:49
• not really smash, just {\sum} will get different spacing to \sum – David Carlisle Feb 13 at 18:51
• @DavidCarlisle, using braces gives the same horizontal problem. – Cham Feb 13 at 18:54
• That is what @DavidCarlisle just said. The issue is not \smash...the issue is the braces. – Steven B. Segletes Feb 13 at 18:55

There are cases where a very high or deep object is better smashed; for instance, in an alignment where a formula ends with a summation and the next is much shorter, we can save vertical space by using \smash[b]{...} around the summation. Also your case can take advantage of smashing because of the short lines of text around the display.

However, one has to be aware that \smash (with or without the optional argument, for which one needs amsmath) always makes an ordinary atom. The nature of the object can be reinstated with the appropriate command, in this case \mathop.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\noindent
Blablabla bla bla blabla blaaaa.
$$x = \frac{1}{2} \mathop{\smash{\sum_{n=1}^N}} x.$$
Blablabla bla bla blabla blaaaa.
$$x = \frac{1}{2} \sum_{n=1}^N x.$$
Blablabla bla bla blabla blaaaa.

\end{document}


Note that the x should go outside \smash.

In this particular case you might decide to smash also the fraction and the input can be simplified:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\noindent
Blablabla bla bla blabla blaaaa.
$$x = \smash{\frac{1}{2} \sum_{n=1}^N x}.$$
Blablabla bla bla blabla blaaaa.
$$x = \frac{1}{2} \sum_{n=1}^N x.$$
Blablabla bla bla blabla blaaaa.

\end{document}


Be careful and do this refinements only when the document is in final-no-more-changes-to-the-text-I-mean-really-really-final state.

• What's the [b] option to \smash? Bottom smash only? And I guess that [t] would be top smash only? – Cham Feb 14 at 0:59
• @Cham well guessed, that's indeed the meaning of the optional argument. – Skillmon likes topanswers.xyz Feb 15 at 18:22
• @Cham Yes: the people at AMS noticed that it would be handy in some situations to only smash the top or the bottom, so these options where added: \smash[t] smashes the top (above the baseline) and \smash[b] smashes the bottom (below the baseline). By the way, how's the picture of yours that of a cow? Everybody can see it's a lynx! :-) – egreg Feb 15 at 18:25

How can I smash the \sum without changing the horizontal spacing around it?

To \smash the expression without affecting the spacing between \frac{1}{N} and \sum, insert an empty math atom -- {} -- as the first element of the argument of \smash. For instance,

    \bar{x} = \frac{1}{N}\smash{{}\sum_{n=1}^N x_i}


A full MWE:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern,microtype,mathtools,amssymb}

\begin{document}
\hrule
$\bar{x} = \frac{1}{N} \sum_{n=1}^N x_i %% without \smash$
\hrule

\medskip
\hrule
$\bar{x} = \frac{1}{N} \smash{{}\sum_{n=1}^N x_i}$
\hrule

\medskip
\hrule
$\bar{x} = \smash{\frac{1}{N} \sum_{n=1}^N x_i} %% too extreme, right?$
\hrule
\end{document}