# Scaling isn't affecting a diagram made with the tqft package

I'm trying to make a drawing, part of which will use Andrew Stacey's tqft package. However, everything his package produces seems to be immune from scaling.

For example, the following code is my attempt to essentially use the test drawing from the link above, and scale it by 1/4. However, all it seems to do for me is scale the equal sign by 1/4, and keep the tqft drawings the same:

\documentclass{article}
\usepackage{tikz}
\usepackage{tqft}
\begin{document}
\begin{tikzpicture}[scale=1/4, tqft/flow=east]
\begin{scope}[tqft/boundary lower style={draw,  thick}]
\node[tqft/pair of pants,draw] (a) {};
\node[tqft/reverse pair of pants,draw,anchor=incoming boundary 1] (b) at (a.outgoing  boundary 2) {};
\node[tqft/cylinder,draw,anchor=incoming boundary 1] (c) at (a.outgoing boundary 1) {};
\node[tqft/cylinder to next,draw,anchor=outgoing boundary 1] (e) at (b.incoming boundary 2) {};
\path (b.outgoing boundary 1) ++(1.5,1) node[font=\Huge] {$$=$$};
\path (b.outgoing boundary 1) ++(3,0) node[tqft/reverse pair of pants,draw,anchor=incoming boundary 2] (e) {};
\node[tqft/pair of pants,draw,anchor=incoming boundary 1] (f) at (e.outgoing boundary 1) {};
\end{scope}

\end{tikzpicture}

\end{document}


I'm not an advanced TeX user at all, so hopefully it's something simple. And I thought about just emailing Andrew to ask but he seems to be frequently here, and maybe somebody else will have the same problem sometime.

-
PS please let me know if there's anything that this package doesn't do that it should do. Since this place isn't great for discussions, you can do so either by email, in the chat rooms here, or on the blog (tex.blogoverflow.com/2011/10/the-tqft-package). –  Loop Space Oct 20 '11 at 13:18

Update: Started poking around in the package and realised that this isn't a bug. It's a feature!

The cobordism shapes are drawn as nodes. Nodes have a special relationship with coordinate transformations: they ignore scaling and rotation and only use the shift part. This is normally what you want. However, in their infinite wisdom, the TikZ team provided for a way that nodes can use the full transformation. To make use of this, you need to add the key transform shape to a node. Then it is affected by things like rotation and scaling. In addition, the writer of the TQFT package (in his infinite idiocy) provided for a way to specify an option on every tqft shape in one go: using the every tqft style. So the solution is to add every tqft/.style={transform shape} on the surrounding scope.

Thus:

\documentclass{article}
\usepackage{tikz}
\usepackage{tqft}
\begin{document}
\begin{tikzpicture}[
tqft/flow=east,
]
\begin{scope}[scale=1/4,every tqft/.style={transform shape},
tqft/boundary lower style={draw,  thick}]
\node[tqft/pair of pants,draw] (a) {};
\node[tqft/reverse pair of pants,draw,anchor=incoming boundary 1] (b) at (a.outgoing  boundary 2) {};
\node[tqft/cylinder,draw,anchor=incoming boundary 1] (c) at (a.outgoing boundary 1) {};
\node[tqft/cylinder to next,draw,anchor=outgoing boundary 1] (e) at (b.incoming boundary 2) {};
\path (b.outgoing boundary 1) ++(1.5,1) node[font=\Huge] {$$=$$};
\path (b.outgoing boundary 1) ++(3,0) node[tqft/reverse pair of pants,draw,anchor=incoming boundary 2] (e) {};
\node[tqft/pair of pants,draw,anchor=incoming boundary 1] (f) at (e.outgoing boundary 1) {};
\end{scope}

\end{tikzpicture}

\end{document}


Produces:

which is correct.

However, there is a bug here. It is in the documentation. One wouldn't expect this behaviour of these cobordisms since they don't look like nodes (where does the text go?) so I should have pointed this out in the users' guide.

(PS Absolutely right to post here. Even my colleagues down the hall have started posting here to get my attention.)

Looks like a bug to me. I'd demand my money back if I were you.

Seriously, this looks as though I've not coded correctly for surrounding transformations (if you put rotate=45 in place of the scale then you'll see what I mean!). So I think you have three options.

1. Wait until I figure out how best to fix this.

2. Use the keys tqft/cobordism height and similar to manually fix the size.

3. Use a canvas transform instead of a coordinate transform (make sure you only put this on the scope containing the cobordisms otherwise it will affect things like the = as well).

-
Thanks! In googling about canvas transform, I found this answer: tex.stackexchange.com/q/4338, and using the "transform shape" option mentioned in an answer there seems to help somewhat -- it at least makes it so it will fit on a page, which is enough for now; I'm going to have to put it into an .eps eventually anyway, and I can clip extraneous boundary when I do that. –  Paul Johnson Oct 20 '11 at 12:39
@PaulJohnson: I just realised that transform shape is how this is supposed to be done and updated my answer accordingly. –  Loop Space Oct 20 '11 at 12:51
"Even my colleagues down the hall have started posting here to get my attention." I'm expecting a raft of "Andrew, it's your turn to buy more milk for the departmental fridge" questions on tex.sx now... –  Seamus Oct 20 '11 at 16:03