texlive[71401] Master/texmf-dist: tqft (1jun24)
commits+karl at tug.org
commits+karl at tug.org
Sat Jun 1 22:21:17 CEST 2024
Revision: 71401
https://tug.org/svn/texlive?view=revision&revision=71401
Author: karl
Date: 2024-06-01 22:21:17 +0200 (Sat, 01 Jun 2024)
Log Message:
-----------
tqft (1jun24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/tqft/tqft.pdf
trunk/Master/texmf-dist/doc/latex/tqft/tqft_code.pdf
trunk/Master/texmf-dist/tex/latex/tqft/tikzlibrarytqft.code.tex
trunk/Master/texmf-dist/tex/latex/tqft/tqft.sty
Added Paths:
-----------
trunk/Master/texmf-dist/doc/latex/tqft/README.txt
trunk/Master/texmf-dist/doc/latex/tqft/tqft.tex
trunk/Master/texmf-dist/source/latex/tqft/tqft_code.dtx
trunk/Master/texmf-dist/source/latex/tqft/tqft_code.ins
Removed Paths:
-------------
trunk/Master/texmf-dist/doc/latex/tqft/README
trunk/Master/texmf-dist/doc/latex/tqft/tqft_doc.tex
trunk/Master/texmf-dist/source/latex/tqft/tqft.dtx
trunk/Master/texmf-dist/source/latex/tqft/tqft.ins
Deleted: trunk/Master/texmf-dist/doc/latex/tqft/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tqft/README 2024-06-01 20:20:59 UTC (rev 71400)
+++ trunk/Master/texmf-dist/doc/latex/tqft/README 2024-06-01 20:21:17 UTC (rev 71401)
@@ -1,9 +0,0 @@
-----------------------------------------------------------------
-tqft --- a library for drawing TQFT diagrams with TikZ/PGF
-E-mail: stacey at math.ntnu.no
-Released under the LaTeX Project Public License v1.3c or later
-See http://www.latex-project.org/lppl.txt
-----------------------------------------------------------------
-
-This package defines some shapes useful for drawing TQFT diagrams with TikZ/PGF.
-
Added: trunk/Master/texmf-dist/doc/latex/tqft/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tqft/README.txt (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/tqft/README.txt 2024-06-01 20:21:17 UTC (rev 71401)
@@ -0,0 +1,13 @@
+----------------------------------------------------------------
+tqft --- a TikZ library for drawing TQFT diagrams
+bundle version: v2.3 2024/05/31
+E-mail: Andrew Stacey <loopspace at mathforge.org>
+Released under the LaTeX Project Public License v1.3c or later
+See http://www.latex-project.org/lppl.txt
+----------------------------------------------------------------
+
+This package defines some shapes useful for drawing TQFT diagrams with TikZ/PGF.
+The initial idea of this package came from a question and answer on the site https://tex.stackexchange.com.
+
+The package comes in two versions: a package (tqft.sty) and a TikZ library (tikzlibrarytqft.code.tex). The original package (tqft.sty) is depreciated and has been frozen at version 2.1. The TikZ library is maintained and should be used in preference, except for legacy code.
+
Property changes on: trunk/Master/texmf-dist/doc/latex/tqft/README.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/tqft/tqft.pdf
===================================================================
(Binary files differ)
Added: trunk/Master/texmf-dist/doc/latex/tqft/tqft.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tqft/tqft.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/tqft/tqft.tex 2024-06-01 20:21:17 UTC (rev 71401)
@@ -0,0 +1,1000 @@
+\documentclass{ltxdoc}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+\usepackage{morefloats}
+\usepackage[svgnames]{xcolor}
+\usepackage{tikz}
+\usepackage{tqft}
+\usetikzlibrary{tqft}
+\usepackage[numbered]{hypdoc}
+\definecolor{lstbgcolor}{rgb}{0.9,0.9,0.9}
+
+\usepackage{listings}
+\lstloadlanguages{[LaTeX]TeX}
+\lstset{breakatwhitespace=true,breaklines=true,language=TeX}
+
+\usepackage{fancyvrb}
+
+\newenvironment{example}
+ {\VerbatimEnvironment
+ \begin{VerbatimOut}{example.out}}
+ {\end{VerbatimOut}
+ \begin{center}
+ \setlength{\parindent}{0pt}
+ \fbox{\begin{minipage}{.9\linewidth}
+ \lstset{breakatwhitespace=true,breaklines=true,language=TeX,basicstyle=\small}
+ \lstinputlisting[]{example.out}
+ \end{minipage}}
+
+ \fbox{\begin{minipage}{.9\linewidth}
+ \centering
+ \input{example.out}
+ \end{minipage}}
+\end{center}
+}
+
+\providecommand*{\url}{\texttt}
+\GetFileInfo{tikzlibrarytqft.code.tex}
+\pdfstringdefDisableCommands{%
+ \def\\{}%
+ \def\url#1{<#1>}%
+}
+
+
+\title{The \textsf{tqft} Ti\emph{k}Z Library: Documentation}
+\author{Andrew Stacey \\ \url{loopspace at mathforge.org}}
+\date{\fileversion~from \filedate}
+
+\begin{document}
+
+\maketitle
+
+\begin{center}
+\begin{tikzpicture}[
+ scale=.5,
+ every tqft/.style={
+ transform shape
+ },
+ tqft/cobordism/.style={
+ fill=DarkMagenta,
+ draw,
+ ultra thick},
+ ]
+ \pic[
+ name=a,
+ tqft,
+ incoming boundary components=0,
+ outgoing boundary components=3,
+ ];
+ \pic[
+ name=b,
+ at=(a-outgoing boundary 2),
+ tqft cylinder,
+ anchor=incoming boundary 1,
+ ];
+ \pic[
+ at=(a-outgoing boundary 3),
+ name=c,
+ tqft,
+ incoming boundary components=0,
+ outgoing boundary components=2,
+ anchor={(0,1)},
+ ];
+ \pic[
+ at=(c-outgoing boundary 1),
+ name=d,
+ tqft,
+ incoming boundary components=3,
+ outgoing boundary components=1,
+ offset=2.5,
+ anchor=incoming boundary 1,
+ boundary separation=1cm,
+ cobordism height=2.5cm,
+ ];
+ \pic[
+ at=(c-outgoing boundary 2),
+ name=e,
+ tqft,
+ rotate=90,
+ incoming boundary components=0,
+ outgoing boundary components=3,
+ anchor={(2,-.5)}
+ ];
+ \pic[
+ at=(e-outgoing boundary 3),
+ name=f,
+ tqft cylinder,
+ rotate=90,
+ anchor=incoming boundary 1,
+ ];
+ \pic[
+ at=(e-outgoing boundary 2),
+ name=g,
+ tqft cylinder,
+ rotate=90,
+ anchor=incoming boundary 1,
+ ];
+ \pic[
+ at=(g-outgoing boundary 1),
+ name=h,
+ tqft,
+ anchor={(0,1)},
+ incoming boundary components=0,
+ outgoing boundary components=3,
+ ];
+ \pic[
+ at=(h-outgoing boundary 2),
+ name=i,
+ tqft cylinder,
+ anchor=incoming boundary 1,
+ ];
+\end{tikzpicture}
+\end{center}
+
+\section{Introduction}
+This package defines some Ti\emph{k}Z/PGF picture shapes that can be used to construct the diagrams common in Topological Quantum Field Theory (TQFT).
+An example follows:
+
+\begin{example}
+\begin{tikzpicture}[tqft/cobordism/.style={draw}]
+\pic[tqft/pair of pants,name=a];
+\pic[tqft/cylinder to next,anchor=incoming boundary 1,name=c,at=(a-outgoing boundary 1)];
+\pic[tqft/reverse pair of pants, anchor=incoming boundary 1,at=(a-outgoing boundary 2)];
+\end{tikzpicture}
+\end{example}
+
+\tableofcontents
+
+\section{History}
+
+This is the second version of the TQFT package.
+The first version used nodes to draw the shapes.
+However, with the advent of Ti\emph{k}Z3.0 came the ability to define subdrawings called \Verb+pic+s which were a bit like nodes but were geared more towards drawings than containers for text.
+This seems a much more suitable mechanism for drawing these diagrams and so the package has been rewritten to make use of this new facility.
+
+The second version is designed to be similar to the first, but with some improvements.
+The original version was distributed as a \Verb+.sty+ file and so is loaded using \Verb+\usepackage{tqft}+.
+The newer version is a Ti\emph{k}Z library and so is loaded using \Verb+\usetikzlibrary{tqft}+.
+This makes it possible to use both in the same document.
+This is not recommended, but an attempt has been made to make it possible to switch between the two methods (mainly to stop this documentation file complaining every time I compile it).
+This hasn't been extensively tested so use with caution.
+To make the switch use the key \Verb+/tikz/tqft/use nodes=<true|false>+.
+By default, the one loaded last should be in effect at the start of the document.
+
+\section{Keys}
+
+Before giving any details, a word is in order about the keys involved in this package.
+There are many options and keys that can be set via the \Verb+\pgfkeys+ system (which is used for setting options in Ti\emph{k}Z).
+Such keys live in a ``directory'' but often that can be omitted.
+For example, in the Ti\emph{k}Z command \Verb+\draw[red] (0,0) -- (1,0);+ the key \Verb+red+ is actually in the ``directory'' \Verb+/tikz+ but it is not necessary to specify that as it is assumed.
+Defining a ``directory'' helps separate keys and ensure that there is no conflict.
+The keys in this library are (mostly) defined in the directories \Verb+/tikz/tqft+ (the newer version) and \Verb+/pgf/tqft+ (the old version).
+
+Invoking \Verb+/tikz/tqft+ itself sets the ``current directory'' to whichever directory is right for the current version in force and so all subsequent keys do not need prefixing.
+Moreover, any unknown keys are passed on to the \Verb+/tikz+ directory so there is (or should be!) no harm in mixing \Verb+tqft+ specific keys with ordinary Ti\emph{k}Z keys.
+Some examples take advantage of this switch so when copying and modifying examples from this document, it is important to remember that the first \Verb+tqft+ specific key needs an explicit \Verb+tqft/+ prefix.
+
+
+\section{Version 2: Pics via a TikZ Library}
+\label{sec:pic}
+
+\subsection{The Shapes}
+
+There is only one picture shape: \Verb+cobordism+.
+This is a cobordism between a number of incoming circles and a number of outgoing circles, where the numbers of boundary components can be specified as options to the shape.
+There are certain common shapes that are predefined as aliases to the main shape with specified boundaries.
+The list of predefined shapes follows.
+The names are all in the \Verb+tqft+ family, but an alias is made so that \Verb+tqft <shape>+ will work without any further qualification.
+
+\begin{enumerate}
+\item \Verb+pair of pants+
+
+\begin{tikzpicture}
+\pic[draw,tqft/pair of pants];
+\end{tikzpicture}
+
+\item \Verb+reverse pair of pants+
+
+\begin{tikzpicture}
+\pic[draw,tqft/reverse pair of pants];
+\end{tikzpicture}
+
+\item \Verb+cylinder to prior+
+
+This is a cylinder that has been skewed to one side, thus following the same path as the \Verb+pair of pants+ cobordism but with only one outgoing boundary component.
+The name \Verb+to prior+ is because it goes towards the lower-numbered component on the \Verb+pair of pants+.
+
+\begin{tikzpicture}
+\pic[draw,tqft/cylinder to prior];
+\end{tikzpicture}
+
+\item \Verb+cylinder to next+
+
+This is a cylinder that has been skewed to one side, thus following the same path as the \Verb+pair of pants+ cobordism but with only one outgoing boundary component.
+The name \Verb+to next+ is because it goes towards the higher-numbered component on the \Verb+pair of pants+.
+
+\begin{tikzpicture}
+\pic[draw,tqft/cylinder to next];
+\end{tikzpicture}
+
+\item \Verb+cylinder+
+
+This is a straight cylinder.
+
+\begin{tikzpicture}
+\pic[draw,tqft/cylinder];
+\end{tikzpicture}
+
+\item \Verb+cap+
+
+This is a cap.
+
+\begin{tikzpicture}
+\pic[draw,tqft/cap];
+\end{tikzpicture}
+
+\item \Verb+cup+
+
+This is a cup (an upside-down cap).
+
+\begin{tikzpicture}
+\pic[draw,tqft/cup];
+\end{tikzpicture}
+
+\end{enumerate}
+
+The general shape is controlled by the following keys:
+
+\begin{itemize}
+\item \DescribeMacro{view from} To get a simulated 3D effect, the cobordism is drawn as if viewed from a slight angle.
+The value of this key determines whether the cobordism is viewed from the direction of the incoming boundary components or the outgoing ones.
+This key can take the values \Verb+incoming+ and \Verb+outgoing+.
+The default is \Verb+outgoing+.
+\item \DescribeMacro{cobordism height} This is the height of the cobordism (``height'' interpreted in its own internal coordinate system).
+With no offset (q.v.), this would be the distance between the centres of the first incoming and first outgoing boundary components.
+
+\item \DescribeMacro{boundary separation} This is the distance between the centres of the boundary components of the same type.
+
+\item \DescribeMacro{circle x radius} This is the half-width of the boundary circles.
+
+\item \DescribeMacro{circle y radius} This is the half-depth of the boundary circles (``depth'' since, in the internal coordinate system, this corresponds to the \(z\)-axis out of the page).
+
+\item \DescribeMacro{incoming boundary components} The number of incoming boundary components (can be zero).
+
+\item \DescribeMacro{skip incoming boundary components} A list of incoming boundary components to be skipped.
+
+\item \DescribeMacro{outgoing boundary components} The number of outgoing boundary components (can be zero).
+
+\item \DescribeMacro{skip outgoing boundary components} A list of outgoing boundary components to be skipped.
+
+\item \DescribeMacro{offset} This offsets the first outgoing boundary component horizontally relative to the first incoming boundary component.
+It is a dimensionless number (not necessarily an integer) and is interpreted so that a value of \(1\) aligns the first outgoing boundary component with the second incoming boundary component.
+
+\item \DescribeMacro{genus} This defines the number of holes in the shape.
+These are spread out in a horizontal line in the middle of the shape.
+
+\item \DescribeMacro{twisted} This is a boolean that, if set, makes the cobordism \emph{twisted} in that the edges cross as they pass from the incoming to outgoing boundaries.
+This probably won't look good with a non-zero genus, but there's nothing stopping you doing it.
+\end{itemize}
+
+\subsection{Styling}
+
+There are various options for styling the diagrams.
+To understand how they work, it is important to know the order in which a cobordism is drawn and how many pieces it decomposes into.
+This is the following list, with the corresponding keys:
+
+\begin{enumerate}
+\item The boundary circles are drawn.
+These are actually elliptical nodes (and thus can be individually styled).
+Applicable styles:
+
+\begin{itemize}
+\item \Verb+every boundary component+,
+\item \Verb+every incoming boundary component+,\\
+or \Verb+every outgoing boundary component+,
+\item \Verb+incoming boundary component <n>+,\\
+or \Verb+outgoing boundary component <n>+
+\end{itemize}
+
+\item The lower edges of the boundary circles are redrawn.
+These are individual arcs.
+
+\begin{itemize}
+\item \Verb+every lower boundary component+,
+\item \Verb+every incoming lower boundary component+,\\or \Verb+every outgoing lower boundary component+,
+\item \Verb+incoming lower boundary component <n>+,\\or \Verb+outgoing lower boundary component <n>+
+\end{itemize}
+
+\item The full edge of the cobordism is drawn.
+This is a closed path so can be sensibly filled.
+It is clipped against a path defined by the genus of the cobordism which results in holes if it is filled (or shaded or anything else that goes in to the interior).
+
+\begin{itemize}
+\item \Verb+cobordism+,
+\item also, any actions specified on the \Verb+pic+ are applied here (specifically, the \Verb+pic actions+ key is invoked; see the Ti\emph{k}Z manual for full details on this),
+\item \Verb+cobordism outer path+.
+\end{itemize}
+
+\item Any holes specified by the genus are now drawn.
+These are styled to give the 3D impression, and this follows the direction specified by the \Verb+view from+ key.
+The paths are split so that each can be individually styled.
+
+\begin{itemize}
+\item \Verb+cobordism+, this style is applied because the curves defined by the genus can be thought of as part of the edge of the cobordism shape.
+\item \Verb+pic actions+, for the same reason as above.
+
+However, following this key then \Verb+fill=none,shade=none+ is issued.
+This is because even if the main shape is filled or shaded, the paths drawing the holes should almost certainly not be.
+\item \Verb+cobordism edge+, the same logic applies to the edge path (q.v.).
+\item \Verb+genus style+,
+\item \Verb+genus upper+ or \Verb+genus lower+,
+\item \Verb+hole <n>+,
+\item \Verb+hole <n> upper+ or \Verb+hole <n> lower+.
+\end{itemize}
+
+\item The non-boundary edge of the cobordism is redrawn.
+This is split in to pieces to allow for individual styling.
+
+\begin{itemize}
+\item \Verb+cobordism edge+,
+\item \Verb+cobordism outer edge+,
+\item \Verb+between incoming+, or \Verb+between outgoing+, or \Verb+between incoming and outgoing+.
+The latter is for the two sides, but note that if the cobordism has no incoming or no outgoing components then it also applies to the ``over the top'' edge.
+\item \Verb+<anchor>+, where the \Verb+<anchor>+ is the name of the anchor that lies on the midpoint of the curve, so it will be one of:
+%
+\begin{itemize}
+\item \Verb=between incoming <n> and <n+1>=,
+\item \Verb=between outgoing <n> and <n+1>=,
+\item \Verb+between first incoming and first outgoing+,
+\item \Verb+between last incoming and last outgoing+,
+\item \Verb+between first and last incoming+,
+\item \Verb+between first and last outgoing+.
+\end{itemize}
+\end{itemize}
+
+\item The upper edges of the boundary circles are redrawn.
+These are arcs.
+
+\begin{itemize}
+\item \Verb+every upper boundary component+,
+\item \Verb+every incoming upper boundary component+,\\or \Verb+every outgoing upper boundary component+,
+\item \Verb+incoming upper boundary component <n>+,\\or \Verb+outgoing upper boundary component <n>+
+\end{itemize}
+\end{enumerate}
+
+The fact that there are so many is to allow different style to be applied to different pieces and to give as much control as possible, whilst still making it fairly straightforward to draw a simple cobordism.
+The duplication of paths is to allow certain composite pieces to be \emph{filled}.
+Here is a progressively built up cobordism.
+
+\begin{example}
+\begin{tikzpicture}[tqft/view from=incoming]
+\begin{scope}[tqft/every boundary component/.style={fill=green,fill opacity=1}]
+\pic[tqft/cylinder,at={(1,0)}];
+\begin{scope}[tqft/every lower boundary component/.style={draw=purple,thick}]
+\pic[tqft/cylinder,at={(2,0)}];
+\begin{scope}[tqft/cobordism/.style={fill=yellow,fill opacity=.7}]
+\pic[tqft/cylinder,at={(3,0)}];
+\begin{scope}[tqft/cobordism edge/.style={draw,thick,blue}]
+\pic[tqft/cylinder,fill=yellow,fill opacity=.7,at={(4,0)}];
+\begin{scope}[tqft/every upper boundary component/.style={draw,thick,orange}]
+\pic[tqft/cylinder,fill=yellow,fill opacity=.7,at={(5,0)}];
+\end{scope}
+\end{scope}
+\end{scope}
+\end{scope}
+\end{scope}
+\end{tikzpicture}
+\end{example}
+
+Here's an example with lots of styling.
+
+\begin{example}
+\begin{tikzpicture}
+\pic[
+ tqft,
+ incoming boundary components=3,
+ outgoing boundary components=3,
+ offset=1,
+ genus=3,
+ hole 3/.style={ultra thick, purple,solid},
+ genus lower/.style={dashed},
+ fill=red!50,
+ cobordism edge/.style={draw},
+ between incoming and outgoing/.style={dotted},
+ between outgoing 2 and 3/.style={ultra thick},
+];
+\end{tikzpicture}
+\end{example}
+
+\subsection{Anchors}
+
+The cobordism is a \Verb+pic+ so does not have any native anchors.
+Nevertheless, a multitude of coordinates are defined that simulate the anchors associated with nodes.
+There is also support for specifying the shape to be located relative to a particular anchor.
+
+The \Verb+\pic+ should be named via the \Verb+name=<prefix>+ key, whereupon the anchors are prefixed by this value.
+The pseudo-anchors defined have the naming convention \Verb+<prefix>-<anchor name>+ (at the moment, it doesn't check to see if the \Verb+name+ key has been specified so if it isn't then the pseudo-anchors are still defined but with an empty prefix).
+They are:
+%
+\begin{itemize}
+\item \Verb+incoming boundary <n>+, these are in fact elliptical nodes and so also define actual anchors.
+\item \Verb+incoming boundary+ is an alias for \Verb+incoming boundary 1+.
+\item \Verb+outgoing boundary <n>+, same.
+\item \Verb+outgoing boundary+ is an alias for \Verb+outgoing boundary 1+.
+\item \Verb=between incoming <n> and <n+1>=, this lies on the midpoint of the curve between successive boundary components.
+\item \Verb=between outgoing <n> and <n+1>=, this lies on the midpoint of the curve between successive boundary components.
+\item \Verb=between first incoming and first outgoing= is on the edge between the first incoming and first outgoing boundary components; note that this is only defined if there are both incoming and outgoing boundary components.
+\item \Verb=between last incoming and last outgoing= is on the edge between the last incoming and last outgoing boundary components; note that this is only defined if there are both incoming and outgoing boundary components.
+\item \Verb=between first and last incoming=; this is only defined if there are no outgoing components.
+
+This is also available via the alias \Verb=between first incoming and last incoming=.
+\item \Verb=between first and last outgoing=; this is only defined if there are no incoming components.
+
+This is also available via the alias \Verb=between first outgoing and last outgoing=.
+\item \Verb=hole <n>=; if the genus is non-zero, this points to the centre of the \(n\)th hole.
+\end{itemize}
+
+To place the shape relative to an anchor, use the \Verb+tqft/anchor+ key.
+The argument should be just the name of the anchor without the leading \Verb+<prefix>-+.
+The \Verb+anchor+ key can also take another type of argument.
+If its argument is of the form \Verb+(x,y)+ then this is taken as a pseudo-coordinate\footnote{Note that due to the presence of the comma, this type of argument must be protected by braces.}.
+It is interpreted as being \(x\) boundary components across and \(y\) times the cobordism height down.
+However, if an \Verb+offset+ is specified then the resulting \(x\) value is shifted so that if \(y < 0\) then \((1,y)\) is in line with the first incoming boundary component and if \(y > 1\) then \((1,y)\) is in line with the first outgoing boundary component.
+If \(0 < y < 1\) then \((1,y)\) linearly interpolates between the first incoming and first outgoing boundary components.
+Thus \((1,0)\) is the first incoming boundary component, \((1,1)\) the first outgoing boundary component, \((0,0)\) is one unit to the left of the first incoming, and \((1,2)\) one unit below the first outgoing.
+Note that the picture is shifted to put this point at the current coordinate.
+
+\begin{example}
+\begin{tikzpicture}
+\pic[tqft, incoming boundary components=2,outgoing boundary components=4,offset=-1,draw,name=a];
+\foreach \anchor/\placement in
+{
+between first incoming and first outgoing/left,
+between last incoming and last outgoing/right,
+between outgoing 2 and 3/above,
+incoming boundary 1/above left,
+incoming boundary 2/above right,
+outgoing boundary 1/below left,
+outgoing boundary 4/below right}
+\draw[overlay,shift=(a-\anchor)] plot[mark=x] coordinates{(0,0)} node[\placement] {\scriptsize\texttt{(a-\anchor)}};
+\path (a-incoming boundary) +(0,.5) (a-outgoing boundary) +(0,-1);
+\end{tikzpicture}
+\end{example}
+
+\subsection{Notes}
+
+\begin{enumerate}
+\item Like \Verb+node+s, \Verb+pic+s need the \Verb+transform shape+ key to be set to take note of external transformations (other than shifts).
+The tqft pic uses nodes internally and those nodes have \Verb+transform shape+ automatically set so this should \emph{just work}.
+\item There is an additional \Verb+every tqft+ key which is run when the \Verb+tqft+ key is invoked (which might be via some other key).
+This is better placed than the \Verb+every pic+ key since that applies to a surrounding scope rather than to the \Verb+pic+ itself.
+\item If the \Verb+tqft+ key is invoked, either implicitly or explicitly, then the \Verb+pic type+ is set to \Verb+cobordism+.
+This has the side effect that the invoking syntax has to be completely set by keys; so the \Verb+pic (<name>) at (<coord>) {<type>}+ cannot be used.
+Rather, the \Verb+name+ and \Verb+at+ have to be specified by keys and the \Verb+type+ omitted.
+
+\item If upgrading from the previous version of TQFT, as well as shifting from a \Verb+node+ to a \Verb+pic+, the following changes have been made in the implementation:
+
+\begin{itemize}
+\item The \Verb+flow+ key has not made it across to the new version.
+Use \Verb+transform shape+ and apply your own transformation.
+
+\item The \Verb+circle width+ and \Verb+circle depth+ are now \Verb+circle x radius+ and \Verb+circle y radius+ (the old names weren't correct anyway).
+
+\item The bounding box is a little better, particularly for cobordisms with only one type of boundary component.
+\end{itemize}
+\end{enumerate}
+
+\subsection{More Examples}
+
+\begin{example}
+\begin{tikzpicture}[tqft/cobordism height=1.5cm,tqft/boundary separation=1.5cm]
+\foreach \coord/\style in {
+{(0,0)}/{tqft/view from=outgoing,fill},
+{(5,0)}/{tqft/view from=incoming,draw},
+{(0,-8)}/{fill=orange,fill opacity=.5,tqft/every lower boundary component/.style={draw,blue,ultra thin,dashed},tqft/every upper boundary component/.style={draw,green},tqft/cobordism edge/.style={draw,purple},tqft/every boundary component/.style={fill=yellow}},
+{(5,-8)}/{fill=orange,fill opacity=.5,tqft/cobordism edge/.style={draw,purple},tqft/every boundary component/.style={fill=yellow,draw=green}}
+} {
+ \begin{scope}[every tqft/.style/.expand once=\style]
+\pic[tqft/cap,name=h,at=\coord];
+\pic[tqft/pair of pants,anchor=incoming boundary 1,name=a,at=(h-outgoing boundary 1)];
+\pic[tqft/cylinder to next,anchor={(0,1)},name=d,at=(a-outgoing boundary 2)];
+\pic[tqft/reverse pair of pants,anchor=incoming boundary 1,name=b,at=(a-outgoing boundary 2)];
+\pic[tqft/cylinder to prior,anchor=incoming boundary 1,name=c,at=(b-outgoing boundary 1)];
+\pic[tqft/cylinder,twisted,anchor=incoming boundary 1,name=e,at=(a-outgoing boundary 1)];
+\pic[tqft/cylinder,anchor=incoming boundary 1,name=f,at=(e-outgoing boundary 1)];
+\pic[tqft/reverse pair of pants,anchor=incoming boundary 1,name=g,at=(f-outgoing boundary 1)];
+\pic[tqft/cup,anchor=incoming boundary 1,name=i,at=(g-outgoing boundary 1)];
+\end{scope}
+}
+\end{tikzpicture}
+\end{example}
+
+\begin{example}
+\begin{tikzpicture}[every tqft/.append style={transform shape}]
+\foreach \ang in {0,90,180,270} {
+\begin{scope}[rotate=\ang]
+\pic[draw,tqft/pair of pants,name=a,at={(3,3)}];
+\pic[draw,tqft/cap,anchor=outgoing boundary 1,at=(a-incoming boundary 1)];
+\pic[fill,tqft/cup,anchor=incoming boundary 1,at=(a-outgoing boundary 1)];
+\pic[draw,tqft/cup,anchor=incoming boundary 1,at=(a-outgoing boundary 2)];
+\end{scope}
+}
+\end{tikzpicture}
+\end{example}
+
+\begin{example}
+\begin{tikzpicture}[
+ tqft,
+ every outgoing boundary component/.style={fill=blue!50},
+ outgoing boundary component 3/.style={fill=none,draw=red},
+ every incoming boundary component/.style={fill=green!50},
+ every lower boundary component/.style={draw,ultra thick, dashed},
+ every upper boundary component/.style={draw,purple},
+ cobordism/.style={fill=red!50},
+ cobordism edge/.style={draw},
+ genus=3,
+ hole 2/.style={ultra thick, blue},
+ view from=incoming,
+ anchor=between incoming 1 and 2
+]
+\pic[rotate=90,
+ %every node/.style={transform shape},
+ name=a,tqft,incoming boundary components=5,skip incoming boundary components={2,4},outgoing boundary components=7,skip outgoing boundary components={2,3,5},offset=-.5];
+
+\begin{scope}[every pin edge/.style={<-}]
+\foreach \anchor/\ang in {
+ hole 1/-90,
+ hole 2/90,
+ hole 3/-90,
+ incoming boundary 3/180,
+ outgoing boundary 4/0,
+ between last incoming and last outgoing/90,
+ between first incoming and first outgoing/-90,
+ between incoming 1 and 3/180,
+ between outgoing 1 and 4/0,
+ between outgoing 4 and 6/0
+} {
+ \node[pin=\ang:\anchor,at=(a-\anchor),inner sep=0pt] {};
+}
+\draw[<-] (0,0) -- ++(-2,0) node[left] {origin};
+\end{scope}
+\end{tikzpicture}
+\end{example}
+
+%\begin{example}
+\begin{tikzpicture}
+\pic[
+ tqft,
+ incoming boundary components=2,
+ outgoing boundary components=2,
+ genus=2,
+ draw,
+ name=a
+];
+\pic[
+ tqft,
+ incoming boundary components=2,
+ outgoing boundary components=1,
+ draw,
+ at=(a-outgoing boundary 1),
+ offset=.5,
+ cobordism height=1cm,
+ name=b
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=3,
+ draw,
+ at=(b-outgoing boundary 1),
+ offset=-1,
+ name=c
+];
+\pic[tqft,
+ incoming boundary components=2,
+ outgoing boundary components=1,
+ draw,
+ at=(c-outgoing boundary 1),
+ anchor=incoming boundary 2,
+ name=d,
+ boundary separation=1.6cm,
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(c-outgoing boundary 3),
+ offset=.5,
+ name=e,
+ every outgoing lower boundary component/.style={draw}
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(c-outgoing boundary 2),
+ name=f
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=2,
+ draw,
+ at=(f-outgoing boundary),
+ name=g,
+ offset=-.5,
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(g-outgoing boundary 1),
+ name=h,
+ offset=-.25,
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(g-outgoing boundary 2),
+ name=i,
+ offset=.25,
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(h-outgoing boundary),
+ name=j,
+ every outgoing lower boundary component/.style={draw}
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(i-outgoing boundary),
+ name=k,
+ every outgoing lower boundary component/.style={draw}
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(d-outgoing boundary),
+ name=l
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=0,
+ draw,
+ at=(l-outgoing boundary),
+ name=m
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(d-incoming boundary),
+ anchor=outgoing boundary,
+ name=n
+];
+\pic[tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ draw,
+ at=(n-incoming boundary),
+ anchor=outgoing boundary,
+ name=o
+];
+\pic[tqft,
+ incoming boundary components=3,
+ outgoing boundary components=3,
+ draw,
+ at=(o-incoming boundary),
+ anchor={(2,1)},
+ name=p,
+ boundary separation=1.25cm,
+ outgoing lower boundary component 1/.style={draw},
+ outgoing lower boundary component 3/.style={draw}
+];
+\pic[tqft,
+ incoming boundary components=5,
+ outgoing boundary components=5,
+ genus=3,
+ at=(k-outgoing boundary),
+ anchor={(4,-1)},
+ draw,
+ name=q,
+ every outgoing lower boundary component/.style={draw}
+];
+\path (q-incoming boundary 3) ++(0,1) node {\Huge \(=\)};
+\end{tikzpicture}
+%\end{example}
+
+\section{Version 1: Nodes via a Style File}
+
+\tikzset{tqft/use nodes=true}
+
+As mentioned in the introduction, this is the original method of drawing cobordism diagrams using nodes and is no longer updated (though I will fix bugs if I can).
+If drawing a new diagram, use the pic method from Section~\ref{sec:pic}.
+
+\subsection{The Node Shapes}
+
+There are only two shapes, \Verb+tqft cobordism+ and \Verb+tqft boundary circle+.
+The first, which is the main shape, is a cobordism between a number of incoming circles and a number of outgoing circles, where the numbers of boundary components can be specified as options to the shape.
+The second is just the boundary circle.
+It is used as a sub-node of the first to add extra anchors, but can be used by itself.
+There are certain common shapes that are predefined as aliases to the main shape with specified boundaries.
+The list of predefined shapes follows.
+The names are all in the \Verb+tqft+ family, but an alias is made so that \Verb+tqft nodeshape+ will work without any further qualification.
+
+\begin{enumerate}
+\item \Verb+pair of pants+
+
+\begin{tikzpicture}
+\node[draw,tqft/pair of pants] (a) {};
+\end{tikzpicture}
+
+\item \Verb+reverse pair of pants+
+
+\begin{tikzpicture}
+\node[draw,tqft/reverse pair of pants] (a) {};
+\end{tikzpicture}
+
+\item \Verb+cylinder to prior+
+
+This is a cylinder that has been skewed to one side, thus following the same path as the \Verb+pair of pants+ cobordism but with only one outgoing boundary component.
+The name \Verb+to prior+ is because it goes towards the lower-numbered component on the \Verb+pair of pants+.
+
+\begin{tikzpicture}
+\node[draw,tqft/cylinder to prior] (a) {};
+\end{tikzpicture}
+
+\item \Verb+cylinder to next+
+
+This is a cylinder that has been skewed to one side, thus following the same path as the \Verb+pair of pants+ cobordism but with only one outgoing boundary component.
+The name \Verb+to next+ is because it goes towards the higher-numbered component on the \Verb+pair of pants+.
+
+\begin{tikzpicture}
+\node[draw,tqft/cylinder to next] (a) {};
+\end{tikzpicture}
+
+\item \Verb+cylinder+
+
+This is a straight cylinder.
+
+\begin{tikzpicture}
+\node[draw,tqft/cylinder] (a) {};
+\end{tikzpicture}
+
+\item \Verb+cap+
+
+This is a cap.
+
+\begin{tikzpicture}
+\node[draw,tqft/cap] (a) {};
+\end{tikzpicture}
+
+\item \Verb+cup+
+
+This is a cup (an upside-down cap).
+
+\begin{tikzpicture}
+\node[draw,tqft/cup] (a) {};
+\end{tikzpicture}
+
+\end{enumerate}
+
+The general shape is controlled by the following keys:
+
+\begin{itemize}
+\item \DescribeMacro{flow} A cobordism ``flows'' from its incoming to its outgoing boundaries.
+This key controls the direction of that flow.
+The shape is transformed so that the incoming-outgoing axis aligns with the argument.
+However, the transformation may be more than just a rotation as the shape is set up so that the numbering of the boundary components is always left-to-right or top-to-bottom (as appropriate).
+Currently, this key can take the values \Verb+north+, \Verb+south+ (default), \Verb+east+, and \Verb+west+.
+
+\item \DescribeMacro{view from} To get a simulated 3D effect, the cobordism is drawn as if viewed from a slight angle.
+The value of this key determines whether the cobordism is viewed from the direction of the incoming boundary components or the outgoing ones.
+This key can take the values \Verb+incoming+ and \Verb+outgoing+.
+The default is \Verb+outgoing+.
+\item \DescribeMacro{cobordism height} This is the height of the cobordism (``height'' interpreted in its own internal coordinate system).
+With no offset (q.v.), this would be the distance between the centres of the first incoming and first outgoing boundary components.
+
+\item \DescribeMacro{boundary separation} This is the distance between the centres of the boundary components of the same type.
+
+\item \DescribeMacro{circle width} This is the half-width of the boundary circles.
+
+\item \DescribeMacro{circle depth} This is the half-depth of the boundary circles (``depth'' since, in the internal coordinate system, this corresponds to the \(z\)-axis out of the page).
+
+\item \DescribeMacro{incoming boundary components} The number of incoming boundary components (can be zero).
+
+\item \DescribeMacro{outgoing boundary components} The number of outgoing boundary components (can be zero).
+
+\item \DescribeMacro{offset} This offsets the first outgoing boundary component horizontally relative to the first incoming boundary component.
+It is a dimensionless number (not necessarily an integer) and is interpreted so that a value of \(1\) aligns the first outgoing boundary component with the second incoming boundary component.
+\end{itemize}
+
+\subsection{Styling}
+
+There are various options for styling the diagrams.
+To understand how they work, it is important to know the order in which a cobordism is drawn and how many pieces it decomposes into.
+This is the following list, with the corresponding key:
+
+\begin{enumerate}
+\item The boundary circles are drawn.
+\Verb+boundary style+
+\item The lower edges of the boundary circles are redrawn.
+\Verb+boundary lower style+
+\item The cobordism itself is drawn.
+\item The non-boundary edge of the cobordism is redrawn.
+\Verb+cobordism style+
+\item The upper edges of the boundary circles are redrawn.
+\Verb+boundary upper style+
+\end{enumerate}
+
+The fact that there are so many is to allow different style to be applied to different pieces.
+The duplication is to allow certain composite pieces to be \emph{filled}.
+All of these items can be styled separately.
+The style given to the node itself is passed on to the third item in that list, the cobordism itself.
+The styles of the others are controlled by a series of keys, each of should be a list of styles to be applied to that component.
+Not all options make sense, in particular only the first and third can be filled.
+(That is, the \Verb+fill+ style is ignored on the other components.)
+Here is a progressively built up cobordism.
+
+\begin{example}
+\begin{tikzpicture}
+\begin{scope}[tqft/boundary style={fill=purple,fill opacity=1}]
+\node[tqft/cylinder] at (1,0) {};
+\begin{scope}[tqft/boundary lower style={draw,dashed,green,thick}]
+\node[tqft/cylinder] at (2,0) {};
+\begin{scope}
+\node[tqft/cylinder,fill=yellow,fill opacity=.7] at (3,0) {};
+\begin{scope}[tqft/cobordism style={draw,thick,blue}]
+\node[tqft/cylinder,fill=yellow,fill opacity=.7] at (4,0) {};
+\begin{scope}[tqft/boundary upper style={draw,thick,orange}]
+\node[tqft/cylinder,fill=yellow,fill opacity=.7] at (5,0) {};
+\end{scope}
+\end{scope}
+\end{scope}
+\end{scope}
+\end{scope}
+\end{tikzpicture}
+\end{example}
+
+\subsection{Anchors}
+
+As with all PGF node shapes, there are certain anchors defined by the \Verb+tqft+ shape.
+These are the \Verb+center+ (and \Verb+centre+) anchors and the \Verb+incoming boundary n+, \Verb+outgoing boundary n+ anchors.
+The positioning of the \Verb+center+ anchor is slightly unusual in that if there are no, say, incoming boundary components then the centre anchor is still at the same height above the outgoing boundary components as if there were incoming boundary components.
+The reason for this is two-fold: computing the \emph{actual} centre of the shape in such circumstances would be tricky, and when aligning these shapes it is more useful to have the anchors consistent across shapes of varying boundary components.
+
+There are also the directional anchors \Verb+north+, \Verb+south+, \Verb+east+, \Verb+west+, \Verb+north east+, \Verb+north west+, \Verb+south east+, \Verb+south west+.
+The \Verb+east+ and \Verb+west+ anchors are placed at the midpoints of the sides.
+The \Verb+north+ and \Verb+south+ anchors are placed in a vertical line with the \Verb+center+ anchor and vertically aligned with the centres of the corresponding boundary circles.
+The other four directional anchors are placed at the corners of the cobordism (the placement of these anchors in the case that there are no boundary circles in the corresponding direction may change in future versions).
+
+The \Verb+incoming boundary n+ and \Verb+outgoing boundary n+ are placed at the centres of the corresponding boundary components, with the numbering starting at the left or the top as appropriate to the flow of the cobordism.
+A hack borrowed from the \Verb+regular polygon+ shape ensures that there are always enough anchors for the boundary components.
+
+There are also anchors placed at the midpoint of the cobordism edge between the boundary circles.
+The names of these are \Verb+after incoming boundary n+ and \Verb+after outgoing boundary n+.
+
+The above anchors can all be ``floated'' off the cobordism using the keys \Verb+outer sep+, \Verb+outer xsep+, and \Verb+outer ysep+.
+The last two are the ones actually used, the first is a shortcut for setting both simultaneously.
+
+There are also ``sub-nodes''.
+Provding the main node is named, each boundary circle is covered by a \Verb+tqft boundary circle+ node.
+This means that the anchors of the \Verb+tqft boundary circle+ can be used.
+These cannot be used for placing the main shape, but can be used afterwards.
+These are not affected by the \Verb+outer (x/y)sep+ keys.
+The names of these sub-nodes are of the form \Verb+name incoming n+ and \Verb+name outgoing n+ where \Verb+name+ is the name of the main node.
+The \Verb+tqft boundary circle+ shape is based on an ellipse and defines a boundary so the syntax \Verb+(name.angle)+ works as expected.
+It also defines anchors \Verb+next+, \Verb+prior+, \Verb+above+, and \Verb+below+.
+These correspond to where the boundary circle in the prescribed direction should be placed.
+
+\begin{example}
+\begin{tikzpicture}
+\node[tqft, incoming boundary components=2,outgoing boundary components=4,offset=-1,draw] (a) {};
+\foreach \anchor/\placement in
+{
+north/above,
+south/below,
+east/right,
+west/left,
+north west/left,
+south west/left,
+north east/right,
+south east/right,
+incoming boundary 1/above left,
+incoming boundary 2/above right,
+outgoing boundary 1/below left,
+outgoing boundary 4/below right,
+after outgoing boundary 1/below}
+\draw[shift=(a.\anchor)] plot[mark=x] coordinates{(0,0)} node[\placement] {\scriptsize\texttt{(a.\anchor)}};
+\end{tikzpicture}
+\end{example}
+
+\begin{example}
+\begin{tikzpicture}
+\node[tqft,cylinder, circle width=2cm, circle depth=1cm, cobordism height=4cm,boundary separation=3cm,draw] (b) {};
+\foreach \anchor/\placement in
+{
+prior/left,
+next/right,
+above/above,
+below/below,
+0/right,
+60/right,
+200/left}
+\draw[shift=(b incoming 1.\anchor)] plot[mark=x] coordinates{(0,0)} node[\placement] {\scriptsize\texttt{(b incoming 1.\anchor)}};
+\end{tikzpicture}
+\end{example}
+
+\subsection{Improvements}
+
+Here are some ideas for extending this, and some minor ``bugs''.
+
+\begin{enumerate}
+\item Make \Verb+incoming boundary+ an alias of \Verb+incoming boundary 1+ so that if there is only one incoming boundary component then we don't need to specify the number (ditto outgoing).
+\item No thought has been given as to where the text gets placed if it is specified.
+\item Add the ability to hide certain boundary components.
+This is useful if the shapes are not specified in their natural order so certain boundary components should be hidden behind earlier drawn shapes.
+\item Some style options on the main node get passed to the other pieces (\Verb+fill opacity+ being one).
+This shouldn't happen, or should happen by design not by accident.
+\item The bounding box isn't as good as it could be.
+\item Add a way to specify more directions for the flow.
+\item Add the ability to apply different styles to the incoming and outgoing components.
+\end{enumerate}
+
+\subsection{More Examples}
+
+\begin{example}
+\begin{tikzpicture}[tqft/cobordism height=1.5cm,tqft/boundary separation=1.5cm]
+\foreach \coord/\style in {
+{(0,0)}/{tqft/view from=outgoing,fill},
+{(5,0)}/{tqft/view from=incoming,draw},
+{(0,-8)}/{fill=orange,fill opacity=.5,tqft/boundary lower style={draw,blue,ultra thin,dashed},tqft/boundary upper style={draw,green},tqft/cobordism style={draw,purple},tqft/boundary style={fill=yellow}},
+{(5,-8)}/{fill=orange,fill opacity=.5,tqft/cobordism style={draw,purple},tqft/boundary style={fill=yellow,draw=green}}
+} {
+\begin{scope}[every node/.style/.expand once=\style]
+\node[tqft/cap] (h) at \coord {};
+\node[tqft/pair of pants,anchor=incoming boundary 1] (a) at (h.outgoing boundary 1) {};
+\node[tqft/cylinder to next,anchor=incoming boundary 1] (d) at (a.incoming boundary 2) {};
+\node[tqft/reverse pair of pants,anchor=incoming boundary 1] (b) at (a.outgoing boundary 2) {};
+\node[tqft/cylinder to prior,anchor=incoming boundary 1] (c) at (b.outgoing boundary 1) {};
+\node[tqft/cylinder,anchor=incoming boundary 1] (e) at (a.outgoing boundary 1) {};
+\node[tqft/cylinder,anchor=incoming boundary 1] (f) at (e.outgoing boundary 1) {};
+\node[tqft/reverse pair of pants,anchor=incoming boundary 1] (g) at (f.outgoing boundary 1) {};
+\node[tqft/cup,anchor=incoming boundary 1] (i) at (g.outgoing boundary 1) {};
+\end{scope}
+}
+\end{tikzpicture}
+\end{example}
+
+\begin{example}
+\begin{tikzpicture}
+\node[draw,tqft/pair of pants] (a) {};
+\node[draw,tqft/cap,anchor=outgoing boundary 1] at (a.incoming boundary 1) {};
+\node[fill,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 1) {};
+\node[draw,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 2) {};
+\begin{scope}[tqft/flow=east]
+\node[draw,tqft/pair of pants] (a) at (4,0) {};
+\node[draw,tqft/cap,anchor=outgoing boundary 1] at (a.incoming boundary 1) {};
+\node[fill,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 1) {};
+\node[draw,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 2) {};
+\end{scope}
+\begin{scope}[tqft/flow=north]
+\node[draw,tqft/pair of pants] (a) at (0,-4) {};
+\node[draw,tqft/cap,anchor=outgoing boundary 1] at (a.incoming boundary 1) {};
+\node[fill,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 1) {};
+\node[draw,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 2) {};
+\end{scope}
+\begin{scope}[tqft/flow=west]
+\node[draw,tqft/pair of pants] (a) at (4,-4) {};
+\node[draw,tqft/cap,anchor=outgoing boundary 1] at (a.incoming boundary 1) {};
+\node[fill,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 1) {};
+\node[draw,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 2) {};
+\end{scope}
+\end{tikzpicture}
+\end{example}
+
+\end{document}
Property changes on: trunk/Master/texmf-dist/doc/latex/tqft/tqft.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/tqft/tqft_code.pdf
===================================================================
(Binary files differ)
Deleted: trunk/Master/texmf-dist/doc/latex/tqft/tqft_doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tqft/tqft_doc.tex 2024-06-01 20:20:59 UTC (rev 71400)
+++ trunk/Master/texmf-dist/doc/latex/tqft/tqft_doc.tex 2024-06-01 20:21:17 UTC (rev 71401)
@@ -1,987 +0,0 @@
-\documentclass{ltxdoc}
-\usepackage[T1]{fontenc}
-\usepackage{lmodern}
-\usepackage{morefloats}
-\usepackage[svgnames]{xcolor}
-\usepackage{tikz}
-\usepackage{tqft}
-\usetikzlibrary{tqft}
-\usepackage[numbered]{hypdoc}
-\definecolor{lstbgcolor}{rgb}{0.9,0.9,0.9}
-
-\usepackage{listings}
-\lstloadlanguages{[LaTeX]TeX}
-\lstset{breakatwhitespace=true,breaklines=true,language=TeX}
-
-\usepackage{fancyvrb}
-
-\newenvironment{example}
- {\VerbatimEnvironment
- \begin{VerbatimOut}{example.out}}
- {\end{VerbatimOut}
- \begin{center}
- \setlength{\parindent}{0pt}
- \fbox{\begin{minipage}{.9\linewidth}
- \lstset{breakatwhitespace=true,breaklines=true,language=TeX,basicstyle=\small}
- \lstinputlisting[]{example.out}
- \end{minipage}}
-
- \fbox{\begin{minipage}{.9\linewidth}
- \centering
- \input{example.out}
- \end{minipage}}
-\end{center}
-}
-
-\providecommand*{\url}{\texttt}
-\GetFileInfo{tqft.sty}
-
-
-\title{The \textsf{tqft} Ti\emph{k}Z Library: Documentation}
-\author{Andrew Stacey \\ \url{loopspace at mathforge.org}}
-
-\begin{document}
-
-\maketitle
-
-\begin{center}
-\begin{tikzpicture}[
- scale=.5,
- every tqft/.style={
- transform shape
- },
- tqft/cobordism/.style={
- fill=DarkMagenta,
- draw,
- ultra thick},
- ]
- \pic[
- name=a,
- tqft,
- incoming boundary components=0,
- outgoing boundary components=3,
- ];
- \pic[
- name=b,
- at=(a-outgoing boundary 2),
- tqft cylinder,
- anchor=incoming boundary 1,
- ];
- \pic[
- at=(a-outgoing boundary 3),
- name=c,
- tqft,
- incoming boundary components=0,
- outgoing boundary components=2,
- anchor={(0,1)},
- ];
- \pic[
- at=(c-outgoing boundary 1),
- name=d,
- tqft,
- incoming boundary components=3,
- outgoing boundary components=1,
- offset=2.5,
- anchor=incoming boundary 1,
- boundary separation=1cm,
- cobordism height=2.5cm,
- ];
- \pic[
- at=(c-outgoing boundary 2),
- name=e,
- tqft,
- rotate=90,
- incoming boundary components=0,
- outgoing boundary components=3,
- anchor={(2,-.5)}
- ];
- \pic[
- at=(e-outgoing boundary 3),
- name=f,
- tqft cylinder,
- rotate=90,
- anchor=incoming boundary 1,
- ];
- \pic[
- at=(e-outgoing boundary 2),
- name=g,
- tqft cylinder,
- rotate=90,
- anchor=incoming boundary 1,
- ];
- \pic[
- at=(g-outgoing boundary 1),
- name=h,
- tqft,
- anchor={(0,1)},
- incoming boundary components=0,
- outgoing boundary components=3,
- ];
- \pic[
- at=(h-outgoing boundary 2),
- name=i,
- tqft cylinder,
- anchor=incoming boundary 1,
- ];
-\end{tikzpicture}
-\end{center}
-
-\section{Introduction}
-This package defines some Ti\emph{k}Z/PGF picture shapes that can be used to construct the diagrams common in Topological Quantum Field Theory (TQFT).
-An example follows:
-
-\begin{example}
-\begin{tikzpicture}[tqft/cobordism/.style={draw}]
-\pic[tqft/pair of pants,name=a];
-\pic[tqft/cylinder to next,anchor=incoming boundary 1,name=c,at=(a-outgoing boundary 1)];
-\pic[tqft/reverse pair of pants, anchor=incoming boundary 1,at=(a-outgoing boundary 2)];
-\end{tikzpicture}
-\end{example}
-
-\tableofcontents
-
-\section{History}
-
-This is the second version of the TQFT package.
-The first version used nodes to draw the shapes.
-However, with the advent of Ti\emph{k}Z3.0 came the ability to define subdrawings called \Verb+pic+s which were a bit like nodes but were geared more towards drawings than containers for text.
-This seems a much more suitable mechanism for drawing these diagrams and so the package has been rewritten to make use of this new facility.
-
-The second version is designed to be similar to the first, but with some improvements.
-The original version was distributed as a \Verb+.sty+ file and so is loaded using \Verb+\usepackage{tqft}+.
-The newer version is a Ti\emph{k}Z library and so is loaded using \Verb+\usetikzlibrary{tqft}+.
-This makes it possible to use both in the same document.
-This is not recommended, but an attempt has been made to make it possible to switch between the two methods.
-This hasn't been extensively tested so use with caution.
-To make the switch use the key \Verb+/tikz/tqft/use nodes=<true|false>+.
-By default, the one loaded last should be in effect at the start of the document.
-
-\section{Keys}
-
-Before giving any details, a word is in order about the keys involved in this package.
-There are many options and keys that can be set via the \Verb+\pgfkeys+ system (which is used for setting options in Ti\emph{k}Z).
-Such keys live in a ``directory'' but often that can be omitted.
-For example, in the Ti\emph{k}Z command \Verb+\draw[red] (0,0) -- (1,0);+ the key \Verb+red+ is actually in the ``directory'' \Verb+/tikz+ but it is not necessary to specify that as it is assumed.
-Defining a ``directory'' helps separate keys and ensure that there is no conflict.
-The keys in this library are (mostly) defined in the directories \Verb+/tikz/tqft+ (the newer version) and \Verb+/pgf/tqft+ (the old version).
-
-Invoking \Verb+/tikz/tqft+ itself sets the ``current directory'' to whichever directory is right for the current version in force and so all subsequent keys do not need prefixing.
-Moreover, any unknown keys are passed on to the \Verb+/tikz+ directory so there is (or should be!) no harm in mixing \Verb+tqft+ specific keys with ordinary Ti\emph{k}Z keys.
-Some examples take advantage of this switch so when copying and modifying examples from this document, it is important to remember that the first \Verb+tqft+ specific key needs an explicit \Verb+tqft/+ prefix.
-
-
-\section{Version 2.0}
-
-\subsection{The Shapes}
-
-There is only one picture shape: \Verb+cobordism+.
-This is a cobordism between a number of incoming circles and a number of outgoing circles, where the numbers of boundary components can be specified as options to the shape.
-There are certain common shapes that are predefined as aliases to the main shape with specified boundaries.
-The list of predefined shapes follows.
-The names are all in the \Verb+tqft+ family, but an alias is made so that \Verb+tqft <shape>+ will work without any further qualification.
-
-\begin{enumerate}
-\item \Verb+pair of pants+
-
-\begin{tikzpicture}
-\pic[draw,tqft/pair of pants];
-\end{tikzpicture}
-
-\item \Verb+reverse pair of pants+
-
-\begin{tikzpicture}
-\pic[draw,tqft/reverse pair of pants];
-\end{tikzpicture}
-
-\item \Verb+cylinder to prior+
-
-This is a cylinder that has been skewed to one side, thus following the same path as the \Verb+pair of pants+ cobordism but with only one outgoing boundary component.
-The name \Verb+to prior+ is because it goes towards the lower-numbered component on the \Verb+pair of pants+.
-
-\begin{tikzpicture}
-\pic[draw,tqft/cylinder to prior];
-\end{tikzpicture}
-
-\item \Verb+cylinder to next+
-
-This is a cylinder that has been skewed to one side, thus following the same path as the \Verb+pair of pants+ cobordism but with only one outgoing boundary component.
-The name \Verb+to next+ is because it goes towards the higher-numbered component on the \Verb+pair of pants+.
-
-\begin{tikzpicture}
-\pic[draw,tqft/cylinder to next];
-\end{tikzpicture}
-
-\item \Verb+cylinder+
-
-This is a straight cylinder.
-
-\begin{tikzpicture}
-\pic[draw,tqft/cylinder];
-\end{tikzpicture}
-
-\item \Verb+cap+
-
-This is a cap.
-
-\begin{tikzpicture}
-\pic[draw,tqft/cap];
-\end{tikzpicture}
-
-\item \Verb+cup+
-
-This is a cup (an upside-down cap).
-
-\begin{tikzpicture}
-\pic[draw,tqft/cup];
-\end{tikzpicture}
-
-\end{enumerate}
-
-The general shape is controlled by the following keys:
-
-\begin{itemize}
-\item \DescribeMacro{view from} To get a simulated 3D effect, the cobordism is drawn as if viewed from a slight angle.
-The value of this key determines whether the cobordism is viewed from the direction of the incoming boundary components or the outgoing ones.
-This key can take the values \Verb+incoming+ and \Verb+outgoing+.
-The default is \Verb+outgoing+.
-\item \DescribeMacro{cobordism height} This is the height of the cobordism (``height'' interpreted in its own internal coordinate system).
-With no offset (q.v.), this would be the distance between the centres of the first incoming and first outgoing boundary components.
-
-\item \DescribeMacro{boundary separation} This is the distance between the centres of the boundary components of the same type.
-
-\item \DescribeMacro{circle x radius} This is the half-width of the boundary circles.
-
-\item \DescribeMacro{circle y radius} This is the half-depth of the boundary circles (``depth'' since, in the internal coordinate system, this corresponds to the \(z\)-axis out of the page).
-
-\item \DescribeMacro{incoming boundary components} The number of incoming boundary components (can be zero).
-
-\item \DescribeMacro{skip incoming boundary components} A list of incoming boundary components to be skipped.
-
-\item \DescribeMacro{outgoing boundary components} The number of outgoing boundary components (can be zero).
-
-\item \DescribeMacro{skip outgoing boundary components} A list of outgoing boundary components to be skipped.
-
-\item \DescribeMacro{offset} This offsets the first outgoing boundary component horizontally relative to the first incoming boundary component.
-It is a dimensionless number (not necessarily an integer) and is interpreted so that a value of \(1\) aligns the first outgoing boundary component with the second incoming boundary component.
-
-\item \DescribeMacro{genus} This defines the number of holes in the shape.
-These are spread out in a horizontal line in the middle of the shape.
-\end{itemize}
-
-\subsection{Styling}
-
-There are various options for styling the diagrams.
-To understand how they work, it is important to know the order in which a cobordism is drawn and how many pieces it decomposes into.
-This is the following list, with the corresponding keys:
-
-\begin{enumerate}
-\item The boundary circles are drawn.
-These are actually elliptical nodes (and thus can be individually styled).
-Applicable styles:
-
-\begin{itemize}
-\item \Verb+every boundary component+,
-\item \Verb+every incoming boundary component+,\\
-or \Verb+every outgoing boundary component+,
-\item \Verb+incoming boundary component <n>+,\\
-or \Verb+outgoing boundary component <n>+
-\end{itemize}
-
-\item The lower edges of the boundary circles are redrawn.
-These are individual arcs.
-
-\begin{itemize}
-\item \Verb+every lower boundary component+,
-\item \Verb+every incoming lower boundary component+,\\or \Verb+every outgoing lower boundary component+,
-\item \Verb+incoming lower boundary component <n>+,\\or \Verb+outgoing lower boundary component <n>+
-\end{itemize}
-
-\item The full edge of the cobordism is drawn.
-This is a closed path so can be sensibly filled.
-It is clipped against a path defined by the genus of the cobordism which results in holes if it is filled (or shaded or anything else that goes in to the interior).
-
-\begin{itemize}
-\item \Verb+cobordism+,
-\item also, any actions specified on the \Verb+pic+ are applied here (specifically, the \Verb+pic actions+ key is invoked; see the Ti\emph{k}Z manual for full details on this),
-\item \Verb+cobordism outer path+.
-\end{itemize}
-
-\item Any holes specified by the genus are now drawn.
-These are styled to give the 3D impression, and this follows the direction specified by the \Verb+view from+ key.
-The paths are split so that each can be individually styled.
-
-\begin{itemize}
-\item \Verb+cobordism+, this style is applied because the curves defined by the genus can be thought of as part of the edge of the cobordism shape.
-\item \Verb+pic actions+, for the same reason as above.
-
-However, following this key then \Verb+fill=none,shade=none+ is issued.
-This is because even if the main shape is filled or shaded, the paths drawing the holes should almost certainly not be.
-\item \Verb+cobordism edge+, the same logic applies to the edge path (q.v.).
-\item \Verb+genus style+,
-\item \Verb+genus upper+ or \Verb+genus lower+,
-\item \Verb+hole <n>+,
-\item \Verb+hole <n> upper+ or \Verb+hole <n> lower+.
-\end{itemize}
-
-\item The non-boundary edge of the cobordism is redrawn.
-This is split in to pieces to allow for individual styling.
-
-\begin{itemize}
-\item \Verb+cobordism edge+,
-\item \Verb+cobordism outer edge+,
-\item \Verb+between incoming+, or \Verb+between outgoing+, or \Verb+between incoming and outgoing+.
-The latter is for the two sides, but note that if the cobordism has no incoming or no outgoing components then it also applies to the ``over the top'' edge.
-\item \Verb+<anchor>+, where the \Verb+<anchor>+ is the name of the anchor that lies on the midpoint of the curve, so it will be one of:
-%
-\begin{itemize}
-\item \Verb=between incoming <n> and <n+1>=,
-\item \Verb=between outgoing <n> and <n+1>=,
-\item \Verb+between first incoming and first outgoing+,
-\item \Verb+between first incoming and first outgoing+,
-\item \Verb+between last incoming and last outgoing+,
-\item \Verb+between first and last incoming+,
-\item \Verb+between first and last outgoing+.
-\end{itemize}
-\end{itemize}
-
-\item The upper edges of the boundary circles are redrawn.
-These are arcs.
-
-\begin{itemize}
-\item \Verb+every upper boundary component+,
-\item \Verb+every incoming upper boundary component+,\\or \Verb+every outgoing upper boundary component+,
-\item \Verb+incoming upper boundary component <n>+,\\or \Verb+outgoing upper boundary component <n>+
-\end{itemize}
-\end{enumerate}
-
-The fact that there are so many is to allow different style to be applied to different pieces and to give as much control as possible, whilst still making it fairly straightforward to draw a simple cobordism.
-The duplication of paths is to allow certain composite pieces to be \emph{filled}.
-Here is a progressively built up cobordism.
-
-\begin{example}
-\begin{tikzpicture}[tqft/view from=incoming]
-\begin{scope}[tqft/every boundary component/.style={fill=green,fill opacity=1}]
-\pic[tqft/cylinder,at={(1,0)}];
-\begin{scope}[tqft/every lower boundary component/.style={draw=purple,thick}]
-\pic[tqft/cylinder,at={(2,0)}];
-\begin{scope}[tqft/cobordism/.style={fill=yellow,fill opacity=.7}]
-\pic[tqft/cylinder,at={(3,0)}];
-\begin{scope}[tqft/cobordism edge/.style={draw,thick,blue}]
-\pic[tqft/cylinder,fill=yellow,fill opacity=.7,at={(4,0)}];
-\begin{scope}[tqft/every upper boundary component/.style={draw,thick,orange}]
-\pic[tqft/cylinder,fill=yellow,fill opacity=.7,at={(5,0)}];
-\end{scope}
-\end{scope}
-\end{scope}
-\end{scope}
-\end{scope}
-\end{tikzpicture}
-\end{example}
-
-Here's an example with lots of styling.
-
-\begin{example}
-\begin{tikzpicture}
-\pic[
- tqft,
- incoming boundary components=3,
- outgoing boundary components=3,
- offset=1,
- genus=3,
- hole 3/.style={ultra thick, purple,solid},
- genus lower/.style={dashed},
- fill=red!50,
- cobordism edge/.style={draw},
- between incoming and outgoing/.style={dotted},
- between outgoing 2 and 3/.style={ultra thick},
-];
-\end{tikzpicture}
-\end{example}
-
-\subsection{Anchors}
-
-The cobordism is a \Verb+pic+ so does not have any native anchors.
-Nevertheless, a multitude of coordinates are defined that simulate the anchors associated with nodes.
-There is also support for specifying the shape to be located relative to a particular anchor.
-
-The \Verb+\pic+ should be named via the \Verb+name=<prefix>+ key, whereupon the anchors are prefixed by this value.
-The pseudo-anchors defined have the naming convention \Verb+<prefix>-<anchor name>+ (at the moment, it doesn't check to see if the \Verb+name+ key has been specified so if it isn't then the pseudo-anchors are still defined but with an empty prefix).
-They are:
-%
-\begin{itemize}
-\item \Verb+incoming boundary <n>+, these are in fact elliptical nodes and so also define actual anchors.
-\item \Verb+incoming boundary+ is an alias for \Verb+incoming boundary 1+.
-\item \Verb+outgoing boundary <n>+, same.
-\item \Verb+outgoing boundary+ is an alias for \Verb+outgoing boundary 1+.
-\item \Verb=between incoming <n> and <n+1>=, this lies on the midpoint of the curve between successive boundary components.
-\item \Verb=between outgoing <n> and <n+1>=, this lies on the midpoint of the curve between successive boundary components.
-\item \Verb=between first incoming and first outgoing= is on the edge between the first incoming and first outgoing boundary components; note that this is only defined if there are both incoming and outgoing boundary components.
-\item \Verb=between last incoming and last outgoing= is on the edge between the last incoming and last outgoing boundary components; note that this is only defined if there are both incoming and outgoing boundary components.
-\item \Verb=between first and last incoming=; this is only defined if there are no outgoing components.
-\item \Verb=between first and last outgoing=; this is only defined if there are no incoming components.
-\item \Verb=hole <n>=; if the genus is non-zero, this points to the centre of the \(n\)th hole.
-\end{itemize}
-
-To place the shape relative to an anchor, use the \Verb+tqft/anchor+ key.
-The argument should be just the name of the anchor without the leading \Verb+<prefix>-+.
-The \Verb+anchor+ key can also take another type of argument.
-If its argument is of the form \Verb+(x,y)+ then this is taken as a pseudo-coordinate\footnote{Note that due to the presence of the comma, this type of argument must be protected by braces.}.
-It is interpreted as being \(x\) boundary components across and \(y\) times the cobordism height down.
-However, if an \Verb+offset+ is specified then the resulting \(x\) value is shifted so that if \(y < 0\) then \((1,y)\) is in line with the first incoming boundary component and if \(y > 1\) then \((1,y)\) is in line with the first outgoing boundary component.
-If \(0 < y < 1\) then \((1,y)\) linearly interpolates between the first incoming and first outgoing boundary components.
-Thus \((1,0)\) is the first incoming boundary component, \((1,1)\) the first outgoing boundary component, \((0,0)\) is one unit to the left of the first incoming, and \((1,2)\) one unit below the first outgoing.
-Note that the picture is shifted to put this point at the current coordinate.
-
-\begin{example}
-\begin{tikzpicture}
-\pic[tqft, incoming boundary components=2,outgoing boundary components=4,offset=-1,draw,name=a];
-\foreach \anchor/\placement in
-{
-between first incoming and first outgoing/left,
-between last incoming and last outgoing/right,
-between outgoing 2 and 3/above,
-incoming boundary 1/above left,
-incoming boundary 2/above right,
-outgoing boundary 1/below left,
-outgoing boundary 4/below right}
-\draw[overlay,shift=(a-\anchor)] plot[mark=x] coordinates{(0,0)} node[\placement] {\scriptsize\texttt{(a-\anchor)}};
-\path (a-incoming boundary) +(0,.5) (a-outgoing boundary) +(0,-1);
-\end{tikzpicture}
-\end{example}
-
-\subsection{Notes}
-
-\begin{enumerate}
-\item Like \Verb+node+s, \Verb+pic+s need the \Verb+transform shape+ key to be set to take note of external transformations (other than shifts).
-Also, as the tqft pic uses nodes internally, if you use the \Verb+transform shape+ key on the pic, you might find you need to use \Verb+every node/.style={transform shape}+ as well.
-\item There is an additional \Verb+every tqft+ key which is run when the \Verb+tqft+ key is invoked (which might be via some other key).
-This is better placed than the \Verb+every pic+ key since that applies to a surrounding scope rather than to the \Verb+pic+ itself.
-\item If the \Verb+tqft+ key is invoked, either implicitly or explicitly, then the \Verb+pic type+ is set to \Verb+cobordism+.
-This has the side effect that the invoking syntax has to be completely set by keys; so the \Verb+pic (<name>) at (<coord>) {<type>}+ cannot be used.
-Rather, the \Verb+name+ and \Verb+at+ have to be specified by keys and the \Verb+type+ omitted.
-
-\item If upgrading from the previous version of TQFT, as well as shifting from a \Verb+node+ to a \Verb+pic+, the following changes have been made in the implementation:
-
-\begin{itemize}
-\item The \Verb+flow+ key has not made it across to the new version.
-Use \Verb+transform shape+ and apply your own transformation.
-
-\item The \Verb+circle width+ and \Verb+circle depth+ are now \Verb+circle x radius+ and \Verb+circle y radius+ (the old names weren't correct anyway).
-
-\item The bounding box is a little better, particularly for cobordisms with only one type of boundary component.
-\end{itemize}
-\end{enumerate}
-
-\subsection{More Examples}
-
-\begin{example}
-\begin{tikzpicture}[tqft/cobordism height=1.5cm,tqft/boundary separation=1.5cm]
-\foreach \coord/\style in {
-{(0,0)}/{tqft/view from=outgoing,fill},
-{(5,0)}/{tqft/view from=incoming,draw},
-{(0,-8)}/{fill=orange,fill opacity=.5,tqft/every lower boundary component/.style={draw,blue,ultra thin,dashed},tqft/every upper boundary component/.style={draw,green},tqft/cobordism edge/.style={draw,purple},tqft/every boundary component/.style={fill=yellow}},
-{(5,-8)}/{fill=orange,fill opacity=.5,tqft/cobordism edge/.style={draw,purple},tqft/every boundary component/.style={fill=yellow,draw=green}}
-} {
-\begin{scope}
-\edef\styleit{\noexpand\tikzset{every tqft/.style={\style}}}
-\styleit
-\pic[tqft/cap,name=h,at=\coord];
-\pic[tqft/pair of pants,anchor=incoming boundary 1,name=a,at=(h-outgoing boundary 1)];
-\pic[tqft/cylinder to next,anchor={(0,1)},name=d,at=(a-outgoing boundary 2)];
-\pic[tqft/reverse pair of pants,anchor=incoming boundary 1,name=b,at=(a-outgoing boundary 2)];
-\pic[tqft/cylinder to prior,anchor=incoming boundary 1,name=c,at=(b-outgoing boundary 1)];
-\pic[tqft/cylinder,anchor=incoming boundary 1,name=e,at=(a-outgoing boundary 1)];
-\pic[tqft/cylinder,anchor=incoming boundary 1,name=f,at=(e-outgoing boundary 1)];
-\pic[tqft/reverse pair of pants,anchor=incoming boundary 1,name=g,at=(f-outgoing boundary 1)];
-\pic[tqft/cup,anchor=incoming boundary 1,name=i,at=(g-outgoing boundary 1)];
-\end{scope}
-}
-\end{tikzpicture}
-\end{example}
-
-\begin{example}
-\begin{tikzpicture}[every tqft/.append style={transform shape}]
-\foreach \ang in {0,90,180,270} {
-\begin{scope}[rotate=\ang]
-\pic[draw,tqft/pair of pants,name=a,at={(3,3)}];
-\pic[draw,tqft/cap,anchor=outgoing boundary 1,at=(a-incoming boundary 1)];
-\pic[fill,tqft/cup,anchor=incoming boundary 1,at=(a-outgoing boundary 1)];
-\pic[draw,tqft/cup,anchor=incoming boundary 1,at=(a-outgoing boundary 2)];
-\end{scope}
-}
-\end{tikzpicture}
-\end{example}
-
-\begin{example}
-\begin{tikzpicture}[
- tqft,
- every outgoing boundary component/.style={fill=blue!50},
- outgoing boundary component 3/.style={fill=none,draw=red},
- every incoming boundary component/.style={fill=green!50},
- every lower boundary component/.style={draw,ultra thick, dashed},
- every upper boundary component/.style={draw,purple},
- cobordism/.style={fill=red!50},
- cobordism edge/.style={draw},
- genus=3,
- hole 2/.style={ultra thick, blue},
- view from=incoming,
- anchor=between incoming 1 and 2
-]
-\pic[rotate=90,every node/.style={transform shape},name=a,tqft,incoming boundary components=5,skip incoming boundary components={2,4},outgoing boundary components=7,skip outgoing boundary components={2,3,5},offset=-.5];
-
-\begin{scope}[every pin edge/.style={<-}]
-\foreach \anchor/\ang in {
- hole 1/-90,
- hole 2/90,
- hole 3/-90,
- incoming boundary 3/90,
- outgoing boundary 4/-90,
- between last incoming and last outgoing/180,
- between first incoming and first outgoing/180,
- between incoming 1 and 3/90,
- between outgoing 1 and 4/-90,
- between outgoing 4 and 6/-90
-} {
- \node[pin=\ang:\anchor,at=(a-\anchor),inner sep=0pt] {};
-}
-\draw[<-] (0,0) -- ++(0,3);
-\end{scope}
-\end{tikzpicture}
-\end{example}
-
-%\begin{example}
-\begin{tikzpicture}
-\pic[
- tqft,
- incoming boundary components=2,
- outgoing boundary components=2,
- genus=2,
- draw,
- name=a
-];
-\pic[
- tqft,
- incoming boundary components=2,
- outgoing boundary components=1,
- draw,
- at=(a-outgoing boundary 1),
- offset=.5,
- cobordism height=1cm,
- name=b
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=3,
- draw,
- at=(b-outgoing boundary 1),
- offset=-1,
- name=c
-];
-\pic[tqft,
- incoming boundary components=2,
- outgoing boundary components=1,
- draw,
- at=(c-outgoing boundary 1),
- anchor=incoming boundary 2,
- name=d,
- boundary separation=1.6cm,
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(c-outgoing boundary 3),
- offset=.5,
- name=e,
- every outgoing lower boundary component/.style={draw}
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(c-outgoing boundary 2),
- name=f
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=2,
- draw,
- at=(f-outgoing boundary),
- name=g,
- offset=-.5,
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(g-outgoing boundary 1),
- name=h,
- offset=-.25,
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(g-outgoing boundary 2),
- name=i,
- offset=.25,
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(h-outgoing boundary),
- name=j,
- every outgoing lower boundary component/.style={draw}
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(i-outgoing boundary),
- name=k,
- every outgoing lower boundary component/.style={draw}
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(d-outgoing boundary),
- name=l
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=0,
- draw,
- at=(l-outgoing boundary),
- name=m
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(d-incoming boundary),
- anchor=outgoing boundary,
- name=n
-];
-\pic[tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- draw,
- at=(n-incoming boundary),
- anchor=outgoing boundary,
- name=o
-];
-\pic[tqft,
- incoming boundary components=3,
- outgoing boundary components=3,
- draw,
- at=(o-incoming boundary),
- anchor={(2,1)},
- name=p,
- boundary separation=1.25cm,
- outgoing lower boundary component 1/.style={draw},
- outgoing lower boundary component 3/.style={draw}
-];
-\pic[tqft,
- incoming boundary components=5,
- outgoing boundary components=5,
- genus=3,
- at=(k-outgoing boundary),
- anchor={(4,-1)},
- draw,
- name=q,
- every outgoing lower boundary component/.style={draw}
-];
-\path (q-incoming boundary 3) ++(0,1) node {\Huge \(=\)};
-\end{tikzpicture}
-%\end{example}
-
-\section{Version 1.0}
-
-\tikzset{tqft/use nodes=true}
-
-\subsection{The Node Shapes}
-
-There are only two shapes, \Verb+tqft cobordism+ and \Verb+tqft boundary circle+.
-The first, which is the main shape, is a cobordism between a number of incoming circles and a number of outgoing circles, where the numbers of boundary components can be specified as options to the shape.
-The second is just the boundary circle.
-It is used as a sub-node of the first to add extra anchors, but can be used by itself.
-There are certain common shapes that are predefined as aliases to the main shape with specified boundaries.
-The list of predefined shapes follows.
-The names are all in the \Verb+tqft+ family, but an alias is made so that \Verb+tqft nodeshape+ will work without any further qualification.
-
-\begin{enumerate}
-\item \Verb+pair of pants+
-
-\begin{tikzpicture}
-\node[draw,tqft/pair of pants] (a) {};
-\end{tikzpicture}
-
-\item \Verb+reverse pair of pants+
-
-\begin{tikzpicture}
-\node[draw,tqft/reverse pair of pants] (a) {};
-\end{tikzpicture}
-
-\item \Verb+cylinder to prior+
-
-This is a cylinder that has been skewed to one side, thus following the same path as the \Verb+pair of pants+ cobordism but with only one outgoing boundary component.
-The name \Verb+to prior+ is because it goes towards the lower-numbered component on the \Verb+pair of pants+.
-
-\begin{tikzpicture}
-\node[draw,tqft/cylinder to prior] (a) {};
-\end{tikzpicture}
-
-\item \Verb+cylinder to next+
-
-This is a cylinder that has been skewed to one side, thus following the same path as the \Verb+pair of pants+ cobordism but with only one outgoing boundary component.
-The name \Verb+to next+ is because it goes towards the higher-numbered component on the \Verb+pair of pants+.
-
-\begin{tikzpicture}
-\node[draw,tqft/cylinder to next] (a) {};
-\end{tikzpicture}
-
-\item \Verb+cylinder+
-
-This is a straight cylinder.
-
-\begin{tikzpicture}
-\node[draw,tqft/cylinder] (a) {};
-\end{tikzpicture}
-
-\item \Verb+cap+
-
-This is a cap.
-
-\begin{tikzpicture}
-\node[draw,tqft/cap] (a) {};
-\end{tikzpicture}
-
-\item \Verb+cup+
-
-This is a cup (an upside-down cap).
-
-\begin{tikzpicture}
-\node[draw,tqft/cup] (a) {};
-\end{tikzpicture}
-
-\end{enumerate}
-
-The general shape is controlled by the following keys:
-
-\begin{itemize}
-\item \DescribeMacro{flow} A cobordism ``flows'' from its incoming to its outgoing boundaries.
-This key controls the direction of that flow.
-The shape is transformed so that the incoming-outgoing axis aligns with the argument.
-However, the transformation may be more than just a rotation as the shape is set up so that the numbering of the boundary components is always left-to-right or top-to-bottom (as appropriate).
-Currently, this key can take the values \Verb+north+, \Verb+south+ (default), \Verb+east+, and \Verb+west+.
-
-\item \DescribeMacro{view from} To get a simulated 3D effect, the cobordism is drawn as if viewed from a slight angle.
-The value of this key determines whether the cobordism is viewed from the direction of the incoming boundary components or the outgoing ones.
-This key can take the values \Verb+incoming+ and \Verb+outgoing+.
-The default is \Verb+outgoing+.
-\item \DescribeMacro{cobordism height} This is the height of the cobordism (``height'' interpreted in its own internal coordinate system).
-With no offset (q.v.), this would be the distance between the centres of the first incoming and first outgoing boundary components.
-
-\item \DescribeMacro{boundary separation} This is the distance between the centres of the boundary components of the same type.
-
-\item \DescribeMacro{circle width} This is the half-width of the boundary circles.
-
-\item \DescribeMacro{circle depth} This is the half-depth of the boundary circles (``depth'' since, in the internal coordinate system, this corresponds to the \(z\)-axis out of the page).
-
-\item \DescribeMacro{incoming boundary components} The number of incoming boundary components (can be zero).
-
-\item \DescribeMacro{outgoing boundary components} The number of outgoing boundary components (can be zero).
-
-\item \DescribeMacro{offset} This offsets the first outgoing boundary component horizontally relative to the first incoming boundary component.
-It is a dimensionless number (not necessarily an integer) and is interpreted so that a value of \(1\) aligns the first outgoing boundary component with the second incoming boundary component.
-\end{itemize}
-
-\subsection{Styling}
-
-There are various options for styling the diagrams.
-To understand how they work, it is important to know the order in which a cobordism is drawn and how many pieces it decomposes into.
-This is the following list, with the corresponding key:
-
-\begin{enumerate}
-\item The boundary circles are drawn.
-\Verb+boundary style+
-\item The lower edges of the boundary circles are redrawn.
-\Verb+boundary lower style+
-\item The cobordism itself is drawn.
-\item The non-boundary edge of the cobordism is redrawn.
-\Verb+cobordism style+
-\item The upper edges of the boundary circles are redrawn.
-\Verb+boundary upper style+
-\end{enumerate}
-
-The fact that there are so many is to allow different style to be applied to different pieces.
-The duplication is to allow certain composite pieces to be \emph{filled}.
-All of these items can be styled separately.
-The style given to the node itself is passed on to the third item in that list, the cobordism itself.
-The styles of the others are controlled by a series of keys, each of should be a list of styles to be applied to that component.
-Not all options make sense, in particular only the first and third can be filled.
-(That is, the \Verb+fill+ style is ignored on the other components.)
-Here is a progressively built up cobordism.
-
-\begin{example}
-\begin{tikzpicture}
-\begin{scope}[tqft/boundary style={fill=purple,fill opacity=1}]
-\node[tqft/cylinder] at (1,0) {};
-\begin{scope}[tqft/boundary lower style={draw,dashed,green,thick}]
-\node[tqft/cylinder] at (2,0) {};
-\begin{scope}
-\node[tqft/cylinder,fill=yellow,fill opacity=.7] at (3,0) {};
-\begin{scope}[tqft/cobordism style={draw,thick,blue}]
-\node[tqft/cylinder,fill=yellow,fill opacity=.7] at (4,0) {};
-\begin{scope}[tqft/boundary upper style={draw,thick,orange}]
-\node[tqft/cylinder,fill=yellow,fill opacity=.7] at (5,0) {};
-\end{scope}
-\end{scope}
-\end{scope}
-\end{scope}
-\end{scope}
-\end{tikzpicture}
-\end{example}
-
-\subsection{Anchors}
-
-As with all PGF node shapes, there are certain anchors defined by the \Verb+tqft+ shape.
-These are the \Verb+center+ (and \Verb+centre+) anchors and the \Verb+incoming boundary n+, \Verb+outgoing boundary n+ anchors.
-The positioning of the \Verb+center+ anchor is slightly unusual in that if there are no, say, incoming boundary components then the centre anchor is still at the same height above the outgoing boundary components as if there were incoming boundary components.
-The reason for this is two-fold: computing the \emph{actual} centre of the shape in such circumstances would be tricky, and when aligning these shapes it is more useful to have the anchors consistent across shapes of varying boundary components.
-
-There are also the directional anchors \Verb+north+, \Verb+south+, \Verb+east+, \Verb+west+, \Verb+north east+, \Verb+north west+, \Verb+south east+, \Verb+south west+.
-The \Verb+east+ and \Verb+west+ anchors are placed at the midpoints of the sides.
-The \Verb+north+ and \Verb+south+ anchors are placed in a vertical line with the \Verb+center+ anchor and vertically aligned with the centres of the corresponding boundary circles.
-The other four directional anchors are placed at the corners of the cobordism (the placement of these anchors in the case that there are no boundary circles in the corresponding direction may change in future versions).
-
-The \Verb+incoming boundary n+ and \Verb+outgoing boundary n+ are placed at the centres of the corresponding boundary components, with the numbering starting at the left or the top as appropriate to the flow of the cobordism.
-A hack borrowed from the \Verb+regular polygon+ shape ensures that there are always enough anchors for the boundary components.
-
-There are also anchors placed at the midpoint of the cobordism edge between the boundary circles.
-The names of these are \Verb+after incoming boundary n+ and \Verb+after outgoing boundary n+.
-
-The above anchors can all be ``floated'' off the cobordism using the keys \Verb+outer sep+, \Verb+outer xsep+, and \Verb+outer ysep+.
-The last two are the ones actually used, the first is a shortcut for setting both simultaneously.
-
-There are also ``sub-nodes''.
-Provding the main node is named, each boundary circle is covered by a \Verb+tqft boundary circle+ node.
-This means that the anchors of the \Verb+tqft boundary circle+ can be used.
-These cannot be used for placing the main shape, but can be used afterwards.
-These are not affected by the \Verb+outer (x/y)sep+ keys.
-The names of these sub-nodes are of the form \Verb+name incoming n+ and \Verb+name outgoing n+ where \Verb+name+ is the name of the main node.
-The \Verb+tqft boundary circle+ shape is based on an ellipse and defines a boundary so the syntax \Verb+(name.angle)+ works as expected.
-It also defines anchors \Verb+next+, \Verb+prior+, \Verb+above+, and \Verb+below+.
-These correspond to where the boundary circle in the prescribed direction should be placed.
-
-\begin{example}
-\begin{tikzpicture}
-\node[tqft, incoming boundary components=2,outgoing boundary components=4,offset=-1,draw] (a) {};
-\foreach \anchor/\placement in
-{
-north/above,
-south/below,
-east/right,
-west/left,
-north west/left,
-south west/left,
-north east/right,
-south east/right,
-incoming boundary 1/above left,
-incoming boundary 2/above right,
-outgoing boundary 1/below left,
-outgoing boundary 4/below right,
-after outgoing boundary 1/below}
-\draw[shift=(a.\anchor)] plot[mark=x] coordinates{(0,0)} node[\placement] {\scriptsize\texttt{(a.\anchor)}};
-\end{tikzpicture}
-\end{example}
-
-\begin{example}
-\begin{tikzpicture}
-\node[tqft,cylinder, circle width=2cm, circle depth=1cm, cobordism height=4cm,boundary separation=3cm,draw] (b) {};
-\foreach \anchor/\placement in
-{
-prior/left,
-next/right,
-above/above,
-below/below,
-0/right,
-60/right,
-200/left}
-\draw[shift=(b incoming 1.\anchor)] plot[mark=x] coordinates{(0,0)} node[\placement] {\scriptsize\texttt{(b incoming 1.\anchor)}};
-\end{tikzpicture}
-\end{example}
-
-\subsection{Improvements}
-
-Here are some ideas for extending this, and some minor ``bugs''.
-
-\begin{enumerate}
-\item Make \Verb+incoming boundary+ an alias of \Verb+incoming boundary 1+ so that if there is only one incoming boundary component then we don't need to specify the number (ditto outgoing).
-\item No thought has been given as to where the text gets placed if it is specified.
-\item Add the ability to hide certain boundary components.
-This is useful if the shapes are not specified in their natural order so certain boundary components should be hidden behind earlier drawn shapes.
-\item Some style options on the main node get passed to the other pieces (\Verb+fill opacity+ being one).
-This shouldn't happen, or should happen by design not by accident.
-\item The bounding box isn't as good as it could be.
-\item Add a way to specify more directions for the flow.
-\item Add the ability to apply different styles to the incoming and outgoing components.
-\end{enumerate}
-
-\subsection{More Examples}
-
-\begin{example}
-\begin{tikzpicture}[tqft/cobordism height=1.5cm,tqft/boundary separation=1.5cm]
-\foreach \coord/\style in {
-{(0,0)}/{tqft/view from=outgoing,fill},
-{(5,0)}/{tqft/view from=incoming,draw},
-{(0,-8)}/{fill=orange,fill opacity=.5,tqft/boundary lower style={draw,blue,ultra thin,dashed},tqft/boundary upper style={draw,green},tqft/cobordism style={draw,purple},tqft/boundary style={fill=yellow}},
-{(5,-8)}/{fill=orange,fill opacity=.5,tqft/cobordism style={draw,purple},tqft/boundary style={fill=yellow,draw=green}}
-} {
-\begin{scope}
-\edef\styleit{\noexpand\tikzset{every node/.style={\style}}}
-\styleit
-\node[tqft/cap] (h) at \coord {};
-\node[tqft/pair of pants,anchor=incoming boundary 1] (a) at (h.outgoing boundary 1) {};
-\node[tqft/cylinder to next,anchor=incoming boundary 1] (d) at (a.incoming boundary 2) {};
-\node[tqft/reverse pair of pants,anchor=incoming boundary 1] (b) at (a.outgoing boundary 2) {};
-\node[tqft/cylinder to prior,anchor=incoming boundary 1] (c) at (b.outgoing boundary 1) {};
-\node[tqft/cylinder,anchor=incoming boundary 1] (e) at (a.outgoing boundary 1) {};
-\node[tqft/cylinder,anchor=incoming boundary 1] (f) at (e.outgoing boundary 1) {};
-\node[tqft/reverse pair of pants,anchor=incoming boundary 1] (g) at (f.outgoing boundary 1) {};
-\node[tqft/cup,anchor=incoming boundary 1] (i) at (g.outgoing boundary 1) {};
-\end{scope}
-}
-\end{tikzpicture}
-\end{example}
-
-\begin{example}
-\begin{tikzpicture}
-\node[draw,tqft/pair of pants] (a) {};
-\node[draw,tqft/cap,anchor=outgoing boundary 1] at (a.incoming boundary 1) {};
-\node[fill,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 1) {};
-\node[draw,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 2) {};
-\begin{scope}[tqft/flow=east]
-\node[draw,tqft/pair of pants] (a) at (4,0) {};
-\node[draw,tqft/cap,anchor=outgoing boundary 1] at (a.incoming boundary 1) {};
-\node[fill,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 1) {};
-\node[draw,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 2) {};
-\end{scope}
-\begin{scope}[tqft/flow=north]
-\node[draw,tqft/pair of pants] (a) at (0,-4) {};
-\node[draw,tqft/cap,anchor=outgoing boundary 1] at (a.incoming boundary 1) {};
-\node[fill,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 1) {};
-\node[draw,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 2) {};
-\end{scope}
-\begin{scope}[tqft/flow=west]
-\node[draw,tqft/pair of pants] (a) at (4,-4) {};
-\node[draw,tqft/cap,anchor=outgoing boundary 1] at (a.incoming boundary 1) {};
-\node[fill,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 1) {};
-\node[draw,tqft/cup,anchor=incoming boundary 1] at (a.outgoing boundary 2) {};
-\end{scope}
-\end{tikzpicture}
-\end{example}
-
-\end{document}
Deleted: trunk/Master/texmf-dist/source/latex/tqft/tqft.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tqft/tqft.dtx 2024-06-01 20:20:59 UTC (rev 71400)
+++ trunk/Master/texmf-dist/source/latex/tqft/tqft.dtx 2024-06-01 20:21:17 UTC (rev 71401)
@@ -1,2146 +0,0 @@
-% \iffalse meta-comment
-%<*internal>
-\iffalse
-%</internal>
-%<*readme>
-----------------------------------------------------------------
-tqft --- a library for drawing TQFT diagrams with TikZ/PGF
-E-mail: stacey at math.ntnu.no
-Released under the LaTeX Project Public License v1.3c or later
-See http://www.latex-project.org/lppl.txt
-----------------------------------------------------------------
-
-This package defines some shapes useful for drawing TQFT diagrams with TikZ/PGF.
-%</readme>
-%<*internal>
-\fi
-\def\nameofplainTeX{plain}
-\ifx\fmtname\nameofplainTeX\else
- \expandafter\begingroup
-\fi
-%</internal>
-%<*install>
-\input docstrip.tex
-\keepsilent
-\askforoverwritefalse
-\preamble
-----------------------------------------------------------------
-tqft --- a library for drawing TQFT diagrams with TikZ/PGF
-E-mail: loopspace at mathforge.org
-Released under the LaTeX Project Public License v1.3c or later
-See http://www.latex-project.org/lppl.txt
-----------------------------------------------------------------
-
-\endpreamble
-\postamble
-
-Copyright (C) 2011 by Andrew Stacey <loopspace at mathforge.org>
-
-This work may be distributed and/or modified under the
-conditions of the LaTeX Project Public License (LPPL), either
-version 1.3c of this license or (at your option) any later
-version. The latest version of this license is in the file:
-
-http://www.latex-project.org/lppl.txt
-
-This work is "maintained" (as per LPPL maintenance status) by
-Andrew Stacey.
-
-This work consists of the files tqft.dtx,
- tqft_doc.tex,
-and the derived files tqft.ins,
- tqft.pdf,
- tqft_doc.pdf,
- tqft.sty, and
- tikzlibrarytqft.code.tex.
-
-\endpostamble
-\usedir{tex/latex/tqft}
-\generate{
- \file{\jobname.sty}{\from{\jobname.dtx}{package}}
-}
-\usedir{tex/latex/tqft}
-\generate{
- \file{tikzlibrary\jobname.code.tex}{\from{\jobname.dtx}{library}}
-}
-%</install>
-%<install>\endbatchfile
-%<*internal>
-\usedir{source/latex/tqft}
-\generate{
- \file{\jobname.ins}{\from{\jobname.dtx}{install}}
-}
-\nopreamble\nopostamble
-\usedir{doc/latex/demopkg}
-\generate{
- \file{README.txt}{\from{\jobname.dtx}{readme}}
-}
-\ifx\fmtname\nameofplainTeX
- \expandafter\endbatchfile
-\else
- \expandafter\endgroup
-\fi
-%</internal>
-%<*package>
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{tqft}[2017/06/01 v2.1 Tikz/PGF commands for drawing TQFT diagrams]
-%</package>
-%<*driver>
-\documentclass{ltxdoc}
-\usepackage[T1]{fontenc}
-\usepackage{lmodern}
-%\usepackage{morefloats}
-\usepackage{tikz}
-\usepackage{\jobname}
-\usepackage[numbered]{hypdoc}
-\definecolor{lstbgcolor}{rgb}{0.9,0.9,0.9}
-
-\usepackage{listings}
-\lstloadlanguages{[LaTeX]TeX}
-\lstset{breakatwhitespace=true,breaklines=true,language=TeX}
-
-\usepackage{fancyvrb}
-\EnableCrossrefs
-\CodelineIndex
-\RecordChanges
-\begin{document}
- \DocInput{\jobname.dtx}
-\end{document}
-%</driver>
-% \fi
-%
-% \CheckSum{2577}
-%
-% \CharacterTable
-% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
-% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
-% Digits \0\1\2\3\4\5\6\7\8\9
-% Exclamation \! Double quote \" Hash (number) \#
-% Dollar \$ Percent \% Ampersand \&
-% Acute accent \' Left paren \( Right paren \)
-% Asterisk \* Plus \+ Comma \,
-% Minus \- Point \. Solidus \/
-% Colon \: Semicolon \; Less than \<
-% Equals \= Greater than \> Question mark \?
-% Commercial at \@ Left bracket \[ Backslash \\
-% Right bracket \] Circumflex \^ Underscore \_
-% Grave accent \` Left brace \{ Vertical bar \|
-% Right brace \} Tilde \~}
-%
-%
-% \changes{1.0}{2011/05/03}{Converted to DTX file}
-% \changes{2.0}{2014/04/07}{Converted nodes to pics}
-% \changes{2.1}{2017/06/01}{Can skip boundary components}
-%
-% \DoNotIndex{\newcommand,\newenvironment}
-%
-% \providecommand*{\url}{\texttt}
-% \GetFileInfo{tqft.dtx}
-% \title{The \textsf{tqft} package: codebase}
-% \author{Andrew Stacey \\ \url{loopspace at mathforge.org}}
-%
-% \maketitle
-%
-%
-% \begin{tikzpicture}[every node/.style={tqft/cobordism style={draw,thick,red}}]
-% \node[
-% tqft,
-% fill=orange,
-% fill opacity=.5,
-% boundary style={fill=purple},
-% cobordism style={draw,thick,red},
-% boundary lower style={draw,dashed,thick,blue},
-% boundary upper style={draw,green,thick},
-% incoming boundary components=4,
-% outgoing boundary components=6,
-% offset=-1.5,
-% ] (a) {};
-% \node[pin=north:1] at (a.incoming boundary 1) {};
-% \node[pin=north:3] at (a.incoming boundary 3) {};
-% \node[pin=south:1] at (a.outgoing boundary 1) {};
-% \node[pin=south:4] at (a.outgoing boundary 4) {};
-% \node[pin=south:6] at (a.outgoing boundary 6) {};
-% \end{tikzpicture}
-%
-% \section{Introduction}
-%
-% This is a package for drawing TQFT diagrams using PGF/TikZ.
-% Its inspiration was a question and answer on the website \url{http://tex.stackexchance.com}.
-%
-%
-% \StopEventually{}
-%
-% \section{Implementation}
-%
-% \subsection{Old Version: Node Shapes}
-%
-% \iffalse
-%<*package>
-% \fi
-% \begin{macrocode}
-\RequirePackage{pgfkeys}
-\RequirePackage{pgf}
-% \end{macrocode}
-%
-% We can view the cobordisms from the \emph{input} or \emph{output} ends, the implementation of the choice is to draw an arc from 0 to 180 or from 0 to -180 so we just need to track minus signs.
-% These macros are for that.
-% \begin{macrocode}
-\def\pgf at tqft@minus{-}
-\let\pgf at tqft@upper\@empty
-\let\pgf at tqft@lower\pgf at tqft@minus
-% \end{macrocode}
-% Some helpful extra functions.
-%
-% \Verb+\tqftset+ is our equivalent of \Verb+\tikzset+.
-% \begin{macrocode}
-\def\tqftset#1{\pgfkeys{/pgf/tqft/.cd,#1}}
-% \end{macrocode}
-% \begin{macro}{\tqft at process}
-% This macro applies our flow transformation to the given coordinates, % with the result stored in \Verb+\pgf at x+ and \Verb+\pgf at y+.
-% \begin{macrocode}
-\def\tqft at process#1#2{%
- \edef\tqft at px{#1}
- \edef\tqft at py{#2}
- \pgf at process{
- \pgftransformreset
- \let\tikz at transform=\pgfutil at empty
- \expandafter\tikzset\expandafter{\tqft at transformation}
- \tikz at transform
- \pgfpointtransformed{\pgfqpoint{\tqft at px}{\tqft at py}}
- }
-}
-% \end{macrocode}
-% \end{macro}
-%
-% Declare some dimension registers to hold the specifications of the cobordism.
-% \begin{macrocode}
-\newdimen\tqft at xa
-\newdimen\tqft at xb
-\newdimen\tqft at c
-\newdimen\tqft at ch
-\newdimen\tqft at h
-\newdimen\tqft at s
-\newdimen\tqft at w
-\newif\iftqft at within@node
-% \end{macrocode}
-% Now we set up all the keys that we'll need in the course of this shape
-% \begin{macrocode}
-\pgfkeys{
-% \end{macrocode}
-% Add a key to switch between the two versions.
-% \begin{macrocode}
- /tikz/tqft/use nodes/.is choice,
- /tikz/tqft/use nodes/true/.code={%
- \tikzset{
-% \end{macrocode}
-% If using nodes, set the defaults
-% \begin{macrocode}
- tqft/.style={%
- /tikz/shape=tqft cobordism,
- /pgf/tqft,
- /tikz/every tqft/.try
- },
-% \end{macrocode}
-% Unknowns go to \Verb+/pgf/tqft+
-% \begin{macrocode}
- tqft/.unknown/.code={%
- \let\tqft at searchname=\pgfkeyscurrentname%
- \pgfkeys{%
- /pgf/tqft/\tqft at searchname={##1}
- }
- },
- }%
- },
-% \end{macrocode}
-% If not using nodes, set the defaults for the library
-% \begin{macrocode}
- /tikz/tqft/use nodes/false/.code={%
- \tikzset{
- tqft/.style={%
- pic type=cobordism,
- tqft/.cd,
- every tqft/.try,
- },
-% \end{macrocode}
-% Pass unknown keys on to TikZ.
-% \begin{macrocode}
- tqft/.unknown/.code={%
- \let\tqft at searchname=\pgfkeyscurrentname%
- \pgfkeys{%
- /tikz/\tqft at searchname={##1}
- }
- },
- }%
- },
- /tikz/tqft/use nodes=true,
-% \end{macrocode}
-% This deals with unknown keys, passing them on to TikZ.
-% \begin{macrocode}
- /pgf/tqft/.unknown/.code={%
- \let\tqft at searchname=\pgfkeyscurrentname%
- \pgfkeysalso{%
- /tikz/\tqft at searchname={#1}
- }
- },
-% \end{macrocode}
-% Let's play happy families!
-% \begin{macrocode}
- /pgf/tqft/.is family,
- /pgf/tqft,
-% \end{macrocode}
-% This sets our shape to be the boundary circle
-% \begin{macrocode}
- boundary circle/.style={
- /tikz/shape=tqft boundary circle
- },
-% \end{macrocode}
-% These set our number of boundary components
-% \begin{macrocode}
- incoming boundary components/.initial=5,
- outgoing boundary components/.initial=4,
-% \end{macrocode}
-% This is the ``horizontal'' offset of the first outgoing component from the first incoming one.
-% \begin{macrocode}
- offset/.initial=0,
-% \end{macrocode}
-% This is the ``vertical'' separation between boundary components.
-% \begin{macrocode}
- cobordism height/.initial=2cm,
-% \end{macrocode}
-% This is the ``horizontal'' separation between boundary components.
-% \begin{macrocode}
- boundary separation/.initial=2cm,
-% \end{macrocode}
-% These are the ``horizontal'' and ``vertical'' radii, respectively, of the boundary components (perhaps poorly named!).
-% \begin{macrocode}
- circle width/.initial=10pt,
- circle depth/.initial=5pt,
-% \end{macrocode}
-% These control the separation between the node and its anchors.
-% \begin{macrocode}
- outer xsep/.initial=0pt,
- outer ysep/.initial=0pt,
- outer sep/.style={
- outer xsep=#1,
- outer ysep=#1
- },
-% \end{macrocode}
-% This is our flow control. The \Verb+flow+ key installs a transformation to be applied to our node shape.
-% The possible transformations are stored in the following keys.
-% They aren't just rotations so that the numbering is always ``top to bottom'' or ``left to right''.
-% \begin{macrocode}
- flow/.code={%
- \pgfkeys{/pgf/tqft/flow transformation/.expand twice/.expand once=\pgfkeysvalueof{/pgf/tqft/flow transformation #1}}
- },
- flow transformation south/.initial={},
- flow transformation north/.initial={%
- xscale=-1,rotate=180
- },
- flow transformation east/.initial={%
- rotate=90,xscale=-1
- },
- flow transformation west/.initial={%
- rotate=270
- },
- flow transformation/.initial={},
-% \end{macrocode}
-% These control the direction from which we view the cobordism.
-% \begin{macrocode}
- view from/.is choice,
- view from/incoming/.code={%
- \let\pgf at tqft@upper\pgf at tqft@minus
- \let\pgf at tqft@lower\@empty
- },
- view from/outgoing/.code={%
- \let\pgf at tqft@lower\pgf at tqft@minus
- \let\pgf at tqft@upper\@empty
- },
-% \end{macrocode}
-% The next set of keys are for styling the different pieces of a cobordism.
-% \begin{macrocode}
- boundary lower style contents/.initial={},
- boundary lower style/.code={%
- \pgfkeys{/pgf/tqft/boundary lower style contents/.style={%
- /tikz/.cd,#1
- }
- }
- },
- boundary style contents/.initial={},
- boundary style/.code={%
- \pgfkeys{/pgf/tqft/boundary style contents/.style={%
- /tikz/.cd,#1
- }
- }
- },
- boundary upper style contents/.initial={},
- boundary upper style/.code={%
- \pgfkeys{/pgf/tqft/boundary upper style contents/.style={%
- /tikz/.cd,#1
- }
- }
- },
- cobordism style contents/.initial={},
- cobordism style/.code={%
- \pgfkeys{/pgf/tqft/cobordism style contents/.style={%
- /tikz/.cd,#1%
- }
- }
- },
-% \end{macrocode}
-% The next set of keys define some default shapes.
-% \begin{macrocode}
- pair of pants/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=2,
- offset=-.5
- },
- /tikz/tqft pair of pants/.style={
- /pgf/tqft/pair of pants,
- },
- reverse pair of pants/.style={
- /tikz/tqft,
- incoming boundary components=2,
- outgoing boundary components=1,
- offset=.5
- },
- /tikz/tqft reverse pair of pants/.style={
- /pgf/tqft/reverse pair of pants,
- },
- cylinder to prior/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- offset=-.5
- },
- /tikz/tqft cylinder to prior/.style={
- /pgf/tqft/cylinder to prior,
- },
- cylinder to next/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- offset=.5
- },
- /tikz/tqft cylinder to next/.style={
- /pgf/tqft/cylinder to next,
- },
- cylinder/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=1
- },
- /tikz/tqft cylinder/.style={
- /pgf/tqft/cylinder,
- },
- cup/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=0
- },
- /tikz/tqft cup/.style={
- /pgf/tqft/cup,
- },
- cap/.style={
- /tikz/tqft,
- incoming boundary components=0,
- outgoing boundary components=1
- },
- /tikz/tqft cap/.style={
- /pgf/tqft/cap,
- },
-}
-% \end{macrocode}
-%
-% \begin{macro}{tqft shape}
-% This is a generic cobordism shape
-% \begin{macrocode}
-\pgfdeclareshape{tqft cobordism}{
-% \end{macrocode}
-% Save our specifications: incoming and outgoing boundary components
-% \begin{macrocode}
- \savedmacro{\tqft at incoming}{\edef\tqft at incoming{\pgfkeysvalueof{/pgf/tqft/incoming boundary components}}}
- \savedmacro{\tqft at outgoing}{\edef\tqft at outgoing{\pgfkeysvalueof{/pgf/tqft/outgoing boundary components}}}
-% \end{macrocode}
-% and the offset (in units of boundary components) between the leading incoming and outgoing components (regarded as a shift of the outgoing components relative to the incoming)
-% \begin{macrocode}
- \savedmacro{\tqft at offset}{\edef\tqft at offset{\pgfkeysvalueof{/pgf/tqft/offset}}}
-% \end{macrocode}
-% Now we save our dimensions: height, separation, the radii of the boundary circles, and outer seps, and the heights of the control points.
-% \begin{macrocode}
- \saveddimen{\tqft at height}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/cobordism height}}
- \saveddimen{\tqft at separation}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/boundary separation}}
- \saveddimen{\tqft at width}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/circle width}}
- \saveddimen{\tqft at depth}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/circle depth}}
- \saveddimen{\tqft at outerxsep}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/outer xsep}}
- \saveddimen{\tqft at outerysep}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/outer ysep}}
- \saveddimen{\tqft at control}{
- \pgfkeysgetvalue{/pgf/tqft/cobordism height}{\tqft at tempa}
- \pgfkeysgetvalue{/pgf/tqft/circle depth}{\tqft at tempb}
- \pgfmathsetlength{\pgf at x}{.5 * \tqft at tempa - 4 * \tqft at tempb}
-}
-% \end{macrocode}
-% This is the internal transformation that is in place
-% \begin{macrocode}
- \savedmacro{\tqft at transformation}{%
- \pgfkeysgetvalue{/pgf/tqft/flow transformation}{\tqft at transformation}
-}
-% \end{macrocode}
-% For the externally available anchors, we need to save a few things as well.
-%
-% Position of first incoming boundary in internal coordinates
-% \begin{macrocode}
- \savedanchor{\tqft at start@incoming}{%
- \pgfmathsetlength{\pgf at x}{-(max(\pgfkeysvalueof{/pgf/tqft/incoming boundary components} - 1,\pgfkeysvalueof{/pgf/tqft/outgoing boundary components} - 1 + \pgfkeysvalueof{/pgf/tqft/offset}) + min(0,\pgfkeysvalueof{/pgf/tqft/offset}) )*\pgfkeysvalueof{/pgf/tqft/boundary separation}/2}
- \pgfmathsetlength{\pgf at y}{.5 * \pgfkeysvalueof{/pgf/tqft/cobordism height}}
-}
-% \end{macrocode}
-% Position of first outgoing boundary in internal coordinates
-% \begin{macrocode}
- \savedanchor{\tqft at start@outgoing}{%
- \pgfmathsetlength{\pgf at x}{-(max(\pgfkeysvalueof{/pgf/tqft/incoming boundary components} - 1,\pgfkeysvalueof{/pgf/tqft/outgoing boundary components} - 1 + \pgfkeysvalueof{/pgf/tqft/offset}) + min(0,\pgfkeysvalueof{/pgf/tqft/offset})- 2*\pgfkeysvalueof{/pgf/tqft/offset})*\pgfkeysvalueof{/pgf/tqft/boundary separation}/2}
- \pgfmathsetlength{\pgf at y}{-.5 * \pgfkeysvalueof{/pgf/tqft/cobordism height}}
-}
-% \end{macrocode}
-% For completeness, we record the size of the text box (not that we expect any text, but you never know)
-% \begin{macrocode}
-\savedanchor{\tqft at textsize}{%
- \pgf at y=-.5\ht\pgfnodeparttextbox%
- \pgf at x=-.5\wd\pgfnodeparttextbox%
-}
-% \end{macrocode}
-%
-% These are our externally available anchors
-% \begin{macrocode}
- \anchor{centre}{\pgfpointorigin}
- \anchor{center}{\pgfpointorigin}
-\anchor{text}{
- \tqft at textsize
-}
-\anchor{north}{%
- \pgf at ya=\tqft at height\relax
- \pgf at yb=.5\pgf at ya
- \advance\pgf at yb by \tqft at outerysep\relax
- \tqft at process{0pt}{\the\pgf at yb}
-}
-\anchor{south}{%
- \pgf at yb=\tqft at height\relax
- \pgf at ya=.5\pgf at yb
- \advance\pgf at ya by \tqft at outerysep\relax
- \pgf at yb=-\pgf at ya
- \tqft at process{0pt}{\the\pgf at yb}
-}
-\anchor{west}{%
- \tqft at start@incoming
- \pgf at xa=\pgf at x
- \advance\pgf at xa by -\tqft at width
- \pgf at ya=\pgf at y
- \tqft at start@outgoing
- \pgf at xb=\pgf at x
- \advance\pgf at xb by -\tqft at width
- \pgf at yb=\pgf at y
- \pgf at xc=.5\pgf at xa
- \advance\pgf at xc by .5\pgf at xb
- \pgf at yc=.5\pgf at ya
- \advance\pgf at yc by .5\pgf at yb
- \advance\pgf at xc by -\tqft at outerxsep\relax
- \tqft at process{\the\pgf at xc}{\the\pgf at yc}
-}
-\anchor{east}{%
- \tqft at start@incoming
- \pgf at xa=\pgf at x
- \pgfmathsetlength{\pgf at xa}{\pgf at xa + (\tqft at incoming - 1) * \tqft at separation}
- \advance\pgf at xa by \tqft at width\relax
- \pgf at ya=\pgf at y
- \tqft at start@outgoing
- \pgf at xb=\pgf at x
- \pgfmathsetlength{\pgf at xb}{\pgf at xb + (\tqft at outgoing - 1) * \tqft at separation}
- \advance\pgf at xb by \tqft at width\relax
- \pgf at yb=\pgf at y
- \pgf at xc=.5\pgf at xa
- \advance\pgf at xc by .5\pgf at xb
- \pgf at yc=.5\pgf at ya
- \advance\pgf at yc by .5\pgf at yb
- \advance\pgf at xc by \tqft at outerxsep\relax
- \tqft at process{\the\pgf at xc}{\the\pgf at yc}
-}
-\anchor{north west}{
- \tqft at start@incoming
- \pgf at xc=\pgf at x
- \pgf at yc=\pgf at y
- \advance\pgf at xc by -\tqft at width\relax
- \advance\pgf at yc by \tqft at outerysep\relax
- \advance\pgf at xc by -\tqft at outerxsep\relax
- \tqft at process{\the\pgf at xc}{\the\pgf at yc}
-}
-\anchor{south west}{
- \tqft at start@outgoing
- \pgf at xc=\pgf at x
- \pgf at yc=\pgf at y
- \advance\pgf at xc by -\tqft at width\relax
- \advance\pgf at yc by -\tqft at outerysep\relax
- \advance\pgf at xc by -\tqft at outerxsep\relax
- \tqft at process{\the\pgf at xc}{\the\pgf at yc}
-}
-\anchor{north east}{
- \tqft at start@incoming
- \pgf at xc=\pgf at x
- \pgfmathsetlength{\pgf at xc}{\pgf at xc + (\tqft at incoming - 1)*\tqft at separation}
- \pgf at yc=\pgf at y
- \advance\pgf at xc by \tqft at width\relax
- \advance\pgf at yc by \tqft at outerysep\relax
- \advance\pgf at xc by \tqft at outerxsep\relax
- \tqft at process{\the\pgf at xc}{\the\pgf at yc}
-}
-\anchor{south east}{
- \tqft at start@outgoing
- \pgf at xc=\pgf at x
- \pgfmathsetlength{\pgf at xc}{\pgf at xc + (\tqft at outgoing - 1)*\tqft at separation}
- \pgf at yc=\pgf at y
- \advance\pgf at xc by \tqft at width\relax
- \advance\pgf at yc by -\tqft at outerysep\relax
- \advance\pgf at xc by \tqft at outerxsep\relax
- \tqft at process{\the\pgf at xc}{\the\pgf at yc}
-}
-% \end{macrocode}
-% To define anchors at the boundary components requires a bit of trickery borrowed from the ``regular polygon'' shape.
-% \begin{macrocode}
-\expandafter\pgfutil at g@addto at macro\csname pgf at sh@s at tqft cobordism\endcsname{%
- \c at pgf@counta\tqft at incoming\relax%
- \pgfmathloop%
- \ifnum\c at pgf@counta>0\relax%
- \pgfutil at ifundefined{pgf at anchor@tqft cobordism at incoming boundary\space\the\c at pgf@counta}{%
- \expandafter\xdef\csname pgf at anchor@tqft cobordism at incoming boundary\space\the\c at pgf@counta\endcsname{%
- \noexpand\tqft at start@incoming
- \noexpand\pgfmathsetlength{\noexpand\pgf at y}{\noexpand\pgf at y + \noexpand\tqft at outerysep}
- \noexpand\pgfmathsetlength{\noexpand\pgf at x}{\noexpand\pgf at x + (\the\c at pgf@counta - 1) * \noexpand\tqft at separation}
- \noexpand\tqft at process{\noexpand\the\noexpand\pgf at x}{\noexpand\the\noexpand\pgf at y}
- }
- }{\c at pgf@counta0\relax}%
- \advance\c at pgf@counta-1\relax%
- \repeatpgfmathloop%
-}
-\expandafter\pgfutil at g@addto at macro\csname pgf at sh@s at tqft cobordism\endcsname{%
- \c at pgf@counta\tqft at outgoing\relax%
- \pgfmathloop%
- \ifnum\c at pgf@counta>0\relax%
- \pgfutil at ifundefined{pgf at anchor@tqft cobordism at outgoing boundary\space\the\c at pgf@counta}{%
- \expandafter\xdef\csname pgf at anchor@tqft cobordism at outgoing boundary\space\the\c at pgf@counta\endcsname{%
- \noexpand\tqft at start@outgoing
- \noexpand\pgfmathsetlength{\noexpand\pgf at y}{\noexpand\pgf at y - \noexpand\tqft at outerysep}
- \noexpand\pgfmathsetlength{\noexpand\pgf at x}{\noexpand\pgf at x + (\the\c at pgf@counta - 1) * \noexpand\tqft at separation}
- \noexpand\tqft at process{\noexpand\the\noexpand\pgf at x}{\noexpand\the\noexpand\pgf at y}
- }
- }{\c at pgf@counta0\relax}%
- \advance\c at pgf@counta-1\relax%
- \repeatpgfmathloop%
-}
-\expandafter\pgfutil at g@addto at macro\csname pgf at sh@s at tqft cobordism\endcsname{%
- \c at pgf@counta\tqft at incoming\relax%
- \advance\c at pgf@counta-1\relax
- \pgfmathloop%
- \ifnum\c at pgf@counta>0\relax%
- \pgfutil at ifundefined{pgf at anchor@tqft cobordism at after incoming boundary\space\the\c at pgf@counta}{%
- \expandafter\xdef\csname pgf at anchor@tqft cobordism at after incoming boundary\space\the\c at pgf@counta\endcsname{%
- \noexpand\tqft at start@incoming
- \noexpand\pgfmathsetlength{\noexpand\pgf at y}{.25 * \noexpand\pgf at y +.75 * \noexpand\tqft at control + \noexpand\tqft at outerysep}
- \noexpand\pgfmathsetlength{\noexpand\pgf at x}{\noexpand\pgf at x + (\the\c at pgf@counta - .5) * \noexpand\tqft at separation}
- \noexpand\tqft at process{\noexpand\the\noexpand\pgf at x}{\noexpand\the\noexpand\pgf at y}
- }
- }{\c at pgf@counta0\relax}%
- \advance\c at pgf@counta-1\relax%
- \repeatpgfmathloop%
-}
-\expandafter\pgfutil at g@addto at macro\csname pgf at sh@s at tqft cobordism\endcsname{%
- \c at pgf@counta\tqft at outgoing\relax%
- \advance\c at pgf@counta-1\relax
- \pgfmathloop%
- \ifnum\c at pgf@counta>0\relax%
- \pgfutil at ifundefined{pgf at anchor@tqft cobordism at after outgoing boundary\space\the\c at pgf@counta}{%
- \expandafter\xdef\csname pgf at anchor@tqft cobordism at after outgoing boundary\space\the\c at pgf@counta\endcsname{%
- \noexpand\tqft at start@outgoing
- \noexpand\pgfmathsetlength{\noexpand\pgf at y}{.25 * \noexpand\pgf at y -.75 * \noexpand\tqft at control - \noexpand\tqft at outerysep}
- \noexpand\pgfmathsetlength{\noexpand\pgf at x}{\noexpand\pgf at x + (\the\c at pgf@counta - .5) * \noexpand\tqft at separation}
- \noexpand\tqft at process{\noexpand\the\noexpand\pgf at x}{\noexpand\the\noexpand\pgf at y}
- }
- }{\c at pgf@counta0\relax}%
- \advance\c at pgf@counta-1\relax%
- \repeatpgfmathloop%
-}
-% \end{macrocode}
-% Now we define the background path.
-% This is the upper part of the cobordism.
-% \begin{macrocode}
- \backgroundpath{
-% \end{macrocode}
-% Apply the internal transformation
-% \begin{macrocode}
- \let\tikz at transform=\pgfutil at empty
- \expandafter\tikzset\expandafter{\tqft at transformation}
- \tikz at transform
-% \end{macrocode}
-% Convert the boundary separation and width to lengths
-% \begin{macrocode}
- \pgfmathsetlength{\tqft at s}{\tqft at separation}
- \pgfmathsetlength{\tqft at w}{2*\tqft at width}
-% \end{macrocode}
-% Compute the starting position of the incoming boundary components so that we get the centre anchor on the centre of the cobordism
-% \begin{macrocode}
-\tqft at start@incoming
-\tqft at xa=\pgf at x
- \advance\tqft at xa by -.5\tqft at w\relax
-\tqft at h=\pgf at y
- \tqft at xb=\tqft at xa
- \advance\tqft at xb by \tqft at w\relax
-\tqft at c=\tqft at control\relax
-% \end{macrocode}
-% Do we have any incoming boundary components at all?
-% \begin{macrocode}
- \ifnum\tqft at incoming>0
-% \end{macrocode}
-% Yes, so move to the position of the first and draw it
-% \begin{macrocode}
- \pgfpathmoveto{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \pgfpatharc{\pgf at tqft@upper180}{0}{\tqft at width and \tqft at depth}
-% \end{macrocode}
-% Do we have any more incoming boundary components?
-% \begin{macrocode}
- \ifnum\tqft at incoming>1
-% \end{macrocode}
-% Yes, so iterate over the remaining incoming boundary components
-% \begin{macrocode}
- \foreach \tqft at k in {2,...,\tqft at incoming} {
- \advance\tqft at xa by \tqft at k\tqft at s
- \advance\tqft at xb by \tqft at k\tqft at s
- \advance\tqft at xb by -2\tqft at s
- \advance\tqft at xa by -\tqft at s
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at c}}{\pgfqpoint{\tqft at xa}{\tqft at c}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \pgfpatharc{\pgf at tqft@upper180}{0}{\tqft at width and \tqft at depth}
- }
- \fi
-% \end{macrocode}
-% If we don't have any outgoing boundary components, may as well close up now.
-% \begin{macrocode}
- \ifnum\tqft at outgoing=0
- \advance\tqft at xb by \tqft at incoming\tqft at s
- \advance\tqft at xb by -\tqft at s
- \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \fi
- \fi
-% \end{macrocode}
-% Shift down to the outgoing components, if we have any
-% \begin{macrocode}
- \ifnum\tqft at outgoing>0
- \advance\tqft at xb by \tqft at incoming\tqft at s
- \advance\tqft at xb by -\tqft at s
- \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing - 1 + \tqft at offset) * \tqft at separation + 2*\tqft at width}
-% \end{macrocode}
-% If we had incoming boundaries, this is a curveto, otherwise it's a moveto
-% \begin{macrocode}
- \ifnum\tqft at incoming>0
- \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \else
- \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \fi
- \tqft at xb=\tqft at xa
- \advance\tqft at xb by -\tqft at w
-% \end{macrocode}
-% Now draw the lower components
-% \begin{macrocode}
- \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
-% \end{macrocode}
-% Now iterate over the remaining outgoing boundary components
-% \begin{macrocode}
- \ifnum\tqft at outgoing>1
- \foreach \tqft at k in {2,...,\tqft at outgoing} {
- \advance\tqft at xa by -\tqft at k\tqft at s
- \advance\tqft at xb by -\tqft at k\tqft at s
- \advance\tqft at xb by 2\tqft at s
- \advance\tqft at xa by \tqft at s
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at c}}{\pgfqpoint{\tqft at xa}{-\tqft at c}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
- }
- \fi
-% \end{macrocode}
-% Shift back up to the incoming components, if we had any, otherwise arc back to our starting point
-% \begin{macrocode}
- \advance\tqft at xb by -\tqft at outgoing\tqft at s
- \advance\tqft at xb by \tqft at s
- \ifnum\tqft at incoming>0
- \pgfmathsetlength{\tqft at xa}{\tqft at xa - (\tqft at outgoing -1 + \tqft at offset) * \tqft at separation - 2*\tqft at width}
- \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \else
- \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \fi
- \fi
-% \end{macrocode}
-% Close the path
-% \begin{macrocode}
- \pgfpathclose
- }
-% \end{macrocode}
-% End of background path
-% Now we define the behind background path.
-% This is the lower part of the boundary circles.
-% \begin{macrocode}
- \behindbackgroundpath{
-% \end{macrocode}
-% Apply the internal transformation
-% \begin{macrocode}
- \let\tikz at transform=\pgfutil at empty
- \expandafter\tikzset\expandafter{\tqft at transformation}
- \tikz at transform
-% \end{macrocode}
-% Convert the boundary separation and width to lengths
-% \begin{macrocode}
- \pgfmathsetlength{\tqft at s}{\tqft at separation}
- \pgfmathsetlength{\tqft at w}{2*\tqft at width}
-% \end{macrocode}
-% Compute the starting position of the incoming boundary components so that we get the centre anchor on the centre of the cobordism
-% \begin{macrocode}
- \pgfmathsetlength{\tqft at xa}{-(max(\tqft at incoming - 1,\tqft at outgoing - 1 + \tqft at offset) + min(0,\tqft at offset) + 2)*\tqft at separation/2}
- \pgfmathsetlength{\tqft at h}{.5 * \tqft at height}
-% \end{macrocode}
-% This section draws the boundary circles
-% \begin{macrocode}
- {
-% \end{macrocode}
-% Initialise the TikZ path settings and read in the style options for the boundary
-% \begin{macrocode}
- \tikz at mode@fillfalse%
- \tikz at mode@drawfalse%
- \let\tikz at mode=\pgfutil at empty
- \let\tikz at options=\pgfutil at empty
- \tqftset{boundary style contents}
- \tikz at mode
- \tikz at options
-% \end{macrocode}
-% Do we have any incoming boundary components at all?
-% \begin{macrocode}
- \ifnum\tqft at incoming>0
-% \end{macrocode}
-% Yes, so iterate over them
-% \begin{macrocode}
- \foreach \tqft at k in {1,...,\tqft at incoming} {
- \advance\tqft at xa by \tqft at k\tqft at s
- \pgfpathellipse{\pgfqpoint{\tqft at xa}{\tqft at h}}{\pgfqpoint{\tqft at width}{0pt}}{\pgfqpoint{0pt}{\tqft at depth}}
- }
- \fi
-% \end{macrocode}
-% Now iterate over the outgoing boundary components, if we have any
-% \begin{macrocode}
- \ifnum\tqft at outgoing>0
- \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing + \tqft at offset + 1) * \tqft at separation}
- \foreach \tqft at k in {1,...,\tqft at outgoing} {
- \advance\tqft at xa by -\tqft at k\tqft at s
-% \advance\tqft at xa by \tqft at s
- \pgfpathellipse{\pgfqpoint{\tqft at xa}{-\tqft at h}}{\pgfqpoint{\tqft at width}{0pt}}{\pgfqpoint{0pt}{\tqft at depth}}
- }
- \fi
-% \end{macrocode}
-% \begin{macrocode}
- \edef\tikz at temp{\noexpand\pgfusepath{%
- \iftikz at mode@fill fill,\fi%
- \iftikz at mode@draw draw\fi%
- }}%
- \tikz at temp
- }
-% \end{macrocode}
-% This section draws the lower parts of the boundary circles
-% \begin{macrocode}
- {
-% \end{macrocode}
-% Initialise the TikZ path settings and read in the style options for the boundary
-% \begin{macrocode}
- \tikz at mode@fillfalse%
- \tikz at mode@drawfalse%
- \let\tikz at mode=\pgfutil at empty
- \let\tikz at options=\pgfutil at empty
- \tqftset{boundary lower style contents}
- \tikz at mode
- \tikz at options
- \advance\tqft at xa by .5\tqft at w
-% \end{macrocode}
-% Do we have any incoming boundary components at all?
-% \begin{macrocode}
- \ifnum\tqft at incoming>0
-% \end{macrocode}
-% Yes, so iterate over them
-% \begin{macrocode}
- \foreach \tqft at k in {1,...,\tqft at incoming} {
- \advance\tqft at xa by \tqft at k\tqft at s
- \pgfpathmoveto{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \pgfpatharc{0}{\pgf at tqft@lower180}{\tqft at width and \tqft at depth}
- }
- \fi
-% \end{macrocode}
-% Now iterate over the outgoing boundary components, if we have any
-% \begin{macrocode}
- \ifnum\tqft at outgoing>0
- \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing + \tqft at offset + 1) * \tqft at separation}
- \foreach \tqft at k in {1,...,\tqft at outgoing} {
- \advance\tqft at xa by -\tqft at k\tqft at s
-% \advance\tqft at xa by \tqft at s
- \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \pgfpatharc{0}{\pgf at tqft@lower180}{\tqft at width and \tqft at depth}
- }
- \fi
-% \end{macrocode}
-% \begin{macrocode}
- \edef\tikz at temp{\noexpand\pgfusepath{%
- \iftikz at mode@fill fill,\fi%
- \iftikz at mode@draw draw\fi%
- }}%
- \tikz at temp
- }
- }
-% \end{macrocode}
-% End of behind background path.
-%
-% Now we define the before background path.
-% This is the upper part of the boundary circles and the cobordism edge.
-% \begin{macrocode}
- \beforebackgroundpath{
-% \end{macrocode}
-% We \emph{don't} apply the internal transformation as it is already in place from the \Verb+\backgroundpath+.
-% Convert the boundary separation and width to lengths
-% \begin{macrocode}
- \pgfmathsetlength{\tqft at s}{\tqft at separation}
- \pgfmathsetlength{\tqft at w}{2*\tqft at width}
-% \end{macrocode}
-% Compute the starting position of the incoming boundary components so that we get the centre anchor on the centre of the cobordism
-% \begin{macrocode}
- \pgfmathsetlength{\tqft at xa}{-(max(\tqft at incoming - 1,\tqft at outgoing - 1 + \tqft at offset) + min(0,\tqft at offset))*\tqft at s/2 - \tqft at width}
- \tqft at xb=\tqft at xa
- \advance\tqft at xb by \tqft at w
-\tqft at c=\tqft at control\relax
- \pgfmathsetlength{\tqft at h}{.5 * \tqft at height}
-% \end{macrocode}
-% This section draws the non-boundary part of the cobordism.
-% \begin{macrocode}
- {
-% \end{macrocode}
-% Initialise the TikZ path settings and read in the style options for the boundary
-% \begin{macrocode}
- \tikz at mode@fillfalse%
- \tikz at mode@drawfalse%
- \let\tikz at mode=\pgfutil at empty
- \let\tikz at options=\pgfutil at empty
- \tqftset{cobordism style contents}
- \tikz at mode
- \tikz at options
-% Do we have any incoming boundary components at all?
-% \begin{macrocode}
- \ifnum\tqft at incoming>0
-% \end{macrocode}
-% Do we have more than one?
-% \begin{macrocode}
- \ifnum\tqft at incoming>1
-% \end{macrocode}
-% Yes, so iterate over the remaining incoming boundary components
-% \begin{macrocode}
- \foreach \tqft at k in {2,...,\tqft at incoming} {
- \advance\tqft at xa by \tqft at k\tqft at s
- \advance\tqft at xb by \tqft at k\tqft at s
- \advance\tqft at xb by -2\tqft at s
- \advance\tqft at xa by -\tqft at s
- \pgfpathmoveto{\pgfqpoint{\tqft at xb}{\tqft at h}}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at c}}{\pgfqpoint{\tqft at xa}{\tqft at c}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
- }
- \fi
-% \end{macrocode}
-% If we don't have any outgoing boundary components, may as well close up now.
-% \begin{macrocode}
- \ifnum\tqft at outgoing=0
- \advance\tqft at xb by \tqft at incoming\tqft at s
- \advance\tqft at xb by -\tqft at s
- \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
- \pgfpathmoveto{\pgfqpoint{\tqft at xb}{\tqft at h}}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \fi
- \fi
-% \end{macrocode}
-% Shift down to the outgoing components, if we have any
-% \begin{macrocode}
- \ifnum\tqft at outgoing>0
- \advance\tqft at xb by \tqft at incoming\tqft at s
- \advance\tqft at xb by -\tqft at s
- \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing - 1 + \tqft at offset) * \tqft at separation + 2*\tqft at width}
-% \end{macrocode}
-% If we had incoming boundaries, this is a curveto, otherwise it's a moveto
-% \begin{macrocode}
- \ifnum\tqft at incoming>0
- \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
- \pgfpathmoveto{\pgfqpoint{\tqft at xb}{\tqft at h}}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \else
- \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \fi
- \tqft at xb=\tqft at xa
- \advance\tqft at xb by -\tqft at w
-% \end{macrocode}
-% Now draw the lower components
-% \begin{macrocode}
- \pgfpathmoveto{\pgfqpoint{\tqft at xb}{-\tqft at h}}
-% \end{macrocode}
-% Now iterate over the remaining outgoing boundary components
-% \begin{macrocode}
- \ifnum\tqft at outgoing>1
- \foreach \tqft at k in {2,...,\tqft at outgoing} {
- \advance\tqft at xa by -\tqft at k\tqft at s
- \advance\tqft at xb by -\tqft at k\tqft at s
- \advance\tqft at xb by 2\tqft at s
- \advance\tqft at xa by \tqft at s
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at c}}{\pgfqpoint{\tqft at xa}{-\tqft at c}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \advance\tqft at xa by -\tqft at w
- \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- }
- \fi
-% \end{macrocode}
-% Shift back up to the incoming components, if we had any, otherwise arc back to our starting point
-% \begin{macrocode}
- \advance\tqft at xb by -\tqft at outgoing\tqft at s
- \advance\tqft at xb by \tqft at s
- \ifnum\tqft at incoming>0
- \pgfmathsetlength{\tqft at xa}{\tqft at xa - (\tqft at outgoing -1 + \tqft at offset) * \tqft at separation - 2*\tqft at width}
- \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \else
- \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
- \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \fi
- \fi
- \edef\tikz at temp{\noexpand\pgfusepath{%
- \iftikz at mode@fill fill,\fi%
- \iftikz at mode@draw draw\fi%
- }}%
- \tikz at temp
-}
-% \end{macrocode}
-% This section draws the upper parts of the boundary circles
-% \begin{macrocode}
- {
-% \end{macrocode}
-% Initialise the TikZ path settings and read in the style options for the boundary
-% \begin{macrocode}
-\let\tqft at bdry@path=\pgfutil at empty
-\let\tqft at bdry@node at path=\pgfutil at empty
-\pgfsyssoftpath at setcurrentpath{\tqft at bdry@path}
- \tikz at mode@fillfalse%
- \tikz at mode@drawfalse%
- \let\tikz at mode=\pgfutil at empty
- \let\tikz at options=\pgfutil at empty
- \tqftset{boundary upper style contents}
- \tikz at mode
- \tikz at options
- \advance\tqft at xa by -\tqft at s
- \advance\tqft at xa by \tqft at w
-% \end{macrocode}
-% Do we have any incoming boundary components at all?
-% \begin{macrocode}
- \ifnum\tqft at incoming>0
-% \end{macrocode}
-% Yes, so iterate over them
-% \begin{macrocode}
- \foreach \tqft at k in {1,...,\tqft at incoming} {
- \advance\tqft at xa by \tqft at k\tqft at s
- \pgfpathmoveto{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
- \ifx\tikz at fig@name\pgfutil at empty
- \else
- {
- \advance\tqft at xa by -\tqft at width
- \pgftransformshift{\pgfqpoint{\tqft at xa}{\tqft at h}}
- \tqft at within@nodetrue
- \pgfsyssoftpath at getcurrentpath{\tqft at bdry@path}
- \pgfsyssoftpath at setcurrentpath{\tqft at bdry@node at path}
- \pgfnode{tqft boundary circle}{centre}{}{\tikz at fig@name\space incoming \tqft at k}{}
- \pgfsyssoftpath at getcurrentpath{\tqft at bdry@node at path}
- \pgfsyssoftpath at setcurrentpath{\tqft at bdry@path}
- }
- \fi
- }
- \fi
-% \end{macrocode}
-% Now iterate over the outgoing boundary components, if we have any
-% \begin{macrocode}
- \ifnum\tqft at outgoing>0
- \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing + \tqft at offset + 1) * \tqft at separation}
- \foreach \tqft at k in {1,...,\tqft at outgoing} {
- \advance\tqft at xa by -\tqft at k\tqft at s
-% \advance\tqft at xa by \tqft at s
- \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
- \ifx\tikz at fig@name\pgfutil at empty
- \else
- {
- \pgfmathtruncatemacro{\tqft at l}{\tqft at outgoing + 1 - \tqft at k}
- \advance\tqft at xa by -\tqft at width
- \pgftransformshift{\pgfqpoint{\tqft at xa}{-\tqft at h}}
- \tqft at within@nodetrue
- \pgfsyssoftpath at getcurrentpath{\tqft at bdry@path}
- \pgfsyssoftpath at setcurrentpath{\tqft at bdry@node at path}
- \pgfnode{tqft boundary circle}{centre}{}{\tikz at fig@name\space outgoing \tqft at l}{}
- \pgfsyssoftpath at getcurrentpath{\tqft at bdry@node at path}
- \pgfsyssoftpath at setcurrentpath{\tqft at bdry@path}
- }
- \fi
- }
- \fi
-% \end{macrocode}
-% \begin{macrocode}
- \edef\tikz at temp{\noexpand\pgfusepath{%
- \iftikz at mode@fill fill,\fi%
- \iftikz at mode@draw draw\fi%
- }}%
- \tikz at temp
- }
- }
-}
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{boundary circle shape}
-% This is a the shape of the boundary circles
-% \begin{macrocode}
-\pgfdeclareshape{tqft boundary circle}{
-% \end{macrocode}
-% Now we save our dimensions: height, separation, and the radii of the boundary circles
-% \begin{macrocode}
- \saveddimen{\tqft at height}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/cobordism height}}
- \saveddimen{\tqft at separation}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/boundary separation}}
- \saveddimen{\tqft at width}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/circle width}}
- \saveddimen{\tqft at depth}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/circle depth}}
-% \end{macrocode}
-%
-% For the externally available anchors, we need to save the declared transformation; we save the actual transformation, not the macro that points to it.
-% If we're called within the main cobordism shape, the transformation is already applied so we ignore it.
-% \begin{macrocode}
- \savedmacro{\tqft at transformation}{%
- \iftqft at within@node
- \let\tqft at transformation=\pgfutil at empty
- \else
- \pgfkeysgetvalue{/pgf/tqft/flow transformation}{\tqft at transformation}
- \fi
-}
-% \end{macrocode}
-% \begin{macrocode}
- \savedanchor{\tqft at centre}{%
- \pgfpointorigin}
-% \end{macrocode}
-% For completeness, we record the size of the text box (not that we expect any text, but you never know)
-% \begin{macrocode}
-\savedanchor{\tqft at textsize}{%
- \pgf at y=-.5\ht\pgfnodeparttextbox%
- \pgf at x=-.5\wd\pgfnodeparttextbox%
-}
-% \end{macrocode}
-% These are our externally available anchors
-% \begin{macrocode}
- \anchor{centre}{\tqft at centre}
- \anchor{center}{\tqft at centre}
-\anchor{text}{
- \tqft at textsize
-}
- \anchor{next}{%
- \tqft at process{\tqft at separation}{0pt}}%
-% \end{macrocode}
-% \begin{macrocode}
- \anchor{prior}{%
- \tqft at process{-\tqft at separation}{0pt}}%
-% \end{macrocode}
-% \begin{macrocode}
- \anchor{above}{%
- \tqft at process{0pt}{\tqft at height}}%
-% \end{macrocode}
-% \begin{macrocode}
- \anchor{below}{%
- \tqft at process{0pt}{-\tqft at height}}%
-% \end{macrocode}
-% The anchor border is the ellipse, but we need to take into account the possible transformation.
-% (This isn't right if the origin is shifted.)
-% At the moment, '0 degrees' is interpreted in the transformed coordinate system.
-% Should provide a system whereby that can be intepreted in the main coordinate system.
-% \begin{macrocode}
- \anchorborder{
-% \end{macrocode}
-% This next \Verb+\pgf at process+ makes the angles absolute.
-% Comment it out to make the angles relative.
-% \begin{macrocode}
- \tqft at process{\the\pgf at x}{\the\pgf at y}
- \edef\tqft at marshal{%
- \noexpand\pgfpointborderellipse
- {\noexpand\pgfqpoint{\the\pgf at x}{\the\pgf at y}}
- {\noexpand\pgfqpoint{\tqft at width}{\tqft at depth}}
- }%
- \tqft at marshal
- \tqft at process{\the\pgf at x}{\the\pgf at y}
-}
-% \end{macrocode}
-% Now we define the background path.
-% This is the upper part of the cobordism.
-% \begin{macrocode}
- \backgroundpath{
-% \end{macrocode}
-% Apply the internal transformation if we're not within a node
-% \begin{macrocode}
- \let\tikz at transform=\pgfutil at empty
- \expandafter\tikzset\expandafter{\tqft at transformation}
- \tikz at transform
-% \end{macrocode}
-% Draw the boundary circle
-% \begin{macrocode}
- \pgfpathellipse{\pgfqpoint{0pt}{0pt}}{\pgfqpoint{\tqft at width}{0pt}}{\pgfqpoint{0pt}{\tqft at depth}}
- }
-% \end{macrocode}
-% We draw the upper and lower arcs again with the appropriate styles
-% \begin{macrocode}
- \beforebackgroundpath{
- \iftqft at within@node
- \else
- \tikz at mode@fillfalse%
- \tikz at mode@drawfalse%
- \let\tikz at mode=\pgfutil at empty
- \let\tikz at options=\pgfutil at empty
- {
- \pgfsys at beginscope
- \tqftset{boundary lower style contents}
- \tikz at mode
- \tikz at options
- \pgfpathmoveto{\pgfqpoint{\tqft at width}{0pt}}
- \pgfpatharc{0}{\pgf at tqft@lower180}{\tqft at width and \tqft at depth}
- \edef\tikz at temp{\noexpand\pgfusepath{%
- \iftikz at mode@fill fill,\fi%
- \iftikz at mode@draw draw\fi%
- }}%
- \tikz at temp
- \pgfsys at endscope
- }
- {
- \pgfsys at beginscope
- \tqftset{boundary upper style contents}
- \tikz at mode
- \tikz at options
- \pgfpathmoveto{\pgfqpoint{\tqft at width}{0pt}}
- \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
- \edef\tikz at temp{\noexpand\pgfusepath{%
- \iftikz at mode@fill fill,\fi%
- \iftikz at mode@draw draw\fi%
- }}%
- \tikz at temp
- \pgfsys at endscope
- }
- \fi
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \iffalse
-%</package>
-% \fi
-%
-% \subsection{New Version: Picture Shapes}
-%
-% \iffalse
-%<*library>
-% \fi
-%
-% Issue a warning if the pic syntax is not available.
-%
-% \begin{macrocode}
-\ifcsname pgfk@/handlers/.pic/. at cmd\endcsname
-\else
-\pgfwarning{This library only works with TikZ 3.0 or later; for earlier versions of TikZ use the TQFT package}
-\fi
-% \end{macrocode}
-% For the boundaries, we need elliptical node shapes.
-% \begin{macrocode}
-\usetikzlibrary{shapes.geometric}
-% \end{macrocode}
-% We can view the cobordisms from the \emph{input} or \emph{output} ends, the implementation of the choice is to draw an arc from 0 to 180 or from 0 to -180 so we just need to track minus signs.
-% These macros are for that.
-% \begin{macrocode}
-\def\pgf at tqft@minus{-}
-\let\pgf at tqft@upper\@empty
-\let\pgf at tqft@lower\pgf at tqft@minus
-% \end{macrocode}
-% Split an anchoring coordinate.
-% The \(y\)--value is simply multiplied by the cobordism height (but pointing downwards, so that \(1\) is level with the outgoing boundary).
-% The \(x\)--value is multiplied by the boundary separation, but is shifted so that at the incoming boundary level, or above, then it is in line with the incoming boundaries and similarly at the outgoing boundary level, or below, it is in line with the outgoing boundaries.
-% \begin{macrocode}
-\def\tqft at split(#1,#2){%
- \pgfmathsetmacro\tqft at y{#2 * (-\tqft at val{cobordism height})}%
- \pgfmathsetmacro\tqft at x{(#1 - 1 + max(min(#2,1),0)*\tqft at val{offset}) * \tqft at val{boundary separation}}%
- \def\tqft at shift{(\tqft at x pt, \tqft at y pt)}%
-}%
-% \end{macrocode}
-% Now we set up all the keys that we'll need in the course of this shape
-% \begin{macrocode}
-\tikzset{
-% \end{macrocode}
-% Fix for the fact that the \verb+alias+ key doesn't use the prefix and suffix.
-% \begin{macrocode}
- pic alias/.code={%
- \tikz at fig@mustbenamed
- \expandafter\def\expandafter\tikz at alias\expandafter{\tikz at alias\pgfnodealias{\tikz at pp@name{#1}}{\tikz at fig@name}}%
- },
-% \end{macrocode}
-% This key is our basic installer key, setting the pic and putting us in the right key family.
-% \begin{macrocode}
- tqft/.style={%
- pic type=cobordism,
- every tqft/.try,
- tqft/.cd,
- },
-% \end{macrocode}
-% This deals with unknown keys, passing them on to TikZ.
-% \begin{macrocode}
- tqft/.unknown/.code={%
- \let\tqft at searchname=\pgfkeyscurrentname%
- \pgfkeysalso{%
- /tikz/\tqft at searchname={#1}
- }
- },
-% \end{macrocode}
-% Let's play happy families!
-% \begin{macrocode}
- tqft/.cd,
-% \end{macrocode}
-% These set our number of boundary components and genus.
-% \begin{macrocode}
- incoming boundary components/.initial=5,
- outgoing boundary components/.initial=4,
- skip incoming boundary components/.initial={},
- skip outgoing boundary components/.initial={},
- genus/.initial = 0,
-% \end{macrocode}
-% This is the ``horizontal'' offset of the first outgoing component from the first incoming one.
-% \begin{macrocode}
- offset/.initial=0,
-% \end{macrocode}
-% This is the ``vertical'' separation between boundary components.
-% \begin{macrocode}
- cobordism height/.initial=2cm,
-% \end{macrocode}
-% This is the ``horizontal'' separation between boundary components.
-% \begin{macrocode}
- boundary separation/.initial=2cm,
-% \end{macrocode}
-% These are the ``horizontal'' and ``vertical'' radii, respectively, of the boundary components.
-% \begin{macrocode}
- circle x radius/.initial=10pt,
- circle y radius/.initial=5pt,
-% \end{macrocode}
-% These control the direction from which we view the cobordism.
-% \begin{macrocode}
- view from/.is choice,
- view from/incoming/.code={%
- \let\pgf at tqft@upper\pgf at tqft@minus
- \let\pgf at tqft@lower\@empty
- },
- view from/outgoing/.code={%
- \let\pgf at tqft@lower\pgf at tqft@minus
- \let\pgf at tqft@upper\@empty
- },
-% \end{macrocode}
-% We simulate node placement using the following key.
-% \begin{macrocode}
- anchor/.initial = none,
-% \end{macrocode}
-% The next set of keys define some default shapes.
-% \begin{macrocode}
- pair of pants/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=2,
- offset=-.5
- },
- /tikz/tqft pair of pants/.style={
- /tikz/tqft/pair of pants,
- },
- reverse pair of pants/.style={
- /tikz/tqft,
- incoming boundary components=2,
- outgoing boundary components=1,
- offset=.5
- },
- /tikz/tqft reverse pair of pants/.style={
- /tikz/tqft/reverse pair of pants,
- },
- cylinder to prior/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- offset=-.5
- },
- /tikz/tqft cylinder to prior/.style={
- /tikz/tqft/cylinder to prior,
- },
- cylinder to next/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=1,
- offset=.5
- },
- /tikz/tqft cylinder to next/.style={
- /tikz/tqft/cylinder to next,
- },
- cylinder/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=1
- },
- /tikz/tqft cylinder/.style={
- /tikz/tqft/cylinder,
- },
- cup/.style={
- /tikz/tqft,
- incoming boundary components=1,
- outgoing boundary components=0
- },
- /tikz/tqft cup/.style={
- /tikz/tqft/cup,
- },
- cap/.style={
- /tikz/tqft,
- incoming boundary components=0,
- outgoing boundary components=1
- },
- /tikz/tqft cap/.style={
- /tikz/tqft/cap,
- },
-}
-% \end{macrocode}
-%
-% This is a little helper macro for getting the values of tqft keys.
-% \begin{macrocode}
-\def\tqft at val#1{\pgfkeysvalueof{/tikz/tqft/#1}}
-% \end{macrocode}
-%
-% Now we define the code for the actual cobordism shape.
-% \begin{macrocode}
-\tikzset{
- cobordism/.pic={
-% \end{macrocode}
-% Defining the cobordism paths.
-% This holds the full boundary path of the cobordism shape.
-% \begin{macrocode}
- \gdef\tqft at fullpath{}%
-% \end{macrocode}
-% This is a list of the edge pieces without the boundary circles.
-% \begin{macrocode}
- \global\let\tqft at blist\pgfutil at gobble%
-% \end{macrocode}
-% This punches the holes (if there are any) in the cobordism shape.
-% \begin{macrocode}
- \gdef\tqft at gclip{}%
-% \end{macrocode}
-% This is a list of the paths for drawing the holes.
-% \begin{macrocode}
- \global\let\tqft at glist\pgfutil at gobble%
-% \end{macrocode}
-% This collects any coordinates that are to be defined (it appears to be difficult to define them as we go along).
-% \begin{macrocode}
- \global\let\tqft at clist\pgfutil at gobble%
-% \end{macrocode}
-% This collects any coordinates that can be used to shift the shape that aren't to be defined using \verb+\tqft at clist+.
-% \begin{macrocode}
- \global\let\tqft at alist\pgfutil at gobble
-% \end{macrocode}
-% These will be lists of the boundary components, divided into sets as to whether or not they are rendered. For the outgoing ones, we need too lists because they are rendered in the opposite order to how they are labelled.
-% \begin{macrocode}
- \global\let\tqft at ibdrylist=\pgfutil at gobble
- \global\let\tqft at cibdrylist=\pgfutil at gobble
- \global\let\tqft at obdrylist=\pgfutil at gobble
- \global\let\tqft at cobdrylist=\pgfutil at gobble
- \global\let\tqft at robdrylist=\pgfutil at gobble
- \global\let\tqft at rcobdrylist=\pgfutil at gobble
-% \end{macrocode}
-% The first stage is to iterate over the incoming boundary components (if there are any), building up the various paths.
-% \begin{macrocode}
- \ifnum\tqft at val{incoming boundary components}>0\relax
-% \end{macrocode}
-% We have some so draw the half circle for the first component.
-% Note that we use \verb+\pgf at tqft@upper+ to flip the sign of the start angle depending on the \verb+view from+ setting.
-% \begin{macrocode}
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- (-\tqft at val{circle x radius},0) arc[start angle=\pgf at tqft@upper180, end angle=0, x radius=\tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
- }%
-% \end{macrocode}
-% And add the centre to the list for available shifts.
-% \begin{macrocode}
- \xdef\tqft at alist{%
- \tqft at alist,-incoming boundary 1/{(0,0)},-incoming boundary/{(0,0)}%
- }%
-% \end{macrocode}
-% If there are more than one then for each subsequent one we add the curve between them and the corresponding arc of the boundary circle.
-% \begin{macrocode}
- \ifnum\tqft at val{incoming boundary components}>1\relax
- \foreach \k in {2,...,\tqft at val{incoming boundary components}} {
- \edef\tqft at temp{\noexpand\pgfutil at in@{,\k,}{,\tqft at val{skip incoming boundary components},}}
- \tqft at temp
- \ifpgfutil at in@
- \xdef\tqft at cibdrylist{\tqft at cibdrylist,\k}
- \else
- \xdef\tqft at ibdrylist{\tqft at ibdrylist,\k}
- \fi
- }
- \ifx\tqft at ibdrylist\pgfutil at gobble
- \else
- \foreach \k [
- remember=\k as \kmo (initially 1),
- evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation} -\tqft at val{circle x radius},
- ] in \tqft at ibdrylist {
- \pgfmathsetmacro\xppos{(\kmo - 1)*\tqft at val{boundary separation} + \tqft at val{circle x radius}}
- \pgfmathsetmacro\cpos{(\xpos + \xppos)/2}
-% \end{macrocode}
-% Add the curve and the arc.
-% \begin{macrocode}
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- .. controls +(0,-\tqft at val{cobordism height}/3) and +(0,-\tqft at val{cobordism height}/3) .. (\xpos pt,0) arc[start angle=\pgf at tqft@upper180, end angle=0, x radius=\tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
- }%
-% \end{macrocode}
-% But for the edge path, just add the curve to the list.
-% \begin{macrocode}
- \xdef\tqft at blist{%
- \tqft at blist,incoming boundary \k/incoming/{%
- (\xppos pt,0) .. controls +(0,-\tqft at val{cobordism height}/3) and +(0,-\tqft at val{cobordism height}/3) .. (\xpos pt,0)}%
- }%
-% \end{macrocode}
-% We add a coordinate at the midpoint of the curve.
-% \begin{macrocode}
- \xdef\tqft at clist{%
- \tqft at clist,-between incoming \kmo\space and \k/{(\cpos pt,-\tqft at val{cobordism height}/4)}%
- }%
-% \end{macrocode}
-% And add the centre to the list for available shifts.
-% \begin{macrocode}
- \xdef\tqft at alist{%
- \tqft at alist,-incoming boundary \k/{(\kmo * \tqft at val{boundary separation},0)}%
- }%
- }%
- \fi
- \fi
-% \end{macrocode}
-% We're at the edge of the last incoming boundary component.
-% What we do now depends on whether or not there are outgoing boundary components.
-% \begin{macrocode}
- \ifnum\tqft at val{outgoing boundary components}>0\relax
-% \end{macrocode}
-% There are, so we add a curve from the end of the last incoming to the last outgoing component to the full path,
-% \begin{macrocode}
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} +\tqft at val{circle x radius}}%
- \pgfmathsetmacro\tqft at ht{abs(\tqft at val{incoming boundary components} - \tqft at val{outgoing boundary components} - \tqft at val{offset})}%
- \pgfmathsetmacro\tqft at ht{1/3 + 2/3*\tqft at ht/(\tqft at ht + 1)}%
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- .. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,\tqft at ht*\tqft at val{cobordism height}) .. (\xppos pt, -\tqft at val{cobordism height})
- }%
-% \end{macrocode}
-% and the edge path.
-% \begin{macrocode}
- \xdef\tqft at blist{%
- \tqft at blist,between last incoming and last outgoing/incoming and outgoing/{%
- (\tqft at val{incoming boundary components} * \tqft at val{boundary separation} + \tqft at val{circle x radius} - \tqft at val{boundary separation},0pt)
- .. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,\tqft at ht*\tqft at val{cobordism height}) .. (\xppos pt, -\tqft at val{cobordism height})}%
- }%
-% \end{macrocode}
-% In addition, we add a coordinate at the midpoint.
-% \begin{macrocode}
- \pgfmathsetmacro\xppos{(\xppos + (\tqft at val{incoming boundary components} -1) * \tqft at val{boundary separation} +\tqft at val{circle x radius})/2}%
- \xdef\tqft at clist{%
- \tqft at clist,-between last incoming and last outgoing/{(\xppos pt,-\tqft at val{cobordism height}/2)}%
- }%
- \else
-% \end{macrocode}
-% There aren't any outgoing boundary components so we loop back to the start.
-% We adjust the height of the control points to take into account the overall width.
-% \begin{macrocode}
- \pgfmathsetmacro\tqft at ht{1/3 + 2/3*(\tqft at val{incoming boundary components} - 1)/\tqft at val{incoming boundary components}}
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- .. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)
- }%
-% \end{macrocode}
-% Same for the edge path.
-% \begin{macrocode}
- \xdef\tqft at blist{%
- \tqft at blist,between first incoming and last incoming/incoming and outgoing/{%
- (\tqft at val{incoming boundary components} * \tqft at val{boundary separation} + \tqft at val{circle x radius} - \tqft at val{boundary separation},0pt)
- .. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)}
- }%
-% \end{macrocode}
-% Add a coordinate at the midpoint.
-% \begin{macrocode}
- \pgfmathsetmacro\xppos{(\tqft at val{incoming boundary components} -1) * \tqft at val{boundary separation}/2}%
- \xdef\tqft at clist{%
- \tqft at clist,-between first incoming and last incoming/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height}*3/4)}%
- }%
- \fi
- \else
-% \end{macrocode}
-% There weren't any incoming boundary components, so we test to see if there were any outgoing ones and move to the start of them.
-% \begin{macrocode}
- \ifnum\tqft at val{outgoing boundary components}>0\relax
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} +\tqft at val{circle x radius}}
-% \end{macrocode}
-% Add a move to the full path,
-% \begin{macrocode}
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- (\xppos pt, -\tqft at val{cobordism height})
- }%
- \fi
- \fi
-% \end{macrocode}
-% We're done with the incoming boundary components, now we're set up for the outgoing ones.
-% However we got there, if we have outgoing boundary components then we're now located at the start of them, although we're counting backwards.
-% \begin{macrocode}
- \ifnum\tqft at val{outgoing boundary components}>0\relax
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} -\tqft at val{circle x radius}}%
-% \end{macrocode}
-% Draw the arc for the first (well, last actually) boundary component.
-% \begin{macrocode}
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- arc[end angle=\pgf at tqft@upper180, start angle=0, x radius=\tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
- }%
-% \end{macrocode}
-% And add the centre to the list for available shifts.
-% \begin{macrocode}
- \xdef\tqft at alist{%
- \tqft at alist,-outgoing boundary \tqft at val{outgoing boundary components}/{(\xppos pt + \tqft at val{circle x radius},-\tqft at val{cobordism height})},-outgoing boundary/{(\tqft at val{offset}*\tqft at val{boundary separation},-\tqft at val{cobordism height})}%
- }%
-% \end{macrocode}
-% Do we have more than one boundary component?
-% \begin{macrocode}
- \ifnum\tqft at val{outgoing boundary components}>1\relax
-% \end{macrocode}
-% Yes, so add a curve and arc for each.
-% \begin{macrocode}
- \foreach \k [evaluate=\k as \ok using int(\tqft at val{outgoing boundary components} - \k + 1)] in {2,...,\tqft at val{outgoing boundary components}} {
- \edef\tqft at temp{\noexpand\pgfutil at in@{,\ok,}{,\tqft at val{skip outgoing boundary components},}}
- \tqft at temp
- \ifpgfutil at in@
- \xdef\tqft at cobdrylist{\tqft at cobdrylist,\k}
- \else
- \xdef\tqft at obdrylist{\tqft at obdrylist,\k}
- \fi
- }
- \ifx\tqft at obdrylist\pgfutil at gobble
- \else
- \foreach \k [
- remember=\k as \kmo (initially 1),
- evaluate=\k as \xpos using (\tqft at val{outgoing boundary components} - \k + \tqft at val{offset})*\tqft at val{boundary separation} + \tqft at val{circle x radius},
- ] in \tqft at obdrylist {
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} - \kmo + \tqft at val{offset})*\tqft at val{boundary separation} - \tqft at val{circle x radius}}
- \pgfmathsetmacro\cpos{(\xpos + \xppos)/2}
- \pgfmathsetmacro\nk{int(\tqft at val{outgoing boundary components} - \k + 1)}
- \pgfmathsetmacro\nkpo{int(\tqft at val{outgoing boundary components} - \kmo + 1)}
-% \end{macrocode}
-% Both are added to the full path.
-% \begin{macrocode}
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- .. controls +(0,\tqft at val{cobordism height}/3) and +(0,\tqft at val{cobordism height}/3) .. (\xpos pt,-\tqft at val{cobordism height}) arc[end angle=\pgf at tqft@upper180, start angle=0, x radius=\tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
- }%
-% \end{macrocode}
-% Just the arc for the edge paths.
-% \begin{macrocode}
- \xdef\tqft at blist{%
- \tqft at blist,between outgoing \nk\space and \nkpo/outgoing/{%
- (\xppos pt,-\tqft at val{cobordism height})
- .. controls +(0,\tqft at val{cobordism height}/3) and +(0,\tqft at val{cobordism height}/3) .. (\xpos pt,-\tqft at val{cobordism height}) ++(-2*\tqft at val{circle x radius},0)}%
- }%
-% \end{macrocode}
-% And a coordinate at the midpoint.
-% \begin{macrocode}
- \xdef\tqft at clist{%
- \tqft at clist,-between outgoing \nk\space and \nkpo/{(\cpos pt,-3*\tqft at val{cobordism height}/4)}%
- }%
-% \end{macrocode}
-% And add the centre to the list for available shifts.
-% \begin{macrocode}
- \xdef\tqft at alist{%
- \tqft at alist,-outgoing boundary \nk/{(\xpos pt - \tqft at val{circle x radius},-\tqft at val{cobordism height})}%
- }%
- }%
- \fi
- \fi
-% \end{macrocode}
-% Now we're at the end of the outgoing boundary components (well, the start actually).
-% What we do now depends on whether or not there are any incoming boundary components.
-% \begin{macrocode}
- \ifnum\tqft at val{incoming boundary components}>0\relax
-% \end{macrocode}
-% There are, so we draw the path back up.
-% \begin{macrocode}
- \pgfmathsetmacro\tqft at ht{1/3 + 2/3*abs(\tqft at val{offset})/(abs(\tqft at val{offset}) + 1)}%
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- .. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)
- }%
-% \end{macrocode}
-% And the edge path does the same.
-% \begin{macrocode}
- \xdef\tqft at blist{%
- \tqft at blist,between first incoming and first outgoing/incoming and outgoing/{%
- (\tqft at val{offset} * \tqft at val{boundary separation} - \tqft at val{circle x radius},-\tqft at val{cobordism height})
- .. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)}%
- }%
-% \end{macrocode}
-% Add a coordinate at the midpoint.
-% \begin{macrocode}
- \xdef\tqft at clist{%
- \tqft at clist,-between first incoming and first outgoing/{(\tqft at val{offset}*\tqft at val{boundary separation}/2-\tqft at val{circle x radius},-\tqft at val{cobordism height}/2)}%
- }%
- \else
-% \end{macrocode}
-% No incoming boundary components so loop back to the other end of the outgoing boundary components.
-% \begin{macrocode}
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} +\tqft at val{circle x radius}}%
- \pgfmathsetmacro\tqft at ht{1/3 + 2/3*(\tqft at val{outgoing boundary components} - 1)/\tqft at val{outgoing boundary components}}
-% \end{macrocode}
-% Full path.
-% \begin{macrocode}
- \xdef\tqft at fullpath{%
- \tqft at fullpath
- .. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,\tqft at ht*\tqft at val{cobordism height}) .. (\xppos pt,-\tqft at val{cobordism height})
- }%
-% \end{macrocode}
-% Edge path.
-% \begin{macrocode}
- \xdef\tqft at blist{%
- \tqft at blist,between first and last outgoing/incoming and outgoing/{%
- (\tqft at val{offset} * \tqft at val{boundary separation} - \tqft at val{circle x radius},-\tqft at val{cobordism height})
- .. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,\tqft at ht*\tqft at val{cobordism height}) .. (\xppos pt,-\tqft at val{cobordism height})}%
- }%
-% \end{macrocode}
-% Add a coordinate at the midpoint.
-% \begin{macrocode}
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components}/2 + \tqft at val{offset} -1/2) * \tqft at val{boundary separation}}%
- \pgfmathsetmacro\tqft at ht{1 -\tqft at ht*3/4}%
- \xdef\tqft at clist{%
- \tqft at clist,-between first and last outgoing/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height})}%
- }%
- \fi
- \fi
-% \end{macrocode}
-% Now we define the clip path for the genus holes.
-% We start with a big rectangle that \emph{ought} to be big enough to contain the whole shape.
-% We start with the top left corner.
-% \begin{macrocode}
- \pgfmathsetmacro\xpos{%
- (
- \tqft at val{outgoing boundary components} > 0 ?
- (
- \tqft at val{incoming boundary components} > 0 ?
- min(0,\tqft at val{offset}) : \tqft at val{offset}
- ) : 0
- )
- *\tqft at val{boundary separation} - 2*\tqft at val{circle x radius}}%
- \xdef\tqft at gclip{(\xpos pt,2*\tqft at val{circle y radius}) rectangle }%
-% \end{macrocode}
-% Now the bottom right.
-% \begin{macrocode}
- \pgfmathsetmacro\xpos{%
- ((
- \tqft at val{outgoing boundary components} > 0 ?
- (
- \tqft at val{incoming boundary components} > 0 ?
- max(\tqft at val{incoming boundary components},\tqft at val{outgoing boundary components} + \tqft at val{offset}) : \tqft at val{outgoing boundary components} + \tqft at val{offset}
- ) : \tqft at val{incoming boundary components}
- )-1)
- *\tqft at val{boundary separation} + 2*\tqft at val{circle x radius}}%
-% \end{macrocode}
-% Together, these make a rectangle.
-% \begin{macrocode}
- \xdef\tqft at gclip{\tqft at gclip (\xpos pt,-\tqft at val{cobordism height} - 2*\tqft at val{circle y radius})}%
-% \end{macrocode}
-% Are there any holes?
-% \begin{macrocode}
- \ifnum\tqft at val{genus}>0\relax
-% \end{macrocode}
-% Yes, so first we need to figure out where to place them.
-% We work out the left-hand edge of the cobordism.
-% \begin{macrocode}
- \pgfmathsetmacro\xpos{%
- (
- \tqft at val{outgoing boundary components} > 0 ?
- (
- \tqft at val{incoming boundary components} > 0 ?
- \tqft at val{offset}/2 : \tqft at val{offset}
- ) : 0
- )
- *\tqft at val{boundary separation} - \tqft at val{circle x radius}}%
-% \end{macrocode}
-% Work out the height that the holes should be punched at.
-% \begin{macrocode}
- \pgfmathsetmacro\ypos{%
- (
- \tqft at val{outgoing boundary components} > 0 ?
- (
- \tqft at val{incoming boundary components} > 0 ?
- -\tqft at val{cobordism height}/2 : -1 + \tqft at val{cobordism height}/3
- ) : - \tqft at val{cobordism height}/3
- )}%
-% \end{macrocode}
-% Start our clip path at this point
-% \begin{macrocode}
- \xdef\tqft at gclip{%
- \tqft at gclip
- (\xpos pt,\ypos pt)
- }%
-% \end{macrocode}
-% Now work out the width of the cobordism, in units of circle half-widths.
-% This may not be very accurate if there aren't any boundary components of a given type.
-% \begin{macrocode}
- \pgfmathsetmacro\gsize{%
- ((
- \tqft at val{outgoing boundary components} > 0 ?
- (
- \tqft at val{incoming boundary components} > 0 ?
- (\tqft at val{incoming boundary components} + \tqft at val{outgoing boundary components})/2 : \tqft at val{outgoing boundary components}
- ) : \tqft at val{incoming boundary components}
- )-1)
- *\tqft at val{boundary separation}/\tqft at val{circle x radius} + 2}%
-% \end{macrocode}
-% Each hole should take up three half-widths, but we want a little extra on the edges so the total number of half-widths we want is \(3g + 1\).
-% Do we need to scale down the holes (we never scale up)?
-% If so, \verb+\gscale+ holds the overall scale factor and \verb+\gxscale+ and \verb+gyscale+ are the resulting horizontal and vertical measurements.
-% The baseline is the size of the boundary circles.
-% \begin{macrocode}
- \pgfmathsetmacro\gscale{min(1,\gsize/(3*\tqft at val{genus}+1))}%
- \pgfmathsetmacro\gyscale{\tqft at val{circle y radius}*\gscale*.707}%
- \pgfmathsetmacro\gxscale{\tqft at val{circle x radius}*\gscale}%
-% \end{macrocode}
-% Each hole should take up 2 half widths, modulo scaling, so the total width used by the holes is \(2 g s\) leaving \(w - 2 g s\) left for the gaps which is divided in to \(g + 1\) lots.
-% \begin{macrocode}
- \pgfmathsetmacro\gsep{((\gsize - 2*\tqft at val{genus}*\gscale)/(\tqft at val{genus} + 1)*\tqft at val{circle x radius}}%
-% \end{macrocode}
-% We shift in by half of one unit of excess separation.
-% \begin{macrocode}
- \xdef\tqft at gclip{%
- \tqft at gclip
- ++(\gsep/2 pt,0)
- }%
-% \end{macrocode}
-% Some useful quantities.
-% \begin{macrocode}
- \pgfmathsetmacro\omrstwo{1 - 1/sqrt(2)}%
- \pgfmathsetmacro\sqrtwo{sqrt(2)}%
-% \end{macrocode}
-% Now we iterate over the holes.
-% \begin{macrocode}
- \foreach[
- evaluate=\k as \kmo using int(2 * \k-1)
- ] \k in {1,...,\tqft at val{genus}} {
-% \end{macrocode}
-% For the clipping path, we just want the bare hole.
-% \begin{macrocode}
- \xdef\tqft at gclip{%
- \tqft at gclip
-% \end{macrocode}
-% Move in by half an excess separation unit and move to the left-hand extent of the hole.
-% \begin{macrocode}
- ++(\gsep/2 pt + \omrstwo*\gxscale pt,0)
-% \end{macrocode}
-% Now curve up over the hole,
-% \begin{macrocode}
- .. controls +(\gxscale*\sqrtwo/3 pt,4/3*\gyscale pt) and +(-\gxscale*\sqrtwo/3 pt,4/3*\gyscale pt)
- .. ++(\sqrtwo*\gxscale pt,0)
-% \end{macrocode}
-% and return on the underside.
-% \begin{macrocode}
- .. controls +(-\gxscale*\sqrtwo/3 pt,-4/3*\gyscale pt) and +(\gxscale*\sqrtwo/3 pt,-4/3*\gyscale pt)
- .. ++(-\sqrtwo*\gxscale pt,0)
-% \end{macrocode}
-% Lastly, move to the right-hand edge of the space taken up by this hole.
-% \begin{macrocode}
- ++(2*\gxscale pt -\omrstwo*\gxscale pt + \gsep/2 pt,0)
- }
-% \end{macrocode}
-% For the genus \emph{path} we want to add the little ``tails'' which means that the two curves are different, and we need to take into acount the \verb+view from+ direction.
-% \begin{macrocode}
- \xdef\tqft at glist{%
- \tqft at glist,%
- hole \k/lower/{%
-% \end{macrocode}
-% Move to the starting point of the smaller curve and add that.
-% \begin{macrocode}
- (\xpos pt + \k * \gsep pt + \kmo * \gxscale pt + \gxscale pt -\omrstwo*\gxscale pt,\ypos pt)
- .. controls +(-\gxscale pt*\sqrtwo/3,\pgf at tqft@upper4/3*\gyscale pt) and +(\gxscale pt*\sqrtwo/3,\pgf at tqft@upper4/3*\gyscale pt)
- .. ++(-\sqrtwo*\gxscale pt,0)},%
-% Move to the left-hand corner of the path, with the upper or lower chosen by the \verb+view from+ direction.
- hole \k/upper/{(\xpos pt + \k * \gsep pt + \kmo * \gxscale pt - \gxscale pt,\ypos pt + \pgf at tqft@upper\gyscale pt)%
-% \end{macrocode}
-% Add the larger of the two curves.
-% \begin{macrocode}
- .. controls +(\gxscale pt*2/3,\pgf at tqft@lower8/3*\gyscale pt) and +(-\gxscale pt*2/3,\pgf at tqft@lower8/3*\gyscale pt)
- .. ++(2*\gxscale pt,0)}%
- }%
-% \end{macrocode}
-% Add a coordinate at the centre of the hole.
-% \begin{macrocode}
- \xdef\tqft at clist{%
- \tqft at clist,-hole \k/{(\xpos pt + \k * \gsep pt + \kmo * \gxscale pt,\ypos pt)}%
- }%
- }%
- \fi
-% \end{macrocode}
-% Now we start to lay out the cobordism
-% Were we given a shift? If so, shift.
-% \begin{macrocode}
-\gdef\tqft at shift{(0,0)}%
-\edef\tqft at anchor{\tqft at val{anchor}}%
-\expandafter\pgfutil at in@\expandafter{\expandafter,\expandafter}\expandafter{\tqft at anchor}%
-\ifpgfutil at in@
-\expandafter\tqft at split\tqft at anchor\relax
-\else
-\edef\tqft at anchor{-\tqft at val{anchor}}%
-\xdef\tqft at alist{\tqft at clist,\tqft at alist}%
-\foreach \anchor/\coord in \tqft at alist
-{
- \ifx\anchor\tqft at anchor\relax
- \global\let\tqft at shift\coord
- \fi
-}%
-\fi
-\tikz at scan@one at point\pgfutil at firstofone\tqft at shift\relax
-\begin{scope}[shift={(-\pgf at x,-\pgf at y)}]
-% \end{macrocode}
-% At each incoming boundary component we place an elliptical node of the right size.
-% \begin{macrocode}
-\ifnum\tqft at val{incoming boundary components}>0\relax
-\ifx\tqft at ibdrylist\pgfutil at gobble
-\xdef\tqft at ibdrylist{1}
-\else
-\xdef\tqft at ibdrylist{1,\tqft at ibdrylist}
-\fi
- \foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at ibdrylist {
- \node[
- node contents={},
- ellipse,
- inner sep=0pt,
- outer sep=0pt,
- minimum width=2*\tqft at val{circle x radius},
- minimum height=2*\tqft at val{circle y radius},
- at={(\xpos pt,0)},
- name=-incoming boundary \k,
- /tikz/tqft/every boundary component/.try,
- /tikz/tqft/every incoming boundary component/.try,
- /tikz/tqft/incoming boundary component \k/.try
- ];
- }%
-\ifx\tqft at cibdrylist\pgfutil at gobble
-\else
- \foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at cibdrylist {
- \node[
- node contents={},
- ellipse,
- inner sep=0pt,
- outer sep=0pt,
- minimum width=2*\tqft at val{circle x radius},
- minimum height=2*\tqft at val{circle y radius},
- at={(\xpos pt,0)},
- name=-incoming boundary \k,
- /tikz/tqft/every skipped boundary component/.try,
- /tikz/tqft/every skipped incoming boundary component/.try,
- /tikz/tqft/skipped incoming boundary component \k/.try,
- ];
-}%
-\fi
-% \end{macrocode}
-% Add an alias for the first.
-% \begin{macrocode}
- \path node also[pic alias=-incoming boundary] (-incoming boundary 1);
- \fi
-% \end{macrocode}
-% Same for the outgoing boundary components.
-% \begin{macrocode}
- \ifnum\tqft at val{outgoing boundary components}>0\relax
-\ifx\tqft at obdrylist\pgfutil at gobble
-\xdef\tqft at obdrylist{1}
-\else
-\xdef\tqft at obdrylist{1,\tqft at obdrylist}
-\fi
-\foreach \k [evaluate=\k as \ok using int(\tqft at val{outgoing boundary components} - \k + 1)] in \tqft at obdrylist {
- \xdef\tqft at robdrylist{\tqft at robdrylist,\ok}
-}
- \foreach[
- evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
- ] \k in \tqft at robdrylist {
- \node[
- node contents={},
- ellipse,
- inner sep=0pt,
- outer sep=0pt,
- minimum width=2*\tqft at val{circle x radius},
- minimum height=2*\tqft at val{circle y radius},
- at={(\xpos pt,-\tqft at val{cobordism height})},
- name=-outgoing boundary \k,
- /tikz/tqft/every boundary component/.try,
- /tikz/tqft/every outgoing boundary component/.try,
- /tikz/tqft/outgoing boundary component \k/.try
- ];
-}%
-\ifx\tqft at cobdrylist\pgfutil at gobble
-\else
-\foreach \k [evaluate=\k as \ok using int(\tqft at val{outgoing boundary components} - \k + 1)] in \tqft at cobdrylist {
- \xdef\tqft at rcobdrylist{\tqft at rcobdrylist,\ok}
-}
- \foreach[
- evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
- ] \k in \tqft at rcobdrylist {
- \node[
- node contents={},
- ellipse,
- inner sep=0pt,
- outer sep=0pt,
- minimum width=2*\tqft at val{circle x radius},
- minimum height=2*\tqft at val{circle y radius},
- at={(\xpos pt,-\tqft at val{cobordism height})},
- name=-outgoing boundary \k,
- /tikz/tqft/every skipped boundary component/.try,
- /tikz/tqft/every skipped outgoing boundary component/.try,
- /tikz/tqft/skipped outgoing boundary component \k/.try
- ];
- }%
-\fi
-% \end{macrocode}
-% Add an alias for the first.
-% \begin{macrocode}
- \path node also[pic alias=-outgoing boundary] (-outgoing boundary 1);
- \fi
-% \end{macrocode}
-% Now we draw the lower paths of the incoming boundary components.
-% \begin{macrocode}
- \ifnum\tqft at val{incoming boundary components}>0\relax
- \foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at ibdrylist {
- \path[
- /tikz/tqft/every lower boundary component/.try,
- /tikz/tqft/every incoming lower boundary component/.try,
- /tikz/tqft/incoming lower boundary component \k/.try
- ] (\xpos pt - \tqft at val{circle x radius},0) arc[start angle=\pgf at tqft@lower180,end angle=0, x radius=\tqft at val{circle x radius}, y radius =\tqft at val{circle y radius}];
- }%
- \fi
-% \end{macrocode}
-% Same for the outgoing boundary components.
-% \begin{macrocode}
- \ifnum\tqft at val{outgoing boundary components}>0\relax
- \foreach[
- evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
- ] \k in \tqft at robdrylist {
- \path[
- /tikz/tqft/every lower boundary component/.try,
- /tikz/tqft/every outgoing lower boundary component/.try,
- /tikz/tqft/outgoing lower boundary component \k/.try
- ] (\xpos pt - \tqft at val{circle x radius},-\tqft at val{cobordism height}) arc[start angle=\pgf at tqft@lower180,end angle=0, x radius=\tqft at val{circle x radius}, y radius =\tqft at val{circle y radius}];
- }%
- \fi
-% \end{macrocode}
-% Full outer path, clipped against the genus holes in case it is filled.
-% \begin{macrocode}
- \begin{scope}
- \path[overlay,clip] \tqft at gclip;
- \path[
- /tikz/tqft/cobordism/.try,
- pic actions,
- /tikz/tqft/cobordism outer path/.try,
- ] \tqft at fullpath;
- \end{scope}
-% \end{macrocode}
-% Now we draw the genus path, outside the clip.
-% We view this as part of the full cobordism path so try to apply the same style as for the full path, but if that is filled then we turn the fill off.
-% It can be turned back on again using the styles \verb+cobordism edge+ or \verb+genus style+.
-% We also apply the \verb+cobordism edge+ style as it could be thought of as part of the non-boundary edge.
-% Finally, it has its own style to enable overrides if the other two get confused.
-% \begin{macrocode}
-\ifx\tqft at glist\pgfutil at gobble
-\else
-\foreach \tqft at gstyle/\tqft at gside/\tqft at gpath in \tqft at glist {
- \path[
- /tikz/tqft/cobordism/.try,
- pic actions,
- fill=none,
- shade=none,
- /tikz/tqft/cobordism edge/.try,
- /tikz/tqft/genus style/.try,
- /tikz/tqft/genus \tqft at gside/.try,
- /tikz/tqft/\tqft at gstyle/.try,
- /tikz/tqft/\tqft at gstyle\space\tqft at gside/.try,
- ] \tqft at gpath;
-}
-\fi
-% \end{macrocode}
-% Now we redraw the non-boundary paths.
-% \begin{macrocode}
-\ifx\tqft at blist\pgfutil at gobble
-\else
-\foreach \tqft at bstyle/\tqft at btype/\tqft at bpath in \tqft at blist {
- \path[
- /tikz/tqft/cobordism edge/.try,
- /tikz/tqft/cobordism outer edge/.try,
- /tikz/tqft/between \tqft at btype/.try,
- /tikz/tqft/\tqft at bstyle/.try,
- ] \tqft at bpath;
-}
-\fi
-% \end{macrocode}
-% There were various coordinates that we wanted to define but couldn't.
-% Here, we put those in place.
-% \begin{macrocode}
- \ifx\tqft at clist\pgfutil at gobble
- \else
- \foreach \name/\coord in \tqft at clist {
- \path \coord node[coordinate,node contents={},name=\name];
- }
- \fi
-% \end{macrocode}
-% The last task is to draw the upper paths of the boundary components.
-% First, incoming.
-% \begin{macrocode}
- \ifnum\tqft at val{incoming boundary components}>0\relax
- \foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at ibdrylist {
- \path[
- /tikz/tqft/every upper boundary component/.try,
- /tikz/tqft/every incoming upper boundary component/.try,
- /tikz/tqft/incoming upper boundary component \k/.try
- ] (\xpos pt - \tqft at val{circle x radius},0) arc[start angle=\pgf at tqft@upper180,end angle=0, x radius=\tqft at val{circle x radius}, y radius =\tqft at val{circle y radius}];
- }
- \fi
-% \end{macrocode}
-% Next, outgoing.
-% \begin{macrocode}
- \ifnum\tqft at val{outgoing boundary components}>0\relax
- \foreach[
- evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
- ] \k in \tqft at robdrylist {
- \path[
- /tikz/tqft/every upper boundary component/.try,
- /tikz/tqft/every outgoing upper boundary component/.try,
- /tikz/tqft/outgoing upper boundary component \k/.try
- ] (\xpos pt - \tqft at val{circle x radius},-\tqft at val{cobordism height}) arc[start angle=\pgf at tqft@upper180,end angle=0, x radius=\tqft at val{circle x radius}, y radius =\tqft at val{circle y radius}];
- }
- \fi
-\end{scope}
-% \end{macrocode}
-% We're done!
-% Phew.
-% \begin{macrocode}
- }
-}
-% \end{macrocode}
-%
-% \iffalse
-%</library>
-% \fi
-% \Finale
-
-\endinput
Deleted: trunk/Master/texmf-dist/source/latex/tqft/tqft.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/tqft/tqft.ins 2024-06-01 20:20:59 UTC (rev 71400)
+++ trunk/Master/texmf-dist/source/latex/tqft/tqft.ins 2024-06-01 20:21:17 UTC (rev 71401)
@@ -1,82 +0,0 @@
-%%
-%% This is file `tqft.ins',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% tqft.dtx (with options: `install')
-%% ----------------------------------------------------------------
-%% tqft --- a library for drawing TQFT diagrams with TikZ/PGF
-%% E-mail: loopspace at mathforge.org
-%% Released under the LaTeX Project Public License v1.3c or later
-%% See http://www.latex-project.org/lppl.txt
-%% ----------------------------------------------------------------
-%%
-\input docstrip.tex
-\keepsilent
-\askforoverwritefalse
-\preamble
-----------------------------------------------------------------
-tqft --- a library for drawing TQFT diagrams with TikZ/PGF
-E-mail: loopspace at mathforge.org
-Released under the LaTeX Project Public License v1.3c or later
-See http://www.latex-project.org/lppl.txt
-----------------------------------------------------------------
-
-\endpreamble
-\postamble
-
-Copyright (C) 2011 by Andrew Stacey <loopspace at mathforge.org>
-
-This work may be distributed and/or modified under the
-conditions of the LaTeX Project Public License (LPPL), either
-version 1.3c of this license or (at your option) any later
-version. The latest version of this license is in the file:
-
-http://www.latex-project.org/lppl.txt
-
-This work is "maintained" (as per LPPL maintenance status) by
-Andrew Stacey.
-
-This work consists of the files tqft.dtx,
- tqft_doc.tex,
-and the derived files tqft.ins,
- tqft.pdf,
- tqft_doc.pdf,
- tqft.sty, and
- tikzlibrarytqft.code.tex.
-
-\endpostamble
-\usedir{tex/latex/tqft}
-\generate{
- \file{\jobname.sty}{\from{\jobname.dtx}{package}}
-}
-\usedir{tex/latex/tqft}
-\generate{
- \file{tikzlibrary\jobname.code.tex}{\from{\jobname.dtx}{library}}
-}
-\endbatchfile
-
-%%
-%% Copyright (C) 2011 by Andrew Stacey <loopspace at mathforge.org>
-%%
-%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License (LPPL), either
-%% version 1.3c of this license or (at your option) any later
-%% version. The latest version of this license is in the file:
-%%
-%% http://www.latex-project.org/lppl.txt
-%%
-%% This work is "maintained" (as per LPPL maintenance status) by
-%% Andrew Stacey.
-%%
-%% This work consists of the files tqft.dtx,
-%% tqft_doc.tex,
-%% and the derived files tqft.ins,
-%% tqft.pdf,
-%% tqft_doc.pdf,
-%% tqft.sty, and
-%% tikzlibrarytqft.code.tex.
-%%
-%%
-%% End of file `tqft.ins'.
Added: trunk/Master/texmf-dist/source/latex/tqft/tqft_code.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tqft/tqft_code.dtx (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tqft/tqft_code.dtx 2024-06-01 20:21:17 UTC (rev 71401)
@@ -0,0 +1,2190 @@
+% \iffalse meta-comment
+%<*internal>
+\iffalse
+%</internal>
+%<*readme>
+----------------------------------------------------------------
+tqft --- a TikZ library for drawing TQFT diagrams
+bundle version: v2.3 2024/05/31
+E-mail: Andrew Stacey <loopspace at mathforge.org>
+Released under the LaTeX Project Public License v1.3c or later
+See http://www.latex-project.org/lppl.txt
+----------------------------------------------------------------
+
+This package defines some shapes useful for drawing TQFT diagrams with TikZ/PGF.
+The initial idea of this package came from a question and answer on the site https://tex.stackexchange.com.
+
+The package comes in two versions: a package (tqft.sty) and a TikZ library (tikzlibrarytqft.code.tex). The original package (tqft.sty) is depreciated and has been frozen at version 2.1. The TikZ library is maintained and should be used in preference, except for legacy code.
+%</readme>
+%<*internal>
+\fi
+\def\nameofplainTeX{plain}
+\ifx\fmtname\nameofplainTeX\else
+ \expandafter\begingroup
+\fi
+%</internal>
+%<*install>
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+\preamble
+----------------------------------------------------------------
+tqft --- a TikZ library for drawing TQFT diagrams
+E-mail: loopspace at mathforge.org
+Released under the LaTeX Project Public License v1.3c or later
+See http://www.latex-project.org/lppl.txt
+----------------------------------------------------------------
+
+\endpreamble
+\postamble
+
+Copyright (C) 2011-2024 by Andrew Stacey <loopspace at mathforge.org>
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License (LPPL), either
+version 1.3c of this license or (at your option) any later
+version. The latest version of this license is in the file:
+
+http://www.latex-project.org/lppl.txt
+
+This work is "maintained" (as per LPPL maintenance status) by
+Andrew Stacey.
+
+This work consists of the files tqft_code.dtx,
+ tqft.tex,
+and the derived files tqft_code.ins,
+ tqft_code.pdf,
+ tqft.pdf,
+ tqft.sty, and
+ tikzlibrarytqft.code.tex.
+
+\endpostamble
+\usedir{tex/latex/tqft}
+\generate{
+ \file{tqft.sty}{\from{\jobname.dtx}{package}}
+}
+\usedir{tex/latex/tqft}
+\generate{
+ \file{tikzlibrarytqft.code.tex}{\from{\jobname.dtx}{library}}
+}
+%</install>
+%<install>\endbatchfile
+%<*internal>
+\usedir{source/latex/tqft}
+\generate{
+ \file{tqft_code.ins}{\from{\jobname.dtx}{install}}
+}
+\nopreamble\nopostamble
+\usedir{doc/latex/demopkg}
+\generate{
+ \file{README.txt}{\from{\jobname.dtx}{readme}}
+}
+\ifx\fmtname\nameofplainTeX
+ \expandafter\endbatchfile
+\else
+ \expandafter\endgroup
+\fi
+%</internal>
+%<*package>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{tqft}[2017/06/01 v2.1 Tikz/PGF commands for drawing TQFT diagrams]
+%</package>
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+%\usepackage{morefloats}
+\usepackage{tikz}
+\usepackage{tqft}
+\usepackage[numbered]{hypdoc}
+\definecolor{lstbgcolor}{rgb}{0.9,0.9,0.9}
+
+\usepackage{listings}
+\lstloadlanguages{[LaTeX]TeX}
+\lstset{breakatwhitespace=true,breaklines=true,language=TeX}
+
+\usepackage{fancyvrb}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{2623}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{1.0}{2011/05/03}{Converted to DTX file}
+% \changes{2.0}{2014/04/07}{Converted nodes to pics}
+% \changes{2.1}{2017/06/01}{Can skip boundary components}
+% \changes{2.2}{2022/08/24}{Twisted shapes}
+% \changes{2.3}{2022/08/24}{File incorrectly named}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+% \pdfstringdefDisableCommands{%
+% \def\\{}%
+% \def\url#1{<#1>}%
+% }
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{tikzlibrarytqft.code.tex}
+% \title{The \textsf{tqft} package: codebase}
+% \author{Andrew Stacey \\ \url{loopspace at mathforge.org}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+%
+% \begin{tikzpicture}[every node/.style={tqft/cobordism style={draw,thick,red}}]
+% \node[
+% tqft,
+% fill=orange,
+% fill opacity=.5,
+% boundary style={fill=purple},
+% cobordism style={draw,thick,red},
+% boundary lower style={draw,dashed,thick,blue},
+% boundary upper style={draw,green,thick},
+% incoming boundary components=4,
+% outgoing boundary components=6,
+% offset=-1.5,
+% ] (a) {};
+% \node[pin=north:1] at (a.incoming boundary 1) {};
+% \node[pin=north:3] at (a.incoming boundary 3) {};
+% \node[pin=south:1] at (a.outgoing boundary 1) {};
+% \node[pin=south:4] at (a.outgoing boundary 4) {};
+% \node[pin=south:6] at (a.outgoing boundary 6) {};
+% \end{tikzpicture}
+%
+% \section{Introduction}
+%
+% This is a package for drawing TQFT diagrams using PGF/TikZ.
+% Its inspiration was a question and answer on the website \url{http://tex.stackexchance.com}.
+%
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \subsection{Old Version: Node Shapes}
+%
+% \iffalse
+%<*package>
+% \fi
+% \begin{macrocode}
+\RequirePackage{pgfkeys}
+\RequirePackage{pgf}
+% \end{macrocode}
+%
+% We can view the cobordisms from the \emph{input} or \emph{output} ends, the implementation of the choice is to draw an arc from 0 to 180 or from 0 to -180 so we just need to track minus signs.
+% These macros are for that.
+% \begin{macrocode}
+\def\pgf at tqft@minus{-}
+\let\pgf at tqft@upper\@empty
+\let\pgf at tqft@lower\pgf at tqft@minus
+% \end{macrocode}
+% Some helpful extra functions.
+%
+% \Verb+\tqftset+ is our equivalent of \Verb+\tikzset+.
+% \begin{macrocode}
+\def\tqftset#1{\pgfkeys{/pgf/tqft/.cd,#1}}
+% \end{macrocode}
+% \begin{macro}{\tqft at process}
+% This macro applies our flow transformation to the given coordinates, % with the result stored in \Verb+\pgf at x+ and \Verb+\pgf at y+.
+% \begin{macrocode}
+\def\tqft at process#1#2{%
+ \edef\tqft at px{#1}
+ \edef\tqft at py{#2}
+ \pgf at process{
+ \pgftransformreset
+ \let\tikz at transform=\pgfutil at empty
+ \expandafter\tikzset\expandafter{\tqft at transformation}
+ \tikz at transform
+ \pgfpointtransformed{\pgfqpoint{\tqft at px}{\tqft at py}}
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Declare some dimension registers to hold the specifications of the cobordism.
+% \begin{macrocode}
+\newdimen\tqft at xa
+\newdimen\tqft at xb
+\newdimen\tqft at c
+\newdimen\tqft at ch
+\newdimen\tqft at h
+\newdimen\tqft at s
+\newdimen\tqft at w
+\newif\iftqft at within@node
+% \end{macrocode}
+% Now we set up all the keys that we'll need in the course of this shape
+% \begin{macrocode}
+\pgfkeys{
+% \end{macrocode}
+% Add a key to switch between the two versions.
+% \begin{macrocode}
+ /tikz/tqft/use nodes/.is choice,
+ /tikz/tqft/use nodes/true/.code={%
+ \tikzset{
+% \end{macrocode}
+% If using nodes, set the defaults
+% \begin{macrocode}
+ tqft/.style={%
+ /tikz/shape=tqft cobordism,
+ /pgf/tqft,
+ /tikz/every tqft/.try
+ },
+% \end{macrocode}
+% Unknowns go to \Verb+/pgf/tqft+
+% \begin{macrocode}
+ tqft/.unknown/.code={%
+ \let\tqft at searchname=\pgfkeyscurrentname%
+ \pgfkeys{%
+ /pgf/tqft/\tqft at searchname={##1}
+ }
+ },
+ }%
+ },
+% \end{macrocode}
+% If not using nodes, set the defaults for the library
+% \begin{macrocode}
+ /tikz/tqft/use nodes/false/.code={%
+ \tikzset{
+ tqft/.style={%
+ pic type=cobordism,
+ tqft/.cd,
+ every tqft/.try,
+ },
+% \end{macrocode}
+% Pass unknown keys on to TikZ.
+% \begin{macrocode}
+ tqft/.unknown/.code={%
+ \let\tqft at searchname=\pgfkeyscurrentname%
+ \pgfkeys{%
+ /tikz/\tqft at searchname={##1}
+ }
+ },
+ }%
+ },
+ /tikz/tqft/use nodes=true,
+% \end{macrocode}
+% This deals with unknown keys, passing them on to TikZ.
+% \begin{macrocode}
+ /pgf/tqft/.unknown/.code={%
+ \let\tqft at searchname=\pgfkeyscurrentname%
+ \pgfkeysalso{%
+ /tikz/\tqft at searchname={#1}
+ }
+ },
+% \end{macrocode}
+% Let's play happy families!
+% \begin{macrocode}
+ /pgf/tqft/.is family,
+ /pgf/tqft,
+% \end{macrocode}
+% This sets our shape to be the boundary circle
+% \begin{macrocode}
+ boundary circle/.style={
+ /tikz/shape=tqft boundary circle
+ },
+% \end{macrocode}
+% These set our number of boundary components
+% \begin{macrocode}
+ incoming boundary components/.initial=5,
+ outgoing boundary components/.initial=4,
+% \end{macrocode}
+% This is the ``horizontal'' offset of the first outgoing component from the first incoming one.
+% \begin{macrocode}
+ offset/.initial=0,
+% \end{macrocode}
+% This is the ``vertical'' separation between boundary components.
+% \begin{macrocode}
+ cobordism height/.initial=2cm,
+% \end{macrocode}
+% This is the ``horizontal'' separation between boundary components.
+% \begin{macrocode}
+ boundary separation/.initial=2cm,
+% \end{macrocode}
+% These are the ``horizontal'' and ``vertical'' radii, respectively, of the boundary components (perhaps poorly named!).
+% \begin{macrocode}
+ circle width/.initial=10pt,
+ circle depth/.initial=5pt,
+% \end{macrocode}
+% These control the separation between the node and its anchors.
+% \begin{macrocode}
+ outer xsep/.initial=0pt,
+ outer ysep/.initial=0pt,
+ outer sep/.style={
+ outer xsep=#1,
+ outer ysep=#1
+ },
+% \end{macrocode}
+% This is our flow control. The \Verb+flow+ key installs a transformation to be applied to our node shape.
+% The possible transformations are stored in the following keys.
+% They aren't just rotations so that the numbering is always ``top to bottom'' or ``left to right''.
+% \begin{macrocode}
+ flow/.code={%
+ \pgfkeys{/pgf/tqft/flow transformation/.expand twice/.expand once=\pgfkeysvalueof{/pgf/tqft/flow transformation #1}}
+ },
+ flow transformation south/.initial={},
+ flow transformation north/.initial={%
+ xscale=-1,rotate=180
+ },
+ flow transformation east/.initial={%
+ rotate=90,xscale=-1
+ },
+ flow transformation west/.initial={%
+ rotate=270
+ },
+ flow transformation/.initial={},
+% \end{macrocode}
+% These control the direction from which we view the cobordism.
+% \begin{macrocode}
+ view from/.is choice,
+ view from/incoming/.code={%
+ \let\pgf at tqft@upper\pgf at tqft@minus
+ \let\pgf at tqft@lower\@empty
+ },
+ view from/outgoing/.code={%
+ \let\pgf at tqft@lower\pgf at tqft@minus
+ \let\pgf at tqft@upper\@empty
+ },
+% \end{macrocode}
+% The next set of keys are for styling the different pieces of a cobordism.
+% \begin{macrocode}
+ boundary lower style contents/.initial={},
+ boundary lower style/.code={%
+ \pgfkeys{/pgf/tqft/boundary lower style contents/.style={%
+ /tikz/.cd,#1
+ }
+ }
+ },
+ boundary style contents/.initial={},
+ boundary style/.code={%
+ \pgfkeys{/pgf/tqft/boundary style contents/.style={%
+ /tikz/.cd,#1
+ }
+ }
+ },
+ boundary upper style contents/.initial={},
+ boundary upper style/.code={%
+ \pgfkeys{/pgf/tqft/boundary upper style contents/.style={%
+ /tikz/.cd,#1
+ }
+ }
+ },
+ cobordism style contents/.initial={},
+ cobordism style/.code={%
+ \pgfkeys{/pgf/tqft/cobordism style contents/.style={%
+ /tikz/.cd,#1%
+ }
+ }
+ },
+% \end{macrocode}
+% The next set of keys define some default shapes.
+% \begin{macrocode}
+ pair of pants/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=2,
+ offset=-.5
+ },
+ /tikz/tqft pair of pants/.style={
+ /pgf/tqft/pair of pants,
+ },
+ reverse pair of pants/.style={
+ /tikz/tqft,
+ incoming boundary components=2,
+ outgoing boundary components=1,
+ offset=.5
+ },
+ /tikz/tqft reverse pair of pants/.style={
+ /pgf/tqft/reverse pair of pants,
+ },
+ cylinder to prior/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ offset=-.5
+ },
+ /tikz/tqft cylinder to prior/.style={
+ /pgf/tqft/cylinder to prior,
+ },
+ cylinder to next/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ offset=.5
+ },
+ /tikz/tqft cylinder to next/.style={
+ /pgf/tqft/cylinder to next,
+ },
+ cylinder/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1
+ },
+ /tikz/tqft cylinder/.style={
+ /pgf/tqft/cylinder,
+ },
+ cup/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=0
+ },
+ /tikz/tqft cup/.style={
+ /pgf/tqft/cup,
+ },
+ cap/.style={
+ /tikz/tqft,
+ incoming boundary components=0,
+ outgoing boundary components=1
+ },
+ /tikz/tqft cap/.style={
+ /pgf/tqft/cap,
+ },
+}
+% \end{macrocode}
+%
+% \begin{macro}{tqft shape}
+% This is a generic cobordism shape
+% \begin{macrocode}
+\pgfdeclareshape{tqft cobordism}{
+% \end{macrocode}
+% Save our specifications: incoming and outgoing boundary components
+% \begin{macrocode}
+ \savedmacro{\tqft at incoming}{\edef\tqft at incoming{\pgfkeysvalueof{/pgf/tqft/incoming boundary components}}}
+ \savedmacro{\tqft at outgoing}{\edef\tqft at outgoing{\pgfkeysvalueof{/pgf/tqft/outgoing boundary components}}}
+% \end{macrocode}
+% and the offset (in units of boundary components) between the leading incoming and outgoing components (regarded as a shift of the outgoing components relative to the incoming)
+% \begin{macrocode}
+ \savedmacro{\tqft at offset}{\edef\tqft at offset{\pgfkeysvalueof{/pgf/tqft/offset}}}
+% \end{macrocode}
+% Now we save our dimensions: height, separation, the radii of the boundary circles, and outer seps, and the heights of the control points.
+% \begin{macrocode}
+ \saveddimen{\tqft at height}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/cobordism height}}
+ \saveddimen{\tqft at separation}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/boundary separation}}
+ \saveddimen{\tqft at width}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/circle width}}
+ \saveddimen{\tqft at depth}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/circle depth}}
+ \saveddimen{\tqft at outerxsep}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/outer xsep}}
+ \saveddimen{\tqft at outerysep}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/outer ysep}}
+ \saveddimen{\tqft at control}{
+ \pgfkeysgetvalue{/pgf/tqft/cobordism height}{\tqft at tempa}
+ \pgfkeysgetvalue{/pgf/tqft/circle depth}{\tqft at tempb}
+ \pgfmathsetlength{\pgf at x}{.5 * \tqft at tempa - 4 * \tqft at tempb}
+}
+% \end{macrocode}
+% This is the internal transformation that is in place
+% \begin{macrocode}
+ \savedmacro{\tqft at transformation}{%
+ \pgfkeysgetvalue{/pgf/tqft/flow transformation}{\tqft at transformation}
+}
+% \end{macrocode}
+% For the externally available anchors, we need to save a few things as well.
+%
+% Position of first incoming boundary in internal coordinates
+% \begin{macrocode}
+ \savedanchor{\tqft at start@incoming}{%
+ \pgfmathsetlength{\pgf at x}{-(max(\pgfkeysvalueof{/pgf/tqft/incoming boundary components} - 1,\pgfkeysvalueof{/pgf/tqft/outgoing boundary components} - 1 + \pgfkeysvalueof{/pgf/tqft/offset}) + min(0,\pgfkeysvalueof{/pgf/tqft/offset}) )*\pgfkeysvalueof{/pgf/tqft/boundary separation}/2}
+ \pgfmathsetlength{\pgf at y}{.5 * \pgfkeysvalueof{/pgf/tqft/cobordism height}}
+}
+% \end{macrocode}
+% Position of first outgoing boundary in internal coordinates
+% \begin{macrocode}
+ \savedanchor{\tqft at start@outgoing}{%
+ \pgfmathsetlength{\pgf at x}{-(max(\pgfkeysvalueof{/pgf/tqft/incoming boundary components} - 1,\pgfkeysvalueof{/pgf/tqft/outgoing boundary components} - 1 + \pgfkeysvalueof{/pgf/tqft/offset}) + min(0,\pgfkeysvalueof{/pgf/tqft/offset})- 2*\pgfkeysvalueof{/pgf/tqft/offset})*\pgfkeysvalueof{/pgf/tqft/boundary separation}/2}
+ \pgfmathsetlength{\pgf at y}{-.5 * \pgfkeysvalueof{/pgf/tqft/cobordism height}}
+}
+% \end{macrocode}
+% For completeness, we record the size of the text box (not that we expect any text, but you never know)
+% \begin{macrocode}
+\savedanchor{\tqft at textsize}{%
+ \pgf at y=-.5\ht\pgfnodeparttextbox%
+ \pgf at x=-.5\wd\pgfnodeparttextbox%
+}
+% \end{macrocode}
+%
+% These are our externally available anchors
+% \begin{macrocode}
+ \anchor{centre}{\pgfpointorigin}
+ \anchor{center}{\pgfpointorigin}
+\anchor{text}{
+ \tqft at textsize
+}
+\anchor{north}{%
+ \pgf at ya=\tqft at height\relax
+ \pgf at yb=.5\pgf at ya
+ \advance\pgf at yb by \tqft at outerysep\relax
+ \tqft at process{0pt}{\the\pgf at yb}
+}
+\anchor{south}{%
+ \pgf at yb=\tqft at height\relax
+ \pgf at ya=.5\pgf at yb
+ \advance\pgf at ya by \tqft at outerysep\relax
+ \pgf at yb=-\pgf at ya
+ \tqft at process{0pt}{\the\pgf at yb}
+}
+\anchor{west}{%
+ \tqft at start@incoming
+ \pgf at xa=\pgf at x
+ \advance\pgf at xa by -\tqft at width
+ \pgf at ya=\pgf at y
+ \tqft at start@outgoing
+ \pgf at xb=\pgf at x
+ \advance\pgf at xb by -\tqft at width
+ \pgf at yb=\pgf at y
+ \pgf at xc=.5\pgf at xa
+ \advance\pgf at xc by .5\pgf at xb
+ \pgf at yc=.5\pgf at ya
+ \advance\pgf at yc by .5\pgf at yb
+ \advance\pgf at xc by -\tqft at outerxsep\relax
+ \tqft at process{\the\pgf at xc}{\the\pgf at yc}
+}
+\anchor{east}{%
+ \tqft at start@incoming
+ \pgf at xa=\pgf at x
+ \pgfmathsetlength{\pgf at xa}{\pgf at xa + (\tqft at incoming - 1) * \tqft at separation}
+ \advance\pgf at xa by \tqft at width\relax
+ \pgf at ya=\pgf at y
+ \tqft at start@outgoing
+ \pgf at xb=\pgf at x
+ \pgfmathsetlength{\pgf at xb}{\pgf at xb + (\tqft at outgoing - 1) * \tqft at separation}
+ \advance\pgf at xb by \tqft at width\relax
+ \pgf at yb=\pgf at y
+ \pgf at xc=.5\pgf at xa
+ \advance\pgf at xc by .5\pgf at xb
+ \pgf at yc=.5\pgf at ya
+ \advance\pgf at yc by .5\pgf at yb
+ \advance\pgf at xc by \tqft at outerxsep\relax
+ \tqft at process{\the\pgf at xc}{\the\pgf at yc}
+}
+\anchor{north west}{
+ \tqft at start@incoming
+ \pgf at xc=\pgf at x
+ \pgf at yc=\pgf at y
+ \advance\pgf at xc by -\tqft at width\relax
+ \advance\pgf at yc by \tqft at outerysep\relax
+ \advance\pgf at xc by -\tqft at outerxsep\relax
+ \tqft at process{\the\pgf at xc}{\the\pgf at yc}
+}
+\anchor{south west}{
+ \tqft at start@outgoing
+ \pgf at xc=\pgf at x
+ \pgf at yc=\pgf at y
+ \advance\pgf at xc by -\tqft at width\relax
+ \advance\pgf at yc by -\tqft at outerysep\relax
+ \advance\pgf at xc by -\tqft at outerxsep\relax
+ \tqft at process{\the\pgf at xc}{\the\pgf at yc}
+}
+\anchor{north east}{
+ \tqft at start@incoming
+ \pgf at xc=\pgf at x
+ \pgfmathsetlength{\pgf at xc}{\pgf at xc + (\tqft at incoming - 1)*\tqft at separation}
+ \pgf at yc=\pgf at y
+ \advance\pgf at xc by \tqft at width\relax
+ \advance\pgf at yc by \tqft at outerysep\relax
+ \advance\pgf at xc by \tqft at outerxsep\relax
+ \tqft at process{\the\pgf at xc}{\the\pgf at yc}
+}
+\anchor{south east}{
+ \tqft at start@outgoing
+ \pgf at xc=\pgf at x
+ \pgfmathsetlength{\pgf at xc}{\pgf at xc + (\tqft at outgoing - 1)*\tqft at separation}
+ \pgf at yc=\pgf at y
+ \advance\pgf at xc by \tqft at width\relax
+ \advance\pgf at yc by -\tqft at outerysep\relax
+ \advance\pgf at xc by \tqft at outerxsep\relax
+ \tqft at process{\the\pgf at xc}{\the\pgf at yc}
+}
+% \end{macrocode}
+% To define anchors at the boundary components requires a bit of trickery borrowed from the ``regular polygon'' shape.
+% \begin{macrocode}
+\expandafter\pgfutil at g@addto at macro\csname pgf at sh@s at tqft cobordism\endcsname{%
+ \c at pgf@counta\tqft at incoming\relax%
+ \pgfmathloop%
+ \ifnum\c at pgf@counta>0\relax%
+ \pgfutil at ifundefined{pgf at anchor@tqft cobordism at incoming boundary\space\the\c at pgf@counta}{%
+ \expandafter\xdef\csname pgf at anchor@tqft cobordism at incoming boundary\space\the\c at pgf@counta\endcsname{%
+ \noexpand\tqft at start@incoming
+ \noexpand\pgfmathsetlength{\noexpand\pgf at y}{\noexpand\pgf at y + \noexpand\tqft at outerysep}
+ \noexpand\pgfmathsetlength{\noexpand\pgf at x}{\noexpand\pgf at x + (\the\c at pgf@counta - 1) * \noexpand\tqft at separation}
+ \noexpand\tqft at process{\noexpand\the\noexpand\pgf at x}{\noexpand\the\noexpand\pgf at y}
+ }
+ }{\c at pgf@counta0\relax}%
+ \advance\c at pgf@counta-1\relax%
+ \repeatpgfmathloop%
+}
+\expandafter\pgfutil at g@addto at macro\csname pgf at sh@s at tqft cobordism\endcsname{%
+ \c at pgf@counta\tqft at outgoing\relax%
+ \pgfmathloop%
+ \ifnum\c at pgf@counta>0\relax%
+ \pgfutil at ifundefined{pgf at anchor@tqft cobordism at outgoing boundary\space\the\c at pgf@counta}{%
+ \expandafter\xdef\csname pgf at anchor@tqft cobordism at outgoing boundary\space\the\c at pgf@counta\endcsname{%
+ \noexpand\tqft at start@outgoing
+ \noexpand\pgfmathsetlength{\noexpand\pgf at y}{\noexpand\pgf at y - \noexpand\tqft at outerysep}
+ \noexpand\pgfmathsetlength{\noexpand\pgf at x}{\noexpand\pgf at x + (\the\c at pgf@counta - 1) * \noexpand\tqft at separation}
+ \noexpand\tqft at process{\noexpand\the\noexpand\pgf at x}{\noexpand\the\noexpand\pgf at y}
+ }
+ }{\c at pgf@counta0\relax}%
+ \advance\c at pgf@counta-1\relax%
+ \repeatpgfmathloop%
+}
+\expandafter\pgfutil at g@addto at macro\csname pgf at sh@s at tqft cobordism\endcsname{%
+ \c at pgf@counta\tqft at incoming\relax%
+ \advance\c at pgf@counta-1\relax
+ \pgfmathloop%
+ \ifnum\c at pgf@counta>0\relax%
+ \pgfutil at ifundefined{pgf at anchor@tqft cobordism at after incoming boundary\space\the\c at pgf@counta}{%
+ \expandafter\xdef\csname pgf at anchor@tqft cobordism at after incoming boundary\space\the\c at pgf@counta\endcsname{%
+ \noexpand\tqft at start@incoming
+ \noexpand\pgfmathsetlength{\noexpand\pgf at y}{.25 * \noexpand\pgf at y +.75 * \noexpand\tqft at control + \noexpand\tqft at outerysep}
+ \noexpand\pgfmathsetlength{\noexpand\pgf at x}{\noexpand\pgf at x + (\the\c at pgf@counta - .5) * \noexpand\tqft at separation}
+ \noexpand\tqft at process{\noexpand\the\noexpand\pgf at x}{\noexpand\the\noexpand\pgf at y}
+ }
+ }{\c at pgf@counta0\relax}%
+ \advance\c at pgf@counta-1\relax%
+ \repeatpgfmathloop%
+}
+\expandafter\pgfutil at g@addto at macro\csname pgf at sh@s at tqft cobordism\endcsname{%
+ \c at pgf@counta\tqft at outgoing\relax%
+ \advance\c at pgf@counta-1\relax
+ \pgfmathloop%
+ \ifnum\c at pgf@counta>0\relax%
+ \pgfutil at ifundefined{pgf at anchor@tqft cobordism at after outgoing boundary\space\the\c at pgf@counta}{%
+ \expandafter\xdef\csname pgf at anchor@tqft cobordism at after outgoing boundary\space\the\c at pgf@counta\endcsname{%
+ \noexpand\tqft at start@outgoing
+ \noexpand\pgfmathsetlength{\noexpand\pgf at y}{.25 * \noexpand\pgf at y -.75 * \noexpand\tqft at control - \noexpand\tqft at outerysep}
+ \noexpand\pgfmathsetlength{\noexpand\pgf at x}{\noexpand\pgf at x + (\the\c at pgf@counta - .5) * \noexpand\tqft at separation}
+ \noexpand\tqft at process{\noexpand\the\noexpand\pgf at x}{\noexpand\the\noexpand\pgf at y}
+ }
+ }{\c at pgf@counta0\relax}%
+ \advance\c at pgf@counta-1\relax%
+ \repeatpgfmathloop%
+}
+% \end{macrocode}
+% Now we define the background path.
+% This is the upper part of the cobordism.
+% \begin{macrocode}
+ \backgroundpath{
+% \end{macrocode}
+% Apply the internal transformation
+% \begin{macrocode}
+ \let\tikz at transform=\pgfutil at empty
+ \expandafter\tikzset\expandafter{\tqft at transformation}
+ \tikz at transform
+% \end{macrocode}
+% Convert the boundary separation and width to lengths
+% \begin{macrocode}
+ \pgfmathsetlength{\tqft at s}{\tqft at separation}
+ \pgfmathsetlength{\tqft at w}{2*\tqft at width}
+% \end{macrocode}
+% Compute the starting position of the incoming boundary components so that we get the centre anchor on the centre of the cobordism
+% \begin{macrocode}
+\tqft at start@incoming
+\tqft at xa=\pgf at x
+ \advance\tqft at xa by -.5\tqft at w\relax
+\tqft at h=\pgf at y
+ \tqft at xb=\tqft at xa
+ \advance\tqft at xb by \tqft at w\relax
+\tqft at c=\tqft at control\relax
+% \end{macrocode}
+% Do we have any incoming boundary components at all?
+% \begin{macrocode}
+ \ifnum\tqft at incoming>0
+% \end{macrocode}
+% Yes, so move to the position of the first and draw it
+% \begin{macrocode}
+ \pgfpathmoveto{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \pgfpatharc{\pgf at tqft@upper180}{0}{\tqft at width and \tqft at depth}
+% \end{macrocode}
+% Do we have any more incoming boundary components?
+% \begin{macrocode}
+ \ifnum\tqft at incoming>1
+% \end{macrocode}
+% Yes, so iterate over the remaining incoming boundary components
+% \begin{macrocode}
+ \foreach \tqft at k in {2,...,\tqft at incoming} {
+ \advance\tqft at xa by \tqft at k\tqft at s
+ \advance\tqft at xb by \tqft at k\tqft at s
+ \advance\tqft at xb by -2\tqft at s
+ \advance\tqft at xa by -\tqft at s
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at c}}{\pgfqpoint{\tqft at xa}{\tqft at c}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \pgfpatharc{\pgf at tqft@upper180}{0}{\tqft at width and \tqft at depth}
+ }
+ \fi
+% \end{macrocode}
+% If we don't have any outgoing boundary components, may as well close up now.
+% \begin{macrocode}
+ \ifnum\tqft at outgoing=0
+ \advance\tqft at xb by \tqft at incoming\tqft at s
+ \advance\tqft at xb by -\tqft at s
+ \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \fi
+ \fi
+% \end{macrocode}
+% Shift down to the outgoing components, if we have any
+% \begin{macrocode}
+ \ifnum\tqft at outgoing>0
+ \advance\tqft at xb by \tqft at incoming\tqft at s
+ \advance\tqft at xb by -\tqft at s
+ \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing - 1 + \tqft at offset) * \tqft at separation + 2*\tqft at width}
+% \end{macrocode}
+% If we had incoming boundaries, this is a curveto, otherwise it's a moveto
+% \begin{macrocode}
+ \ifnum\tqft at incoming>0
+ \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \else
+ \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \fi
+ \tqft at xb=\tqft at xa
+ \advance\tqft at xb by -\tqft at w
+% \end{macrocode}
+% Now draw the lower components
+% \begin{macrocode}
+ \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
+% \end{macrocode}
+% Now iterate over the remaining outgoing boundary components
+% \begin{macrocode}
+ \ifnum\tqft at outgoing>1
+ \foreach \tqft at k in {2,...,\tqft at outgoing} {
+ \advance\tqft at xa by -\tqft at k\tqft at s
+ \advance\tqft at xb by -\tqft at k\tqft at s
+ \advance\tqft at xb by 2\tqft at s
+ \advance\tqft at xa by \tqft at s
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at c}}{\pgfqpoint{\tqft at xa}{-\tqft at c}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
+ }
+ \fi
+% \end{macrocode}
+% Shift back up to the incoming components, if we had any, otherwise arc back to our starting point
+% \begin{macrocode}
+ \advance\tqft at xb by -\tqft at outgoing\tqft at s
+ \advance\tqft at xb by \tqft at s
+ \ifnum\tqft at incoming>0
+ \pgfmathsetlength{\tqft at xa}{\tqft at xa - (\tqft at outgoing -1 + \tqft at offset) * \tqft at separation - 2*\tqft at width}
+ \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \else
+ \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \fi
+ \fi
+% \end{macrocode}
+% Close the path
+% \begin{macrocode}
+ \pgfpathclose
+ }
+% \end{macrocode}
+% End of background path
+% Now we define the behind background path.
+% This is the lower part of the boundary circles.
+% \begin{macrocode}
+ \behindbackgroundpath{
+% \end{macrocode}
+% Apply the internal transformation
+% \begin{macrocode}
+ \let\tikz at transform=\pgfutil at empty
+ \expandafter\tikzset\expandafter{\tqft at transformation}
+ \tikz at transform
+% \end{macrocode}
+% Convert the boundary separation and width to lengths
+% \begin{macrocode}
+ \pgfmathsetlength{\tqft at s}{\tqft at separation}
+ \pgfmathsetlength{\tqft at w}{2*\tqft at width}
+% \end{macrocode}
+% Compute the starting position of the incoming boundary components so that we get the centre anchor on the centre of the cobordism
+% \begin{macrocode}
+ \pgfmathsetlength{\tqft at xa}{-(max(\tqft at incoming - 1,\tqft at outgoing - 1 + \tqft at offset) + min(0,\tqft at offset) + 2)*\tqft at separation/2}
+ \pgfmathsetlength{\tqft at h}{.5 * \tqft at height}
+% \end{macrocode}
+% This section draws the boundary circles
+% \begin{macrocode}
+ {
+% \end{macrocode}
+% Initialise the TikZ path settings and read in the style options for the boundary
+% \begin{macrocode}
+ \tikz at mode@fillfalse%
+ \tikz at mode@drawfalse%
+ \let\tikz at mode=\pgfutil at empty
+ \let\tikz at options=\pgfutil at empty
+ \tqftset{boundary style contents}
+ \tikz at mode
+ \tikz at options
+% \end{macrocode}
+% Do we have any incoming boundary components at all?
+% \begin{macrocode}
+ \ifnum\tqft at incoming>0
+% \end{macrocode}
+% Yes, so iterate over them
+% \begin{macrocode}
+ \foreach \tqft at k in {1,...,\tqft at incoming} {
+ \advance\tqft at xa by \tqft at k\tqft at s
+ \pgfpathellipse{\pgfqpoint{\tqft at xa}{\tqft at h}}{\pgfqpoint{\tqft at width}{0pt}}{\pgfqpoint{0pt}{\tqft at depth}}
+ }
+ \fi
+% \end{macrocode}
+% Now iterate over the outgoing boundary components, if we have any
+% \begin{macrocode}
+ \ifnum\tqft at outgoing>0
+ \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing + \tqft at offset + 1) * \tqft at separation}
+ \foreach \tqft at k in {1,...,\tqft at outgoing} {
+ \advance\tqft at xa by -\tqft at k\tqft at s
+% \advance\tqft at xa by \tqft at s
+ \pgfpathellipse{\pgfqpoint{\tqft at xa}{-\tqft at h}}{\pgfqpoint{\tqft at width}{0pt}}{\pgfqpoint{0pt}{\tqft at depth}}
+ }
+ \fi
+% \end{macrocode}
+% \begin{macrocode}
+ \edef\tikz at temp{\noexpand\pgfusepath{%
+ \iftikz at mode@fill fill,\fi%
+ \iftikz at mode@draw draw\fi%
+ }}%
+ \tikz at temp
+ }
+% \end{macrocode}
+% This section draws the lower parts of the boundary circles
+% \begin{macrocode}
+ {
+% \end{macrocode}
+% Initialise the TikZ path settings and read in the style options for the boundary
+% \begin{macrocode}
+ \tikz at mode@fillfalse%
+ \tikz at mode@drawfalse%
+ \let\tikz at mode=\pgfutil at empty
+ \let\tikz at options=\pgfutil at empty
+ \tqftset{boundary lower style contents}
+ \tikz at mode
+ \tikz at options
+ \advance\tqft at xa by .5\tqft at w
+% \end{macrocode}
+% Do we have any incoming boundary components at all?
+% \begin{macrocode}
+ \ifnum\tqft at incoming>0
+% \end{macrocode}
+% Yes, so iterate over them
+% \begin{macrocode}
+ \foreach \tqft at k in {1,...,\tqft at incoming} {
+ \advance\tqft at xa by \tqft at k\tqft at s
+ \pgfpathmoveto{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \pgfpatharc{0}{\pgf at tqft@lower180}{\tqft at width and \tqft at depth}
+ }
+ \fi
+% \end{macrocode}
+% Now iterate over the outgoing boundary components, if we have any
+% \begin{macrocode}
+ \ifnum\tqft at outgoing>0
+ \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing + \tqft at offset + 1) * \tqft at separation}
+ \foreach \tqft at k in {1,...,\tqft at outgoing} {
+ \advance\tqft at xa by -\tqft at k\tqft at s
+% \advance\tqft at xa by \tqft at s
+ \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \pgfpatharc{0}{\pgf at tqft@lower180}{\tqft at width and \tqft at depth}
+ }
+ \fi
+% \end{macrocode}
+% \begin{macrocode}
+ \edef\tikz at temp{\noexpand\pgfusepath{%
+ \iftikz at mode@fill fill,\fi%
+ \iftikz at mode@draw draw\fi%
+ }}%
+ \tikz at temp
+ }
+ }
+% \end{macrocode}
+% End of behind background path.
+%
+% Now we define the before background path.
+% This is the upper part of the boundary circles and the cobordism edge.
+% \begin{macrocode}
+ \beforebackgroundpath{
+% \end{macrocode}
+% We \emph{don't} apply the internal transformation as it is already in place from the \Verb+\backgroundpath+.
+% Convert the boundary separation and width to lengths
+% \begin{macrocode}
+ \pgfmathsetlength{\tqft at s}{\tqft at separation}
+ \pgfmathsetlength{\tqft at w}{2*\tqft at width}
+% \end{macrocode}
+% Compute the starting position of the incoming boundary components so that we get the centre anchor on the centre of the cobordism
+% \begin{macrocode}
+ \pgfmathsetlength{\tqft at xa}{-(max(\tqft at incoming - 1,\tqft at outgoing - 1 + \tqft at offset) + min(0,\tqft at offset))*\tqft at s/2 - \tqft at width}
+ \tqft at xb=\tqft at xa
+ \advance\tqft at xb by \tqft at w
+\tqft at c=\tqft at control\relax
+ \pgfmathsetlength{\tqft at h}{.5 * \tqft at height}
+% \end{macrocode}
+% This section draws the non-boundary part of the cobordism.
+% \begin{macrocode}
+ {
+% \end{macrocode}
+% Initialise the TikZ path settings and read in the style options for the boundary
+% \begin{macrocode}
+ \tikz at mode@fillfalse%
+ \tikz at mode@drawfalse%
+ \let\tikz at mode=\pgfutil at empty
+ \let\tikz at options=\pgfutil at empty
+ \tqftset{cobordism style contents}
+ \tikz at mode
+ \tikz at options
+% Do we have any incoming boundary components at all?
+% \begin{macrocode}
+ \ifnum\tqft at incoming>0
+% \end{macrocode}
+% Do we have more than one?
+% \begin{macrocode}
+ \ifnum\tqft at incoming>1
+% \end{macrocode}
+% Yes, so iterate over the remaining incoming boundary components
+% \begin{macrocode}
+ \foreach \tqft at k in {2,...,\tqft at incoming} {
+ \advance\tqft at xa by \tqft at k\tqft at s
+ \advance\tqft at xb by \tqft at k\tqft at s
+ \advance\tqft at xb by -2\tqft at s
+ \advance\tqft at xa by -\tqft at s
+ \pgfpathmoveto{\pgfqpoint{\tqft at xb}{\tqft at h}}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at c}}{\pgfqpoint{\tqft at xa}{\tqft at c}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ }
+ \fi
+% \end{macrocode}
+% If we don't have any outgoing boundary components, may as well close up now.
+% \begin{macrocode}
+ \ifnum\tqft at outgoing=0
+ \advance\tqft at xb by \tqft at incoming\tqft at s
+ \advance\tqft at xb by -\tqft at s
+ \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
+ \pgfpathmoveto{\pgfqpoint{\tqft at xb}{\tqft at h}}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \fi
+ \fi
+% \end{macrocode}
+% Shift down to the outgoing components, if we have any
+% \begin{macrocode}
+ \ifnum\tqft at outgoing>0
+ \advance\tqft at xb by \tqft at incoming\tqft at s
+ \advance\tqft at xb by -\tqft at s
+ \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing - 1 + \tqft at offset) * \tqft at separation + 2*\tqft at width}
+% \end{macrocode}
+% If we had incoming boundaries, this is a curveto, otherwise it's a moveto
+% \begin{macrocode}
+ \ifnum\tqft at incoming>0
+ \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
+ \pgfpathmoveto{\pgfqpoint{\tqft at xb}{\tqft at h}}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \else
+ \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \fi
+ \tqft at xb=\tqft at xa
+ \advance\tqft at xb by -\tqft at w
+% \end{macrocode}
+% Now draw the lower components
+% \begin{macrocode}
+ \pgfpathmoveto{\pgfqpoint{\tqft at xb}{-\tqft at h}}
+% \end{macrocode}
+% Now iterate over the remaining outgoing boundary components
+% \begin{macrocode}
+ \ifnum\tqft at outgoing>1
+ \foreach \tqft at k in {2,...,\tqft at outgoing} {
+ \advance\tqft at xa by -\tqft at k\tqft at s
+ \advance\tqft at xb by -\tqft at k\tqft at s
+ \advance\tqft at xb by 2\tqft at s
+ \advance\tqft at xa by \tqft at s
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at c}}{\pgfqpoint{\tqft at xa}{-\tqft at c}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \advance\tqft at xa by -\tqft at w
+ \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ }
+ \fi
+% \end{macrocode}
+% Shift back up to the incoming components, if we had any, otherwise arc back to our starting point
+% \begin{macrocode}
+ \advance\tqft at xb by -\tqft at outgoing\tqft at s
+ \advance\tqft at xb by \tqft at s
+ \ifnum\tqft at incoming>0
+ \pgfmathsetlength{\tqft at xa}{\tqft at xa - (\tqft at outgoing -1 + \tqft at offset) * \tqft at separation - 2*\tqft at width}
+ \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at ch}}{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \else
+ \pgfmathsetlength{\tqft at ch}{min(0,max(-\tqft at h,\tqft at h - (\tqft at h - \tqft at c) * ((abs(\tqft at xb - \tqft at xa) - \tqft at w)/\tqft at s + 1)))}
+ \pgfpathcurveto{\pgfqpoint{\tqft at xb}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at ch}}{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \fi
+ \fi
+ \edef\tikz at temp{\noexpand\pgfusepath{%
+ \iftikz at mode@fill fill,\fi%
+ \iftikz at mode@draw draw\fi%
+ }}%
+ \tikz at temp
+}
+% \end{macrocode}
+% This section draws the upper parts of the boundary circles
+% \begin{macrocode}
+ {
+% \end{macrocode}
+% Initialise the TikZ path settings and read in the style options for the boundary
+% \begin{macrocode}
+\let\tqft at bdry@path=\pgfutil at empty
+\let\tqft at bdry@node at path=\pgfutil at empty
+\pgfsyssoftpath at setcurrentpath{\tqft at bdry@path}
+ \tikz at mode@fillfalse%
+ \tikz at mode@drawfalse%
+ \let\tikz at mode=\pgfutil at empty
+ \let\tikz at options=\pgfutil at empty
+ \tqftset{boundary upper style contents}
+ \tikz at mode
+ \tikz at options
+ \advance\tqft at xa by -\tqft at s
+ \advance\tqft at xa by \tqft at w
+% \end{macrocode}
+% Do we have any incoming boundary components at all?
+% \begin{macrocode}
+ \ifnum\tqft at incoming>0
+% \end{macrocode}
+% Yes, so iterate over them
+% \begin{macrocode}
+ \foreach \tqft at k in {1,...,\tqft at incoming} {
+ \advance\tqft at xa by \tqft at k\tqft at s
+ \pgfpathmoveto{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
+ \ifx\tikz at fig@name\pgfutil at empty
+ \else
+ {
+ \advance\tqft at xa by -\tqft at width
+ \pgftransformshift{\pgfqpoint{\tqft at xa}{\tqft at h}}
+ \tqft at within@nodetrue
+ \pgfsyssoftpath at getcurrentpath{\tqft at bdry@path}
+ \pgfsyssoftpath at setcurrentpath{\tqft at bdry@node at path}
+ \pgfnode{tqft boundary circle}{centre}{}{\tikz at fig@name\space incoming \tqft at k}{}
+ \pgfsyssoftpath at getcurrentpath{\tqft at bdry@node at path}
+ \pgfsyssoftpath at setcurrentpath{\tqft at bdry@path}
+ }
+ \fi
+ }
+ \fi
+% \end{macrocode}
+% Now iterate over the outgoing boundary components, if we have any
+% \begin{macrocode}
+ \ifnum\tqft at outgoing>0
+ \pgfmathsetlength{\tqft at xa}{\tqft at xa + (\tqft at outgoing + \tqft at offset + 1) * \tqft at separation}
+ \foreach \tqft at k in {1,...,\tqft at outgoing} {
+ \advance\tqft at xa by -\tqft at k\tqft at s
+% \advance\tqft at xa by \tqft at s
+ \pgfpathmoveto{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
+ \ifx\tikz at fig@name\pgfutil at empty
+ \else
+ {
+ \pgfmathtruncatemacro{\tqft at l}{\tqft at outgoing + 1 - \tqft at k}
+ \advance\tqft at xa by -\tqft at width
+ \pgftransformshift{\pgfqpoint{\tqft at xa}{-\tqft at h}}
+ \tqft at within@nodetrue
+ \pgfsyssoftpath at getcurrentpath{\tqft at bdry@path}
+ \pgfsyssoftpath at setcurrentpath{\tqft at bdry@node at path}
+ \pgfnode{tqft boundary circle}{centre}{}{\tikz at fig@name\space outgoing \tqft at l}{}
+ \pgfsyssoftpath at getcurrentpath{\tqft at bdry@node at path}
+ \pgfsyssoftpath at setcurrentpath{\tqft at bdry@path}
+ }
+ \fi
+ }
+ \fi
+% \end{macrocode}
+% \begin{macrocode}
+ \edef\tikz at temp{\noexpand\pgfusepath{%
+ \iftikz at mode@fill fill,\fi%
+ \iftikz at mode@draw draw\fi%
+ }}%
+ \tikz at temp
+ }
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{boundary circle shape}
+% This is a the shape of the boundary circles
+% \begin{macrocode}
+\pgfdeclareshape{tqft boundary circle}{
+% \end{macrocode}
+% Now we save our dimensions: height, separation, and the radii of the boundary circles
+% \begin{macrocode}
+ \saveddimen{\tqft at height}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/cobordism height}}
+ \saveddimen{\tqft at separation}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/boundary separation}}
+ \saveddimen{\tqft at width}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/circle width}}
+ \saveddimen{\tqft at depth}{\pgf at x=\pgfkeysvalueof{/pgf/tqft/circle depth}}
+% \end{macrocode}
+%
+% For the externally available anchors, we need to save the declared transformation; we save the actual transformation, not the macro that points to it.
+% If we're called within the main cobordism shape, the transformation is already applied so we ignore it.
+% \begin{macrocode}
+ \savedmacro{\tqft at transformation}{%
+ \iftqft at within@node
+ \let\tqft at transformation=\pgfutil at empty
+ \else
+ \pgfkeysgetvalue{/pgf/tqft/flow transformation}{\tqft at transformation}
+ \fi
+}
+% \end{macrocode}
+% \begin{macrocode}
+ \savedanchor{\tqft at centre}{%
+ \pgfpointorigin}
+% \end{macrocode}
+% For completeness, we record the size of the text box (not that we expect any text, but you never know)
+% \begin{macrocode}
+\savedanchor{\tqft at textsize}{%
+ \pgf at y=-.5\ht\pgfnodeparttextbox%
+ \pgf at x=-.5\wd\pgfnodeparttextbox%
+}
+% \end{macrocode}
+% These are our externally available anchors
+% \begin{macrocode}
+ \anchor{centre}{\tqft at centre}
+ \anchor{center}{\tqft at centre}
+\anchor{text}{
+ \tqft at textsize
+}
+ \anchor{next}{%
+ \tqft at process{\tqft at separation}{0pt}}%
+% \end{macrocode}
+% \begin{macrocode}
+ \anchor{prior}{%
+ \tqft at process{-\tqft at separation}{0pt}}%
+% \end{macrocode}
+% \begin{macrocode}
+ \anchor{above}{%
+ \tqft at process{0pt}{\tqft at height}}%
+% \end{macrocode}
+% \begin{macrocode}
+ \anchor{below}{%
+ \tqft at process{0pt}{-\tqft at height}}%
+% \end{macrocode}
+% The anchor border is the ellipse, but we need to take into account the possible transformation.
+% (This isn't right if the origin is shifted.)
+% At the moment, '0 degrees' is interpreted in the transformed coordinate system.
+% Should provide a system whereby that can be intepreted in the main coordinate system.
+% \begin{macrocode}
+ \anchorborder{
+% \end{macrocode}
+% This next \Verb+\pgf at process+ makes the angles absolute.
+% Comment it out to make the angles relative.
+% \begin{macrocode}
+ \tqft at process{\the\pgf at x}{\the\pgf at y}
+ \edef\tqft at marshal{%
+ \noexpand\pgfpointborderellipse
+ {\noexpand\pgfqpoint{\the\pgf at x}{\the\pgf at y}}
+ {\noexpand\pgfqpoint{\tqft at width}{\tqft at depth}}
+ }%
+ \tqft at marshal
+ \tqft at process{\the\pgf at x}{\the\pgf at y}
+}
+% \end{macrocode}
+% Now we define the background path.
+% This is the upper part of the cobordism.
+% \begin{macrocode}
+ \backgroundpath{
+% \end{macrocode}
+% Apply the internal transformation if we're not within a node
+% \begin{macrocode}
+ \let\tikz at transform=\pgfutil at empty
+ \expandafter\tikzset\expandafter{\tqft at transformation}
+ \tikz at transform
+% \end{macrocode}
+% Draw the boundary circle
+% \begin{macrocode}
+ \pgfpathellipse{\pgfqpoint{0pt}{0pt}}{\pgfqpoint{\tqft at width}{0pt}}{\pgfqpoint{0pt}{\tqft at depth}}
+ }
+% \end{macrocode}
+% We draw the upper and lower arcs again with the appropriate styles
+% \begin{macrocode}
+ \beforebackgroundpath{
+ \iftqft at within@node
+ \else
+ \tikz at mode@fillfalse%
+ \tikz at mode@drawfalse%
+ \let\tikz at mode=\pgfutil at empty
+ \let\tikz at options=\pgfutil at empty
+ {
+ \pgfsys at beginscope
+ \tqftset{boundary lower style contents}
+ \tikz at mode
+ \tikz at options
+ \pgfpathmoveto{\pgfqpoint{\tqft at width}{0pt}}
+ \pgfpatharc{0}{\pgf at tqft@lower180}{\tqft at width and \tqft at depth}
+ \edef\tikz at temp{\noexpand\pgfusepath{%
+ \iftikz at mode@fill fill,\fi%
+ \iftikz at mode@draw draw\fi%
+ }}%
+ \tikz at temp
+ \pgfsys at endscope
+ }
+ {
+ \pgfsys at beginscope
+ \tqftset{boundary upper style contents}
+ \tikz at mode
+ \tikz at options
+ \pgfpathmoveto{\pgfqpoint{\tqft at width}{0pt}}
+ \pgfpatharc{0}{\pgf at tqft@upper180}{\tqft at width and \tqft at depth}
+ \edef\tikz at temp{\noexpand\pgfusepath{%
+ \iftikz at mode@fill fill,\fi%
+ \iftikz at mode@draw draw\fi%
+ }}%
+ \tikz at temp
+ \pgfsys at endscope
+ }
+ \fi
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \iffalse
+%</package>
+% \fi
+%
+% \subsection{New Version: Picture Shapes}
+%
+% \iffalse
+%<*library>
+\ProvidesFile{tikzlibrarytqft.code.tex}[2024/05/31 v2.3 Tikz/PGF commands for drawing TQFT diagrams]
+% \fi
+%
+% Issue a warning if the pic syntax is not available.
+%
+% \begin{macrocode}
+\ifcsname pgfk@/handlers/.pic/. at cmd\endcsname
+\else
+\pgfwarning{This library only works with TikZ 3.0 or later; for earlier versions of TikZ use the TQFT package}
+\fi
+% \end{macrocode}
+% For the boundaries, we need elliptical node shapes.
+% \begin{macrocode}
+\usetikzlibrary{shapes.geometric}
+% \end{macrocode}
+% We can view the cobordisms from the \emph{input} or \emph{output} ends, the implementation of the choice is to draw an arc from 0 to 180 or from 0 to -180 so we just need to track minus signs.
+% These macros are for that.
+% \begin{macrocode}
+\def\pgf at tqft@minus{-}
+\let\pgf at tqft@upper\@empty
+\let\pgf at tqft@lower\pgf at tqft@minus
+% \end{macrocode}
+% Should we twist the cobordism?
+% \begin{macrocode}
+\newif\iftqft at twisted
+% \end{macrocode}
+% Split an anchoring coordinate.
+% The \(y\)--value is simply multiplied by the cobordism height (but pointing downwards, so that \(1\) is level with the outgoing boundary).
+% The \(x\)--value is multiplied by the boundary separation, but is shifted so that at the incoming boundary level, or above, then it is in line with the incoming boundaries and similarly at the outgoing boundary level, or below, it is in line with the outgoing boundaries.
+% \begin{macrocode}
+\def\tqft at split(#1,#2){%
+ \pgfmathsetmacro\tqft at y{#2 * (-\tqft at val{cobordism height})}%
+ \pgfmathsetmacro\tqft at x{(#1 - 1 + max(min(#2,1),0)*\tqft at val{offset}) * \tqft at val{boundary separation}}%
+ \def\tqft at shift{(\tqft at x pt, \tqft at y pt)}%
+}%
+% \end{macrocode}
+% Now we set up all the keys that we'll need in the course of this shape
+% \begin{macrocode}
+\tikzset{
+% \end{macrocode}
+% Fix for the fact that the \verb+alias+ key doesn't use the prefix and suffix.
+% \begin{macrocode}
+ pic alias/.code={%
+ \tikz at fig@mustbenamed
+ \expandafter\def\expandafter\tikz at alias\expandafter{\tikz at alias\pgfnodealias{\tikz at pp@name{#1}}{\tikz at fig@name}}%
+ },
+% \end{macrocode}
+% This key is our basic installer key, setting the pic and putting us in the right key family.
+% \begin{macrocode}
+ tqft/.style={%
+ pic type=cobordism,
+ every tqft/.try,
+ tqft/.cd,
+ },
+% \end{macrocode}
+% This deals with unknown keys, passing them on to TikZ.
+% \begin{macrocode}
+ tqft/.unknown/.code={%
+ \let\tqft at searchname=\pgfkeyscurrentname%
+ \pgfkeysalso{%
+ /tikz/\tqft at searchname={#1}
+ }
+ },
+% \end{macrocode}
+% Let's play happy families!
+% \begin{macrocode}
+ tqft/.cd,
+% \end{macrocode}
+% These set our number of boundary components and genus.
+% \begin{macrocode}
+ incoming boundary components/.initial=5,
+ outgoing boundary components/.initial=4,
+ skip incoming boundary components/.initial={},
+ skip outgoing boundary components/.initial={},
+ genus/.initial = 0,
+% \end{macrocode}
+% This is the ``horizontal'' offset of the first outgoing component from the first incoming one.
+% \begin{macrocode}
+ offset/.initial=0,
+% \end{macrocode}
+% This is the ``vertical'' separation between boundary components.
+% \begin{macrocode}
+ cobordism height/.initial=2cm,
+% \end{macrocode}
+% This is the ``horizontal'' separation between boundary components.
+% \begin{macrocode}
+ boundary separation/.initial=2cm,
+% \end{macrocode}
+% These are the ``horizontal'' and ``vertical'' radii, respectively, of the boundary components.
+% \begin{macrocode}
+ circle x radius/.initial=10pt,
+ circle y radius/.initial=5pt,
+% \end{macrocode}
+% These control the direction from which we view the cobordism.
+% \begin{macrocode}
+ view from/.is choice,
+ view from/incoming/.code={%
+ \let\pgf at tqft@upper\pgf at tqft@minus
+ \let\pgf at tqft@lower\@empty
+ },
+ view from/outgoing/.code={%
+ \let\pgf at tqft@lower\pgf at tqft@minus
+ \let\pgf at tqft@upper\@empty
+ },
+% \end{macrocode}
+% Should we twist the cobordism?
+% \begin{macrocode}
+ twisted/.is if=tqft at twisted,
+% \end{macrocode}
+% We simulate node placement using the following key.
+% \begin{macrocode}
+ anchor/.initial = none,
+% \end{macrocode}
+% The next set of keys define some default shapes.
+% \begin{macrocode}
+ pair of pants/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=2,
+ offset=-.5
+ },
+ /tikz/tqft pair of pants/.style={
+ /tikz/tqft/pair of pants,
+ },
+ reverse pair of pants/.style={
+ /tikz/tqft,
+ incoming boundary components=2,
+ outgoing boundary components=1,
+ offset=.5
+ },
+ /tikz/tqft reverse pair of pants/.style={
+ /tikz/tqft/reverse pair of pants,
+ },
+ cylinder to prior/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ offset=-.5
+ },
+ /tikz/tqft cylinder to prior/.style={
+ /tikz/tqft/cylinder to prior,
+ },
+ cylinder to next/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1,
+ offset=.5
+ },
+ /tikz/tqft cylinder to next/.style={
+ /tikz/tqft/cylinder to next,
+ },
+ cylinder/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=1
+ },
+ /tikz/tqft cylinder/.style={
+ /tikz/tqft/cylinder,
+ },
+ cup/.style={
+ /tikz/tqft,
+ incoming boundary components=1,
+ outgoing boundary components=0
+ },
+ /tikz/tqft cup/.style={
+ /tikz/tqft/cup,
+ },
+ cap/.style={
+ /tikz/tqft,
+ incoming boundary components=0,
+ outgoing boundary components=1
+ },
+ /tikz/tqft cap/.style={
+ /tikz/tqft/cap,
+ },
+}
+% \end{macrocode}
+%
+% This is a little helper macro for getting the values of tqft keys.
+% \begin{macrocode}
+\def\tqft at val#1{\pgfkeysvalueof{/tikz/tqft/#1}}
+% \end{macrocode}
+%
+% Now we define the code for the actual cobordism shape.
+% \begin{macrocode}
+\tikzset{
+ cobordism/.pic={
+% \end{macrocode}
+% Defining the cobordism paths.
+% This holds the full boundary path of the cobordism shape.
+% \begin{macrocode}
+ \gdef\tqft at fullpath{}%
+% \end{macrocode}
+% This is a list of the edge pieces without the boundary circles.
+% \begin{macrocode}
+ \global\let\tqft at blist\pgfutil at gobble%
+% \end{macrocode}
+% This punches the holes (if there are any) in the cobordism shape.
+% \begin{macrocode}
+ \gdef\tqft at gclip{}%
+% \end{macrocode}
+% This is a list of the paths for drawing the holes.
+% \begin{macrocode}
+ \global\let\tqft at glist\pgfutil at gobble%
+% \end{macrocode}
+% This collects any coordinates that are to be defined (it appears to be difficult to define them as we go along).
+% \begin{macrocode}
+ \global\let\tqft at clist\pgfutil at gobble%
+% \end{macrocode}
+% This collects any coordinates that can be used to shift the shape that aren't to be defined using \verb+\tqft at clist+.
+% \begin{macrocode}
+ \global\let\tqft at alist\pgfutil at gobble
+% \end{macrocode}
+% These will be lists of the boundary components, divided into sets as to whether or not they are rendered. For the outgoing ones, we need two lists because they are rendered in the opposite order to how they are labelled.
+% \begin{macrocode}
+ \global\let\tqft at ibdrylist=\pgfutil at gobble
+ \global\let\tqft at cibdrylist=\pgfutil at gobble
+ \global\let\tqft at obdrylist=\pgfutil at gobble
+ \global\let\tqft at cobdrylist=\pgfutil at gobble
+ \global\let\tqft at robdrylist=\pgfutil at gobble
+ \global\let\tqft at rcobdrylist=\pgfutil at gobble
+% \end{macrocode}
+% Is the cobordism twisted? If so, we need to reverse the order of the
+% outgoing boundary components.
+% \begin{macrocode}
+ \iftqft at twisted
+ \pgfmathsetmacro\tqft at outgoing@end{0}%
+ \pgfmathsetmacro\tqft at outgoing@dir{-1}%
+ \else
+ \pgfmathsetmacro\tqft at outgoing@end{1}%
+ \pgfmathsetmacro\tqft at outgoing@dir{1}%
+ \fi
+% \end{macrocode}
+% The first stage is to iterate over the incoming boundary components (if there are any), building up the various paths.
+% \begin{macrocode}
+ \ifnum\tqft at val{incoming boundary components}>0\relax
+% \end{macrocode}
+% We have some so draw the half circle for the first component.
+% Note that we use \verb+\pgf at tqft@upper+ to flip the sign of the start angle depending on the \verb+view from+ setting.
+% \begin{macrocode}
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ (-\tqft at val{circle x radius},0) arc[start angle=\pgf at tqft@upper180, end angle=0, x radius=\tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
+ }%
+% \end{macrocode}
+% And add the centre to the list for available shifts.
+% \begin{macrocode}
+ \xdef\tqft at alist{%
+ \tqft at alist,-incoming boundary 1/{(0,0)},-incoming boundary/{(0,0)}%
+ }%
+% \end{macrocode}
+% If there are more than one then for each subsequent one we add the curve between them and the corresponding arc of the boundary circle.
+% \begin{macrocode}
+ \ifnum\tqft at val{incoming boundary components}>1\relax
+ \foreach \k in {2,...,\tqft at val{incoming boundary components}} {
+ \edef\tqft at temp{\noexpand\pgfutil at in@{,\k,}{,\tqft at val{skip incoming boundary components},}}
+ \tqft at temp
+ \ifpgfutil at in@
+ \xdef\tqft at cibdrylist{\tqft at cibdrylist,\k}
+ \else
+ \xdef\tqft at ibdrylist{\tqft at ibdrylist,\k}
+ \fi
+ }
+ \ifx\tqft at ibdrylist\pgfutil at gobble
+ \else
+ \foreach \k [
+ remember=\k as \kmo (initially 1),
+ evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation} -\tqft at val{circle x radius},
+ ] in \tqft at ibdrylist {
+ \pgfmathsetmacro\xppos{(\kmo - 1)*\tqft at val{boundary separation} + \tqft at val{circle x radius}}
+ \pgfmathsetmacro\cpos{(\xpos + \xppos)/2}
+% \end{macrocode}
+% Add the curve and the arc.
+% \begin{macrocode}
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ .. controls +(0,-\tqft at val{cobordism height}/3) and +(0,-\tqft at val{cobordism height}/3) .. (\xpos pt,0) arc[start angle=\pgf at tqft@upper180, end angle=0, x radius=\tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
+ }%
+% \end{macrocode}
+% But for the edge path, just add the curve to the list.
+% \begin{macrocode}
+ \xdef\tqft at blist{%
+ \tqft at blist,incoming boundary \k/incoming/{%
+ (\xppos pt,0) .. controls +(0,-\tqft at val{cobordism height}/3) and +(0,-\tqft at val{cobordism height}/3) .. (\xpos pt,0)}%
+ }%
+% \end{macrocode}
+% We add a coordinate at the midpoint of the curve.
+% \begin{macrocode}
+ \xdef\tqft at clist{%
+ \tqft at clist,-between incoming \kmo\space and \k/{(\cpos pt,-\tqft at val{cobordism height}/4)}%
+ }%
+% \end{macrocode}
+% And add the centre to the list for available shifts.
+% \begin{macrocode}
+ \xdef\tqft at alist{%
+ \tqft at alist,-incoming boundary \k/{(\kmo * \tqft at val{boundary separation},0)}%
+ }%
+ }%
+ \fi
+ \fi
+% \end{macrocode}
+% We're at the edge of the last incoming boundary component.
+% What we do now depends on whether or not there are outgoing boundary components.
+% \begin{macrocode}
+ \ifnum\tqft at val{outgoing boundary components}>0\relax
+% \end{macrocode}
+% There are.
+%
+% We start by adding a curve from the end of the last incoming to the last outgoing component to the full path,
+% \begin{macrocode}
+ \pgfmathsetmacro\xppos{%
+ (\tqft at outgoing@end * (\tqft at val{outgoing boundary components} -1)
+ + \tqft at val{offset}) * \tqft at val{boundary separation}
+ + \tqft at outgoing@dir * \tqft at val{circle x radius}}%
+ \pgfmathsetmacro\tqft at ht{abs(\tqft at val{incoming boundary components} - \tqft at val{outgoing boundary components} - \tqft at val{offset})}%
+ \pgfmathsetmacro\tqft at ht{1/3 + 2/3*\tqft at ht/(\tqft at ht + 1)}%
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ .. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,\tqft at ht*\tqft at val{cobordism height}) .. (\xppos pt, -\tqft at val{cobordism height})
+ }%
+% \end{macrocode}
+% and the edge path.
+% \begin{macrocode}
+ \xdef\tqft at blist{%
+ \tqft at blist,between last incoming and last outgoing/incoming and outgoing/{%
+ (\tqft at val{incoming boundary components} * \tqft at val{boundary separation} + \tqft at val{circle x radius} - \tqft at val{boundary separation},0pt)
+ .. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,\tqft at ht*\tqft at val{cobordism height}) .. (\xppos pt, -\tqft at val{cobordism height})}%
+ }%
+% \end{macrocode}
+% In addition, we add a coordinate at the midpoint.
+% \begin{macrocode}
+ \pgfmathsetmacro\xppos{(\xppos + (\tqft at val{incoming boundary components} -1) * \tqft at val{boundary separation} +\tqft at val{circle x radius})/2}%
+ \xdef\tqft at clist{%
+ \tqft at clist,-between last incoming and last outgoing/{(\xppos pt,-\tqft at val{cobordism height}/2)}%
+ }%
+ \else
+% \end{macrocode}
+% There aren't any outgoing boundary components so we loop back to the start.
+% We adjust the height of the control points to take into account the overall width.
+% \begin{macrocode}
+ \pgfmathsetmacro\tqft at ht{1/3 + 2/3*(\tqft at val{incoming boundary components} - 1)/\tqft at val{incoming boundary components}}
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ .. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)
+ }%
+% \end{macrocode}
+% Same for the edge path.
+% \begin{macrocode}
+ \xdef\tqft at blist{%
+ \tqft at blist,between first and last incoming/incoming and outgoing/{%
+ (\tqft at val{incoming boundary components} * \tqft at val{boundary separation} + \tqft at val{circle x radius} - \tqft at val{boundary separation},0pt)
+ .. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)}
+ }%
+% \end{macrocode}
+% Add a coordinate at the midpoint.
+% \begin{macrocode}
+ \pgfmathsetmacro\xppos{(\tqft at val{incoming boundary components} -1) * \tqft at val{boundary separation}/2}%
+ \xdef\tqft at clist{%
+ \tqft at clist,-between first and last incoming/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height}*3/4)},-between first incoming and last incoming/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height}*3/4)}%
+ }%
+ \fi
+ \else
+% \end{macrocode}
+% There weren't any incoming boundary components, so we test to see if there were any outgoing ones and move to the start of them.
+% \begin{macrocode}
+ \ifnum\tqft at val{outgoing boundary components}>0\relax
+ \pgfmathsetmacro\xppos{( \tqft at outgoing@end * (\tqft at val{outgoing boundary components} -1)+\tqft at val{offset}) * \tqft at val{boundary separation} + \tqft at outgoing@dir * \tqft at val{circle x radius}}
+% \end{macrocode}
+% Add a move to the full path,
+% \begin{macrocode}
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ (\xppos pt, -\tqft at val{cobordism height})
+ }%
+ \fi
+ \fi
+% \end{macrocode}
+% We're done with the incoming boundary components, now we're set up for the outgoing ones.
+% However we got there, if we have outgoing boundary components then we're now located at the start of them, although we might be counting backwards .
+% \begin{macrocode}
+ \ifnum\tqft at val{outgoing boundary components}>0\relax
+ \pgfmathsetmacro\xppos{%
+ ( \tqft at outgoing@end * (\tqft at val{outgoing boundary components} -1)
+ + \tqft at val{offset}) * \tqft at val{boundary separation}
+ - \tqft at outgoing@dir * \tqft at val{circle x radius}}%
+% \end{macrocode}
+% Draw the arc for the first (well, last actually) boundary component.
+% \begin{macrocode}
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ arc[end angle=\pgf at tqft@upper180, start angle=0, x radius=\tqft at outgoing@dir * \tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
+ }%
+% \end{macrocode}
+% And add the centre to the list for available shifts.
+% \begin{macrocode}
+ \xdef\tqft at alist{%
+ \tqft at alist,-outgoing boundary \tqft at val{outgoing boundary components}/{(\xppos pt + \tqft at outgoing@dir * \tqft at val{circle x radius},-\tqft at val{cobordism height})},-outgoing boundary/{(\tqft at val{offset}*\tqft at val{boundary separation},-\tqft at val{cobordism height})}%
+ }%
+% \end{macrocode}
+% Do we have more than one boundary component?
+% \begin{macrocode}
+ \ifnum\tqft at val{outgoing boundary components}>1\relax
+% \end{macrocode}
+% Yes, so add a curve and arc for each.
+% \begin{macrocode}
+ \foreach \k [evaluate=\k as \ok using int(\tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - \tqft at outgoing@dir * \k)] in {2,...,\tqft at val{outgoing boundary components}} {
+ \edef\tqft at temp{\noexpand\pgfutil at in@{,\ok,}{,\tqft at val{skip outgoing boundary components},}}
+ \tqft at temp
+ \ifpgfutil at in@
+ \xdef\tqft at cobdrylist{\tqft at cobdrylist,\k}
+ \else
+ \xdef\tqft at obdrylist{\tqft at obdrylist,\k}
+ \fi
+ }
+ \ifx\tqft at obdrylist\pgfutil at gobble
+ \else
+ \foreach \k [
+ remember=\k as \kmo (initially 1),
+ evaluate=\k as \xpos using ( \tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - 1 - \tqft at outgoing@dir * \k + \tqft at val{offset})*\tqft at val{boundary separation} + \tqft at outgoing@dir * \tqft at val{circle x radius},
+ ] in \tqft at obdrylist {
+ \pgfmathsetmacro\xppos{(\tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - 1 - \tqft at outgoing@dir * \kmo + \tqft at val{offset})*\tqft at val{boundary separation} - \tqft at outgoing@dir * \tqft at val{circle x radius}}
+ \pgfmathsetmacro\cpos{(\xpos + \xppos)/2}
+ \pgfmathsetmacro\nk{int(\tqft at val{outgoing boundary components} - \k + 1)}
+ \pgfmathsetmacro\nkpo{int(\tqft at val{outgoing boundary components} - \kmo + 1)}
+% \end{macrocode}
+% Both are added to the full path.
+% \begin{macrocode}
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ .. controls +(0,\tqft at val{cobordism height}/3) and +(0,\tqft at val{cobordism height}/3) .. (\xpos pt,-\tqft at val{cobordism height}) arc[end angle=\pgf at tqft@upper180, start angle=0, x radius=\tqft at outgoing@dir * \tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
+ }%
+% \end{macrocode}
+% Just the arc for the edge paths.
+% \begin{macrocode}
+ \xdef\tqft at blist{%
+ \tqft at blist,between outgoing \nk\space and \nkpo/outgoing/{%
+ (\xppos pt,-\tqft at val{cobordism height})
+ .. controls +(0,\tqft at val{cobordism height}/3) and +(0,\tqft at val{cobordism height}/3) .. (\xpos pt,-\tqft at val{cobordism height}) ++(-2*\tqft at val{circle x radius},0)}%
+ }%
+% \end{macrocode}
+% And a coordinate at the midpoint.
+% \begin{macrocode}
+ \xdef\tqft at clist{%
+ \tqft at clist,-between outgoing \nk\space and \nkpo/{(\cpos pt,-3*\tqft at val{cobordism height}/4)}%
+ }%
+% \end{macrocode}
+% And add the centre to the list for available shifts.
+% \begin{macrocode}
+ \xdef\tqft at alist{%
+ \tqft at alist,-outgoing boundary \nk/{(\xpos pt - \tqft at val{circle x radius},-\tqft at val{cobordism height})}%
+ }%
+ }%
+ \fi
+ \fi
+% \end{macrocode}
+% Now we're at the end of the outgoing boundary components (well, the start actually).
+% What we do now depends on whether or not there are any incoming boundary components.
+% \begin{macrocode}
+ \ifnum\tqft at val{incoming boundary components}>0\relax
+% \end{macrocode}
+% There are, so we draw the path back up.
+% \begin{macrocode}
+ \pgfmathsetmacro\tqft at ht{1/3 + 2/3*abs(\tqft at val{offset})/(abs(\tqft at val{offset}) + 1)}%
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ .. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)
+ }%
+% \end{macrocode}
+% And the edge path does the same.
+% \begin{macrocode}
+ \xdef\tqft at blist{%
+ \tqft at blist,between first incoming and first outgoing/incoming and outgoing/{%
+ ({ ( (1 - \tqft at outgoing@end) * (\tqft at val{outgoing boundary components} - 1) + \tqft at val{offset}) * \tqft at val{boundary separation} - \tqft at outgoing@dir * \tqft at val{circle x radius}},-\tqft at val{cobordism height})
+ .. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)}%
+ }%
+% \end{macrocode}
+% Add a coordinate at the midpoint.
+% \begin{macrocode}
+ \xdef\tqft at clist{%
+ \tqft at clist,-between first incoming and first outgoing/{({ ( (1 - \tqft at outgoing@end) * (\tqft at val{outgoing boundary components} - 1) +\tqft at val{offset})*\tqft at val{boundary separation}/2- \tqft at outgoing@end * \tqft at val{circle x radius}},-\tqft at val{cobordism height}/2)}%
+ }%
+ \else
+% \end{macrocode}
+% No incoming boundary components so loop back to the other end of the outgoing boundary components.
+% \begin{macrocode}
+ \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} +\tqft at val{circle x radius}}%
+ \pgfmathsetmacro\tqft at ht{1/3 + 2/3*(\tqft at val{outgoing boundary components} - 1)/\tqft at val{outgoing boundary components}}
+% \end{macrocode}
+% Full path.
+% \begin{macrocode}
+ \xdef\tqft at fullpath{%
+ \tqft at fullpath
+ .. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,\tqft at ht*\tqft at val{cobordism height}) .. (\xppos pt,-\tqft at val{cobordism height})
+ }%
+% \end{macrocode}
+% Edge path.
+% \begin{macrocode}
+ \xdef\tqft at blist{%
+ \tqft at blist,between first and last outgoing/incoming and outgoing/{%
+ (\tqft at val{offset} * \tqft at val{boundary separation} - \tqft at val{circle x radius},-\tqft at val{cobordism height})
+ .. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,\tqft at ht*\tqft at val{cobordism height}) .. (\xppos pt,-\tqft at val{cobordism height})}%
+ }%
+% \end{macrocode}
+% Add a coordinate at the midpoint.
+% \begin{macrocode}
+ \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components}/2 + \tqft at val{offset} -1/2) * \tqft at val{boundary separation}}%
+ \pgfmathsetmacro\tqft at ht{1 -\tqft at ht*3/4}%
+ \xdef\tqft at clist{%
+ \tqft at clist,-between first and last outgoing/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height})},-between first outgoing and last outgoing/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height})}%
+ }%
+ \fi
+ \fi
+% \end{macrocode}
+% Now we define the clip path for the genus holes.
+% We start with a big rectangle that \emph{ought} to be big enough to contain the whole shape.
+% We start with the top left corner.
+% \begin{macrocode}
+ \pgfmathsetmacro\xpos{%
+ (
+ \tqft at val{outgoing boundary components} > 0 ?
+ (
+ \tqft at val{incoming boundary components} > 0 ?
+ min(0,\tqft at val{offset}) : \tqft at val{offset}
+ ) : 0
+ )
+ *\tqft at val{boundary separation} - 2*\tqft at val{circle x radius}}%
+ \xdef\tqft at gclip{(\xpos pt,2*\tqft at val{circle y radius}) rectangle }%
+% \end{macrocode}
+% Now the bottom right.
+% \begin{macrocode}
+ \pgfmathsetmacro\xpos{%
+ ((
+ \tqft at val{outgoing boundary components} > 0 ?
+ (
+ \tqft at val{incoming boundary components} > 0 ?
+ max(\tqft at val{incoming boundary components},\tqft at val{outgoing boundary components} + \tqft at val{offset}) : \tqft at val{outgoing boundary components} + \tqft at val{offset}
+ ) : \tqft at val{incoming boundary components}
+ )-1)
+ *\tqft at val{boundary separation} + 2*\tqft at val{circle x radius}}%
+% \end{macrocode}
+% Together, these make a rectangle.
+% \begin{macrocode}
+ \xdef\tqft at gclip{\tqft at gclip (\xpos pt,-\tqft at val{cobordism height} - 2*\tqft at val{circle y radius})}%
+% \end{macrocode}
+% Are there any holes?
+% \begin{macrocode}
+ \ifnum\tqft at val{genus}>0\relax
+% \end{macrocode}
+% Yes, so first we need to figure out where to place them.
+% We work out the left-hand edge of the cobordism.
+% \begin{macrocode}
+ \pgfmathsetmacro\xpos{%
+ (
+ \tqft at val{outgoing boundary components} > 0 ?
+ (
+ \tqft at val{incoming boundary components} > 0 ?
+ \tqft at val{offset}/2 : \tqft at val{offset}
+ ) : 0
+ )
+ *\tqft at val{boundary separation} - \tqft at val{circle x radius}}%
+% \end{macrocode}
+% Work out the height that the holes should be punched at.
+% \begin{macrocode}
+ \pgfmathsetmacro\ypos{%
+ (
+ \tqft at val{outgoing boundary components} > 0 ?
+ (
+ \tqft at val{incoming boundary components} > 0 ?
+ -\tqft at val{cobordism height}/2 : -1 + \tqft at val{cobordism height}/3
+ ) : - \tqft at val{cobordism height}/3
+ )}%
+% \end{macrocode}
+% Start our clip path at this point
+% \begin{macrocode}
+ \xdef\tqft at gclip{%
+ \tqft at gclip
+ (\xpos pt,\ypos pt)
+ }%
+% \end{macrocode}
+% Now work out the width of the cobordism, in units of circle half-widths.
+% This may not be very accurate if there aren't any boundary components of a given type.
+% \begin{macrocode}
+ \pgfmathsetmacro\gsize{%
+ ((
+ \tqft at val{outgoing boundary components} > 0 ?
+ (
+ \tqft at val{incoming boundary components} > 0 ?
+ (\tqft at val{incoming boundary components} + \tqft at val{outgoing boundary components})/2 : \tqft at val{outgoing boundary components}
+ ) : \tqft at val{incoming boundary components}
+ )-1)
+ *\tqft at val{boundary separation}/\tqft at val{circle x radius} + 2}%
+% \end{macrocode}
+% Each hole should take up three half-widths, but we want a little extra on the edges so the total number of half-widths we want is \(3g + 1\).
+% Do we need to scale down the holes (we never scale up)?
+% If so, \verb+\gscale+ holds the overall scale factor and \verb+\gxscale+ and \verb+gyscale+ are the resulting horizontal and vertical measurements.
+% The baseline is the size of the boundary circles.
+% \begin{macrocode}
+ \pgfmathsetmacro\gscale{min(1,\gsize/(3*\tqft at val{genus}+1))}%
+ \pgfmathsetmacro\gyscale{\tqft at val{circle y radius}*\gscale*.707}%
+ \pgfmathsetmacro\gxscale{\tqft at val{circle x radius}*\gscale}%
+% \end{macrocode}
+% Each hole should take up 2 half widths, modulo scaling, so the total width used by the holes is \(2 g s\) leaving \(w - 2 g s\) left for the gaps which is divided in to \(g + 1\) lots.
+% \begin{macrocode}
+ \pgfmathsetmacro\gsep{((\gsize - 2*\tqft at val{genus}*\gscale)/(\tqft at val{genus} + 1)*\tqft at val{circle x radius}}%
+% \end{macrocode}
+% We shift in by half of one unit of excess separation.
+% \begin{macrocode}
+ \xdef\tqft at gclip{%
+ \tqft at gclip
+ ++(\gsep/2 pt,0)
+ }%
+% \end{macrocode}
+% Some useful quantities.
+% \begin{macrocode}
+ \pgfmathsetmacro\omrstwo{1 - 1/sqrt(2)}%
+ \pgfmathsetmacro\sqrtwo{sqrt(2)}%
+% \end{macrocode}
+% Now we iterate over the holes.
+% \begin{macrocode}
+ \foreach[
+ evaluate=\k as \kmo using int(2 * \k-1)
+ ] \k in {1,...,\tqft at val{genus}} {
+% \end{macrocode}
+% For the clipping path, we just want the bare hole.
+% \begin{macrocode}
+ \xdef\tqft at gclip{%
+ \tqft at gclip
+% \end{macrocode}
+% Move in by half an excess separation unit and move to the left-hand extent of the hole.
+% \begin{macrocode}
+ ++(\gsep/2 pt + \omrstwo*\gxscale pt,0)
+% \end{macrocode}
+% Now curve up over the hole,
+% \begin{macrocode}
+ .. controls +(\gxscale*\sqrtwo/3 pt,4/3*\gyscale pt) and +(-\gxscale*\sqrtwo/3 pt,4/3*\gyscale pt)
+ .. ++(\sqrtwo*\gxscale pt,0)
+% \end{macrocode}
+% and return on the underside.
+% \begin{macrocode}
+ .. controls +(-\gxscale*\sqrtwo/3 pt,-4/3*\gyscale pt) and +(\gxscale*\sqrtwo/3 pt,-4/3*\gyscale pt)
+ .. ++(-\sqrtwo*\gxscale pt,0)
+% \end{macrocode}
+% Lastly, move to the right-hand edge of the space taken up by this hole.
+% \begin{macrocode}
+ ++(2*\gxscale pt -\omrstwo*\gxscale pt + \gsep/2 pt,0)
+ }
+% \end{macrocode}
+% For the genus \emph{path} we want to add the little ``tails'' which means that the two curves are different, and we need to take into acount the \verb+view from+ direction.
+% \begin{macrocode}
+ \xdef\tqft at glist{%
+ \tqft at glist,%
+ hole \k/lower/{%
+% \end{macrocode}
+% Move to the starting point of the smaller curve and add that.
+% \begin{macrocode}
+ (\xpos pt + \k * \gsep pt + \kmo * \gxscale pt + \gxscale pt -\omrstwo*\gxscale pt,\ypos pt)
+ .. controls +(-\gxscale pt*\sqrtwo/3,\pgf at tqft@upper4/3*\gyscale pt) and +(\gxscale pt*\sqrtwo/3,\pgf at tqft@upper4/3*\gyscale pt)
+ .. ++(-\sqrtwo*\gxscale pt,0)},%
+% Move to the left-hand corner of the path, with the upper or lower chosen by the \verb+view from+ direction.
+ hole \k/upper/{(\xpos pt + \k * \gsep pt + \kmo * \gxscale pt - \gxscale pt,\ypos pt + \pgf at tqft@upper\gyscale pt)%
+% \end{macrocode}
+% Add the larger of the two curves.
+% \begin{macrocode}
+ .. controls +(\gxscale pt*2/3,\pgf at tqft@lower8/3*\gyscale pt) and +(-\gxscale pt*2/3,\pgf at tqft@lower8/3*\gyscale pt)
+ .. ++(2*\gxscale pt,0)}%
+ }%
+% \end{macrocode}
+% Add a coordinate at the centre of the hole.
+% \begin{macrocode}
+ \xdef\tqft at clist{%
+ \tqft at clist,-hole \k/{(\xpos pt + \k * \gsep pt + \kmo * \gxscale pt,\ypos pt)}%
+ }%
+ }%
+ \fi
+% \end{macrocode}
+% Now we start to lay out the cobordism
+% Were we given a shift? If so, shift.
+% \begin{macrocode}
+\gdef\tqft at shift{(0,0)}%
+\edef\tqft at anchor{\tqft at val{anchor}}%
+\expandafter\pgfutil at in@\expandafter{\expandafter,\expandafter}\expandafter{\tqft at anchor}%
+\ifpgfutil at in@
+\expandafter\tqft at split\tqft at anchor\relax
+\else
+\edef\tqft at anchor{-\tqft at val{anchor}}%
+\xdef\tqft at alist{\tqft at clist,\tqft at alist}%
+\foreach \anchor/\coord in \tqft at alist
+{
+ \ifx\anchor\tqft at anchor\relax
+ \global\let\tqft at shift\coord
+ \fi
+}%
+\fi
+\tikz at scan@one at point\pgfutil at firstofone\tqft at shift\relax
+\begin{scope}[shift={(-\pgf at x,-\pgf at y)}]
+% \end{macrocode}
+% At each incoming boundary component we place an elliptical node of the right size.
+% \begin{macrocode}
+\ifnum\tqft at val{incoming boundary components}>0\relax
+\ifx\tqft at ibdrylist\pgfutil at gobble
+\xdef\tqft at ibdrylist{1}
+\else
+\xdef\tqft at ibdrylist{1,\tqft at ibdrylist}
+\fi
+ \foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at ibdrylist {
+ \node[
+ transform shape,
+ node contents={},
+ ellipse,
+ inner sep=0pt,
+ outer sep=0pt,
+ minimum width=2*\tqft at val{circle x radius},
+ minimum height=2*\tqft at val{circle y radius},
+ at={(\xpos pt,0)},
+ name=-incoming boundary \k,
+ /tikz/tqft/every boundary component/.try,
+ /tikz/tqft/every incoming boundary component/.try,
+ /tikz/tqft/incoming boundary component \k/.try
+ ];
+ }%
+\ifx\tqft at cibdrylist\pgfutil at gobble
+\else
+ \foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at cibdrylist {
+ \node[
+ transform shape,
+ node contents={},
+ ellipse,
+ inner sep=0pt,
+ outer sep=0pt,
+ minimum width=2*\tqft at val{circle x radius},
+ minimum height=2*\tqft at val{circle y radius},
+ at={(\xpos pt,0)},
+ name=-incoming boundary \k,
+ /tikz/tqft/every skipped boundary component/.try,
+ /tikz/tqft/every skipped incoming boundary component/.try,
+ /tikz/tqft/skipped incoming boundary component \k/.try,
+ ];
+}%
+\fi
+% \end{macrocode}
+% Add an alias for the first.
+% \begin{macrocode}
+ \path node also[pic alias=-incoming boundary] (-incoming boundary 1);
+ \fi
+% \end{macrocode}
+% Same for the outgoing boundary components.
+% \begin{macrocode}
+ \ifnum\tqft at val{outgoing boundary components}>0\relax
+\ifx\tqft at obdrylist\pgfutil at gobble
+\xdef\tqft at obdrylist{1}
+\else
+\xdef\tqft at obdrylist{1,\tqft at obdrylist}
+\fi
+\foreach \k [evaluate=\k as \ok using int(\tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - \tqft at outgoing@dir * \k)] in \tqft at obdrylist {
+ \xdef\tqft at robdrylist{\tqft at robdrylist,\ok}
+}
+ \foreach[
+ evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
+ ] \k in \tqft at robdrylist {
+ \node[
+ transform shape,
+ node contents={},
+ ellipse,
+ inner sep=0pt,
+ outer sep=0pt,
+ minimum width=2*\tqft at val{circle x radius},
+ minimum height=2*\tqft at val{circle y radius},
+ at={(\xpos pt,-\tqft at val{cobordism height})},
+ name=-outgoing boundary \k,
+ /tikz/tqft/every boundary component/.try,
+ /tikz/tqft/every outgoing boundary component/.try,
+ /tikz/tqft/outgoing boundary component \k/.try
+ ];
+}%
+\ifx\tqft at cobdrylist\pgfutil at gobble
+\else
+\foreach \k[evaluate=\k as \ok using int(\tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - \tqft at outgoing@dir * \k)]
+ in \tqft at cobdrylist {
+ \xdef\tqft at rcobdrylist{\tqft at rcobdrylist,\ok}
+}
+ \foreach[
+ evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
+ ] \k in \tqft at rcobdrylist {
+ \node[
+ transform shape,
+ node contents={},
+ ellipse,
+ inner sep=0pt,
+ outer sep=0pt,
+ minimum width=2*\tqft at val{circle x radius},
+ minimum height=2*\tqft at val{circle y radius},
+ at={(\xpos pt,-\tqft at val{cobordism height})},
+ name=-outgoing boundary \k,
+ /tikz/tqft/every skipped boundary component/.try,
+ /tikz/tqft/every skipped outgoing boundary component/.try,
+ /tikz/tqft/skipped outgoing boundary component \k/.try
+ ];
+ }%
+\fi
+% \end{macrocode}
+% Add an alias for the first.
+% \begin{macrocode}
+ \path node also[pic alias=-outgoing boundary] (-outgoing boundary 1);
+ \fi
+% \end{macrocode}
+% Now we draw the lower paths of the incoming boundary components.
+% \begin{macrocode}
+ \ifnum\tqft at val{incoming boundary components}>0\relax
+ \foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at ibdrylist {
+ \path[
+ /tikz/tqft/every lower boundary component/.try,
+ /tikz/tqft/every incoming lower boundary component/.try,
+ /tikz/tqft/incoming lower boundary component \k/.try
+ ] (\xpos pt - \tqft at val{circle x radius},0) arc[start angle=\pgf at tqft@lower180,end angle=0, x radius=\tqft at val{circle x radius}, y radius =\tqft at val{circle y radius}];
+ }%
+ \fi
+% \end{macrocode}
+% Same for the outgoing boundary components.
+% \begin{macrocode}
+ \ifnum\tqft at val{outgoing boundary components}>0\relax
+ \foreach[
+ evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
+ ] \k in \tqft at robdrylist {
+ \path[
+ /tikz/tqft/every lower boundary component/.try,
+ /tikz/tqft/every outgoing lower boundary component/.try,
+ /tikz/tqft/outgoing lower boundary component \k/.try
+ ] (\xpos pt - \tqft at val{circle x radius},-\tqft at val{cobordism height}) arc[start angle=\pgf at tqft@lower180,end angle=0, x radius=\tqft at val{circle x radius}, y radius =\tqft at val{circle y radius}];
+ }%
+ \fi
+% \end{macrocode}
+% Full outer path, clipped against the genus holes in case it is filled.
+% \begin{macrocode}
+ \begin{scope}
+ \path[overlay,clip] \tqft at gclip;
+ \path[
+ /tikz/tqft/cobordism/.try,
+ pic actions,
+ /tikz/tqft/cobordism outer path/.try,
+ ] \tqft at fullpath;
+ \end{scope}
+% \end{macrocode}
+% Now we draw the genus path, outside the clip.
+% We view this as part of the full cobordism path so try to apply the same style as for the full path, but if that is filled then we turn the fill off.
+% It can be turned back on again using the styles \verb+cobordism edge+ or \verb+genus style+.
+% We also apply the \verb+cobordism edge+ style as it could be thought of as part of the non-boundary edge.
+% Finally, it has its own style to enable overrides if the other two get confused.
+% \begin{macrocode}
+\ifx\tqft at glist\pgfutil at gobble
+\else
+\foreach \tqft at gstyle/\tqft at gside/\tqft at gpath in \tqft at glist {
+ \path[
+ /tikz/tqft/cobordism/.try,
+ pic actions,
+ fill=none,
+ shade=none,
+ /tikz/tqft/cobordism edge/.try,
+ /tikz/tqft/genus style/.try,
+ /tikz/tqft/genus \tqft at gside/.try,
+ /tikz/tqft/\tqft at gstyle/.try,
+ /tikz/tqft/\tqft at gstyle\space\tqft at gside/.try,
+ ] \tqft at gpath;
+}
+\fi
+% \end{macrocode}
+% Now we redraw the non-boundary paths.
+% \begin{macrocode}
+\ifx\tqft at blist\pgfutil at gobble
+\else
+\foreach \tqft at bstyle/\tqft at btype/\tqft at bpath in \tqft at blist {
+ \path[
+ /tikz/tqft/cobordism edge/.try,
+ /tikz/tqft/cobordism outer edge/.try,
+ /tikz/tqft/between \tqft at btype/.try,
+ /tikz/tqft/\tqft at bstyle/.try,
+ ] \tqft at bpath;
+}
+\fi
+% \end{macrocode}
+% There were various coordinates that we wanted to define but couldn't.
+% Here, we put those in place.
+% \begin{macrocode}
+ \ifx\tqft at clist\pgfutil at gobble
+ \else
+ \foreach \name/\coord in \tqft at clist {
+ \path \coord node[coordinate,node contents={},name=\name];
+ }
+ \fi
+% \end{macrocode}
+% The last task is to draw the upper paths of the boundary components.
+% First, incoming.
+% \begin{macrocode}
+ \ifnum\tqft at val{incoming boundary components}>0\relax
+ \foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at ibdrylist {
+ \path[
+ /tikz/tqft/every upper boundary component/.try,
+ /tikz/tqft/every incoming upper boundary component/.try,
+ /tikz/tqft/incoming upper boundary component \k/.try
+ ] (\xpos pt - \tqft at val{circle x radius},0) arc[start angle=\pgf at tqft@upper180,end angle=0, x radius=\tqft at val{circle x radius}, y radius =\tqft at val{circle y radius}];
+ }
+ \fi
+% \end{macrocode}
+% Next, outgoing.
+% \begin{macrocode}
+ \ifnum\tqft at val{outgoing boundary components}>0\relax
+ \foreach[
+ evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
+ ] \k in \tqft at robdrylist {
+ \path[
+ /tikz/tqft/every upper boundary component/.try,
+ /tikz/tqft/every outgoing upper boundary component/.try,
+ /tikz/tqft/outgoing upper boundary component \k/.try
+ ] (\xpos pt - \tqft at val{circle x radius},-\tqft at val{cobordism height}) arc[start angle=\pgf at tqft@upper180,end angle=0, x radius=\tqft at val{circle x radius}, y radius =\tqft at val{circle y radius}];
+ }
+ \fi
+\end{scope}
+% \end{macrocode}
+% We're done!
+% Phew.
+% \begin{macrocode}
+ }
+}
+% \end{macrocode}
+%
+% \iffalse
+%</library>
+% \fi
+% \Finale
+
+\endinput
Property changes on: trunk/Master/texmf-dist/source/latex/tqft/tqft_code.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tqft/tqft_code.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/tqft/tqft_code.ins (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tqft/tqft_code.ins 2024-06-01 20:21:17 UTC (rev 71401)
@@ -0,0 +1,82 @@
+%%
+%% This is file `tqft_code.ins',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tqft_code.dtx (with options: `install')
+%% ----------------------------------------------------------------
+%% tqft --- a TikZ library for drawing TQFT diagrams
+%% E-mail: loopspace at mathforge.org
+%% Released under the LaTeX Project Public License v1.3c or later
+%% See http://www.latex-project.org/lppl.txt
+%% ----------------------------------------------------------------
+%%
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+\preamble
+----------------------------------------------------------------
+tqft --- a TikZ library for drawing TQFT diagrams
+E-mail: loopspace at mathforge.org
+Released under the LaTeX Project Public License v1.3c or later
+See http://www.latex-project.org/lppl.txt
+----------------------------------------------------------------
+
+\endpreamble
+\postamble
+
+Copyright (C) 2011-2024 by Andrew Stacey <loopspace at mathforge.org>
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License (LPPL), either
+version 1.3c of this license or (at your option) any later
+version. The latest version of this license is in the file:
+
+http://www.latex-project.org/lppl.txt
+
+This work is "maintained" (as per LPPL maintenance status) by
+Andrew Stacey.
+
+This work consists of the files tqft_code.dtx,
+ tqft.tex,
+and the derived files tqft_code.ins,
+ tqft_code.pdf,
+ tqft.pdf,
+ tqft.sty, and
+ tikzlibrarytqft.code.tex.
+
+\endpostamble
+\usedir{tex/latex/tqft}
+\generate{
+ \file{tqft.sty}{\from{\jobname.dtx}{package}}
+}
+\usedir{tex/latex/tqft}
+\generate{
+ \file{tikzlibrarytqft.code.tex}{\from{\jobname.dtx}{library}}
+}
+\endbatchfile
+
+%%
+%% Copyright (C) 2011-2024 by Andrew Stacey <loopspace at mathforge.org>
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License (LPPL), either
+%% version 1.3c of this license or (at your option) any later
+%% version. The latest version of this license is in the file:
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% This work is "maintained" (as per LPPL maintenance status) by
+%% Andrew Stacey.
+%%
+%% This work consists of the files tqft_code.dtx,
+%% tqft.tex,
+%% and the derived files tqft_code.ins,
+%% tqft_code.pdf,
+%% tqft.pdf,
+%% tqft.sty, and
+%% tikzlibrarytqft.code.tex.
+%%
+%%
+%% End of file `tqft_code.ins'.
Modified: trunk/Master/texmf-dist/tex/latex/tqft/tikzlibrarytqft.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tqft/tikzlibrarytqft.code.tex 2024-06-01 20:20:59 UTC (rev 71400)
+++ trunk/Master/texmf-dist/tex/latex/tqft/tikzlibrarytqft.code.tex 2024-06-01 20:21:17 UTC (rev 71401)
@@ -4,14 +4,15 @@
%%
%% The original source files were:
%%
-%% tqft.dtx (with options: `library')
+%% tqft_code.dtx (with options: `library')
%% ----------------------------------------------------------------
-%% tqft --- a library for drawing TQFT diagrams with TikZ/PGF
+%% tqft --- a TikZ library for drawing TQFT diagrams
%% E-mail: loopspace at mathforge.org
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%%
+\ProvidesFile{tikzlibrarytqft.code.tex}[2024/05/31 v2.3 Tikz/PGF commands for drawing TQFT diagrams]
\ifcsname pgfk@/handlers/.pic/. at cmd\endcsname
\else
\pgfwarning{This library only works with TikZ 3.0 or later; for earlier versions of TikZ use the TQFT package}
@@ -20,6 +21,7 @@
\def\pgf at tqft@minus{-}
\let\pgf at tqft@upper\@empty
\let\pgf at tqft@lower\pgf at tqft@minus
+\newif\iftqft at twisted
\def\tqft at split(#1,#2){%
\pgfmathsetmacro\tqft at y{#2 * (-\tqft at val{cobordism height})}%
\pgfmathsetmacro\tqft at x{(#1 - 1 + max(min(#2,1),0)*\tqft at val{offset}) * \tqft at val{boundary separation}}%
@@ -61,6 +63,7 @@
\let\pgf at tqft@lower\pgf at tqft@minus
\let\pgf at tqft@upper\@empty
},
+ twisted/.is if=tqft at twisted,
anchor/.initial = none,
pair of pants/.style={
/tikz/tqft,
@@ -138,6 +141,13 @@
\global\let\tqft at cobdrylist=\pgfutil at gobble
\global\let\tqft at robdrylist=\pgfutil at gobble
\global\let\tqft at rcobdrylist=\pgfutil at gobble
+ \iftqft at twisted
+ \pgfmathsetmacro\tqft at outgoing@end{0}%
+ \pgfmathsetmacro\tqft at outgoing@dir{-1}%
+ \else
+ \pgfmathsetmacro\tqft at outgoing@end{1}%
+ \pgfmathsetmacro\tqft at outgoing@dir{1}%
+ \fi
\ifnum\tqft at val{incoming boundary components}>0\relax
\xdef\tqft at fullpath{%
\tqft at fullpath
@@ -182,7 +192,10 @@
\fi
\fi
\ifnum\tqft at val{outgoing boundary components}>0\relax
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} +\tqft at val{circle x radius}}%
+ \pgfmathsetmacro\xppos{%
+ (\tqft at outgoing@end * (\tqft at val{outgoing boundary components} -1)
+ + \tqft at val{offset}) * \tqft at val{boundary separation}
+ + \tqft at outgoing@dir * \tqft at val{circle x radius}}%
\pgfmathsetmacro\tqft at ht{abs(\tqft at val{incoming boundary components} - \tqft at val{outgoing boundary components} - \tqft at val{offset})}%
\pgfmathsetmacro\tqft at ht{1/3 + 2/3*\tqft at ht/(\tqft at ht + 1)}%
\xdef\tqft at fullpath{%
@@ -205,18 +218,18 @@
.. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)
}%
\xdef\tqft at blist{%
- \tqft at blist,between first incoming and last incoming/incoming and outgoing/{%
+ \tqft at blist,between first and last incoming/incoming and outgoing/{%
(\tqft at val{incoming boundary components} * \tqft at val{boundary separation} + \tqft at val{circle x radius} - \tqft at val{boundary separation},0pt)
.. controls +(0,-\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)}
}%
\pgfmathsetmacro\xppos{(\tqft at val{incoming boundary components} -1) * \tqft at val{boundary separation}/2}%
\xdef\tqft at clist{%
- \tqft at clist,-between first incoming and last incoming/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height}*3/4)}%
+ \tqft at clist,-between first and last incoming/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height}*3/4)},-between first incoming and last incoming/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height}*3/4)}%
}%
\fi
\else
\ifnum\tqft at val{outgoing boundary components}>0\relax
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} +\tqft at val{circle x radius}}
+ \pgfmathsetmacro\xppos{( \tqft at outgoing@end * (\tqft at val{outgoing boundary components} -1)+\tqft at val{offset}) * \tqft at val{boundary separation} + \tqft at outgoing@dir * \tqft at val{circle x radius}}
\xdef\tqft at fullpath{%
\tqft at fullpath
(\xppos pt, -\tqft at val{cobordism height})
@@ -223,17 +236,20 @@
}%
\fi
\fi
- \ifnum\tqft at val{outgoing boundary components}>0\relax
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} -\tqft at val{circle x radius}}%
+ \ifnum\tqft at val{outgoing boundary components}>0\relax
+ \pgfmathsetmacro\xppos{%
+ ( \tqft at outgoing@end * (\tqft at val{outgoing boundary components} -1)
+ + \tqft at val{offset}) * \tqft at val{boundary separation}
+ - \tqft at outgoing@dir * \tqft at val{circle x radius}}%
\xdef\tqft at fullpath{%
\tqft at fullpath
- arc[end angle=\pgf at tqft@upper180, start angle=0, x radius=\tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
+ arc[end angle=\pgf at tqft@upper180, start angle=0, x radius=\tqft at outgoing@dir * \tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
}%
\xdef\tqft at alist{%
- \tqft at alist,-outgoing boundary \tqft at val{outgoing boundary components}/{(\xppos pt + \tqft at val{circle x radius},-\tqft at val{cobordism height})},-outgoing boundary/{(\tqft at val{offset}*\tqft at val{boundary separation},-\tqft at val{cobordism height})}%
+ \tqft at alist,-outgoing boundary \tqft at val{outgoing boundary components}/{(\xppos pt + \tqft at outgoing@dir * \tqft at val{circle x radius},-\tqft at val{cobordism height})},-outgoing boundary/{(\tqft at val{offset}*\tqft at val{boundary separation},-\tqft at val{cobordism height})}%
}%
\ifnum\tqft at val{outgoing boundary components}>1\relax
- \foreach \k [evaluate=\k as \ok using int(\tqft at val{outgoing boundary components} - \k + 1)] in {2,...,\tqft at val{outgoing boundary components}} {
+ \foreach \k [evaluate=\k as \ok using int(\tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - \tqft at outgoing@dir * \k)] in {2,...,\tqft at val{outgoing boundary components}} {
\edef\tqft at temp{\noexpand\pgfutil at in@{,\ok,}{,\tqft at val{skip outgoing boundary components},}}
\tqft at temp
\ifpgfutil at in@
@@ -246,15 +262,15 @@
\else
\foreach \k [
remember=\k as \kmo (initially 1),
- evaluate=\k as \xpos using (\tqft at val{outgoing boundary components} - \k + \tqft at val{offset})*\tqft at val{boundary separation} + \tqft at val{circle x radius},
+ evaluate=\k as \xpos using ( \tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - 1 - \tqft at outgoing@dir * \k + \tqft at val{offset})*\tqft at val{boundary separation} + \tqft at outgoing@dir * \tqft at val{circle x radius},
] in \tqft at obdrylist {
- \pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} - \kmo + \tqft at val{offset})*\tqft at val{boundary separation} - \tqft at val{circle x radius}}
+ \pgfmathsetmacro\xppos{(\tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - 1 - \tqft at outgoing@dir * \kmo + \tqft at val{offset})*\tqft at val{boundary separation} - \tqft at outgoing@dir * \tqft at val{circle x radius}}
\pgfmathsetmacro\cpos{(\xpos + \xppos)/2}
\pgfmathsetmacro\nk{int(\tqft at val{outgoing boundary components} - \k + 1)}
\pgfmathsetmacro\nkpo{int(\tqft at val{outgoing boundary components} - \kmo + 1)}
\xdef\tqft at fullpath{%
\tqft at fullpath
- .. controls +(0,\tqft at val{cobordism height}/3) and +(0,\tqft at val{cobordism height}/3) .. (\xpos pt,-\tqft at val{cobordism height}) arc[end angle=\pgf at tqft@upper180, start angle=0, x radius=\tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
+ .. controls +(0,\tqft at val{cobordism height}/3) and +(0,\tqft at val{cobordism height}/3) .. (\xpos pt,-\tqft at val{cobordism height}) arc[end angle=\pgf at tqft@upper180, start angle=0, x radius=\tqft at outgoing@dir * \tqft at val{circle x radius}, y radius=\tqft at val{circle y radius}]
}%
\xdef\tqft at blist{%
\tqft at blist,between outgoing \nk\space and \nkpo/outgoing/{%
@@ -278,11 +294,11 @@
}%
\xdef\tqft at blist{%
\tqft at blist,between first incoming and first outgoing/incoming and outgoing/{%
- (\tqft at val{offset} * \tqft at val{boundary separation} - \tqft at val{circle x radius},-\tqft at val{cobordism height})
+ ({ ( (1 - \tqft at outgoing@end) * (\tqft at val{outgoing boundary components} - 1) + \tqft at val{offset}) * \tqft at val{boundary separation} - \tqft at outgoing@dir * \tqft at val{circle x radius}},-\tqft at val{cobordism height})
.. controls +(0,\tqft at ht*\tqft at val{cobordism height}) and +(0,-\tqft at ht*\tqft at val{cobordism height}) .. (-\tqft at val{circle x radius},0)}%
}%
\xdef\tqft at clist{%
- \tqft at clist,-between first incoming and first outgoing/{(\tqft at val{offset}*\tqft at val{boundary separation}/2-\tqft at val{circle x radius},-\tqft at val{cobordism height}/2)}%
+ \tqft at clist,-between first incoming and first outgoing/{({ ( (1 - \tqft at outgoing@end) * (\tqft at val{outgoing boundary components} - 1) +\tqft at val{offset})*\tqft at val{boundary separation}/2- \tqft at outgoing@end * \tqft at val{circle x radius}},-\tqft at val{cobordism height}/2)}%
}%
\else
\pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components} -1+\tqft at val{offset}) * \tqft at val{boundary separation} +\tqft at val{circle x radius}}%
@@ -299,7 +315,7 @@
\pgfmathsetmacro\xppos{(\tqft at val{outgoing boundary components}/2 + \tqft at val{offset} -1/2) * \tqft at val{boundary separation}}%
\pgfmathsetmacro\tqft at ht{1 -\tqft at ht*3/4}%
\xdef\tqft at clist{%
- \tqft at clist,-between first and last outgoing/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height})}%
+ \tqft at clist,-between first and last outgoing/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height})},-between first outgoing and last outgoing/{(\xppos pt,-\tqft at ht*\tqft at val{cobordism height})}%
}%
\fi
\fi
@@ -415,7 +431,8 @@
\xdef\tqft at ibdrylist{1,\tqft at ibdrylist}
\fi
\foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at ibdrylist {
- \node[
+ \node[
+ transform shape,
node contents={},
ellipse,
inner sep=0pt,
@@ -432,7 +449,8 @@
\ifx\tqft at cibdrylist\pgfutil at gobble
\else
\foreach[evaluate=\k as \xpos using (\k-1)*\tqft at val{boundary separation}] \k in \tqft at cibdrylist {
- \node[
+ \node[
+ transform shape,
node contents={},
ellipse,
inner sep=0pt,
@@ -455,13 +473,14 @@
\else
\xdef\tqft at obdrylist{1,\tqft at obdrylist}
\fi
-\foreach \k [evaluate=\k as \ok using int(\tqft at val{outgoing boundary components} - \k + 1)] in \tqft at obdrylist {
+\foreach \k [evaluate=\k as \ok using int(\tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - \tqft at outgoing@dir * \k)] in \tqft at obdrylist {
\xdef\tqft at robdrylist{\tqft at robdrylist,\ok}
}
\foreach[
evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
] \k in \tqft at robdrylist {
- \node[
+ \node[
+ transform shape,
node contents={},
ellipse,
inner sep=0pt,
@@ -477,13 +496,15 @@
}%
\ifx\tqft at cobdrylist\pgfutil at gobble
\else
-\foreach \k [evaluate=\k as \ok using int(\tqft at val{outgoing boundary components} - \k + 1)] in \tqft at cobdrylist {
+\foreach \k[evaluate=\k as \ok using int(\tqft at outgoing@end * (\tqft at val{outgoing boundary components} + 1) - \tqft at outgoing@dir * \k)]
+ in \tqft at cobdrylist {
\xdef\tqft at rcobdrylist{\tqft at rcobdrylist,\ok}
}
\foreach[
evaluate=\k as \xpos using (\k-1+\tqft at val{offset})*\tqft at val{boundary separation}
] \k in \tqft at rcobdrylist {
- \node[
+ \node[
+ transform shape,
node contents={},
ellipse,
inner sep=0pt,
@@ -586,7 +607,7 @@
}
%%
-%% Copyright (C) 2011 by Andrew Stacey <loopspace at mathforge.org>
+%% Copyright (C) 2011-2024 by Andrew Stacey <loopspace at mathforge.org>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
@@ -598,11 +619,11 @@
%% This work is "maintained" (as per LPPL maintenance status) by
%% Andrew Stacey.
%%
-%% This work consists of the files tqft.dtx,
-%% tqft_doc.tex,
-%% and the derived files tqft.ins,
+%% This work consists of the files tqft_code.dtx,
+%% tqft.tex,
+%% and the derived files tqft_code.ins,
+%% tqft_code.pdf,
%% tqft.pdf,
-%% tqft_doc.pdf,
%% tqft.sty, and
%% tikzlibrarytqft.code.tex.
%%
Modified: trunk/Master/texmf-dist/tex/latex/tqft/tqft.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tqft/tqft.sty 2024-06-01 20:20:59 UTC (rev 71400)
+++ trunk/Master/texmf-dist/tex/latex/tqft/tqft.sty 2024-06-01 20:21:17 UTC (rev 71401)
@@ -4,9 +4,9 @@
%%
%% The original source files were:
%%
-%% tqft.dtx (with options: `package')
+%% tqft_code.dtx (with options: `package')
%% ----------------------------------------------------------------
-%% tqft --- a library for drawing TQFT diagrams with TikZ/PGF
+%% tqft --- a TikZ library for drawing TQFT diagrams
%% E-mail: loopspace at mathforge.org
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
@@ -752,7 +752,7 @@
}
%%
-%% Copyright (C) 2011 by Andrew Stacey <loopspace at mathforge.org>
+%% Copyright (C) 2011-2024 by Andrew Stacey <loopspace at mathforge.org>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
@@ -764,11 +764,11 @@
%% This work is "maintained" (as per LPPL maintenance status) by
%% Andrew Stacey.
%%
-%% This work consists of the files tqft.dtx,
-%% tqft_doc.tex,
-%% and the derived files tqft.ins,
+%% This work consists of the files tqft_code.dtx,
+%% tqft.tex,
+%% and the derived files tqft_code.ins,
+%% tqft_code.pdf,
%% tqft.pdf,
-%% tqft_doc.pdf,
%% tqft.sty, and
%% tikzlibrarytqft.code.tex.
%%
More information about the tex-live-commits
mailing list.