
Estou tentando criar este símbolo:
Eu tentei usar isso:
\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}
Mas não faz da maneira certa, e também não tenho certeza de como colocar os delimitadores. Obrigado.
Responder1
Aqui está uma mistura de modo \ooalign
e picture
.
\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}
Possível melhoria, onde o overshoot é variável e o símbolo tem a mesma extensão vertical que \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}
Responder2
Tentar melhorar uma das respostas de egreg é um exercício que é, ao mesmo tempo, agradável e instrutivo – além disso, pode dar o direito de se gabar. (;-) Neste caso, considero que a solução aceite é subóptima em termos de eficiência, pelas duas razões seguintes:
Enquanto desenha,por exemplo, uma bruxa requer total flexibilidade do
picture
ambiente, essa flexibilidade não é necessária para traçar uma linha simples.A solução usa
\vphantom
inside\mathpalette
, que equivale a\mathchoice
nós de aninhamento, com cada uma das dezesseis combinações resultantes contendo umpicture
ambiente.
Em particular, isto significa que a \@barredsumbar
macro é executada 20 vezes para cada invocação do \barredsum
comando. Pessoas como eu, que testemunharam a era heróica em que o LaTeX demorava mais de meia hora para compilar uma tese, são particularmente sensíveis a esse argumento.
O código a seguir executa a \@rodriguez@overprint@bar
macro apenas quatro vezes para cada invocação de \barredsum
e depende apenas dos comandos de regras primitivas do TeX para desenhar a linha. Como um bônus adicional, ele também define o \barredprod
comando, produzindo uma versão barrada de \prod
: isso mostra como a construção pode ser generalizada.
% 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{amsmath} % the code below assumes this
\makeatletter
\newcommand*\barredsum{%
\DOTSB\mathop{%
\@rodriguez@mathpalette \@rodriguez@overprint@bar \sum
}\slimits@
}
\newcommand*\barredprod{%
\DOTSB\mathop{%
\@rodriguez@mathpalette \@rodriguez@overprint@bar \prod
}\slimits@
}
% A home-brewed version of "\mathpalette" that also supplies the font
% selector (e.g., "\textfont"):
\newcommand*\@rodriguez@mathpalette[2]{%
% #1 := macro doing the actual job, which expects as its own arguments
% - #1, a style selector (e.g., "\displaystyle")
% - #2, a font selector (e.g., "\textfont")
% - #3, a custom argument (not truly necessary, here!)
% #2 := custom argument that should be passed as #3 to macro #1
\mathchoice
{#1\displaystyle \textfont {#2}}%
{#1\textstyle \textfont {#2}}%
{#1\scriptstyle \scriptfont {#2}}%
{#1\scriptscriptstyle \scriptscriptfont {#2}}%
}
\newcommand*\@rodriguez@overprint@bar[3]{%
% #1 := style selector (e.g., "\displaystyle")
% #2 := font selector (e.g., "\textfont")
% #3 := base symbol
\sbox\z@{$#1#3$}%
\dimen@ = \ht\z@ \advance \dimen@ \p@
\dimen@ii = \dp\z@ \advance \dimen@ii \p@
\dimen4 = 1.25\fontdimen 8 #2\thr@@ \relax
\ooalign{% the resulting box has the same...
\@rodriguez@bar \dimen@ \z@ \cr % ... height as the first row
$\m@th #1#3$\cr
\@rodriguez@bar \z@ \dimen@ii \cr % ... depth as the last row
}%
}
\newcommand*\@rodriguez@bar[2]{%
\hidewidth \vrule \@width \dimen4 \@height #1\@depth #2\hidewidth
}
\makeatother
\begin{document}
In display:
\[
\barredsum_{i=1}^{N} x_{i} \neq \sum_{i=1}^{N} x_{i}
\]
In-line:
\begin{center}
\( \barredsum_{i=1}^{N} x_{i} \neq \sum_{i=1}^{N} x_{i} \),
\quad
\( A_{\barredsum_{i=1}^{N} x_{i}} \neq A_{\sum_{i=1}^{N} x_{i}} \),
\quad
\( A_{B^{\barredsum_{i=1}^{N} x_{i}}} \neq A_{B^{\sum_{i=1}^{N} x_{i}}} \).
\end{center}
The barred product:
\[
\barredprod_{i=1}^{N} x_{i} \neq \prod_{i=1}^{N} x_{i}
\]
Etc.\ etc.
\end{document}
É certo que esta solução carece das tampas redondas nas duas extremidades da barra vertical…
Editar: Eu pretendia incluir uma imagem mostrando a saída, mas claramente esqueci de fazer isso: agora estou corrigindo isso.