[Tex/LaTex] How to create a summation symbol with a vertical bar

mathtoolssymbols

I am trying to create this symbol: enter image description here

I have tryed to use this:

\documentclass{article}
\usepackage{mathtools}

\makeatletter
\newcommand{\superimpose}[2]{%
  {\ooalign{$#1\@firstoftwo#2$\cr\hfil$#1\@secondoftwo#2$\hfil\cr}}}
\makeatother
\newcommand{\MyTry}{\mathpalette\superimpose{{\sum}{\vert}}}

\begin{document}
 $\MyTry$
\end{document}

But it doesn't do it the right way, and also i am not sure how to use put the delimeters. Thanks.

Best Answer

Here's a mixture of \ooalign and picture mode.

\documentclass{article}
\usepackage{amsmath,pict2e}

\makeatletter
\newcommand{\barredsum}{%
  \DOTSB\mathop{\mathpalette\@barredsum\relax}\slimits@
}
\newcommand{\@barredsum}[2]{%
  \begingroup
  \sbox\z@{$#1\sum$}%
  \setlength{\unitlength}{\dimexpr2pt+\ht\z@+\dp\z@\relax}%
  \@barredsumthickness{#1}%
  \vphantom{\@barredsumbar}%
  \ooalign{$\m@th#1\sum$\cr\hidewidth$#1\@barredsumbar$\hidewidth\cr}%
  \endgroup
}
\newcommand{\@barredsumbar}{%
  \vcenter{\hbox{\begin{picture}(0,1)\roundcap\Line(0,0)(0,1)\end{picture}}}%
}
\newcommand{\@barredsumthickness}[1]{% see https://tex.stackexchange.com/a/477200/
  \linethickness{%
    1.25\fontdimen8
      \ifx#1\displaystyle\textfont\else
      \ifx#1\textstyle\textfont\else
      \ifx#1\scriptstyle\scriptfont\else
      \scriptscriptfont\fi\fi\fi 3
  }%
}
\makeatother

\begin{document}

\[
\barredsum_{i=1}^N x_i
\]

\begin{center}
$\barredsum_{i=1}^N x_{\barredsum_{i=1}^N x_{\barredsum_{i=1}^N x_i}}$
\end{center}

\end{document}

enter image description here

Possible improvement, where the overshoot is variable and the symbol has the same vertical extent as \sum:

\documentclass{article}
\usepackage{amsmath,pict2e,picture}

\makeatletter
\newcommand{\barredsum}{%
  \DOTSB\mathop{\mathpalette\@barredsum\relax}\slimits@
}
\newcommand{\@barredsum}[2]{%
  \begingroup
  \sbox\z@{$#1\sum$}%
  \setlength{\unitlength}{%
    \dimexpr
      \ifx#1\displaystyle1\else3\fi\dimexpr\@barredsumthickness{#1}\relax+
      \ht\z@+\dp\z@
    \relax
  }%
  \linethickness{\@barredsumthickness{#1}}%
  \vphantom{\sum}%
  \smash{\ooalign{$\m@th#1\sum$\cr\hidewidth$#1\@barredsumbar$\hidewidth\cr}}%
  \endgroup
}
\newcommand{\@barredsumbar}{%
  \vcenter{\hbox{\begin{picture}(0,1)\roundcap\Line(0,0)(0,1)\end{picture}}}%
}
\newcommand{\@barredsumthickness}[1]{% see https://tex.stackexchange.com/a/477200/
  1.25\fontdimen8
    \ifx#1\displaystyle\textfont\else
    \ifx#1\textstyle\textfont\else
    \ifx#1\scriptstyle\scriptfont\else
    \scriptscriptfont\fi\fi\fi 3
}
\makeatother

\begin{document}

\[
\sum_{i=1}^N x_i \ne \barredsum_{i=1}^N x_i
\]

\begin{center}
$\barredsum_{i=1}^N x_{\barredsum_{i=1}^N x_{\barredsum_{i=1}^N x_i}}$
\end{center}

\end{document}

enter image description here