[Tex/LaTex] Math operator always in textstyle

math-operatorsspacing

I would like to define a macro that expands to the same symbol as \sum but using the inline style (\textstyle) even when used in a displayed environment.

Here's what I got:

\newcommand{\Alt}{\@ifstar{\sum}{{\textstyle\sum}}}

the starred version allows me to selectively enable displaystyle in exceptional situations. This is not a strong requirement however.

If I was not wrapping this in a macro I would have accomplished this by doing

bla {\textstyle \sum_a^b bla} bla

I am slightly uncomfortable with wrapping \sum in a group in the macro definition, only to limit the scope of \textstyle.

My question is: are there situations where spacing can be broken by the extra group around \sum?

Best Answer

Based on comment discussion, I had suggested something similar to the answer at How are big operators defined?, in the form of \DeclareMathOperator*{\barr}{\textstyle\sum}. However, that approach still places displaystyle limits above and below the summation (ex. 1). Nonetheless, we know that the spacing provided by \barr in textstyle (ex. 2) is the proper spacing the OP seeks.

I was able to recreate that spacing and sub/superscript placement in ex. 3-5, using different approaches. Ex. 3 tricks the result in displaystyle by using a \mathord instead of a \mathop, but of course, the pre- and post- spacing need adjustment to match the proper (ex. 2) spacing.

Ex. 4 and 5 are variations on the OP's proposed approach. In ex. 4, I add pre- and post- material inside his braces. However, depending on the nature of the material, this approach may not be available for use.

Ex. 5 is the OP's approach, except that thin spaces have been added, since the braces remove the ability of the sum's \mathopedness to extend its reach outside of the braces.

This in fact answer's the OP's question of "are there situations where spacing can be broken by the extra group around \sum?", because without the thin spaces in ex. 5, the spacing of the OP's approach will not be correct.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\barr}{\textstyle\sum}
\begin{document}
\centering
\verb|\barr| in \verb|\displaystyle|:
\[
A\barr_{i=3}^{6}B
\]

\verb|\barr| in \verb|\textstyle|:

\medskip inline: \(A A\barr_{i=3}^{6}B B\)

\verb|\mathord| with thin spaces added
\[
A A\,\mathord{\textstyle\sum}_{i=3}^6\, B B
\]

OP's original approach \textit{if} pre- and post- content embraced
\[
A {A \textstyle \sum_{i=3}^6 B} B
\]

OP's original approach, with no embraced pre- and post- content, but thin spaces added

\[
A A {\,\textstyle \sum_{i=3}^6\,} B B
\]
\end{document}

enter image description here

Related Question