## Introduction ##

I’ve now uploaded the second of the TeX-SX packages to [CTAN](http://www.ctan.org). This is the [TQFT](http://www.ctan.org/pkg/tqft) package and is a TikZ/PGF package for drawing TQFT diagrams. The original question was [Topological Quantum Field Theory diagrams with pstricks or tikz](http://tex.stackexchange.com/q/17031/86).

![](/files/2011/10/tqft-figure0.png)

## TQFWhat? ##

What is TQFT? I’m sure that’s the question on everyone’s minds! It stands for “Topological Quantum Field Theory”. It’s what a mathematician says they’re working on when the head of the department drops by unexpectedly and finds them doing a jigsaw or some other puzzle.

“This? Oh, it’s part of my studies into TQFTs.”

So long as the head of the department is not a topologist, this is guaranteed to work. The combination of the words “topological” and “quantum” are enough to scare off all but the most hardened of department leaders. And the words “field theory” will finish off the few who remain.

That’s not all. It gets worse. If you are ever unlucky enough to attend a conference where one of the initiates in the mysteries of field theories is giving a talk, you will learn that TQFTs are not all there is. There are also Homological Quantum Field Theories, Conformal Quantum Field Theories, and many, many more, all the way to TQRSVPPDQBDFTFTCFT.

## No, But What Are They Really? ##

Actually, it’s quite simple. A TQFT is a functor from the cobordism category of one dimensional closed manifolds and surfaces, to the category of vector spaces and linear transformations.

I can imagine the reaction to that! “A TQFT is a *what* from a *what* to a *what*???”

Actually, for this package you only need to understand the first “*what*” and that (surprise, surprise) is quite visual.

Imagine that you have a bunch of circles, all the same size and sitting in line. Then you let the circles jiggle about a bit. Sometimes, two will touch. Then we can merge them at that point into a single circle. Also, a circle might jiggle about so much that it splits in two. So these circles evolve in time, splitting and recombining.

Now consider their “world line”. If we’ve done everything nicely, as the circles jiggle about they will trace out a surface. At one end, a certain number of circles. At the other, some other number. In between, lots of joining and splitting. The resulting surface is known as a *cobordism* between the two collections of circles. The thing about cobordisms is that, if you’re careful, you can glue them together. You have to have the right number of circles in the middle, of course.

![](/files/2011/10/tqft-figure1.png)

This gives a nice structure, called a *category*, where we think of surfaces as ways of moving between certain numbers of circles. This sort of structure crops up time and time again in mathematics: we have *things* and ways of moving between things. Some are more structured than others. Basically, the more structure we get then the more we can do with it.

A TQFT is a way of taking the information contained in the above *cobordism category* and transforming it to another category which is, hopefully, simpler and easier to understand. We (probably) lose information by doing this, but in the process get easier access to the information that we have preserved.

## The Package ##

This package is for drawing the cobordisms themselves. Just about every talk on TQFTs, or their lesser-spotted varieties, will have at least one picture of these surfaces. So the purpose of this package is to make it easier to draw these surfaces. To that end, it defines a couple of node shapes. There is the `tqft cobordism` shape itself, and then an auxilliary `tqft boundary circle` which can be used for drawing the boundary circles separately. In fact, the `tqft cobordim` shape internally uses the `tqft boundary circle` shape to provide extra anchors.

The `tqft cobordism` shape is highly configurable. The most obvious configuration option is for the numbers of incoming and outgoing boundary circles. In addition to being able to specify these by hand, there are a number of predefined aliases with specific numbers.

For example, the most famous cobordism is, perhaps, the “pair of pants” (it was named by an American … I hope). This looks like the following picture, in which the key line was `\node[tqft/pair of pants,draw] {};`.

![](/files/2011/10/tqft-figure2.png)

It is also possible to style the cobordism considerably. In fact, a cobordism is made up of several pieces and they are rendered in a very specific order. First, the boundary circles are rendered. These are closed paths so could be filled. Next, the lower part of the boundary circle is drawn again. This is so that this can be drawn on top of the boundary circle but underneath the cobordism itself. Third, the cobordism itself is rendered. This is again a closed path so could be filled or stroked or both. Fourth, the part of the cobordism path that is not on a boundary circle is redrawn. Lastly, the upper part of the boundary circle is drawn again. This ensures that this appears on top of the cobordism. Each of these can be individually styled.

Here’s an example, with progressively more styling.

![](/files/2011/10/tqft-figure3.png)

Various other options are available, including the direction of the “flow” and various sizes.

As well as many styling options, there are many anchors. Each boundary circle is a subnode and thus has its own set of anchors, which are an extended set of anchors from the ellipse shape, and the main node is also covered with anchors. The only thing missing from the anchor set is a boundary of the cobordism itself, so one cannot use anchors of the form `(a.120)`. However, the points of the compass are set to sensible things.

## Conclusion ##

So if you’ve ever wanted to draw funky TQFT diagrams, now you can. Here’s one I drew earlier.

![](/files/2011/10/tqft-figure4.png)

Astounding work, Andrew! Congrats! ğŸ™‚

Not only did a tex.sx question lead to this package, but we have come full circle: this package led to a tex.sx question!

http://tex.stackexchange.com/q/32143/215