如何在 tqft 包中将箭头放在边界圆上

如何在 tqft 包中将箭头放在边界圆上

我正在使用 tikz 和 tq​​ft 绘制一些简单的共边线。我想通过在入圆和出圆上放置箭头来指示入圆和出圆的方向。有没有简单的方法可以做到这一点?

我使用的代码是例如

\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}

其结果(尽管分辨率更高):

圆柱体

我想要的箭头就像这张图片中的箭头一样(只有浅绿色部分)在此处输入图片描述

答案1

我已经上传了新版本的tqft致 CTAN(2014 年 4 月 7 日)。一旦此消息在系统中传播,则以下代码将起作用,并将箭头置于边界圆的上弧上。

\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}

请注意,这需要 TikZ3.0(或更高版本)。此外,加载包的方式现在是作为 TikZ 库,而不是作为单独的样式文件。

您可能想要更大的箭头,但那是另一个问题。

带箭头的 TQFT

答案2

修改后的答案(有关方法的描述请参阅下面的原始答案)

\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}

在此处输入图片描述

由于我努力对其进行参数化,以允许诸如此类的语法\LeftSideArrow\setoutside\uppointing{\fig},因此我在此处展示了该代码:

\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}

原始答案(在 OP 发布图片之前)

在这里,我使用 之外的方法tikz建立箭头。我改用\stackinset。我首先使用原始\stackinset语法展示各种用例。但如果这是常见情况,则可以参数化用法,正如我在 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}

在此处输入图片描述


如果tikz图像被反复使用,那么制作一次并装箱就可以节省时间。因此,在这种情况下,\def\fig{...}我的 MWE 中的 可以替换为

\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}

然后,\fig将作为一个现成的盒子,包含的内容\figraw


如果想要不同的箭头样式,可以从中导入隐形箭头符号mathabx,方法是将其插入到序言中:

% 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}

然后,使用\varleftarrow\varrightarrow而不是\leftarrow\rightarrow,将产生如下结果:

在此处输入图片描述

答案3

这是 tikz 和 tq​​ft 中的解决方案。它利用了 tqft 包中提供的节点:整个共边是一个名为“a”的节点。它有子节点“a.incoming bounding n”,其中 n 枚举传入边界圆,传出边界圆也类似。

不幸的是,位移是手动找到的,而且由于不了解 tikz 的内部工作原理,我不知道它如何响应缩放或其他任何事情。一个不错的选择肯定是在 tqft 包中有一个选项,可以将这些小箭头放在圆圈上。

\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}

相关内容