As already said in the comments, this problem is the main subject of Exercise 18.44 of The TeXbook. Barbara Beeton has already suggested a variation of one of the two solutions that Knuth presents in Appendix A, although her code should be modified to read, more or less,
\DeclareRobustCommand*{\sump}{%
\mathop{{\sum}^{\mathrlap{\prime}}}%
}
Here’s a complete, compilable example, that also draws attention to a possible flaw of this solution:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{mathtools}
\newcommand*{\sump}{} % check that the name can be used
\DeclareRobustCommand*{\sump}{%
\mathop{{\sum}^{\mathrlap{\prime}}}%
}
\begin{document}
First in-line:
\( \sump_{i\in I}a_{i} \ne \sum_{i\in I}a_{i} \).
Then in display:
\[
\sump_{i\in I}a_{i} \ne \sum_{i\in I}a_{i}
\mbox{.}
\]
You can also say, for instance,
\( \sump\limits_{i\in I}a_{i} \ne \sum\limits_{i\in I}a_{i} \)
and
\[
\sump\nolimits_{i\in I}a_{i} \ne \sum\nolimits_{i\in I}a_{i}
\mbox{,}
\]
respectively.
There's a caveat, though: because the prime is not taken into account
when computing the width of the \verb|\sump| symbol, it may bump into
adjacent characters:
\[
\sump \biggl[\frac{a+b}{c+d}-\frac{x+y}{x-y}\biggr]
\ne \sum \biggl[\frac{a+b}{c+d}-\frac{x+y}{x-y}\biggr]
\]
The clash is more problematic in in-line math:
\( \sump[a+b] \ne \sum[a+b] \).
However, in practice this is not going to be a problem if you stick to
using the \verb|\sump| symbol only with a (non-empty) subscript.
\end{document}
However, if we have to load the mathtools
package, which, in turn, requires amsmath
, I think we should also support the [no
]sumlimits
option of the latter, as well as its \dots
feature:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
% Try decommenting the following line:
% \usepackage[nosumlimits]{amsmath}
\usepackage{mathtools}
\makeatletter
% Cannot directly use "\DeclareRobustCommand" with "\DOTSB":
\@ifdefinable\sump@{\DeclareRobustCommand*\sump@{%
\mathop{{\sum}^{\mathrlap{\prime}}}%
}}
\newcommand*\sump{%
\DOTSB\sump@\slimits@ % ...or move "\slimits@" into "\sump@"
}
\makeatother
\begin{document}
First in-line:
\( \sump_{i\in I}a_{i} \ne \sum_{i\in I}a_{i} \).
Then in display:
\begin{equation}
\sump_{i\in I}a_{i} \ne \sum_{i\in I}a_{i}
\mbox{.}
\label{eq:displaylimits}
\end{equation}
You can also say, for instance,
\( \sump\limits_{i\in I}a_{i} \ne \sum\limits_{i\in I}a_{i} \)
and
\[
\sump\nolimits_{i\in I}a_{i} \ne \sum\nolimits_{i\in I}a_{i}
\mbox{,}
\]
respectively. And see what happens in the ``default'' case (that is,
in~\eqref{eq:displaylimits}) if you load the \textsf{amsmath} package
with the \texttt{nosumlimits} option.
Finally, note that
\( \sump_{i_{1}}\dots\sump_{i_{p}} x_{i_{1}}\otimes\dots\otimes x_{i_{p}} \)
works exactly in the same way as
\( \sum_{i_{1}}\dots\sum_{i_{p}} x_{i_{1}}\otimes\dots\otimes x_{i_{p}} \)
(as one would expect). Let's repeat it in display:
\[
\sump_{i_{1}}\dots\sump_{i_{p}} x_{i_{1}}\otimes\dots\otimes x_{i_{p}}
\ne
\sum_{i_{1}}\dots\sum_{i_{p}} x_{i_{1}}\otimes\dots\otimes x_{i_{p}}
\]
(this way the formula is more readable!).
\typeout{A test for robustness: \sump}
\typeout{Compare the above with \sum}
\end{document}
Note that the above code (the second MWE) writes a couple of messages during the compilation, which exemplify how the \sump
command is written out to auxiliary files, and shows that its behavior in this respect parallels that of \sum
.
\DeclareMathOperator*{\sump}{\Sigma^{\prime}}
for a more math-like prime.\DeclareMathOperator*{\sump}{{\sum}'}
, is slightly defective (why? ;-) ; the second, more sophisticated, is too complex to be repeated in a comment. See the solution of the exercise in The TeXbook.\mathrlap
, Requiresmathtools
.\mathop{{\sum}^{\mathrlap{\prime}}}
.