106 lines
2.4 KiB
TeX
106 lines
2.4 KiB
TeX
\usetikzlibrary{
|
|
knots,
|
|
hobby,
|
|
braids,
|
|
decorations.pathreplacing,
|
|
shapes.geometric,
|
|
calc
|
|
}
|
|
|
|
\ifDebugKnot
|
|
\tikzset{
|
|
knot diagram/draft mode = crossings,
|
|
knot diagram/only when rendering/.style = {
|
|
show curve endpoints,
|
|
%show curve controls
|
|
}
|
|
}
|
|
\fi
|
|
|
|
\tikzset{
|
|
circle/.style = {
|
|
line width = 0.8mm,
|
|
},
|
|
knot diagram/every strand/.append style={
|
|
line width = 0.8mm,
|
|
black
|
|
},
|
|
show curve controls/.style={
|
|
postaction=decorate,
|
|
decoration={
|
|
show path construction,
|
|
curveto code={
|
|
\draw[blue, dashed]
|
|
(\tikzinputsegmentfirst) -- (\tikzinputsegmentsupporta)
|
|
node [at end, draw, solid, red, inner sep=2pt]{}
|
|
;
|
|
|
|
\draw[blue, dashed]
|
|
(\tikzinputsegmentsupportb) -- (\tikzinputsegmentlast)
|
|
node [at start, draw, solid, red, inner sep=2pt]{}
|
|
node [at end, fill, red, ellipse, inner sep=2pt]{}
|
|
;
|
|
}
|
|
}
|
|
},
|
|
show curve endpoints/.style={
|
|
postaction=decorate,
|
|
decoration={
|
|
show path construction,
|
|
curveto code={
|
|
\node [fill, blue, ellipse, inner sep=2pt] at (\tikzinputsegmentlast) {};
|
|
}
|
|
}
|
|
},
|
|
braid/gap = 0.2,
|
|
braid/width = 5mm,
|
|
braid/height = -8mm,
|
|
braid/control factor = 0.75,
|
|
braid/nudge factor = 0.05,
|
|
braid/every strand/.style = {
|
|
line width = 0.7mm
|
|
},
|
|
bar/.style = {
|
|
% Should match braid line width
|
|
line width = 0.7mm,
|
|
fill = black
|
|
}
|
|
}
|
|
|
|
% Braid bar macro
|
|
% Argument: number of strands
|
|
\newcommand{\braidbars}[1]{
|
|
\draw[bar] ([xshift=-0.7mm]braid-1-s) rectangle (braid-#1-s);
|
|
\draw[bar] ([xshift=-0.7mm]braid-rev-1-e) rectangle (braid-rev-#1-e);
|
|
}
|
|
\newcommand{\widebraidbars}[1]{
|
|
\draw[bar] ([xshift=-0.7mm,yshift=-2mm]braid-1-s) rectangle ([yshift=2mm]braid-#1-s);
|
|
\draw[bar] ([xshift=-0.7mm,yshift=-2mm]braid-rev-1-e) rectangle ([yshift=2mm]braid-rev-#1-e);
|
|
}
|
|
|
|
% Closed braid loops
|
|
% Argument: number of strands
|
|
\newcommand{\closebraid}[1]{
|
|
\foreach \x in {1, ..., #1} {
|
|
\draw[braid/every strand, rounded corners = 4mm]
|
|
(braid-\x-s) --
|
|
([shift=(west:5*\x mm)]braid-\x-s) --
|
|
([shift=(west:5*\x mm),shift=(south:10*\x mm)]braid-\x-s) --
|
|
([shift=(east:5*\x mm),shift=(south:10*\x mm)]braid-rev-\x-e) --
|
|
([shift=(east:5*\x mm)]braid-rev-\x-e) --
|
|
(braid-rev-\x-e)
|
|
;
|
|
}
|
|
}
|
|
|
|
\newcommand{\labelbraidstart}[1]{
|
|
\foreach \x in {1, ..., #1} {
|
|
\node at ([xshift=-2mm]braid-\x-s) {$\x$};
|
|
}
|
|
}
|
|
|
|
\newcommand{\labelbraidend}[1]{
|
|
\foreach \x in {1, ..., #1} {
|
|
\node at ([xshift=2mm]braid-\x-e) {$\x$};
|
|
}
|
|
} |