# How to draw Witten diagrams in XeTex?

I am trying to reproduce the following diagrammatic equation of Witten diagrams in XeTex. I have downloaded the TikZ package, but I'm still beginner. Any help would be appreciated!

• a start for you: \documentclass[tikz,border=5mm]{standalone} \begin{document} \begin{tikzpicture} \draw[blue,fill=blue!30] (0,0) circle(1); \draw (-.5,0)--(.5,0) node[above,midway]{$G$}; \fill (-.5,0) circle(1pt) (.5,0) circle(1pt); \end{tikzpicture} \end{document}  – Black Mild Aug 18 at 3:59
• Read this post to see how to put tikzpicture inline with text tex.stackexchange.com/a/313932/28557 – nidhin Aug 18 at 4:45

If you have tons of such diagrams, you may be better off defining an environment that draws the filled circle and sets the baseline of the diagram appropriately, and does other things. This answer is an overkill in the sense that it shows you two ways to avoid repetition:

1. define a new environment.
2. use execute at begin tikzpicture.

In practice one uses either of them, but this is to illustrate these options. BTW, AFAIK Witten typesets the differential ds upright.

\documentclass{article}
\usepackage{tikz}
\tikzset{Witten diagram/.style={execute at begin picture={%
\path node (X){\phantom{X}};
},baseline={(X.base)}},vertex/.style={circle,fill,inner sep=1.5pt,node
contents={}},
\newenvironment{wittendiagram}[1][]{\begin{tikzpicture}[Witten diagram,#1]}{\end{tikzpicture}}
\begin{document}
$\begin{wittendiagram} \draw (-1,0) node[vertex] -- (1,0) node[vertex]; \end{wittendiagram}=\int\!\mathrm{d}\nu\,g(\nu)\, \begin{wittendiagram} \draw[dashed] (-1,0) node[vertex] -- (90:\pgfkeysvalueof{/tikz/Witten/radius}) node [midway,left]{K} node[vertex] -- (1,0) node [midway,right]{K} node[vertex]; \end{wittendiagram}$
\end{document}


And here is a second version using the environ package and including the missing G (mille grazie @Sebastiano). Here the diagrams are vertically centered.

\documentclass{article}
\usepackage{environ}
\usepackage{tikz}
\tikzset{Witten diagram/.style={execute at begin picture={%
}},vertex/.style={circle,fill,inner sep=1.5pt,node
contents={}},
\NewEnviron{wittendiagram}[1][]{\vcenter{\hbox{\begin{tikzpicture}[Witten diagram,#1]%
\BODY
\end{tikzpicture}}}}
\begin{document}
$\begin{wittendiagram} \draw (-1,0) node[vertex] -- (1,0) node[midway,above]{G} node[vertex]; \end{wittendiagram}=\int\!\mathrm{d}\nu\,g(\nu)\, \begin{wittendiagram} \draw[dashed] (-1,0) node[vertex] -- (90:\pgfkeysvalueof{/tikz/Witten/radius}) node [midway,left]{K} node[vertex] -- (1,0) node [midway,right]{K} node[vertex]; \end{wittendiagram}$
\end{document}


Note that you could combine this with the tikz-feynman package if you want to add some standard Feynman diagram elements.

• Missed the $G$ into 1st graph :-) +1. – Sebastiano Aug 18 at 21:03

A less sophisticated solution:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
mybluenode/.style={
draw=blue,fill=blue!30, circle, minimum width=2cm, inner sep=0pt
},
myblacknode/.style={
circle, inner sep=1pt, fill=black
},
}
\begin{document}
\begin{tikzpicture}
\node[mybluenode] (first) {};
\draw ([xshift=-.5cm]first.center) node [myblacknode] {} -- node[above] {$G$} ([xshift=.5cm]first.center) node [myblacknode] {};
\node[right =4pt of first.east] (second) {$= \displaystyle\int \mathrm{d}\,\nu g(\nu)$};
\node[mybluenode, right =4pt of second.east] (third) {};
\draw[dashed] ([xshift=-.5cm]third.center) node [myblacknode] {} -- node[left] {$K$} (third.north) node [myblacknode] {} -- node[right] {$K$} ([xshift=.5cm]third.center) node [myblacknode] {};
\end{tikzpicture}
\end{document}