TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the 50's, Roger Penrose invented a private graphical notation for tensors, which he later published. Wikipedia has a short description. It's basically a directed graph with some labels on it and some external edges. Predrag Cvitanovic has a modified version which is more amenable to typesetting, because he uses arrows rather than depending on "gravity" to give the direction of the edges, so it's easier to lay out as an inline or displayed equation. Penrose uses geometrical shapes for the nodes his diagrams, but I would be just as happy using letters. With Cvitanovic's convention I can do simple examples as inline tex math, e.g., \rightarrow\bigoplus\rightarrow\bigodot\leftarrow, or \rightarrow u\rightarrow v\leftarrow. (For the geometrical versions, it would be nice to have large squares, circles, and triangles, the size of \bigoplus --- is there any way to produce these? Things like \nabla seem too small.)

What would really be nice would be a way to typeset slightly more complex examples as latex math. Here are two examples using letters in the nodes:

samples of birdtracks

Examples like the top one are clearly doable with symbols like \rightleftarrow. I'm wondering if it's possible to get some of the fancier features such as the circle and loop in the second diagram, or the kinds of crossbars and wiggly crossbars shown in the WP article. The diagrams are somewhat related to Feynman diagrams, so it seems like maybe it could be done with one of the packages used for drawing those, but those seem more oriented toward drawing larger and more inescapably 2-D diagrams, and it's also not obvious to me which package is the best and most modern.

[EDIT] See also: http://mathoverflow.net/questions/25187/resources-for-graphical-languages-penrose-notation-feynman-diagrams-birdtra

share|improve this question
I later found this very nice page on this topic: elishapeterson.wikidot.com/tikz:diagrams – Ben Crowell Mar 10 '13 at 19:18

I figured out enough about tikz to produce the following:

tensors written in birdtracks notation with tikz

My code is below. Comments would be appreciated, since I don't really know what I'm doing with tikz. Is there a good way to avoid hardcoding the distances between nodes and the size of the circle?


\tikzstyle{plain}=[rectangle,fill=none,draw=black,scale=1.0,inner sep=1.8pt] % circle also works

The notation
                \node [style=plain] (n0) at (0, 0) {$u$};
                \node [style=plain] (n1) at +(2.3em, 0) {$v$};
                \draw [style=arrow] (n0) to (n1);
means the inner product $u_a v^a$.

The following displayed picture represents the tensor expression $u^a_{abc}\nabla_d v^{bc}$:

                \node [style=plain] (n0) at (0, 0) {$u$};
                \node [style=plain] (n1) at (3.1em, 0) {$v$};
                \node [style=circle,draw=black,minimum size=2.1\baselineskip] (c1) at (n1) {};
                \draw [style=arrow,out=10,in=170] (n0) to (n1);
                \draw [style=arrow,out=-10,in=190] (n0) to (n1);
                \draw [style=arrow,out=30,in=150, distance=1.8\baselineskip, loop] (n0) to ();
                \draw [style=arrow] (c1.east) to +(1.4em,0);

share|improve this answer
Since there seem to be no objections to your code you should probably accept your answer – Tobias Kienzler May 2 '13 at 6:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.