Knot diagrams in TikZ
This question led to a new package:
spath3
(Technically, this question led to a subpackage of the
spath3
package; thespath3
package provides some foundations on which a TikZ libraryknots
was built and the TikZ library is bundled with thespath3
library.)
See also the blog post: How can I draw a knot in TeX?
I need to use TikZ to draw some knot/braid diagrams. These will be built from families of curves, which appear to cross over each other in places. At each crossing, it needs to be obvious which line is going over which, and so I'm using the TikZ double functionality, to draw a fat white line underneath the thin black lines representing the curves. That way, if I draw 'on top' line segments after 'on the bottom' line segments, I'll get the correct effect.
But still, drawing these diagrams is a pain. In particular, I might have two continuous curves in one diagram, with the first curve going on top of the second in some places, and beneath it in others. So I can't simply draw the 'lower' curve first: I have to draw different segments of the curves individually.
For ease of programming, I'd really like to have all the code for each curve together. One way I could achieve this is if I could change the layer independently for each segment of a multi-point path command. The idea would be something like this:
draw (1) to [layer=middlelayer] (2) to [layer=toplayer] (3) to [layer=bottomlayer] (4);
Is this possible? Or is there a better way to achieve the effect I want?
Unfortunately, my diagrams need to be much more freeform than those produced by Andrew Stacey's braid package. They're not of the form of generators of the braid group stacked neatly on top of one another. Here's an example of the sort of thing I need:
tikz-pgf tikzlibrary
|
show 6 more comments
This question led to a new package:
spath3
(Technically, this question led to a subpackage of the
spath3
package; thespath3
package provides some foundations on which a TikZ libraryknots
was built and the TikZ library is bundled with thespath3
library.)
See also the blog post: How can I draw a knot in TeX?
I need to use TikZ to draw some knot/braid diagrams. These will be built from families of curves, which appear to cross over each other in places. At each crossing, it needs to be obvious which line is going over which, and so I'm using the TikZ double functionality, to draw a fat white line underneath the thin black lines representing the curves. That way, if I draw 'on top' line segments after 'on the bottom' line segments, I'll get the correct effect.
But still, drawing these diagrams is a pain. In particular, I might have two continuous curves in one diagram, with the first curve going on top of the second in some places, and beneath it in others. So I can't simply draw the 'lower' curve first: I have to draw different segments of the curves individually.
For ease of programming, I'd really like to have all the code for each curve together. One way I could achieve this is if I could change the layer independently for each segment of a multi-point path command. The idea would be something like this:
draw (1) to [layer=middlelayer] (2) to [layer=toplayer] (3) to [layer=bottomlayer] (4);
Is this possible? Or is there a better way to achieve the effect I want?
Unfortunately, my diagrams need to be much more freeform than those produced by Andrew Stacey's braid package. They're not of the form of generators of the braid group stacked neatly on top of one another. Here's an example of the sort of thing I need:
tikz-pgf tikzlibrary
6
We've got a resident braids expert, Andrew Stacey, who wrote a nice package for drawing braids diagrams in TikZ. He's written a post on the TeX.sx blog: tex.blogoverflow.com/2011/09/the-braids-package
– Jake
Oct 20 '11 at 9:19
4
This is a job for Andrew Stacey.:)
– Paulo Cereda
Oct 20 '11 at 9:28
4
We had a question a while ago on drawing braids (which is tex.stackexchange.com/q/16897/86) and which led to a package which is now on CTAN (ctan.org/pkg/braids). It (probably) needs PGF2.10. There's a slightly enhanced version at the TeX-SX launchpad site (bazaar.launchpad.net/~tex-sx/tex-sx/development/files), but I'll push the changes to CTAN when I've tested them a bit more. The blog post that Jake links has some details, the CTAN/launchpad have full documentation. If there's anything that it doesn't do that you'd like, please ask and I'll try to implement it.
– Loop Space
Oct 20 '11 at 9:36
1
Thanks everyone for your comments. I've edited the post to clarify that Andrew Stacey's package, although very cool, doesn't do the job I need!
– Jamie Vicary
Oct 21 '11 at 8:27
4
That's not a braid, that's a tangle! For more general knot-like diagrams, we also have tex.stackexchange.com/q/17181/86.
– Loop Space
Oct 21 '11 at 9:10
|
show 6 more comments
This question led to a new package:
spath3
(Technically, this question led to a subpackage of the
spath3
package; thespath3
package provides some foundations on which a TikZ libraryknots
was built and the TikZ library is bundled with thespath3
library.)
See also the blog post: How can I draw a knot in TeX?
I need to use TikZ to draw some knot/braid diagrams. These will be built from families of curves, which appear to cross over each other in places. At each crossing, it needs to be obvious which line is going over which, and so I'm using the TikZ double functionality, to draw a fat white line underneath the thin black lines representing the curves. That way, if I draw 'on top' line segments after 'on the bottom' line segments, I'll get the correct effect.
But still, drawing these diagrams is a pain. In particular, I might have two continuous curves in one diagram, with the first curve going on top of the second in some places, and beneath it in others. So I can't simply draw the 'lower' curve first: I have to draw different segments of the curves individually.
For ease of programming, I'd really like to have all the code for each curve together. One way I could achieve this is if I could change the layer independently for each segment of a multi-point path command. The idea would be something like this:
draw (1) to [layer=middlelayer] (2) to [layer=toplayer] (3) to [layer=bottomlayer] (4);
Is this possible? Or is there a better way to achieve the effect I want?
Unfortunately, my diagrams need to be much more freeform than those produced by Andrew Stacey's braid package. They're not of the form of generators of the braid group stacked neatly on top of one another. Here's an example of the sort of thing I need:
tikz-pgf tikzlibrary
This question led to a new package:
spath3
(Technically, this question led to a subpackage of the
spath3
package; thespath3
package provides some foundations on which a TikZ libraryknots
was built and the TikZ library is bundled with thespath3
library.)
See also the blog post: How can I draw a knot in TeX?
I need to use TikZ to draw some knot/braid diagrams. These will be built from families of curves, which appear to cross over each other in places. At each crossing, it needs to be obvious which line is going over which, and so I'm using the TikZ double functionality, to draw a fat white line underneath the thin black lines representing the curves. That way, if I draw 'on top' line segments after 'on the bottom' line segments, I'll get the correct effect.
But still, drawing these diagrams is a pain. In particular, I might have two continuous curves in one diagram, with the first curve going on top of the second in some places, and beneath it in others. So I can't simply draw the 'lower' curve first: I have to draw different segments of the curves individually.
For ease of programming, I'd really like to have all the code for each curve together. One way I could achieve this is if I could change the layer independently for each segment of a multi-point path command. The idea would be something like this:
draw (1) to [layer=middlelayer] (2) to [layer=toplayer] (3) to [layer=bottomlayer] (4);
Is this possible? Or is there a better way to achieve the effect I want?
Unfortunately, my diagrams need to be much more freeform than those produced by Andrew Stacey's braid package. They're not of the form of generators of the braid group stacked neatly on top of one another. Here's an example of the sort of thing I need:
tikz-pgf tikzlibrary
tikz-pgf tikzlibrary
edited Mar 9 at 10:20
Loop Space
113k29306609
113k29306609
asked Oct 20 '11 at 9:10
Jamie VicaryJamie Vicary
4,53863349
4,53863349
6
We've got a resident braids expert, Andrew Stacey, who wrote a nice package for drawing braids diagrams in TikZ. He's written a post on the TeX.sx blog: tex.blogoverflow.com/2011/09/the-braids-package
– Jake
Oct 20 '11 at 9:19
4
This is a job for Andrew Stacey.:)
– Paulo Cereda
Oct 20 '11 at 9:28
4
We had a question a while ago on drawing braids (which is tex.stackexchange.com/q/16897/86) and which led to a package which is now on CTAN (ctan.org/pkg/braids). It (probably) needs PGF2.10. There's a slightly enhanced version at the TeX-SX launchpad site (bazaar.launchpad.net/~tex-sx/tex-sx/development/files), but I'll push the changes to CTAN when I've tested them a bit more. The blog post that Jake links has some details, the CTAN/launchpad have full documentation. If there's anything that it doesn't do that you'd like, please ask and I'll try to implement it.
– Loop Space
Oct 20 '11 at 9:36
1
Thanks everyone for your comments. I've edited the post to clarify that Andrew Stacey's package, although very cool, doesn't do the job I need!
– Jamie Vicary
Oct 21 '11 at 8:27
4
That's not a braid, that's a tangle! For more general knot-like diagrams, we also have tex.stackexchange.com/q/17181/86.
– Loop Space
Oct 21 '11 at 9:10
|
show 6 more comments
6
We've got a resident braids expert, Andrew Stacey, who wrote a nice package for drawing braids diagrams in TikZ. He's written a post on the TeX.sx blog: tex.blogoverflow.com/2011/09/the-braids-package
– Jake
Oct 20 '11 at 9:19
4
This is a job for Andrew Stacey.:)
– Paulo Cereda
Oct 20 '11 at 9:28
4
We had a question a while ago on drawing braids (which is tex.stackexchange.com/q/16897/86) and which led to a package which is now on CTAN (ctan.org/pkg/braids). It (probably) needs PGF2.10. There's a slightly enhanced version at the TeX-SX launchpad site (bazaar.launchpad.net/~tex-sx/tex-sx/development/files), but I'll push the changes to CTAN when I've tested them a bit more. The blog post that Jake links has some details, the CTAN/launchpad have full documentation. If there's anything that it doesn't do that you'd like, please ask and I'll try to implement it.
– Loop Space
Oct 20 '11 at 9:36
1
Thanks everyone for your comments. I've edited the post to clarify that Andrew Stacey's package, although very cool, doesn't do the job I need!
– Jamie Vicary
Oct 21 '11 at 8:27
4
That's not a braid, that's a tangle! For more general knot-like diagrams, we also have tex.stackexchange.com/q/17181/86.
– Loop Space
Oct 21 '11 at 9:10
6
6
We've got a resident braids expert, Andrew Stacey, who wrote a nice package for drawing braids diagrams in TikZ. He's written a post on the TeX.sx blog: tex.blogoverflow.com/2011/09/the-braids-package
– Jake
Oct 20 '11 at 9:19
We've got a resident braids expert, Andrew Stacey, who wrote a nice package for drawing braids diagrams in TikZ. He's written a post on the TeX.sx blog: tex.blogoverflow.com/2011/09/the-braids-package
– Jake
Oct 20 '11 at 9:19
4
4
This is a job for Andrew Stacey.
:)
– Paulo Cereda
Oct 20 '11 at 9:28
This is a job for Andrew Stacey.
:)
– Paulo Cereda
Oct 20 '11 at 9:28
4
4
We had a question a while ago on drawing braids (which is tex.stackexchange.com/q/16897/86) and which led to a package which is now on CTAN (ctan.org/pkg/braids). It (probably) needs PGF2.10. There's a slightly enhanced version at the TeX-SX launchpad site (bazaar.launchpad.net/~tex-sx/tex-sx/development/files), but I'll push the changes to CTAN when I've tested them a bit more. The blog post that Jake links has some details, the CTAN/launchpad have full documentation. If there's anything that it doesn't do that you'd like, please ask and I'll try to implement it.
– Loop Space
Oct 20 '11 at 9:36
We had a question a while ago on drawing braids (which is tex.stackexchange.com/q/16897/86) and which led to a package which is now on CTAN (ctan.org/pkg/braids). It (probably) needs PGF2.10. There's a slightly enhanced version at the TeX-SX launchpad site (bazaar.launchpad.net/~tex-sx/tex-sx/development/files), but I'll push the changes to CTAN when I've tested them a bit more. The blog post that Jake links has some details, the CTAN/launchpad have full documentation. If there's anything that it doesn't do that you'd like, please ask and I'll try to implement it.
– Loop Space
Oct 20 '11 at 9:36
1
1
Thanks everyone for your comments. I've edited the post to clarify that Andrew Stacey's package, although very cool, doesn't do the job I need!
– Jamie Vicary
Oct 21 '11 at 8:27
Thanks everyone for your comments. I've edited the post to clarify that Andrew Stacey's package, although very cool, doesn't do the job I need!
– Jamie Vicary
Oct 21 '11 at 8:27
4
4
That's not a braid, that's a tangle! For more general knot-like diagrams, we also have tex.stackexchange.com/q/17181/86.
– Loop Space
Oct 21 '11 at 9:10
That's not a braid, that's a tangle! For more general knot-like diagrams, we also have tex.stackexchange.com/q/17181/86.
– Loop Space
Oct 21 '11 at 9:10
|
show 6 more comments
1 Answer
1
active
oldest
votes
Update: This is now available on CTAN (see above). Bugfixes and improvements will generally be available on github before being uploaded to CTAN. Note that that repository is quite cluttered, the relevant .dtx
file is called spath3.dtx
. This generates all the necessary files.
Update: The code has undergone considerable revision following extensive discussion with Jamie in the chat room From Answers to Packages. The code can now be downloaded from the TeX-SX Launchpad Project. The necessary files are knots.dtx
and spath.dtx
. The file knots_test.tex
contains some example code. To create the .sty
files from the .dtx
, run tex <file>.dtx
. Alternatively, running latex (or pdflatex) on knots_test.tex
with shell escapes enabled will automatically generate the .sty
files.
Okay, here's my first attempt at implementing what we discussed in chat. It is certainly a bit rough around the edges, and I give absolutely no guarantees that it won't TeX your cat instead.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections}
makeatletter
newcounter{knot@strings}
newififknot@draftmode
tikzoption{save knot path}{tikz@addmode{pgfsyssoftpath@getcurrentpathknot@tmppathexpandafterglobalexpandafterlet#1=knot@tmppath}}
tikzoption{use knot path}{tikz@addmode{expandafterpgfsyssoftpath@setcurrentpath#1}}
tikzset{
knot/draft mode/.is if=knot@draftmode
}
newenvironment{knot}[1]{%
tikzset{#1}%
setcounter{knot@strings}{0}}{%
foreach knot@str in {1,...,thevalue{knot@strings}} {
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@strendcsname,use knot path=csname knot@string@knot@strendcsname] (0,0);
ifknot@draftmode
begingroup
letpgfsyssoftpath@movetotoken=pgfqpoint
letpgfsyssoftpath@linetotoken=pgfqpoint
letpgfsyssoftpath@curvetotoken=pgfqpoint
letpgfsyssoftpath@curvetosupportatoken=pgfqpoint
letpgfsyssoftpath@curvetosupportbtoken=pgfqpoint
csname knot@string@knot@strendcsname
globalpgf@xa=pgf@x
globalpgf@ya=pgf@y
endgroup
node[circle,fill=white,fill opacity=.5] at (pgf@xa,pgf@ya) {knot@str};
fi
}
pgfmathtruncatemacro{knot@stam}{thevalue{knot@strings}-1}
foreach knot@sta in {1,...,knot@stam} {
pgfmathtruncatemacro{knot@stap}{knot@sta + 1}
foreach knot@stb in {knot@stap,...,thevalue{knot@strings}} {
pgfintersectionofpaths{expandafterpgfsetpathcsname knot@string@knot@staendcsname}{expandafterpgfsetpathcsname knot@string@knot@stbendcsname}
foreach intsect in {1,...,pgfintersectionsolutions} {
pgfpointintersectionsolution{intsect}
pgfgetlastxy{intsectx}{intsecty}
ifknot@draftmode
node[circle,fill=white,fill opacity=.5] at (intsectx,intsecty) {knot@sta-knot@stb-intsect};
else
@ifundefined{knot@crossing@knot@sta-knot@stb-intsect}{
%message{knot@sta-knot@stb-intsect not defined}
}{
pgfmathtruncatemacro{knot@under}{csname knot@crossing@knot@sta-knot@stb-intsectendcsname == knot@sta ? knot@stb : knot@sta}
expandafterletexpandafterknot@overcsname knot@crossing@knot@sta-knot@stb-intsectendcsname
pgfscope
clip (intsectx,intsecty) circle[radius=10pt];
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@underendcsname,use knot path=csname knot@string@knot@underendcsname] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname,white,line width=3pgflinewidth] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname] (0,0);
endpgfscope
}
fi
}
}
}
}
newcommand{strand}[1]{%
stepcounter{knot@strings}%
expandafterdefcsname knot@string@opts@thevalue{knot@strings}endcsname{#1}%
path[save knot path=csname knot@string@thevalue{knot@strings}endcsname]}
newcommand{crossing}[2]{%
expandafterdefcsname knot@crossing@#1endcsname{#2}}
makeatother
begin{document}
begin{tikzpicture}
begin{knot}[knot/draft mode]
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
begin{tikzpicture}
begin{knot}
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
end{document}
Result (draft version on top):
Hopefully the syntax is obvious enough from the example. (It looks a lot nicer in the original PDF; the conversion to PNG is awful!). There are lots of places for improvement, but I thought I'd see if this was on the right track before polishing it.
Andrew, comments posted in the forum.
– Jamie Vicary
Oct 22 '11 at 14:05
Thanks! It doesn't work withscale
other than 1, so I wasn't seeing the crossings. With noscale
argument, everything is beautiful.
– Jack Schmidt
Nov 8 '11 at 19:44
@JackSchmidt: Where were you putting thescale
? Can you post an example in the chatroom chat.stackexchange.com/rooms/409/from-answers-to-packages (if you cut-and-paste code then you can post large blocks). It ought to work with transformations (in the sense that if it doesn't then I should fix it so that it does). The chatroom is a better location for discussing features and bugs.
– Loop Space
Nov 8 '11 at 19:51
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');
});
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%2f32125%2fknot-diagrams-in-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update: This is now available on CTAN (see above). Bugfixes and improvements will generally be available on github before being uploaded to CTAN. Note that that repository is quite cluttered, the relevant .dtx
file is called spath3.dtx
. This generates all the necessary files.
Update: The code has undergone considerable revision following extensive discussion with Jamie in the chat room From Answers to Packages. The code can now be downloaded from the TeX-SX Launchpad Project. The necessary files are knots.dtx
and spath.dtx
. The file knots_test.tex
contains some example code. To create the .sty
files from the .dtx
, run tex <file>.dtx
. Alternatively, running latex (or pdflatex) on knots_test.tex
with shell escapes enabled will automatically generate the .sty
files.
Okay, here's my first attempt at implementing what we discussed in chat. It is certainly a bit rough around the edges, and I give absolutely no guarantees that it won't TeX your cat instead.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections}
makeatletter
newcounter{knot@strings}
newififknot@draftmode
tikzoption{save knot path}{tikz@addmode{pgfsyssoftpath@getcurrentpathknot@tmppathexpandafterglobalexpandafterlet#1=knot@tmppath}}
tikzoption{use knot path}{tikz@addmode{expandafterpgfsyssoftpath@setcurrentpath#1}}
tikzset{
knot/draft mode/.is if=knot@draftmode
}
newenvironment{knot}[1]{%
tikzset{#1}%
setcounter{knot@strings}{0}}{%
foreach knot@str in {1,...,thevalue{knot@strings}} {
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@strendcsname,use knot path=csname knot@string@knot@strendcsname] (0,0);
ifknot@draftmode
begingroup
letpgfsyssoftpath@movetotoken=pgfqpoint
letpgfsyssoftpath@linetotoken=pgfqpoint
letpgfsyssoftpath@curvetotoken=pgfqpoint
letpgfsyssoftpath@curvetosupportatoken=pgfqpoint
letpgfsyssoftpath@curvetosupportbtoken=pgfqpoint
csname knot@string@knot@strendcsname
globalpgf@xa=pgf@x
globalpgf@ya=pgf@y
endgroup
node[circle,fill=white,fill opacity=.5] at (pgf@xa,pgf@ya) {knot@str};
fi
}
pgfmathtruncatemacro{knot@stam}{thevalue{knot@strings}-1}
foreach knot@sta in {1,...,knot@stam} {
pgfmathtruncatemacro{knot@stap}{knot@sta + 1}
foreach knot@stb in {knot@stap,...,thevalue{knot@strings}} {
pgfintersectionofpaths{expandafterpgfsetpathcsname knot@string@knot@staendcsname}{expandafterpgfsetpathcsname knot@string@knot@stbendcsname}
foreach intsect in {1,...,pgfintersectionsolutions} {
pgfpointintersectionsolution{intsect}
pgfgetlastxy{intsectx}{intsecty}
ifknot@draftmode
node[circle,fill=white,fill opacity=.5] at (intsectx,intsecty) {knot@sta-knot@stb-intsect};
else
@ifundefined{knot@crossing@knot@sta-knot@stb-intsect}{
%message{knot@sta-knot@stb-intsect not defined}
}{
pgfmathtruncatemacro{knot@under}{csname knot@crossing@knot@sta-knot@stb-intsectendcsname == knot@sta ? knot@stb : knot@sta}
expandafterletexpandafterknot@overcsname knot@crossing@knot@sta-knot@stb-intsectendcsname
pgfscope
clip (intsectx,intsecty) circle[radius=10pt];
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@underendcsname,use knot path=csname knot@string@knot@underendcsname] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname,white,line width=3pgflinewidth] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname] (0,0);
endpgfscope
}
fi
}
}
}
}
newcommand{strand}[1]{%
stepcounter{knot@strings}%
expandafterdefcsname knot@string@opts@thevalue{knot@strings}endcsname{#1}%
path[save knot path=csname knot@string@thevalue{knot@strings}endcsname]}
newcommand{crossing}[2]{%
expandafterdefcsname knot@crossing@#1endcsname{#2}}
makeatother
begin{document}
begin{tikzpicture}
begin{knot}[knot/draft mode]
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
begin{tikzpicture}
begin{knot}
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
end{document}
Result (draft version on top):
Hopefully the syntax is obvious enough from the example. (It looks a lot nicer in the original PDF; the conversion to PNG is awful!). There are lots of places for improvement, but I thought I'd see if this was on the right track before polishing it.
Andrew, comments posted in the forum.
– Jamie Vicary
Oct 22 '11 at 14:05
Thanks! It doesn't work withscale
other than 1, so I wasn't seeing the crossings. With noscale
argument, everything is beautiful.
– Jack Schmidt
Nov 8 '11 at 19:44
@JackSchmidt: Where were you putting thescale
? Can you post an example in the chatroom chat.stackexchange.com/rooms/409/from-answers-to-packages (if you cut-and-paste code then you can post large blocks). It ought to work with transformations (in the sense that if it doesn't then I should fix it so that it does). The chatroom is a better location for discussing features and bugs.
– Loop Space
Nov 8 '11 at 19:51
add a comment |
Update: This is now available on CTAN (see above). Bugfixes and improvements will generally be available on github before being uploaded to CTAN. Note that that repository is quite cluttered, the relevant .dtx
file is called spath3.dtx
. This generates all the necessary files.
Update: The code has undergone considerable revision following extensive discussion with Jamie in the chat room From Answers to Packages. The code can now be downloaded from the TeX-SX Launchpad Project. The necessary files are knots.dtx
and spath.dtx
. The file knots_test.tex
contains some example code. To create the .sty
files from the .dtx
, run tex <file>.dtx
. Alternatively, running latex (or pdflatex) on knots_test.tex
with shell escapes enabled will automatically generate the .sty
files.
Okay, here's my first attempt at implementing what we discussed in chat. It is certainly a bit rough around the edges, and I give absolutely no guarantees that it won't TeX your cat instead.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections}
makeatletter
newcounter{knot@strings}
newififknot@draftmode
tikzoption{save knot path}{tikz@addmode{pgfsyssoftpath@getcurrentpathknot@tmppathexpandafterglobalexpandafterlet#1=knot@tmppath}}
tikzoption{use knot path}{tikz@addmode{expandafterpgfsyssoftpath@setcurrentpath#1}}
tikzset{
knot/draft mode/.is if=knot@draftmode
}
newenvironment{knot}[1]{%
tikzset{#1}%
setcounter{knot@strings}{0}}{%
foreach knot@str in {1,...,thevalue{knot@strings}} {
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@strendcsname,use knot path=csname knot@string@knot@strendcsname] (0,0);
ifknot@draftmode
begingroup
letpgfsyssoftpath@movetotoken=pgfqpoint
letpgfsyssoftpath@linetotoken=pgfqpoint
letpgfsyssoftpath@curvetotoken=pgfqpoint
letpgfsyssoftpath@curvetosupportatoken=pgfqpoint
letpgfsyssoftpath@curvetosupportbtoken=pgfqpoint
csname knot@string@knot@strendcsname
globalpgf@xa=pgf@x
globalpgf@ya=pgf@y
endgroup
node[circle,fill=white,fill opacity=.5] at (pgf@xa,pgf@ya) {knot@str};
fi
}
pgfmathtruncatemacro{knot@stam}{thevalue{knot@strings}-1}
foreach knot@sta in {1,...,knot@stam} {
pgfmathtruncatemacro{knot@stap}{knot@sta + 1}
foreach knot@stb in {knot@stap,...,thevalue{knot@strings}} {
pgfintersectionofpaths{expandafterpgfsetpathcsname knot@string@knot@staendcsname}{expandafterpgfsetpathcsname knot@string@knot@stbendcsname}
foreach intsect in {1,...,pgfintersectionsolutions} {
pgfpointintersectionsolution{intsect}
pgfgetlastxy{intsectx}{intsecty}
ifknot@draftmode
node[circle,fill=white,fill opacity=.5] at (intsectx,intsecty) {knot@sta-knot@stb-intsect};
else
@ifundefined{knot@crossing@knot@sta-knot@stb-intsect}{
%message{knot@sta-knot@stb-intsect not defined}
}{
pgfmathtruncatemacro{knot@under}{csname knot@crossing@knot@sta-knot@stb-intsectendcsname == knot@sta ? knot@stb : knot@sta}
expandafterletexpandafterknot@overcsname knot@crossing@knot@sta-knot@stb-intsectendcsname
pgfscope
clip (intsectx,intsecty) circle[radius=10pt];
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@underendcsname,use knot path=csname knot@string@knot@underendcsname] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname,white,line width=3pgflinewidth] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname] (0,0);
endpgfscope
}
fi
}
}
}
}
newcommand{strand}[1]{%
stepcounter{knot@strings}%
expandafterdefcsname knot@string@opts@thevalue{knot@strings}endcsname{#1}%
path[save knot path=csname knot@string@thevalue{knot@strings}endcsname]}
newcommand{crossing}[2]{%
expandafterdefcsname knot@crossing@#1endcsname{#2}}
makeatother
begin{document}
begin{tikzpicture}
begin{knot}[knot/draft mode]
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
begin{tikzpicture}
begin{knot}
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
end{document}
Result (draft version on top):
Hopefully the syntax is obvious enough from the example. (It looks a lot nicer in the original PDF; the conversion to PNG is awful!). There are lots of places for improvement, but I thought I'd see if this was on the right track before polishing it.
Andrew, comments posted in the forum.
– Jamie Vicary
Oct 22 '11 at 14:05
Thanks! It doesn't work withscale
other than 1, so I wasn't seeing the crossings. With noscale
argument, everything is beautiful.
– Jack Schmidt
Nov 8 '11 at 19:44
@JackSchmidt: Where were you putting thescale
? Can you post an example in the chatroom chat.stackexchange.com/rooms/409/from-answers-to-packages (if you cut-and-paste code then you can post large blocks). It ought to work with transformations (in the sense that if it doesn't then I should fix it so that it does). The chatroom is a better location for discussing features and bugs.
– Loop Space
Nov 8 '11 at 19:51
add a comment |
Update: This is now available on CTAN (see above). Bugfixes and improvements will generally be available on github before being uploaded to CTAN. Note that that repository is quite cluttered, the relevant .dtx
file is called spath3.dtx
. This generates all the necessary files.
Update: The code has undergone considerable revision following extensive discussion with Jamie in the chat room From Answers to Packages. The code can now be downloaded from the TeX-SX Launchpad Project. The necessary files are knots.dtx
and spath.dtx
. The file knots_test.tex
contains some example code. To create the .sty
files from the .dtx
, run tex <file>.dtx
. Alternatively, running latex (or pdflatex) on knots_test.tex
with shell escapes enabled will automatically generate the .sty
files.
Okay, here's my first attempt at implementing what we discussed in chat. It is certainly a bit rough around the edges, and I give absolutely no guarantees that it won't TeX your cat instead.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections}
makeatletter
newcounter{knot@strings}
newififknot@draftmode
tikzoption{save knot path}{tikz@addmode{pgfsyssoftpath@getcurrentpathknot@tmppathexpandafterglobalexpandafterlet#1=knot@tmppath}}
tikzoption{use knot path}{tikz@addmode{expandafterpgfsyssoftpath@setcurrentpath#1}}
tikzset{
knot/draft mode/.is if=knot@draftmode
}
newenvironment{knot}[1]{%
tikzset{#1}%
setcounter{knot@strings}{0}}{%
foreach knot@str in {1,...,thevalue{knot@strings}} {
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@strendcsname,use knot path=csname knot@string@knot@strendcsname] (0,0);
ifknot@draftmode
begingroup
letpgfsyssoftpath@movetotoken=pgfqpoint
letpgfsyssoftpath@linetotoken=pgfqpoint
letpgfsyssoftpath@curvetotoken=pgfqpoint
letpgfsyssoftpath@curvetosupportatoken=pgfqpoint
letpgfsyssoftpath@curvetosupportbtoken=pgfqpoint
csname knot@string@knot@strendcsname
globalpgf@xa=pgf@x
globalpgf@ya=pgf@y
endgroup
node[circle,fill=white,fill opacity=.5] at (pgf@xa,pgf@ya) {knot@str};
fi
}
pgfmathtruncatemacro{knot@stam}{thevalue{knot@strings}-1}
foreach knot@sta in {1,...,knot@stam} {
pgfmathtruncatemacro{knot@stap}{knot@sta + 1}
foreach knot@stb in {knot@stap,...,thevalue{knot@strings}} {
pgfintersectionofpaths{expandafterpgfsetpathcsname knot@string@knot@staendcsname}{expandafterpgfsetpathcsname knot@string@knot@stbendcsname}
foreach intsect in {1,...,pgfintersectionsolutions} {
pgfpointintersectionsolution{intsect}
pgfgetlastxy{intsectx}{intsecty}
ifknot@draftmode
node[circle,fill=white,fill opacity=.5] at (intsectx,intsecty) {knot@sta-knot@stb-intsect};
else
@ifundefined{knot@crossing@knot@sta-knot@stb-intsect}{
%message{knot@sta-knot@stb-intsect not defined}
}{
pgfmathtruncatemacro{knot@under}{csname knot@crossing@knot@sta-knot@stb-intsectendcsname == knot@sta ? knot@stb : knot@sta}
expandafterletexpandafterknot@overcsname knot@crossing@knot@sta-knot@stb-intsectendcsname
pgfscope
clip (intsectx,intsecty) circle[radius=10pt];
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@underendcsname,use knot path=csname knot@string@knot@underendcsname] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname,white,line width=3pgflinewidth] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname] (0,0);
endpgfscope
}
fi
}
}
}
}
newcommand{strand}[1]{%
stepcounter{knot@strings}%
expandafterdefcsname knot@string@opts@thevalue{knot@strings}endcsname{#1}%
path[save knot path=csname knot@string@thevalue{knot@strings}endcsname]}
newcommand{crossing}[2]{%
expandafterdefcsname knot@crossing@#1endcsname{#2}}
makeatother
begin{document}
begin{tikzpicture}
begin{knot}[knot/draft mode]
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
begin{tikzpicture}
begin{knot}
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
end{document}
Result (draft version on top):
Hopefully the syntax is obvious enough from the example. (It looks a lot nicer in the original PDF; the conversion to PNG is awful!). There are lots of places for improvement, but I thought I'd see if this was on the right track before polishing it.
Update: This is now available on CTAN (see above). Bugfixes and improvements will generally be available on github before being uploaded to CTAN. Note that that repository is quite cluttered, the relevant .dtx
file is called spath3.dtx
. This generates all the necessary files.
Update: The code has undergone considerable revision following extensive discussion with Jamie in the chat room From Answers to Packages. The code can now be downloaded from the TeX-SX Launchpad Project. The necessary files are knots.dtx
and spath.dtx
. The file knots_test.tex
contains some example code. To create the .sty
files from the .dtx
, run tex <file>.dtx
. Alternatively, running latex (or pdflatex) on knots_test.tex
with shell escapes enabled will automatically generate the .sty
files.
Okay, here's my first attempt at implementing what we discussed in chat. It is certainly a bit rough around the edges, and I give absolutely no guarantees that it won't TeX your cat instead.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections}
makeatletter
newcounter{knot@strings}
newififknot@draftmode
tikzoption{save knot path}{tikz@addmode{pgfsyssoftpath@getcurrentpathknot@tmppathexpandafterglobalexpandafterlet#1=knot@tmppath}}
tikzoption{use knot path}{tikz@addmode{expandafterpgfsyssoftpath@setcurrentpath#1}}
tikzset{
knot/draft mode/.is if=knot@draftmode
}
newenvironment{knot}[1]{%
tikzset{#1}%
setcounter{knot@strings}{0}}{%
foreach knot@str in {1,...,thevalue{knot@strings}} {
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@strendcsname,use knot path=csname knot@string@knot@strendcsname] (0,0);
ifknot@draftmode
begingroup
letpgfsyssoftpath@movetotoken=pgfqpoint
letpgfsyssoftpath@linetotoken=pgfqpoint
letpgfsyssoftpath@curvetotoken=pgfqpoint
letpgfsyssoftpath@curvetosupportatoken=pgfqpoint
letpgfsyssoftpath@curvetosupportbtoken=pgfqpoint
csname knot@string@knot@strendcsname
globalpgf@xa=pgf@x
globalpgf@ya=pgf@y
endgroup
node[circle,fill=white,fill opacity=.5] at (pgf@xa,pgf@ya) {knot@str};
fi
}
pgfmathtruncatemacro{knot@stam}{thevalue{knot@strings}-1}
foreach knot@sta in {1,...,knot@stam} {
pgfmathtruncatemacro{knot@stap}{knot@sta + 1}
foreach knot@stb in {knot@stap,...,thevalue{knot@strings}} {
pgfintersectionofpaths{expandafterpgfsetpathcsname knot@string@knot@staendcsname}{expandafterpgfsetpathcsname knot@string@knot@stbendcsname}
foreach intsect in {1,...,pgfintersectionsolutions} {
pgfpointintersectionsolution{intsect}
pgfgetlastxy{intsectx}{intsecty}
ifknot@draftmode
node[circle,fill=white,fill opacity=.5] at (intsectx,intsecty) {knot@sta-knot@stb-intsect};
else
@ifundefined{knot@crossing@knot@sta-knot@stb-intsect}{
%message{knot@sta-knot@stb-intsect not defined}
}{
pgfmathtruncatemacro{knot@under}{csname knot@crossing@knot@sta-knot@stb-intsectendcsname == knot@sta ? knot@stb : knot@sta}
expandafterletexpandafterknot@overcsname knot@crossing@knot@sta-knot@stb-intsectendcsname
pgfscope
clip (intsectx,intsecty) circle[radius=10pt];
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@underendcsname,use knot path=csname knot@string@knot@underendcsname] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname,white,line width=3pgflinewidth] (0,0);
expandafterexpandafterexpandafterdrawexpandafterexpandafterexpandafter[csname knot@string@opts@knot@overendcsname,use knot path=csname knot@string@knot@overendcsname] (0,0);
endpgfscope
}
fi
}
}
}
}
newcommand{strand}[1]{%
stepcounter{knot@strings}%
expandafterdefcsname knot@string@opts@thevalue{knot@strings}endcsname{#1}%
path[save knot path=csname knot@string@thevalue{knot@strings}endcsname]}
newcommand{crossing}[2]{%
expandafterdefcsname knot@crossing@#1endcsname{#2}}
makeatother
begin{document}
begin{tikzpicture}
begin{knot}[knot/draft mode]
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
begin{tikzpicture}
begin{knot}
strand[red,ultra thick] (0,0) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1);
strand[blue,ultra thick] (0,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1) .. controls +(1,0) and +(-1,0) .. ++(2,1) .. controls +(1,0) and +(-1,0) .. ++(2,-1);
crossing{1-2-1}{1}
crossing{1-2-2}{2}
crossing{1-2-3}{1}
crossing{1-2-4}{2}
end{knot}
end{tikzpicture}
end{document}
Result (draft version on top):
Hopefully the syntax is obvious enough from the example. (It looks a lot nicer in the original PDF; the conversion to PNG is awful!). There are lots of places for improvement, but I thought I'd see if this was on the right track before polishing it.
edited Oct 28 '17 at 9:11
answered Oct 21 '11 at 23:06
Loop SpaceLoop Space
113k29306609
113k29306609
Andrew, comments posted in the forum.
– Jamie Vicary
Oct 22 '11 at 14:05
Thanks! It doesn't work withscale
other than 1, so I wasn't seeing the crossings. With noscale
argument, everything is beautiful.
– Jack Schmidt
Nov 8 '11 at 19:44
@JackSchmidt: Where were you putting thescale
? Can you post an example in the chatroom chat.stackexchange.com/rooms/409/from-answers-to-packages (if you cut-and-paste code then you can post large blocks). It ought to work with transformations (in the sense that if it doesn't then I should fix it so that it does). The chatroom is a better location for discussing features and bugs.
– Loop Space
Nov 8 '11 at 19:51
add a comment |
Andrew, comments posted in the forum.
– Jamie Vicary
Oct 22 '11 at 14:05
Thanks! It doesn't work withscale
other than 1, so I wasn't seeing the crossings. With noscale
argument, everything is beautiful.
– Jack Schmidt
Nov 8 '11 at 19:44
@JackSchmidt: Where were you putting thescale
? Can you post an example in the chatroom chat.stackexchange.com/rooms/409/from-answers-to-packages (if you cut-and-paste code then you can post large blocks). It ought to work with transformations (in the sense that if it doesn't then I should fix it so that it does). The chatroom is a better location for discussing features and bugs.
– Loop Space
Nov 8 '11 at 19:51
Andrew, comments posted in the forum.
– Jamie Vicary
Oct 22 '11 at 14:05
Andrew, comments posted in the forum.
– Jamie Vicary
Oct 22 '11 at 14:05
Thanks! It doesn't work with
scale
other than 1, so I wasn't seeing the crossings. With no scale
argument, everything is beautiful.– Jack Schmidt
Nov 8 '11 at 19:44
Thanks! It doesn't work with
scale
other than 1, so I wasn't seeing the crossings. With no scale
argument, everything is beautiful.– Jack Schmidt
Nov 8 '11 at 19:44
@JackSchmidt: Where were you putting the
scale
? Can you post an example in the chatroom chat.stackexchange.com/rooms/409/from-answers-to-packages (if you cut-and-paste code then you can post large blocks). It ought to work with transformations (in the sense that if it doesn't then I should fix it so that it does). The chatroom is a better location for discussing features and bugs.– Loop Space
Nov 8 '11 at 19:51
@JackSchmidt: Where were you putting the
scale
? Can you post an example in the chatroom chat.stackexchange.com/rooms/409/from-answers-to-packages (if you cut-and-paste code then you can post large blocks). It ought to work with transformations (in the sense that if it doesn't then I should fix it so that it does). The chatroom is a better location for discussing features and bugs.– Loop Space
Nov 8 '11 at 19:51
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');
});
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%2f32125%2fknot-diagrams-in-tikz%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');
});
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');
});
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');
});
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
6
We've got a resident braids expert, Andrew Stacey, who wrote a nice package for drawing braids diagrams in TikZ. He's written a post on the TeX.sx blog: tex.blogoverflow.com/2011/09/the-braids-package
– Jake
Oct 20 '11 at 9:19
4
This is a job for Andrew Stacey.
:)
– Paulo Cereda
Oct 20 '11 at 9:28
4
We had a question a while ago on drawing braids (which is tex.stackexchange.com/q/16897/86) and which led to a package which is now on CTAN (ctan.org/pkg/braids). It (probably) needs PGF2.10. There's a slightly enhanced version at the TeX-SX launchpad site (bazaar.launchpad.net/~tex-sx/tex-sx/development/files), but I'll push the changes to CTAN when I've tested them a bit more. The blog post that Jake links has some details, the CTAN/launchpad have full documentation. If there's anything that it doesn't do that you'd like, please ask and I'll try to implement it.
– Loop Space
Oct 20 '11 at 9:36
1
Thanks everyone for your comments. I've edited the post to clarify that Andrew Stacey's package, although very cool, doesn't do the job I need!
– Jamie Vicary
Oct 21 '11 at 8:27
4
That's not a braid, that's a tangle! For more general knot-like diagrams, we also have tex.stackexchange.com/q/17181/86.
– Loop Space
Oct 21 '11 at 9:10