7

I'm drawing some simple cobordisms with tikz and tqft. I would like to indicate the orientation of the incoming and outgoing circles by putting arrowheads on them. Is there a simple way to do that?

Code, I'm using is e.g.

\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage{tikz}
\usepackage{tqft}
\begin{tikzpicture}[tqft/flow=east]
\node[tqft, incoming boundary components=1,
outgoing boundary components=1,draw, boundary lower style={dashed,draw}] at (0,0) {};
\end{tikzpicture}

which produces (though in better resolution):

A cylinder

The kind of arrow I would like to have is like in this picture (only the light green part)enter image description here

Eike
  • 191
  • Will this element be part of a larger tikz picture, or is it a standalone graphic (sans arrows)? – Steven B. Segletes Mar 20 '14 at 15:55
  • I'm not sure where you are heading. I want to use this picture, but also others. For example, I'll be using a pair of pants as well. Does that answer your question? – Eike Mar 20 '14 at 16:04
  • I guess I'm asking whether you are restricting solutions to those that use only tikz, or whether arrows can be attached elsewise? If you wait a few minutes, I'll post an answer, and you can reject it, if it doesn't suit. – Steven B. Segletes Mar 20 '14 at 16:06

3 Answers3

4

I have uploaded a new version of tqft to CTAN (7th April 2014). Once this propagates through the system, then the following code will work and will put arrows on the upper arcs of the boundary circles.

\documentclass{article}
%\url{http://tex.stackexchange.com/q/166698/86}
\usepackage{tikz}
\usetikzlibrary{calc,tqft,decorations.markings}

\begin{document}

\begin{tikzpicture}[every tqft/.style={transform shape},rotate=90]
  \pic[
  tqft,
  incoming boundary components=1,
  outgoing boundary components=1,
  draw,
  every lower boundary component/.style={draw},
  every incoming lower boundary component/.style={dashed,draw},
  every outgoing upper boundary component/.style={
    decorate,
    decoration={
      markings,
      mark=at position .5 with {\arrow{>}},
    },
  },
  every incoming upper boundary component/.style={
    decorate,
    decoration={
      markings,
      mark=at position .5 with {\arrowreversed{>}},
    },
  },
  name=a
];
  \end{tikzpicture}

\end{document}

Note that this requires TikZ3.0 (or later). Also, the way to load the package is now as a TikZ library, not as a separate style file.

You might want bigger arrows, but that's a separate issue.

TQFT with arrows

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751
3

REVISED ANSWER (see original answer below for description of method)

\documentclass{article}
\usepackage{tikz, tqft, graphicx, stackengine}
\parskip 1ex
\begin{document}
\def\figraw{\begin{tikzpicture}[tqft/flow=east]
\node[tqft, incoming boundary components=1,
outgoing boundary components=1,draw, boundary lower style={dashed,draw}] at (0,0) {};
\end{tikzpicture}}
\savestack{\fig}{\figraw}
\def\OUT{-1.60pt}
\def\IN{8.03pt}
\def\WW{1.5pt}
\def\VV{-1.5pt}
\def\VEE{\scalebox{0.6}{$\vee$}}
\def\WEDGE{\scalebox{0.6}{$\wedge$}}
\stackinset{r}{\IN}{c}{\VV}{\VEE}{\fig}\par
\stackinset{l}{\OUT}{c}{\VV}{\VEE}{%
  \stackinset{r}{\IN}{c}{\WW}{\WEDGE}{%
    \fig%
}}\par
\stackinset{l}{\OUT}{c}{\WW}{\WEDGE}{%
  \stackinset{r}{\IN}{c}{\VV}{\VEE}{%
    \fig%
}}\par
\end{document}

enter image description here

And since I went through the effort to parametrize it, to allow syntax such as \LeftSideArrow\setoutside\uppointing{\fig}, I show that code here:

\documentclass{article}
\usepackage{tikz, tqft, graphicx, stackengine}
\parskip 1ex
%
\def\OUT{-1.60pt}
\def\IN{8.03pt}
\def\WW{1.5pt}
\def\VV{-1.5pt}
\def\VEE{\scalebox{0.6}{$\vee$}}
\def\WEDGE{\scalebox{0.6}{$\wedge$}}
%
\def\LeftSideArrowHelper{\stackinset{l}}
\def\RightSideArrowHelper{\stackinset{r}}
\def\setinside{\IN}
\def\setoutside{\OUT}
\def\uppointing{{c}{\WW}{\WEDGE}}
\def\downpointing{{c}{\VV}{\VEE}}
\def\LeftSideArrow{\expandafter\expandafter\expandafter\LeftSideArrowHelper\expandafter}
\def\RightSideArrow{\expandafter\expandafter\expandafter\RightSideArrowHelper\expandafter}

\begin{document}
\def\figraw{\begin{tikzpicture}[tqft/flow=east]
    \node[tqft, incoming boundary components=1,
    outgoing boundary components=1,draw, boundary lower style={dashed,draw}] at (0,0) {};
  \end{tikzpicture}}
\savestack{\fig}{\figraw}

\LeftSideArrow\setoutside\uppointing{%
  \RightSideArrow\setinside\downpointing{%
    \fig}}
\end{document}

ORIGINAL ANSWER (prior to OP posting an image)

Here, I work outside of tikz to establish the arrows. I instead use \stackinset. I first show various use cases using the raw \stackinset syntax. But if this were to be a common occurrence, the usage could be parametrized, as I show at the end of my MWE.

\documentclass{article}
\usepackage{tikz, tqft, graphicx, stackengine}
\parskip 1ex
\begin{document}
\def\fig{\begin{tikzpicture}[tqft/flow=east]
\node[tqft, incoming boundary components=1,
outgoing boundary components=1,draw, boundary lower style={dashed,draw}] at (0,0) {};
\end{tikzpicture}}
\stackinset{r}{-18pt}{c}{-1.8pt}{\scalebox{2.5}{$\rightarrow$}}{\fig}\par
\stackinset{r}{-18pt}{c}{-1.8pt}{\scalebox{2.5}{$\leftarrow$}}{\fig}\par
\stackinset{r}{3pt}{c}{-1.8pt}{\scalebox{2.5}{$\leftarrow$}}{\fig}\par
\stackinset{l}{3pt}{c}{-1.8pt}{\scalebox{2.5}{$\leftarrow$}}{%
  \stackinset{r}{-18pt}{c}{-1.8pt}{\scalebox{2.5}{$\leftarrow$}}{%
    \fig%
}}\par
\stackinset{l}{-18pt}{c}{-1.8pt}{\scalebox{2.5}{$\rightarrow$}}{%
  \stackinset{r}{-18pt}{c}{-1.8pt}{\scalebox{2.5}{$\rightarrow$}}{%
    \fig%
}}\par
If this element were used often, it could be parameterized:
\def\LeftArrow{{\scalebox{2.5}{$\leftarrow$}}}
\def\RightArrow{{\scalebox{2.5}{$\rightarrow$}}}
\edef\insideleft{{l}{3pt}{c}{-1.8pt}}
\edef\outsideleft{{l}{-18pt}{c}{-1.8pt}}
\edef\insideright{{r}{3pt}{c}{-1.8pt}}
\edef\outsideright{{r}{-18pt}{c}{-1.8pt}}
\def\MakeArrow{\expandafter\stackinset}

\MakeArrow\outsideleft\LeftArrow{%
\MakeArrow\outsideright\RightArrow{%
\fig%
}}
\end{document}

enter image description here


If the tikz image is used over and over again, it saves time to make it once and box it. Thus, in that case, the \def\fig{...} in my MWE could be replaced by

\def\figraw{\begin{tikzpicture}[tqft/flow=east]
\node[tqft, incoming boundary components=1,
outgoing boundary components=1,draw, boundary lower style={dashed,draw}] at (0,0) {};
\end{tikzpicture}}
\savestack{\fig}{\figraw}

Then, \fig would be available as a ready-made box, containing the contents of \figraw.


If one wanted a different arrow style, the stealth arrow glyphs could be imported from mathabx, by inserting this into your preamble:

% Setup the matha font (from mathabx.sty)
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
      <5> <6> <7> <8> <9> <10> gen * matha
      <10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
      }{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}

% Define a subset character from that font (from mathabx.dcl)
% to completely replace the \subset character, you can replace
% \varsubset with \subset

\DeclareMathSymbol{\varleftarrow}{3}{matha}{"D0}
\DeclareMathSymbol{\varrightarrow}{3}{matha}{"D1}

Then, using \varleftarrow and \varrightarrow, instead of \leftarrow and \rightarrow, would yield, for example, something like this:

enter image description here

1

Here is a solution within tikz and tqft. It makes use of the nodes provided within the tqft-package: The whole cobordism is a node called "a". It has subnodes "a.incoming boundary n" where n enumerates the incoming boundary circles and similarly for the outgoing ones.

Unfortunately the displacement is found by hand and having no idea about the inner workings of tikz I don't know how it responds to scaling or anything. A nice touch would definitely be to have an option in the tqft package that puts these little arrows on the circles.

\begin{tikzpicture}[tqft/flow=east]
  \node[tqft, incoming boundary components=1,
  outgoing boundary components=1,draw, boundary lower style={dashed,draw}](a) at (0,0) {};
  \node at ($(a.incoming boundary 1)+(-0.166,0)$) {$\wedge$};
  \node at ($(a.outgoing boundary 1)+(-0.172,0)$) {$\vee$};
  \end{tikzpicture}
Eike
  • 191
  • The boundary circles are nodes in their own right so you can use the angle anchors to avoid doing the calculations. Thus \node at (a incoming 1.90) {$\wedge$}; \node at (a outgoing 1.90) {$\vee$}; would put them at the right places. – Andrew Stacey Apr 03 '14 at 09:04