# Contractions using {simplewick}

Hi I need the syntax for a wick contraction under a number that goes to infinity. Essentially the sum going over all contractions. The right side of the contraction doesn't have an end essentially. Does anyone know how to do that? The last equation on the photo is what I need to be able to write.

• Welcome to TeX.se. Instead of posting an image of what you want, please show us how far you've got by editing your question to include a minimal compilable document showing the equation in question and the specific problem you're having. For example, your title suggests that you are using a specific package for the Wick contractions. – Alan Munn Aug 8 at 14:43

simpler-wick it is arguably easier to hack.

\documentclass{article}
\usepackage{simpler-wick}
\newif\ifWickCut
\WickCutfalse
\pgfkeys{
/simplerwick/.cd,
cut/.code={\WickCuttrue},
no cut/.code={\WickCutfalse},
cut ratio/.initial=0.5
}

\makeatletter
\def\swick@end#1#2{
\swick@setfalse@#1
\tikzexternaldisable
\begin{tikzpicture}[remember picture, baseline=(swick-close#1.base)]
\node[use as bounding box, inner sep=0pt, outer sep=0pt] (swick-close#1) {$\displaystyle #2$};
\end{tikzpicture}
\tikz[remember picture, overlay]
{\ifWickCut
\draw ($(swick-open#1.south) + (0, -1pt)$)
-- ($(swick-open#1.base) + (0,3pt -1*\swick@offset) + #1*(0, -1*\swick@sep)$)
-- ($($(swick-open#1.base)!\pgfkeysvalueof{/simplerwick/cut ratio}!(swick-close#1.base)$) + (0,3pt -1*\swick@offset) + #1*(0, -1*\swick@sep)$)
\else
\draw ($(swick-open#1.south) + (0, -1pt)$)
-- ($(swick-open#1.base) + (0,3pt -1*\swick@offset) + #1*(0, -1*\swick@sep)$)
-- ($(swick-close#1.base) + (0,3pt -1*\swick@offset) + #1*(0, -1*\swick@sep)$)
-- ($(swick-close#1.south) + (0,-1pt)$);
\fi}
\tikzexternalenable}
\makeatother
\begin{document}
$$\wick{\c1 \phi \c2 \psi A \c2 \psi \c1 \phi}$$
$$\wick[cut]{\c1 \phi \c2 \psi A \c2 \psi \c1 \phi}$$
$$\wick[cut,cut ratio=0.7]{\c1 \phi \c2 \psi A \c2 \psi \c1 \phi}$$
\end{document}


• Hey, are you retiring or pretending to? :) – Alan Munn Aug 8 at 21:34
• @AlanMunn My profile says This account is scheduled to be deleted Aug 3 at 18:34. They carefully avoid specifying the year.... ;-) – user121799 Aug 8 at 21:36
• One downside of this is that you can't mix cut and non-cut contractions in the same \wick. – Alan Munn Aug 8 at 21:57
• @AlanMunn In this version this is certainly true but of course it is easy to change that. What I did here was to "cook down" the code from here. – user121799 Aug 8 at 22:00

The simplewick package is indeed quite simple, so it's not difficult to produce new commands from its code to do what you want. Here are open on the right contractions \arcontraction and \brcontraction. If you also need open on the left contractions, then you can do analogous commands commenting out the left vertical bar. The syntax of simplewick is somewhat cumbersome, so I would be more inclined to adapt the method described here if I were to implement this functionality myself.

\documentclass{article}

\usepackage{simplewick}
\makeatletter
\newcommand\brcontraction[5][1ex]{%
\mathchoice
{\brcontraction@\displaystyle{#2}{#3}{#4}{#5}{#1}}%
{\brcontraction@\textstyle{#2}{#3}{#4}{#5}{#1}}%
{\brcontraction@\scriptstyle{#2}{#3}{#4}{#5}{#1}}%
{\brcontraction@\scriptscriptstyle{#2}{#3}{#4}{#5}{#1}}}
\newcommand{\brcontraction@}[6]{%
\setbox\swb@xone=\hbox{${}#1{}#2{}$}%
\setbox\swb@xtwo=\hbox{${}#1{}#3{}$}%
\setbox\swb@xthree=\hbox{${}#1{}#4{}$}%
\setbox\swb@xfour=\hbox{${}#1{}#5{}$}%
\swdimen@ne=\wd\swb@xtwo%
\divide\swdimen@ne by 2%
\lower 0.5ex \vbox{%
\hbox to 0pt{%
\kern \wd\swb@xone%
\kern 0.5\wd\swb@xtwo%
\brcontraction@@{\swdimen@ne}{#6}%
\hss}%
}}
\newcommand{\brcontraction@@}[3][0.05em]{%
\hbox{%
\swdimentw@=#3
\vrule width #1 height 0pt depth #3%
\lower\swdimentw@\hbox{\vrule width #2 height 0pt depth #1}%
%    \vrule width #1 height 0pt depth #3% commented out from original code
\relax}}
\newcommand{\brcontracted}[5][1ex]{%
\brcontraction[#1]{#2}{#3}{#4}{#5}\ensuremath{#2#3#4#5}}
\newcommand{\arcontraction}[5][1ex]{%
\mathchoice
{\arcontraction@\displaystyle{#2}{#3}{#4}{#5}{#1}}%
{\arcontraction@\textstyle{#2}{#3}{#4}{#5}{#1}}%
{\arcontraction@\scriptstyle{#2}{#3}{#4}{#5}{#1}}%
{\arcontraction@\scriptscriptstyle{#2}{#3}{#4}{#5}{#1}}}%
\newcommand{\arcontraction@}[6]{%
\setbox\swb@xone=\hbox{${}#1{}#2{}$}%
\setbox\swb@xtwo=\hbox{${}#1{}#3{}$}%
\setbox\swb@xthree=\hbox{${}#1{}#4{}$}%
\setbox\swb@xfour=\hbox{${}#1{}#5{}$}%
\swdimen@ne=\wd\swb@xtwo%
\divide\swdimen@ne by 2%
\vbox{%
\hbox to 0pt{%
\kern \wd\swb@xone%
\kern 0.5\wd\swb@xtwo%
\arcontraction@@{\swdimen@ne}{#6}%
\hss}%
\vskip 0.5ex%  how far above the line starts
\vskip\ht\swb@xtwo}}
\newcommand{\arcontraction@@}[3][0.05em]{%
\hbox{%
\vrule width #1 height 0pt depth #3%
\vrule width #2 height 0pt depth #1%
%    \vrule width #1 height 0pt depth #3% commented out from original code
\relax}}
\newcommand{\arcontracted}[5][1ex]{%
\arcontraction[#1]{#2}{#3}{#4}{#5}\ensuremath{#2#3#4#5}}
\begin{document}

$\arcontraction[2ex]{}{A}{B}{C} \arcontraction{A}{B}{C}{D} ABCD\dots$
$\brcontraction[2ex]{}{A}{B}{C} \brcontraction{A}{B}{C}{D} ABCD\dots$

$\brcontraction[2ex]{\sum n[}{A}{BC}{D} \brcontraction{\sum n[A}{B}{C}{D} \sum n[\hat{A}\hat{B}\hat{C}\hat{D}\dots]$

\end{document}


• How much work you've done. Could you explain to me how you group the characters with your macro, and when these characters are in mathematical mode? I did not understand the mechanism of grouping (see chat). Thank you very much. – Sebastiano Aug 8 at 21:52
• @Sebastiano Not really much work, just some cutting, pasting and commenting out. :) – Alan Munn Aug 8 at 21:54
• 1km of code :-) Please can you add a little code as to have a group of the characters also in math-mode. With the \hat, for example? Is it the same that I have inserted into chat? I have not understood how to group some characters with these brackets {A}{B}{C}{D}. – Sebastiano Aug 8 at 21:58
• I just saw you also got dragged into some "interesting" discussions. Poor you! – user121799 Aug 8 at 23:47