我正在尝试绘制一个带有方框之间箭头的图表。大多数箭头都显示正常,但从节点到其自身的循环上的箭头却显示不正常。
由于默认箭头太小,因此我定义了自定义箭头。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\tikzset{
myarrow/.style={
decoration={markings,mark=at position 1 with {\arrow[scale=2]{>}}},
postaction={decorate},
>=stealth
}
}
\begin{document}
\begin{tikzpicture}
\node [rectangle, fill=none, draw=black, text centered, inner sep=1em]
(box)
at (0, 0)
{box};
\node [rectangle, fill=none, draw=black, text centered, inner sep=1em]
(second box)
at (3, 0)
{second box};
% this works
\draw [myarrow] (box.east) -- (second box.west);
% but this doesn't
\draw (box.north west)
edge[myarrow, out = 120, in = 60, min distance = 3em]
node [anchor = south] {feedback}
(box.north);
\end{tikzpicture}
\end{document}
圆环上的箭头没有出现,而直线上的箭头却出现了。这是为什么呢?带有圆环的盒子应该看起来像这样(糟糕的 Photoshop):
使用默认的(微小)箭头有效:
定义myarrow
错误吗?
非常感谢您的帮助。
答案1
这可能是舍入错误。如果我使用at position 0.999
箭头显示。
然而,将其用于直箭可能不是最佳选择,因此我还定义了一种myarrowstraight
样式以便进行比较。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\tikzset{
myarrow/.style={
decoration={markings,mark=at position 0.999 with {\arrow[scale=2]{>}}},
postaction={decorate},
>=stealth
},
myarrowstraight/.style={
decoration={markings,mark=at position 1 with {\arrow[scale=2]{>}}},
postaction={decorate},
>=stealth
},
}
\begin{document}
\begin{tikzpicture}
\node [rectangle, fill=none, draw=black, text centered, inner sep=1em]
(box)
at (0, 0)
{box};
\node [rectangle, fill=none, draw=black, text centered, inner sep=1em]
(second box)
at (3, 0)
{second box};
% this works
\draw [myarrow] (box.east) -- (second box.west);
\draw [myarrowstraight] (box.north east) -- (second box.north west);
% but this doesn't
\draw (box.north west)
edge[myarrow, out = 120, in = 60, min distance = 3em]
node [anchor = south] {feedback}
(box.north);
\end{tikzpicture}
\end{document}
箭头使用该north east
样式,可能会注意到箭头的微小偏移。north west
myarrowstraight