答案1
您可以rubout
使用这里。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[rubout/.style={/utils/exec=\tikzset{rubout/.cd,#1},
decoration={show path construction,
curveto code={
\draw [white,line width=\pgfkeysvalueof{/tikz/rubout/line width}+2*\pgfkeysvalueof{/tikz/rubout/halo}]
(\tikzinputsegmentfirst) .. controls
(\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast);
\draw [line width=\pgfkeysvalueof{/tikz/rubout/line width},shorten <=-0.1pt,shorten >=-0.1pt] (\tikzinputsegmentfirst) .. controls
(\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast);
}}},rubout/.cd,line width/.initial=2pt,halo/.initial=0.5pt]
\draw[rubout={line width=2pt,halo=1pt},decorate,looseness=2.5]
(0,0) to[out=90,in=90] (1,2) to[out=-90,in=-90] (0,4);
\end{tikzpicture}
\end{document}
答案2
您可以使用该knots
包(包含在spath3)。
\draw
和命令\path
由 替换\strand
,并且必须包含在knot
环境中。
有一种draft
模式可以让你突出显示交叉点。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{knots}
\begin{document}
Two examples from the knots package manual (p 9):
\begin{tikzpicture}
\begin{knot}[consider self intersections,draft mode=crossings]
\strand (0,0) .. controls +(3,1) and +(-3,1) .. (1,0);
\end{knot}
\begin{knot}[xshift=3cm,consider self intersections=no splits,draft mode=crossings]
\strand (0,0) .. controls +(3,1) and +(-3,1) .. (1,0);
\end{knot}
\end{tikzpicture}
The final result is:
\begin{tikzpicture}
\begin{knot}[xshift=6cm,consider self intersections,draft mode=off]
\strand (0,0) .. controls +(3,1) and +(-3,1) .. (1,0);
\end{knot}
\end{tikzpicture}
A figure similar to yours is:
\begin{tikzpicture}[]
\begin{knot}[consider self intersections=no splits,draft mode=off]
\strand (0,-1) .. controls (0,-4) and (2,-4) .. (2,-3)..controls (2,-2) and (0,-2)..(0,-5);
\end{knot}
\end{tikzpicture}
\end{document}