# Using Tikz to write symmetrisers and antisymmetrisers in birdtrack notation

I'm trying to use tikz to write in Cvitanovic's birdtrack notation, but I'm fairly new to tikz and need help.

Basically, I need to draw rectangles, both solid black or white with a black outline, with lines going through them. Then, I need to be able to center these pictures inline with other symbols in an equation. I have the code I use below:

$$A_{1\,2\,3} = \frac{1}{3!} \begin{tikzpicture}[thick] \begin{pgfonlayer}{nodelayer} \node (l3) at (0, 0) {}; \node (l2) at (0, 1em) {}; \node (l1) at (0, 2em) {}; \node (c3) at (2em, 0) {}; \node (c2) at (2em, 1em) {}; \node (c1) at (2em, 2em) {}; \node (r3) at (4em, 0) {}; \node (r2) at (4em, 1em) {}; \node (r1) at (4em, 2em) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [line,out=0,in=0] (r1.center) to (l1.center); \draw [line,out=0,in=0] (r2.center) to (l2.center); \draw [line,out=0,in=0] (r3.center) to (l3.center); \draw[line width=8pt,opacity=1,black,line cap=square,square corners] (c1.center-10pt) -- (c1.center) -- (c3.center) -- (c3.center+10pt); \end{pgfonlayer} \end{tikzpicture}$$


which produces

My issue with this is that the three lines aren't vertically centered with the rest of the equation symbols, and the lines on the right are slightly longer than the ones on the left. Most importantly, if I change the colour on the thick line to white, it just looks like a break in the lines and not a rectangle with lines going through it. I don't know how to make a black outline for the white box, so it looks like this:

I was thinking of somehow drawing a rectangle here instead of a line, but I don't know how to do this. I would appreciate any help. Thanks!

• Hello and welcome to Tex-SE. Please provide a complete MWE, in order to get more help without forcing helpers to rewrite all the environment. Feb 1 at 19:00

I think a command that would help here is rectangle:

\draw (x, y) rectangle (z, w);


draws a rectangle with its bottom left corner at (x, y) and its bottom right corner at (z, w). You then have two options for colouring, first [color=black] will make the lines black (currently you are just using very thick black lines to draw a rectangle), second [fill=black] will fill in the rectangle black. If you don't set the fill then the default is no fill and you get the desired look of lines crossing over an empty rectangle. This is what is done in the following:

$S_{1\,2\,3} = \frac{1}{3!} \begin{tikzpicture}[thick] \begin{pgfonlayer}{nodelayer} \node (l3) at (0, 0) {}; \node (l2) at (0, 1em) {}; \node (l1) at (0, 2em) {}; \node (c3) at (2em, 0) {}; \node (c2) at (2em, 1em) {}; \node (c1) at (2em, 2em) {}; \node (r3) at (4em, 0) {}; \node (r2) at (4em, 1em) {}; \node (r1) at (4em, 2em) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [line,out=0,in=0] (r1.center) to (l1.center); \draw [line,out=0,in=0] (r2.center) to (l2.center); \draw [line,out=0,in=0] (r3.center) to (l3.center); % The next line is the key line that I changed from the MWE \draw ((c3.center)-(0, 0.1)) rectangle ((c1.center-10pt)+(0, 0.1)); \end{pgfonlayer} \end{tikzpicture}$


My answer makes use of the calc library of tikz so to use it you need \usetikzlibrary{calc} in your preamble. If you don't want to use it then you can just fiddle around with the coordinates to find the correct placement of the rectangle. If you want the rectangle taller (or shorter) then just increase (or decrease) the value 0.1 in the line that I have indicated as the key line. Similarly if you want a wider (or thinner) rectangle change the value 0.

I'm afraid I don't know how to make the tikzpicture centre on the line, someone with more pure LaTeX knowledge will have to tell you how to do that.

Maybe you're looking for something like that:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

$S_{1\,2\,3} = \frac{1}{3!}$
\begin{tikzpicture}[thick,baseline=(current  bounding  box)]

\coordinate (l3) at (0, 0);
\coordinate (l2) at (0, 1em);
\coordinate (l1) at (0, 2em);
\def\l{4em}

\draw   (l1) --++ (\l,0) coordinate [midway] (c1)
(l2) --++ (\l,0) coordinate [midway] (c2)
(l3) --++ (\l,0) coordinate [midway] (c3);

\draw ($(c3)-(0, 0.1)$) rectangle ($(c1)+(0.2, 0.1)$);

\end{tikzpicture}

\end{document}


EDIT:
You can manage the way you want to center your image according to the baseline if you change your \begin{tikzpicture}[thick,baseline=(current bounding box)] to \begin{tikzpicture}[thick,baseline=7pt]`.