# Stopping a line at a certain point in tikz

I have made the following figure in Tikzpicture:

\newcommand{\yggDra}[3]{
\draw[ultra thick, xscale=#1, yscale=#2, rotate=#3] ({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}

\newcommand{\whiteSpace}[1]{
\draw[white, ultra thick, rotate=#1]
(0.4,-3.308) -- (0.6,-3.35)
(0.3,-3.395) -- (0.5,-3.45)
%(1.1,-3.41) -- (1.25,-3.417)
%(0.9,-3.52) -- (1.25,-3.526)
(1.11,-3.41) -- (0.99,-3.52)
(1.29,-3.41) -- (1.155,-3.52)
(2.24,-2.9) -- (2.2,-3.0)
(2.358,-2.89) -- (2.32,-3.0)
(1.55,-2.91) -- (1.75,-2.9)
(1.45,-3.025) -- (1.75,-3.0127)
;
\draw[white, ultra thick, rotate=#1, xscale=-1]
(0.4,-3.308) -- (0.6,-3.35)
(0.3,-3.395) -- (0.5,-3.45)
%(1.1,-3.41) -- (1.25,-3.417)
%(0.9,-3.52) -- (1.25,-3.526)
(1.11,-3.41) -- (0.99,-3.52)
(1.29,-3.41) -- (1.155,-3.52)
(2.24,-2.9) -- (2.2,-3.0)
(2.358,-2.89) -- (2.32,-3.0)
(1.55,-2.91) -- (1.75,-2.9)
(1.45,-3.025) -- (1.75,-3.0127)
;
}

\begin{tikzpicture}
\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}

\whiteSpace{0}
\whiteSpace{90}
\whiteSpace{180}
\whiteSpace{270}
\end{tikzpicture}


To make the line breaks, so it looks like the line goes over and under itself, I have simply added some white lines on top. But I really don't like this solution, and I was wondering, if there was a easy way for the line to STOP and START again at specific points while still following the curve I have already made?

Full Code in StandAlone Document (MWE):

\documentclass[a0paper,titlepage,11pt]{standalone}

% Usepackage:
\usepackage{pgfplots}
\usepackage{allrunes}

% Commands:
\newcommand{\yggDra}[3]{
\draw[ultra thick, xscale=#1, yscale=#2, rotate=#3] ({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}

\newcommand{\whiteSpace}[1]{
\draw[white, ultra thick, rotate=#1]
(0.4,-3.308) -- (0.6,-3.35)
(0.3,-3.395) -- (0.5,-3.45)
(1.11,-3.41) -- (0.99,-3.52)
(1.29,-3.41) -- (1.155,-3.52)
(2.24,-2.9) -- (2.2,-3.0)
(2.358,-2.89) -- (2.32,-3.0)
(1.55,-2.91) -- (1.75,-2.9)
(1.45,-3.025) -- (1.75,-3.0127)
;
\draw[white, ultra thick, rotate=#1, xscale=-1]
(0.4,-3.308) -- (0.6,-3.35)
(0.3,-3.395) -- (0.5,-3.45)
(1.11,-3.41) -- (0.99,-3.52)
(1.29,-3.41) -- (1.155,-3.52)
(2.24,-2.9) -- (2.2,-3.0)
(2.358,-2.89) -- (2.32,-3.0)
(1.55,-2.91) -- (1.75,-2.9)
(1.45,-3.025) -- (1.75,-3.0127)
;
}

\begin{document}

\begin{tikzpicture}

\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}

\whiteSpace{0}
\whiteSpace{90}
\whiteSpace{180}
\whiteSpace{270}

\end{tikzpicture}

\end{document}

• Please give a fully compilable code. Commented Feb 17, 2020 at 14:17
• The @LoopSpace knots package was written specifically to do this automatically: ctan.org/pkg/spath3. Commented Feb 17, 2020 at 14:30
• Sorry, I thought the code already was compilable. But I have know uploaded the full code in the bottom. Commented Feb 17, 2020 at 19:53
• Well, now you have to remove all the useless packages you load in the preamble as well as the code that is useless in this question. This is called creating a minimum working example (MWE) tex.meta.stackexchange.com/questions/3300/… Commented Feb 17, 2020 at 20:03
• Ohh, right. Yeah, I can understand there is a lot of noise in the code. I have written a MWE know, with the bare minimum code. Commented Feb 17, 2020 at 20:14

As Paul Gaborit points out, it is necessary to flip some passages. This is done either with the flip crossing/.list={} key, or with the \flipcrossings{} macro, which amounts to the same thing. It takes a trained eye to notice!

Indeed, your original basic drawing is this one:

The drawing obtained without returning some passages is :

When you switch to draft mode=crossings, you find the numbers to return and you find those listed by Paul Gaborit: \flipcrossings{2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}

The final result is the same as the one you wanted to obtain at the beginning.

\documentclass[border=5mm]{standalone}

% Usepackage:
\usepackage{pgfplots}
\usetikzlibrary{calc,knots}
%\usepackage{allrunes}

% Commands:
\newcommand{\yggDra}[3]{
\strand[ultra thick, xscale=#1, yscale=#2, rotate=#3]
({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}

%\newcommand{\whiteSpace}[1]{
%\draw[white, ultra thick, rotate=#1]
%(0.4,-3.308) -- (0.6,-3.35)
%(0.3,-3.395) -- (0.5,-3.45)
%(1.11,-3.41) -- (0.99,-3.52)
%(1.29,-3.41) -- (1.155,-3.52)
%(2.24,-2.9) -- (2.2,-3.0)
%(2.358,-2.89) -- (2.32,-3.0)
%(1.55,-2.91) -- (1.75,-2.9)
%(1.45,-3.025) -- (1.75,-3.0127)
%;
%\draw[white, ultra thick, rotate=#1, xscale=-1]
%(0.4,-3.308) -- (0.6,-3.35)
%(0.3,-3.395) -- (0.5,-3.45)
%(1.11,-3.41) -- (0.99,-3.52)
%(1.29,-3.41) -- (1.155,-3.52)
%(2.24,-2.9) -- (2.2,-3.0)
%(2.358,-2.89) -- (2.32,-3.0)
%(1.55,-2.91) -- (1.75,-2.9)
%(1.45,-3.025) -- (1.75,-3.0127)
%;
%}

\begin{document}

\begin{tikzpicture}
\begin{knot}[consider self intersections,end tolerance=.4pt,
flip crossing/.list={2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16},
% draft mode=crossings
]
%\flipcrossings{2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}
\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}

%\whiteSpace{0}
%\whiteSpace{90}
%\whiteSpace{180}
%\whiteSpace{270}
\end{knot}
\end{tikzpicture}

\end{document}


Translated with www.DeepL.com/Translator (free version)

The knots package included in spath3 written by @LoopSpace allows you to do what you want automatically. Here is the adaptation of your code with this package.

\documentclass[border=5mm]{standalone}

% Usepackage:
\usepackage{pgfplots}
\usetikzlibrary{calc,knots}
%\usepackage{allrunes}

% Commands:
\newcommand{\yggDra}[3]{
\strand[ultra thick, xscale=#1, yscale=#2, rotate=#3]
({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}

%\newcommand{\whiteSpace}[1]{
%\draw[white, ultra thick, rotate=#1]
%(0.4,-3.308) -- (0.6,-3.35)
%(0.3,-3.395) -- (0.5,-3.45)
%(1.11,-3.41) -- (0.99,-3.52)
%(1.29,-3.41) -- (1.155,-3.52)
%(2.24,-2.9) -- (2.2,-3.0)
%(2.358,-2.89) -- (2.32,-3.0)
%(1.55,-2.91) -- (1.75,-2.9)
%(1.45,-3.025) -- (1.75,-3.0127)
%;
%\draw[white, ultra thick, rotate=#1, xscale=-1]
%(0.4,-3.308) -- (0.6,-3.35)
%(0.3,-3.395) -- (0.5,-3.45)
%(1.11,-3.41) -- (0.99,-3.52)
%(1.29,-3.41) -- (1.155,-3.52)
%(2.24,-2.9) -- (2.2,-3.0)
%(2.358,-2.89) -- (2.32,-3.0)
%(1.55,-2.91) -- (1.75,-2.9)
%(1.45,-3.025) -- (1.75,-3.0127)
%;
%}

\begin{document}

\begin{tikzpicture}
\begin{knot}[consider self intersections,end tolerance=.4pt,
flip crossing/.list={2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}
%draft mode=crossings
]
%\flipcrossings{2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}
\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}

%\whiteSpace{0}
%\whiteSpace{90}
%\whiteSpace{180}
%\whiteSpace{270}
\end{knot}
\end{tikzpicture}
\end{document}

• This shape and easy of use was exactly what I was looking for, thank you. But would it be possible to remove the white lines it creates, maybe through another program? Because if you put the picture on any other background, than white, then you can see the white knot lines. I can of course just change the color of the knot lines, to match the background, but it would be better if they there transparant, so I could use the figure everywhere without the need for comling a new figure every time. Commented Feb 18, 2020 at 15:08
• @mriisa Currently, it is not possible to have a transparent background. You have to set the background color yourself so that it blends in with the page. For example  background color=yellow. Andrew Spacey (@LoopSpace) runs this package from github github.com/loopspace/spath3/issues . You can ask him to add this feature. He will tell you whether or not this is possible. Commented Feb 18, 2020 at 16:50
• Super, thank you again. You have been a tremendous help! Commented Feb 18, 2020 at 18:22
• @AndréC To get the same drawing, you must flip some crossings: \flipcrossings{2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}... Commented Feb 19, 2020 at 7:16
• @PaulGaborit Thank you for pointing that out to me. I've updated my answer. Commented Feb 19, 2020 at 8:56

You can just use dash pattern. It is true that you need to adjust the on and off dimensions by hand, but this code does not overdraw anything.

\documentclass[tikz,border=3mm]{standalone}
% Commands:
\newcommand{\yggDra}[3]{
\draw[ultra thick, xscale=#1, yscale=#2, rotate=#3,
dash pattern=on 13pt off 5pt on 51pt off 5pt on 66pt off 6pt on 76pt off 6pt on 35pt] ({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}
\begin{document}

\begin{tikzpicture}

\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}
\end{tikzpicture}

\end{document}


• thank you so much. This works wonders! Commented Feb 19, 2020 at 10:21
• very nice using of dash pattern! Commented Feb 19, 2020 at 13:33