[Tex/LaTex] How to make customized $\sum$ operator

math-operatorssymbols

How can I create the following symbols?

\circlearrowleft or \circlearrowright centered in \sum operator.

enter image description here

EDITED:

So,

In \usepackage{esint} package, \ointclockwise and \ointctrclockwise; how to add closed \circlearrowleft or closed \circlearrowright? Will have we use tikz?

Are there like \clockwise and \ctrclockwise commands?

enter image description here

enter image description here

Best Answer

Here's a possibility. Only text and display style, I hope you don't need them in subscripts, superscripts or small fractions.

\documentclass{article}
\usepackage{amsmath,amssymb,graphicx}

\makeatletter
\newcommand*{\sumcirclearrowleft}{%
  \DOTSB
  \mathop{
    \mathchoice
      {\rlap{\kern.25em\rotatebox[origin=c]{-90}{$\circlearrowleft$}}{\sum}}
      {\vcenter{\rlap{\kern.2em\rotatebox[origin=c]{-90}{$\scriptscriptstyle\circlearrowleft$}}}{\sum}}
      {\sum}{\sum}
  }\slimits@
}

\newcommand*{\sumcirclearrowright}{%
  \DOTSB
  \mathop{
    \mathchoice
      {\rlap{\kern.25em\rotatebox[origin=c]{90}{$\circlearrowright$}}{\sum}}
      {\vcenter{\rlap{\kern.2em\rotatebox[origin=c]{90}{$\scriptscriptstyle\circlearrowright$}}}{\sum}}
      {\sum}{\sum}
  }\slimits@
}
\makeatother

\begin{document}

$\sumcirclearrowleft\displaystyle\sumcirclearrowleft$

$\sumcirclearrowright\displaystyle\sumcirclearrowright$

$\sumcirclearrowleft_{i=1}^n
\displaystyle\sumcirclearrowleft_{i=1}^n$

\end{document}

enter image description here

Alternative version with closed circles

I found a TikZ version (still working only in text and display style), with Qrrbrbirlbel's code in https://tex.stackexchange.com/a/95263/4427 (modified).

\documentclass{article}
\usepackage{amsmath,amssymb,tikz}
\usetikzlibrary{arrows.meta,bending}

\makeatletter
\tikzset{
    /qrr/circle arrow/.cd,
    start angle/.initial={},
    delta angle/.initial={},
    end angle/.initial={},
    arrows/.estore in=\qrr@ca@arrow,
    arrows=-
}
\pgfdeclareshape{circle arrow}{
    \inheritsavedanchors[from=circle] \inheritanchorborder[from=circle]
    \inheritanchor[from=circle]{north}      \inheritanchor[from=circle]{north west}
    \inheritanchor[from=circle]{north east} \inheritanchor[from=circle]{center}
    \inheritanchor[from=circle]{west}       \inheritanchor[from=circle]{east}
    \inheritanchor[from=circle]{mid}        \inheritanchor[from=circle]{mid west}
    \inheritanchor[from=circle]{mid east}   \inheritanchor[from=circle]{base}
    \inheritanchor[from=circle]{base west}  \inheritanchor[from=circle]{base east}
    \inheritanchor[from=circle]{south}      \inheritanchor[from=circle]{south west}
    \inheritanchor[from=circle]{south east}
    \backgroundpath{
        \pgfkeysgetvalue{/qrr/circle arrow/start angle}\qrr@ca@s
        \pgfkeysgetvalue{/qrr/circle arrow/end angle}\qrr@ca@e
        \pgfkeysgetvalue{/qrr/circle arrow/delta angle}\qrr@ca@d
        \ifx\qrr@ca@s\pgfutil@empty%
            \pgfmathsetmacro\qrr@ca@s{\qrr@ca@e-\qrr@ca@d}%
        \else
            \ifx\qrr@ca@e\pgfutil@empty%
                \pgfmathsetmacro\qrr@ca@e{\qrr@ca@s+\qrr@ca@d}%
            \fi%
        \fi
        \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfpointpolar{\qrr@ca@s}{\radius}}}%
        \pgfpatharc{\qrr@ca@s}{\qrr@ca@e}{\radius}%
        \pgfkeys{/tikz/arrows/.expand once=\qrr@ca@arrow}%
    }
}
\tikzset{% the first two styles are internal, they do not work alone!
    turn left/.style={
      /tikz/shape=circle arrow,
      /qrr/circle arrow/arrows={->[flex']},
      /qrr/circle arrow/delta angle=370
    },
    turn right/.style={
      /tikz/shape=circle arrow,
      /qrr/circle arrow/arrows={<[flex']-},
      /qrr/circle arrow/delta angle=370},
    turn left east/.style  = {/tikz/turn left,  /qrr/circle arrow/start angle=20},
    turn right west/.style = {/tikz/turn right, /qrr/circle arrow/start angle=160},
}

\newcommand*{\sumcirclearrowleft}{%
  \DOTSB
  \mathop{\mathpalette\sumcirclearrow@{left east}}
  \slimits@
}
\newcommand*{\sumcirclearrowright}{%
  \DOTSB
  \mathop{\mathpalette\sumcirclearrow@{right west}}
  \slimits@
}
\newcommand{\sumcirclearrow@}[2]{%
  \sbox\z@{$\m@th#1\sum$}%
  \dimen@=.14\wd\z@
  \makecirclearrow@{#2}
  {\sum}%
}

\newcommand{\makecirclearrow@}[1]{%
  \rlap{\kern\dimen@$\m@th\vcenter{\hbox{%
    \begin{tikzpicture}[
      >={Classical TikZ Rightarrow[width=2pt]},
    ]
    \node[draw,inner sep=\dimen@,turn #1] {};
    \end{tikzpicture}%
  }}$}%
}

\makeatother

\begin{document}

$\sumcirclearrowleft\displaystyle\sumcirclearrowleft$

$\sumcirclearrowright\displaystyle\sumcirclearrowright$

$\sumcirclearrowleft_{i=1}^n
\displaystyle\sumcirclearrowleft_{i=1}^n$

\end{document}

enter image description here

Related Question