如何将箭头添加到使用 tikz knots 包绘制的结图?当我使用“装饰”tikz 库向此示例中添加箭头时SA问题我得到两支箭!
\documentclass[11pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{decorations.markings, arrows.meta,knots}
\begin{document}
\begin{tikzpicture}
\begin{knot}[clip width=10, clip radius=15pt, consider self intersections, end tolerance=3pt]
\strand[thick, decoration={markings, mark=at position 0.6 with {\arrow{<}}},postaction={decorate}] (0,0)
to[out=up, in=down] (0,0.7)
to[out=up, in=left] (0.5,1.5)
to[out=right, in=up] (1,1)
to[out=down, in=right] (0.5,0.5)
to[out=left, in=down] (0,1.3)
to[out=up, in=down] (0,2);
\end{knot}
\end{tikzpicture}
\end{document}
答案1
正如所指出的https://tex.stackexchange.com/a/574078,你不一定需要装饰来添加箭头。倾斜的图片也可以。你可以把它放在你想要的部分上,这可能是一个优点或缺点,具体取决于场景。
\documentclass[11pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,knots}
\begin{document}
\begin{tikzpicture}[pics/arrow/.style={code={%
\draw[line width=0pt,{Computer Modern Rightarrow[line
width=0.8pt,width=1.5ex,length=1ex]}-] (-0.5ex,0) -- (0.5ex,0);
}}]
\begin{knot}[clip width=10, clip radius=15pt, consider self intersections,
end tolerance=3pt]
\strand[thick] (0,0)
to[out=up, in=down] (0,0.7)
to[out=up, in=left] (0.5,1.5)
to[out=right, in=up] pic[pos=0.5,sloped]{arrow}(1,1)
to[out=down, in=right] (0.5,0.5)
to[out=left, in=down] (0,1.3)
to[out=up, in=down] (0,2);
\end{knot}
\end{tikzpicture}
\end{document}
更改箭头的任何方面都很容易。除了编辑图片这一显而易见的可能性之外,您还可以添加可选参数。
\documentclass[11pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,knots}
\begin{document}
\begin{tikzpicture}[pics/arrow/.style={code={%
\draw[line width=0pt,{Computer Modern Rightarrow[line
width=0.8pt,width=1.5ex,length=1ex,#1]}-] (-0.5ex,0) -- (0.5ex,0);
}}]
\begin{knot}[clip width=10, clip radius=15pt, consider self intersections,
end tolerance=3pt]
\strand[thick] (0,0)
to[out=up, in=down] (0,0.7)
to[out=up, in=left] (0.5,1.5)
to[out=right, in=up] pic[pos=0,sloped]{arrow={scale=2,line
width=1.6pt}}(1,1)
to[out=down, in=right] (0.5,0.5)
to[out=left, in=down] (0,1.3)
to[out=up, in=down] (0,2);
\end{knot}
\end{tikzpicture}
\end{document}
还要注意,有时需要allow upside down
,例如https://tex.stackexchange.com/a/574078。