# How do I do Wick contraction with Dirac bracket?

So I would like to be able to draw Wick contraction with Dirac bracket, the Dirac bracket is produced with package physics, and the mwe is

\documentclass{article}

\usepackage{physics}

\begin{document}
$$\mathcal{M}_{\hat{s}} \sim \mel**{k , k'}{\overline{\psi}_x \psi _x \overline{\psi}_y \psi _y}{p , p'}$$
\end{document}


The kind of effect I would like to achieve with this bracket is

Sorry that my question was not clear, I was not trying to achieve a red colored Wick contraction lines.

The reason why I would like to use this package physics is, it is the only package I know that would nicely adjust the height of the angled bracket as well as the vertical lines in Dirac bracket, so I would like to stay with this package.

The problem with drawing the Wick contractions is, neither simplewick nor simpler-wick would work, so I am wondering if there is really a solution.

Also, I know it is always possible to do anything with tikz and that is something I could do, but I would appreciate if someone could offer a neater solution.

• – Werner Dec 6 '18 at 19:30

\langle and \rangle will scale and work with simpler-wick:

\documentclass{article}

\usepackage{simpler-wick}

\begin{document}
$\mathcal{M}_{\hat{s}} \sim \langle \wick{ \c1 k, \c2 k' \vert \overline{\c1 \psi}_x \psi_x \overline{\psi}_y \c2 \psi_y \vert p, p' } \rangle$
\end{document}


A solution with pstricks . I also defined a Dirac braket with \DeclarePairedDelimiter from mathtools:

\documentclass[svgnames]{article}
\usepackage{mathtools}
\usepackage{pst-node, auto-pst-pdf}

\DeclarePairedDelimiterX\Dirbraket[3]{\langle}{\rangle}%
{#1\,\delimsize\vert\,\mathopen{}#2\,\delimsize\vert\,\mathopen{}#3}

\begin{document}

\begin{postscript}
$\mathcal{M}_{\hat{s}} \sim \Dirbraket*{\rnode{k}{k} , \rnode{k1}{k'}}{\rnode{opx}{\overline{\psi}_x \rnode{psx}{\psi_x}} \rnode{opy}{\overline{\psi}_y} \rnode{psy}{\psi_y}}{\rnode{p}{\vphantom{k} p} , \rnode{p1}{p'}}$
\psset{angle=90, linewidth=0.5pt, linecolor=IndianRed, nodesep=2pt, arm=3mm, linejoin=1}
\ncbar[offsetB=-8pt]{k}{opx}
\ncbar[arm=2mm]{k1}{psy}
\ncbar[offsetA=2pt]{opy}{p1}
\ncbar[offsetA=1pt, arm=4.5mm]{psx}{p}
\end{postscript}

\end{document}


• Perfect work. I like very much. (+1) – Sebastiano Nov 18 '18 at 23:17

Building on the simpler-wick solution, here is one way to colour the contractions

\documentclass{article}

\usepackage{simpler-wick}
\makeatletter
\pgfkeys{simplerwick,wickcolor/.store in=\swick@color,wickcolor=black}
\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]
\draw[\swick@color] ($(swick-open#1.north) + (0, 3pt)$)
-- ($(swick-open#1.base) + (0, \swick@offset) + #1*(0, \swick@sep)$)
-- ($(swick-close#1.base) + (0, \swick@offset) + #1*(0, \swick@sep)$)
-- ($(swick-close#1.north) + (0, 3pt)$);
\tikzexternalenable}
\makeatother

\begin{document}
$\mathcal{M}_{\hat{s}} \sim \langle \wick[wickcolor=red]{ \c1 k, \c2 k' \vert \overline{\c1 \psi}_x \psi_x \overline{\psi}_y \c2 \psi_y \vert p, p' } \rangle$
\end{document}


I have not yet figured out how to do it exactly, but I found a way around it. We would just write the bra and ket with ladder operators and vacuum states. By doing that, we avoid having to go across the vertical lines. Please see the following

\documentclass{article}

\usepackage{physics}
\usepackage{simpler-wick}

\begin{document}
$\mathcal{M}_{\hat{s}} \sim \mel**{0}{\wick{\c2{a}_{k} \c1{a}_{k'} \c3{\overline{\psi}}_x \c4{\psi}_x \c2{\overline{\psi}}_y \c1{\psi}_y \c4{a}^{\dag}_{p} \c3{a}^{\dag}_{p'}}}{0} = \left( - 1 \right)^5 \mel**{0}{\wick{\c2{a}_{k} \c1{a}_{k'} \c1{\psi}_y \c2{\overline{\psi}}_y} \wick{\c2{\overline{\psi}}_x \c1{\psi}_x \c1{a}^{\dag}_{p} \c2{a}^{\dag}_{p'}}}{0}$
\end{document}


The output looks like