如何在 TikZ 中绘制结的方向?

如何在 TikZ 中绘制结的方向?

因此,我尝试在 8 字形结的路径上添加一个箭头来指示其方向,但我似乎无法在图表上看到它。我是 TikZ 的初学者,任何帮助都将不胜感激。这是我的代码:

\documentclass{article}

\usepackage{graphicx,amssymb,amstext,amsmath}

\usepackage{tikz}
\usepackage{braids}
\usepackage{wrapfig}
\usepackage{blindtext}
\usetikzlibrary{decorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc}


\tikzset{
  knot diagram/every strand/.append style={
    line width=3pt,violet
  },
  show curve controls/.style={
    postaction=decorate,
    decoration={show path construction,
      curveto code={
        \draw [blue, dashed]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentsupporta)
        node [at end, draw, solid, red, inner sep=2pt]{};
        \draw [blue, dashed]
        (\tikzinputsegmentsupportb) -- (\tikzinputsegmentlast)
        node [at start, draw, solid, red, inner sep=2pt]{}
        node [at end, fill, blue, ellipse, inner sep=2pt]{}
        ;
      }
    }
  },
  show curve endpoints/.style={
    postaction=decorate,
    decoration={show path construction,
      curveto code={
        \node [fill, blue, ellipse, inner sep=2pt] at (\tikzinputsegmentlast) {}
        ;
      }
    }
  }
}

\begin{center}
\begin{tikzpicture}[use Hobby shortcut, postaction={decorate}, decoration={
  markings,
  mark=at position 0.2 with {\arrow[line width=3pt]{<}}}]
\begin{knot}[
  consider self intersections=true,
%  draft mode=crossings,
  ignore endpoint intersections=false,
  flip crossing=3,
  rotate=180,
]
\strand ([closed]0,0) .. (1.5,1) .. (.5,2) .. (-.5,1) .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

答案1

欢迎来到 TeX.SE!为了“使用”装饰,您需要将其添加到路径中。为此,我给您的装饰起了个名字

add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.5 with {\arrow[line width=3pt]{<}}}}

然后将其添加到路径中\strand[add arrow] ...

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{braids}
\usetikzlibrary{decorations.markings,hobby,knots,celtic}

\begin{document}
\tikzset{
  knot diagram/every strand/.append style={
    line width=3pt,violet
  },
}

\begin{tikzpicture}[use Hobby shortcut,
 add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.5 with {\arrow[line width=3pt]{<}}}}]
\begin{knot}[
  consider self intersections=true,
%  draft mode=crossings,
  ignore endpoint intersections=false,
  flip crossing=3,
  rotate=180,
]
\strand[add arrow] ([closed]0,0) .. (1.5,1) .. (.5,2) .. (-.5,1) .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
\end{knot}
\path (0,-.7);
\end{tikzpicture}
\end{document}

在此处输入图片描述

0.2请注意,由于存在错误,我必须对位置使用稍微不同的值dimension too large

如果你只想要一个箭头,请考虑例如

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{braids}
\usetikzlibrary{decorations.markings,hobby,knots,celtic}

\begin{document}
\tikzset{
  knot diagram/every strand/.append style={
    line width=3pt,violet
  },
}

\begin{tikzpicture}[use Hobby shortcut,
 add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.5 with {\arrow[line width=3pt]{<}}}}]
\begin{knot}[
  consider self intersections=true,
%  draft mode=crossings,
  ignore endpoint intersections=false,
  flip crossing=3,
  rotate=180
]
\strand ([closed]0,0) .. (1.5,1) .. (.5,2) [add arrow,violet] .. (-.5,1) .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
%\redraw{2}{(1,1)}
\end{knot}
\path (0,-.7);
\end{tikzpicture}
\end{document}

在此处输入图片描述

请注意,这是偶然发生的。

相关内容