TeX - LaTeX Asked on March 16, 2021
How can I add an arrow to a knot diagram drawn with with tikz knots package? When I add an arrow with "decorations" tikz library to an example in this SA question I get two arrows!
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}
As noted in https://tex.stackexchange.com/a/574078, you do not necessarily need decorations to add an arrow. A sloped pic also works. You can put it on the segment you want, which can be an advantage or disadvantage depending on the scenario.
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}
It is easy to change any aspect of the arrow. Apart from the obvious possibility of editing the pic you can just add an optional argument.
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}
Note also that sometimes one needs the allow upside down
key as in https://tex.stackexchange.com/a/574078.
Correct answer by user230864 on March 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP