[Tex/LaTex] Custom Math Symbol – Two Sigma Sums

macrosmath-modesymbols

I'd like to be able to set a new math command/macro that is a Sigma shifted slightly (diagonal) on top of another Sigma, but am unsure how to go about it. I'd like it to behave just as a single Sigma in terms of limits being above and below in equations, and to the side when inline. If it's easier, I really only care for the equation behavior. A depiction of the symbol is the following:
\ssum

Best Answer

At its simplest, with a stack.

EDITED to preserve the math style of the \sums:

\documentclass{article}
\usepackage{stackengine,scalerel}
\newcommand\doublesum{\mathop{\ThisStyle{\ensurestackMath{%
  \stackengine{.3ex}{\SavedStyle\,\sum}{\SavedStyle\sum}{O}{l}{F}{F}{L}}}}}
\begin{document}
\centering
\[
  \doublesum_{ij}^{ND} x_{ij} = 0
\]
\(
  \doublesum_{ij}^{ND} x_{ij} = 0
\)
\end{document}

enter image description here

One can, of course, opt to place a comma or small gap between the respective indices and upper limits. Alternately, one can employ a more complex manipulation to vertically stagger the indices, which are now passed as four mandatory arguments:

\documentclass{article}
\usepackage{stackengine,scalerel,amsmath}
\newcommand\doublesum[4]{\ThisStyle{\ensurestackMath{\mathop{%
  {\stackengine{.3ex}{\SavedStyle\,\sum}{\SavedStyle\sum}{O}{l}{F}{F}{L}}}
    _{\stackengine{.3ex}{\SavedStyle_{\phantom{#1}#2}}{%
                         \SavedStyle_{#1}}{O}{l}{F}{F}{L}}
    ^{\stackengine{.3ex}{\SavedStyle_{#3}}{%
                         \SavedStyle_{\phantom{#3}#4}}{U}{l}{F}{F}{L}}}}}
\begin{document}
\centering
\[
  \doublesum{i}{j}{N}{D} x_{ij} = 0
\]
\(
  \doublesum{i}{j}{N}{D} x_{ij} = 0
\)
\end{document}

enter image description here

Related Question