1

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}

enter image description here

1 Answer 1

2

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}

enter image description here

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}

enter image description here

Note also that sometimes one needs the allow upside down key as in https://tex.stackexchange.com/a/574078.

3
  • my apologies. I removed my answer. You made a comment on my post, which I used to make an improvement. That is how this site is supposed to work. I certainly did not copy your code or any part of your solution. There is no need for hostility in your comments.
    – Sandy G
    Dec 14, 2020 at 8:45
  • If the arrow is near a crossing, it ends up being behind the strands. Is there a way to fix this?
    – nog642
    Sep 19, 2023 at 5:43
  • Also how do you use the allow upside down key?
    – nog642
    Sep 19, 2023 at 6:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .