我正在使用 tikz 和 tqft 繪製一些簡單的座標。我想透過在傳入和傳出圓圈上放置箭頭來指示它們的方向。有沒有一種簡單的方法可以做到這一點?
我正在使用的程式碼是例如
\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 庫,而不是作為單獨的樣式檔案。
您可能想要更大的箭頭,但這是一個單獨的問題。
答案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
and\varrightarrow
代替\leftarrow
and\rightarrow
會產生如下所示的結果:
答案3
這是 tikz 和 tqft 中的解決方案。它利用 tqft-package 中提供的節點:整個座標係是一個名為「a」的節點。它具有子節點“a.incoming border 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}