TikZ Knots package: crossing changed after scalingUnexpected behavior of the “knots” tikz library when a crossing is close to another (thick) line: What's going on?How can the knots TikZ library be used with current l3 (e.g. TeX Live 2015)?Unexpected behavior of the “knots” tikz library when a crossing is close to another (thick) line: What's going on?Tikz knots package: line style with consider self-intersectionsUnwanted white space around knots in TikZHow can I construct a planar tangle, shaed or un-shaded, in LaTeX or Mathematica using the tikz package?Flipping behavior at triple point crossings in knots package for tikzForce individual pin angle in knots package TikZFlip crossing doesn't work in TikZ with two strands
Why do I get two different answers for this counting problem?
I'm flying to France today and my passport expires in less than 2 months
How can I tell someone that I want to be his or her friend?
What is the intuition behind short exact sequences of groups; in particular, what is the intuition behind group extensions?
How to model explosives?
Why does Kotter return in Welcome Back Kotter
90's TV series where a boy goes to another dimension through portal near power lines
Neighboring nodes in the network
Python: return float 1.0 as int 1 but float 1.5 as float 1.5
Can I ask the recruiters in my resume to put the reason why I am rejected?
Etiquette around loan refinance - decision is going to cost first broker a lot of money
How do I find out when a node was added to an availability group?
How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?
Is it canonical bit space?
Cronab fails because shell path not found
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
What exploit are these user agents trying to use?
Is it unprofessional to ask if a job posting on GlassDoor is real?
How do I write bicross product symbols in latex?
Is it possible to create light that imparts a greater proportion of its energy as momentum rather than heat?
How much of data wrangling is a data scientist's job?
How to say in German "enjoying home comforts"
Why 'in' operator is throwing error instead of logging false with string literal
Arrow those variables!
TikZ Knots package: crossing changed after scaling
Unexpected behavior of the “knots” tikz library when a crossing is close to another (thick) line: What's going on?How can the knots TikZ library be used with current l3 (e.g. TeX Live 2015)?Unexpected behavior of the “knots” tikz library when a crossing is close to another (thick) line: What's going on?Tikz knots package: line style with consider self-intersectionsUnwanted white space around knots in TikZHow can I construct a planar tangle, shaed or un-shaded, in LaTeX or Mathematica using the tikz package?Flipping behavior at triple point crossings in knots package for tikzForce individual pin angle in knots package TikZFlip crossing doesn't work in TikZ with two strands
I have realised that my knot diagram changes one of its crossings when it's scaled differently. The crossings should be correct in the second diagram generated by the code below. I don't know how this has happened. I have tried using draft mode=crossings but it was no use. Could I please have some help in switching the crossings to the correct version in the first diagram?
This is my code:
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
tikz-knots
add a comment |
I have realised that my knot diagram changes one of its crossings when it's scaled differently. The crossings should be correct in the second diagram generated by the code below. I don't know how this has happened. I have tried using draft mode=crossings but it was no use. Could I please have some help in switching the crossings to the correct version in the first diagram?
This is my code:
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
tikz-knots
The problem is the presence of the dashed line. Do you need that to be defined as part of the knot? Could it be an ordinary line drawn before the knot is rendered? I'll post some different possibilities when I get back to a proper computer.
– Loop Space
22 hours ago
This is the same underlying problem as addressed in tex.stackexchange.com/q/323758/86 I'll post an answer here as well as it's not easy to generalise, but refer to the answer there for the explanation.
– Loop Space
5 hours ago
add a comment |
I have realised that my knot diagram changes one of its crossings when it's scaled differently. The crossings should be correct in the second diagram generated by the code below. I don't know how this has happened. I have tried using draft mode=crossings but it was no use. Could I please have some help in switching the crossings to the correct version in the first diagram?
This is my code:
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
tikz-knots
I have realised that my knot diagram changes one of its crossings when it's scaled differently. The crossings should be correct in the second diagram generated by the code below. I don't know how this has happened. I have tried using draft mode=crossings but it was no use. Could I please have some help in switching the crossings to the correct version in the first diagram?
This is my code:
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
tikz-knots
tikz-knots
asked Mar 7 at 20:42
JpWJpW
554
554
The problem is the presence of the dashed line. Do you need that to be defined as part of the knot? Could it be an ordinary line drawn before the knot is rendered? I'll post some different possibilities when I get back to a proper computer.
– Loop Space
22 hours ago
This is the same underlying problem as addressed in tex.stackexchange.com/q/323758/86 I'll post an answer here as well as it's not easy to generalise, but refer to the answer there for the explanation.
– Loop Space
5 hours ago
add a comment |
The problem is the presence of the dashed line. Do you need that to be defined as part of the knot? Could it be an ordinary line drawn before the knot is rendered? I'll post some different possibilities when I get back to a proper computer.
– Loop Space
22 hours ago
This is the same underlying problem as addressed in tex.stackexchange.com/q/323758/86 I'll post an answer here as well as it's not easy to generalise, but refer to the answer there for the explanation.
– Loop Space
5 hours ago
The problem is the presence of the dashed line. Do you need that to be defined as part of the knot? Could it be an ordinary line drawn before the knot is rendered? I'll post some different possibilities when I get back to a proper computer.
– Loop Space
22 hours ago
The problem is the presence of the dashed line. Do you need that to be defined as part of the knot? Could it be an ordinary line drawn before the knot is rendered? I'll post some different possibilities when I get back to a proper computer.
– Loop Space
22 hours ago
This is the same underlying problem as addressed in tex.stackexchange.com/q/323758/86 I'll post an answer here as well as it's not easy to generalise, but refer to the answer there for the explanation.
– Loop Space
5 hours ago
This is the same underlying problem as addressed in tex.stackexchange.com/q/323758/86 I'll post an answer here as well as it's not easy to generalise, but refer to the answer there for the explanation.
– Loop Space
5 hours ago
add a comment |
2 Answers
2
active
oldest
votes
I did precisely what you suggested, draft mode=crossings, after which I flipped crossing number 6 and get
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing/.list=3,6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

OK, I am not able to solve the problem. Here is a proposal for a workaround.
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=3.2pt,violet
,
tikzset
my style/.style=
dashed
scalebox0.45
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

1
Ah thank you (as always!) - but I meant how could I change that crossing in the first diagram?
– JpW
Mar 7 at 21:42
@JpW Oh, sorry. Yes, I confirm that this is difficult. One can get the intersection as desired by puttingflip crossing=8,in the first graph, but then the intersection with the vertical line is wrong (I also removed(0,0)in the end). I suspect that the fact that you use the coordinate(0,0)in the end (in addition to[closed]) could be part of the reason.
– marmot
Mar 7 at 22:40
If you alter thescalefrom 1 to 2 without any changes to the crossing flips, then you can actually see the crossing slowly change...
– JpW
Mar 7 at 22:49
@JpW Yes. I see how there can be problems. TikZ uses approximations to find intersections. Sometimes it finds more than there actually are, i.e. it may overcount intersections and so on. This does depend on the scale. What you can always do is to put something that works in a scalebox (and scale the line width and the nodes up withtransform shape). Is your aim to have the second plot scaled down to the first one?
– marmot
Mar 7 at 22:54
Yes it is. I'm writing up my report, which is on a much smaller scale than my poster (which was what I previously used). I wrote the poster in beamer several weeks ago and I'm trying to use the same code for the report but that crossing is a headache.
– JpW
Mar 7 at 22:59
add a comment |
The underlying issue here is the same as noted in Unexpected behavior of the "knots" tikz library when a crossing is close to another (thick) line: What's going on?. There are two crossings that are very close together and the clipping circles (when the crossings are drawn) overlap, meaning that when the violet line is drawn over the dashed grey line, it also draws over itself at that problematic crossing.
Here are a few possible fixes. In the first, I reduce the radius of the clipping circles. In the second, I took the dashed grey line out of the knot as it doesn't seem to be actually part of the knot (note that if you do want to keep it in the knot, you should use the key only when rendering for the dashed part - see the documentation for details). In the third fix, I simplified your hobby path a little.
Results:

Code:
documentclass[a4paper,11pt]report
%urlhttps://tex.stackexchange.com/q/478294/86
usepackageshellesc
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrary
decorations.pathreplacing,
decorations.markings,
hobby,
knots,
celtic,
shapes.geometric,
calc,
external
tikzexternalize
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
Demonstration of the problem: the clipping circles are big enough that the circle associated with the crossing between the violet line and the dashed grey line overlaps the problematic crossing.
tikzsetnextfilenameproblem
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
Fix one: shrink the clipping circles using the verb+clip radius+ key.
tikzsetnextfilenamefix-one
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
clip radius=3pt,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
Fix two: the dashed grey lines don't appear to actually be anything to do with the knot, so draw them separately.
This means that there aren't two crossings near to each other any more.
tikzsetnextfilenamefix-two
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-1.2) -- (-0.7,2.5);
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
% flip crossing=6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
endknot
path (0,-.7);
endtikzpicture
Fix three: you specify a lot of emphnodes in your Hobby path.
If you aren't wedded to that specific path then reducing the number of nodes can simplify the knot algorithm.
tikzsetnextfilenamefix-three
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.2 with arrow[line width=1.5pt]<,
mark=at position 0.28 with arrow[line width=1.5pt]<,
mark=at position 0.8 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-2.2) -- (-0.7,3.5);
beginknot[
consider self intersections=true,
end tolerance=3pt,
flip crossing=4,
rotate=180]
strand ([closed].5,2) [add arrow,violet] .. (-.5,1) .. (.3,-.5) .. (-.3,-.5) .. (.5,1) .. ([tension=3]-1.5,1) .. (.7,-1) .. (-2,1);
endknot
path (0,-.7);
endtikzpicture
tikzsetnextfilenamelarge-scale
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478294%2ftikz-knots-package-crossing-changed-after-scaling%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I did precisely what you suggested, draft mode=crossings, after which I flipped crossing number 6 and get
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing/.list=3,6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

OK, I am not able to solve the problem. Here is a proposal for a workaround.
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=3.2pt,violet
,
tikzset
my style/.style=
dashed
scalebox0.45
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

1
Ah thank you (as always!) - but I meant how could I change that crossing in the first diagram?
– JpW
Mar 7 at 21:42
@JpW Oh, sorry. Yes, I confirm that this is difficult. One can get the intersection as desired by puttingflip crossing=8,in the first graph, but then the intersection with the vertical line is wrong (I also removed(0,0)in the end). I suspect that the fact that you use the coordinate(0,0)in the end (in addition to[closed]) could be part of the reason.
– marmot
Mar 7 at 22:40
If you alter thescalefrom 1 to 2 without any changes to the crossing flips, then you can actually see the crossing slowly change...
– JpW
Mar 7 at 22:49
@JpW Yes. I see how there can be problems. TikZ uses approximations to find intersections. Sometimes it finds more than there actually are, i.e. it may overcount intersections and so on. This does depend on the scale. What you can always do is to put something that works in a scalebox (and scale the line width and the nodes up withtransform shape). Is your aim to have the second plot scaled down to the first one?
– marmot
Mar 7 at 22:54
Yes it is. I'm writing up my report, which is on a much smaller scale than my poster (which was what I previously used). I wrote the poster in beamer several weeks ago and I'm trying to use the same code for the report but that crossing is a headache.
– JpW
Mar 7 at 22:59
add a comment |
I did precisely what you suggested, draft mode=crossings, after which I flipped crossing number 6 and get
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing/.list=3,6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

OK, I am not able to solve the problem. Here is a proposal for a workaround.
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=3.2pt,violet
,
tikzset
my style/.style=
dashed
scalebox0.45
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

1
Ah thank you (as always!) - but I meant how could I change that crossing in the first diagram?
– JpW
Mar 7 at 21:42
@JpW Oh, sorry. Yes, I confirm that this is difficult. One can get the intersection as desired by puttingflip crossing=8,in the first graph, but then the intersection with the vertical line is wrong (I also removed(0,0)in the end). I suspect that the fact that you use the coordinate(0,0)in the end (in addition to[closed]) could be part of the reason.
– marmot
Mar 7 at 22:40
If you alter thescalefrom 1 to 2 without any changes to the crossing flips, then you can actually see the crossing slowly change...
– JpW
Mar 7 at 22:49
@JpW Yes. I see how there can be problems. TikZ uses approximations to find intersections. Sometimes it finds more than there actually are, i.e. it may overcount intersections and so on. This does depend on the scale. What you can always do is to put something that works in a scalebox (and scale the line width and the nodes up withtransform shape). Is your aim to have the second plot scaled down to the first one?
– marmot
Mar 7 at 22:54
Yes it is. I'm writing up my report, which is on a much smaller scale than my poster (which was what I previously used). I wrote the poster in beamer several weeks ago and I'm trying to use the same code for the report but that crossing is a headache.
– JpW
Mar 7 at 22:59
add a comment |
I did precisely what you suggested, draft mode=crossings, after which I flipped crossing number 6 and get
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing/.list=3,6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

OK, I am not able to solve the problem. Here is a proposal for a workaround.
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=3.2pt,violet
,
tikzset
my style/.style=
dashed
scalebox0.45
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

I did precisely what you suggested, draft mode=crossings, after which I flipped crossing number 6 and get
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing/.list=3,6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

OK, I am not able to solve the problem. Here is a proposal for a workaround.
documentclass[a4paper,11pt]report
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrarydecorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc
begindocument
tikzset
knot diagram/every strand/.append style=
line width=3.2pt,violet
,
tikzset
my style/.style=
dashed
scalebox0.45
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[%draft mode=crossings,
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument

edited Mar 7 at 23:09
answered Mar 7 at 21:24
marmotmarmot
114k5145276
114k5145276
1
Ah thank you (as always!) - but I meant how could I change that crossing in the first diagram?
– JpW
Mar 7 at 21:42
@JpW Oh, sorry. Yes, I confirm that this is difficult. One can get the intersection as desired by puttingflip crossing=8,in the first graph, but then the intersection with the vertical line is wrong (I also removed(0,0)in the end). I suspect that the fact that you use the coordinate(0,0)in the end (in addition to[closed]) could be part of the reason.
– marmot
Mar 7 at 22:40
If you alter thescalefrom 1 to 2 without any changes to the crossing flips, then you can actually see the crossing slowly change...
– JpW
Mar 7 at 22:49
@JpW Yes. I see how there can be problems. TikZ uses approximations to find intersections. Sometimes it finds more than there actually are, i.e. it may overcount intersections and so on. This does depend on the scale. What you can always do is to put something that works in a scalebox (and scale the line width and the nodes up withtransform shape). Is your aim to have the second plot scaled down to the first one?
– marmot
Mar 7 at 22:54
Yes it is. I'm writing up my report, which is on a much smaller scale than my poster (which was what I previously used). I wrote the poster in beamer several weeks ago and I'm trying to use the same code for the report but that crossing is a headache.
– JpW
Mar 7 at 22:59
add a comment |
1
Ah thank you (as always!) - but I meant how could I change that crossing in the first diagram?
– JpW
Mar 7 at 21:42
@JpW Oh, sorry. Yes, I confirm that this is difficult. One can get the intersection as desired by puttingflip crossing=8,in the first graph, but then the intersection with the vertical line is wrong (I also removed(0,0)in the end). I suspect that the fact that you use the coordinate(0,0)in the end (in addition to[closed]) could be part of the reason.
– marmot
Mar 7 at 22:40
If you alter thescalefrom 1 to 2 without any changes to the crossing flips, then you can actually see the crossing slowly change...
– JpW
Mar 7 at 22:49
@JpW Yes. I see how there can be problems. TikZ uses approximations to find intersections. Sometimes it finds more than there actually are, i.e. it may overcount intersections and so on. This does depend on the scale. What you can always do is to put something that works in a scalebox (and scale the line width and the nodes up withtransform shape). Is your aim to have the second plot scaled down to the first one?
– marmot
Mar 7 at 22:54
Yes it is. I'm writing up my report, which is on a much smaller scale than my poster (which was what I previously used). I wrote the poster in beamer several weeks ago and I'm trying to use the same code for the report but that crossing is a headache.
– JpW
Mar 7 at 22:59
1
1
Ah thank you (as always!) - but I meant how could I change that crossing in the first diagram?
– JpW
Mar 7 at 21:42
Ah thank you (as always!) - but I meant how could I change that crossing in the first diagram?
– JpW
Mar 7 at 21:42
@JpW Oh, sorry. Yes, I confirm that this is difficult. One can get the intersection as desired by putting
flip crossing=8, in the first graph, but then the intersection with the vertical line is wrong (I also removed (0,0) in the end). I suspect that the fact that you use the coordinate (0,0) in the end (in addition to [closed]) could be part of the reason.– marmot
Mar 7 at 22:40
@JpW Oh, sorry. Yes, I confirm that this is difficult. One can get the intersection as desired by putting
flip crossing=8, in the first graph, but then the intersection with the vertical line is wrong (I also removed (0,0) in the end). I suspect that the fact that you use the coordinate (0,0) in the end (in addition to [closed]) could be part of the reason.– marmot
Mar 7 at 22:40
If you alter the
scale from 1 to 2 without any changes to the crossing flips, then you can actually see the crossing slowly change...– JpW
Mar 7 at 22:49
If you alter the
scale from 1 to 2 without any changes to the crossing flips, then you can actually see the crossing slowly change...– JpW
Mar 7 at 22:49
@JpW Yes. I see how there can be problems. TikZ uses approximations to find intersections. Sometimes it finds more than there actually are, i.e. it may overcount intersections and so on. This does depend on the scale. What you can always do is to put something that works in a scalebox (and scale the line width and the nodes up with
transform shape). Is your aim to have the second plot scaled down to the first one?– marmot
Mar 7 at 22:54
@JpW Yes. I see how there can be problems. TikZ uses approximations to find intersections. Sometimes it finds more than there actually are, i.e. it may overcount intersections and so on. This does depend on the scale. What you can always do is to put something that works in a scalebox (and scale the line width and the nodes up with
transform shape). Is your aim to have the second plot scaled down to the first one?– marmot
Mar 7 at 22:54
Yes it is. I'm writing up my report, which is on a much smaller scale than my poster (which was what I previously used). I wrote the poster in beamer several weeks ago and I'm trying to use the same code for the report but that crossing is a headache.
– JpW
Mar 7 at 22:59
Yes it is. I'm writing up my report, which is on a much smaller scale than my poster (which was what I previously used). I wrote the poster in beamer several weeks ago and I'm trying to use the same code for the report but that crossing is a headache.
– JpW
Mar 7 at 22:59
add a comment |
The underlying issue here is the same as noted in Unexpected behavior of the "knots" tikz library when a crossing is close to another (thick) line: What's going on?. There are two crossings that are very close together and the clipping circles (when the crossings are drawn) overlap, meaning that when the violet line is drawn over the dashed grey line, it also draws over itself at that problematic crossing.
Here are a few possible fixes. In the first, I reduce the radius of the clipping circles. In the second, I took the dashed grey line out of the knot as it doesn't seem to be actually part of the knot (note that if you do want to keep it in the knot, you should use the key only when rendering for the dashed part - see the documentation for details). In the third fix, I simplified your hobby path a little.
Results:

Code:
documentclass[a4paper,11pt]report
%urlhttps://tex.stackexchange.com/q/478294/86
usepackageshellesc
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrary
decorations.pathreplacing,
decorations.markings,
hobby,
knots,
celtic,
shapes.geometric,
calc,
external
tikzexternalize
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
Demonstration of the problem: the clipping circles are big enough that the circle associated with the crossing between the violet line and the dashed grey line overlaps the problematic crossing.
tikzsetnextfilenameproblem
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
Fix one: shrink the clipping circles using the verb+clip radius+ key.
tikzsetnextfilenamefix-one
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
clip radius=3pt,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
Fix two: the dashed grey lines don't appear to actually be anything to do with the knot, so draw them separately.
This means that there aren't two crossings near to each other any more.
tikzsetnextfilenamefix-two
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-1.2) -- (-0.7,2.5);
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
% flip crossing=6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
endknot
path (0,-.7);
endtikzpicture
Fix three: you specify a lot of emphnodes in your Hobby path.
If you aren't wedded to that specific path then reducing the number of nodes can simplify the knot algorithm.
tikzsetnextfilenamefix-three
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.2 with arrow[line width=1.5pt]<,
mark=at position 0.28 with arrow[line width=1.5pt]<,
mark=at position 0.8 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-2.2) -- (-0.7,3.5);
beginknot[
consider self intersections=true,
end tolerance=3pt,
flip crossing=4,
rotate=180]
strand ([closed].5,2) [add arrow,violet] .. (-.5,1) .. (.3,-.5) .. (-.3,-.5) .. (.5,1) .. ([tension=3]-1.5,1) .. (.7,-1) .. (-2,1);
endknot
path (0,-.7);
endtikzpicture
tikzsetnextfilenamelarge-scale
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
add a comment |
The underlying issue here is the same as noted in Unexpected behavior of the "knots" tikz library when a crossing is close to another (thick) line: What's going on?. There are two crossings that are very close together and the clipping circles (when the crossings are drawn) overlap, meaning that when the violet line is drawn over the dashed grey line, it also draws over itself at that problematic crossing.
Here are a few possible fixes. In the first, I reduce the radius of the clipping circles. In the second, I took the dashed grey line out of the knot as it doesn't seem to be actually part of the knot (note that if you do want to keep it in the knot, you should use the key only when rendering for the dashed part - see the documentation for details). In the third fix, I simplified your hobby path a little.
Results:

Code:
documentclass[a4paper,11pt]report
%urlhttps://tex.stackexchange.com/q/478294/86
usepackageshellesc
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrary
decorations.pathreplacing,
decorations.markings,
hobby,
knots,
celtic,
shapes.geometric,
calc,
external
tikzexternalize
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
Demonstration of the problem: the clipping circles are big enough that the circle associated with the crossing between the violet line and the dashed grey line overlaps the problematic crossing.
tikzsetnextfilenameproblem
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
Fix one: shrink the clipping circles using the verb+clip radius+ key.
tikzsetnextfilenamefix-one
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
clip radius=3pt,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
Fix two: the dashed grey lines don't appear to actually be anything to do with the knot, so draw them separately.
This means that there aren't two crossings near to each other any more.
tikzsetnextfilenamefix-two
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-1.2) -- (-0.7,2.5);
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
% flip crossing=6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
endknot
path (0,-.7);
endtikzpicture
Fix three: you specify a lot of emphnodes in your Hobby path.
If you aren't wedded to that specific path then reducing the number of nodes can simplify the knot algorithm.
tikzsetnextfilenamefix-three
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.2 with arrow[line width=1.5pt]<,
mark=at position 0.28 with arrow[line width=1.5pt]<,
mark=at position 0.8 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-2.2) -- (-0.7,3.5);
beginknot[
consider self intersections=true,
end tolerance=3pt,
flip crossing=4,
rotate=180]
strand ([closed].5,2) [add arrow,violet] .. (-.5,1) .. (.3,-.5) .. (-.3,-.5) .. (.5,1) .. ([tension=3]-1.5,1) .. (.7,-1) .. (-2,1);
endknot
path (0,-.7);
endtikzpicture
tikzsetnextfilenamelarge-scale
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
add a comment |
The underlying issue here is the same as noted in Unexpected behavior of the "knots" tikz library when a crossing is close to another (thick) line: What's going on?. There are two crossings that are very close together and the clipping circles (when the crossings are drawn) overlap, meaning that when the violet line is drawn over the dashed grey line, it also draws over itself at that problematic crossing.
Here are a few possible fixes. In the first, I reduce the radius of the clipping circles. In the second, I took the dashed grey line out of the knot as it doesn't seem to be actually part of the knot (note that if you do want to keep it in the knot, you should use the key only when rendering for the dashed part - see the documentation for details). In the third fix, I simplified your hobby path a little.
Results:

Code:
documentclass[a4paper,11pt]report
%urlhttps://tex.stackexchange.com/q/478294/86
usepackageshellesc
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrary
decorations.pathreplacing,
decorations.markings,
hobby,
knots,
celtic,
shapes.geometric,
calc,
external
tikzexternalize
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
Demonstration of the problem: the clipping circles are big enough that the circle associated with the crossing between the violet line and the dashed grey line overlaps the problematic crossing.
tikzsetnextfilenameproblem
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
Fix one: shrink the clipping circles using the verb+clip radius+ key.
tikzsetnextfilenamefix-one
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
clip radius=3pt,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
Fix two: the dashed grey lines don't appear to actually be anything to do with the knot, so draw them separately.
This means that there aren't two crossings near to each other any more.
tikzsetnextfilenamefix-two
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-1.2) -- (-0.7,2.5);
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
% flip crossing=6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
endknot
path (0,-.7);
endtikzpicture
Fix three: you specify a lot of emphnodes in your Hobby path.
If you aren't wedded to that specific path then reducing the number of nodes can simplify the knot algorithm.
tikzsetnextfilenamefix-three
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.2 with arrow[line width=1.5pt]<,
mark=at position 0.28 with arrow[line width=1.5pt]<,
mark=at position 0.8 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-2.2) -- (-0.7,3.5);
beginknot[
consider self intersections=true,
end tolerance=3pt,
flip crossing=4,
rotate=180]
strand ([closed].5,2) [add arrow,violet] .. (-.5,1) .. (.3,-.5) .. (-.3,-.5) .. (.5,1) .. ([tension=3]-1.5,1) .. (.7,-1) .. (-2,1);
endknot
path (0,-.7);
endtikzpicture
tikzsetnextfilenamelarge-scale
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
The underlying issue here is the same as noted in Unexpected behavior of the "knots" tikz library when a crossing is close to another (thick) line: What's going on?. There are two crossings that are very close together and the clipping circles (when the crossings are drawn) overlap, meaning that when the violet line is drawn over the dashed grey line, it also draws over itself at that problematic crossing.
Here are a few possible fixes. In the first, I reduce the radius of the clipping circles. In the second, I took the dashed grey line out of the knot as it doesn't seem to be actually part of the knot (note that if you do want to keep it in the knot, you should use the key only when rendering for the dashed part - see the documentation for details). In the third fix, I simplified your hobby path a little.
Results:

Code:
documentclass[a4paper,11pt]report
%urlhttps://tex.stackexchange.com/q/478294/86
usepackageshellesc
usepackagegraphicx,amssymb,amstext,amsmath
usepackagetikz
usetikzlibrary
decorations.pathreplacing,
decorations.markings,
hobby,
knots,
celtic,
shapes.geometric,
calc,
external
tikzexternalize
begindocument
tikzset
knot diagram/every strand/.append style=
line width=1.5pt,violet
,
tikzset
my style/.style=
dashed
Demonstration of the problem: the clipping circles are big enough that the circle associated with the crossing between the violet line and the dashed grey line overlaps the problematic crossing.
tikzsetnextfilenameproblem
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
%---------------------------------------------------------------
Fix one: shrink the clipping circles using the verb+clip radius+ key.
tikzsetnextfilenamefix-one
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
clip radius=3pt,
background clip/.append style=
preaction=
fill=gray,
fill opacity=.5,
,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
Fix two: the dashed grey lines don't appear to actually be anything to do with the knot, so draw them separately.
This means that there aren't two crossings near to each other any more.
tikzsetnextfilenamefix-two
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-1.2) -- (-0.7,2.5);
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
% flip crossing=6,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
endknot
path (0,-.7);
endtikzpicture
Fix three: you specify a lot of emphnodes in your Hobby path.
If you aren't wedded to that specific path then reducing the number of nodes can simplify the knot algorithm.
tikzsetnextfilenamefix-three
begintikzpicture[scale=0.9, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.2 with arrow[line width=1.5pt]<,
mark=at position 0.28 with arrow[line width=1.5pt]<,
mark=at position 0.8 with arrow[line width=1.5pt]<]
draw[
line width=1.5pt,
my style,
lightgray,
rotate=180
] (-0.7,-2.2) -- (-0.7,3.5);
beginknot[
consider self intersections=true,
end tolerance=3pt,
flip crossing=4,
rotate=180]
strand ([closed].5,2) [add arrow,violet] .. (-.5,1) .. (.3,-.5) .. (-.3,-.5) .. (.5,1) .. ([tension=3]-1.5,1) .. (.7,-1) .. (-2,1);
endknot
path (0,-.7);
endtikzpicture
tikzsetnextfilenamelarge-scale
begintikzpicture[scale=2, use Hobby shortcut, add arrow/.style=postaction=decorate, decoration=
markings,
mark=at position 0.25 with arrow[line width=1.5pt]<,
mark=at position 0.653 with arrow[line width=1.5pt]<,
mark=at position 0.75 with arrow[line width=1.5pt]<]
beginknot[
consider self intersections=true,
ignore endpoint intersections=false,
flip crossing=3,
rotate=180]
strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9);
strand[knot diagram/only when rendering/.style=my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
endknot
path (0,-.7);
endtikzpicture
enddocument
answered 3 hours ago
Loop SpaceLoop Space
113k30308610
113k30308610
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478294%2ftikz-knots-package-crossing-changed-after-scaling%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The problem is the presence of the dashed line. Do you need that to be defined as part of the knot? Could it be an ordinary line drawn before the knot is rendered? I'll post some different possibilities when I get back to a proper computer.
– Loop Space
22 hours ago
This is the same underlying problem as addressed in tex.stackexchange.com/q/323758/86 I'll post an answer here as well as it's not easy to generalise, but refer to the answer there for the explanation.
– Loop Space
5 hours ago