Debian Codegraph @

texmf-dist/tex/latex/strands/strands.sty

raw
1 %%
2 %% This is file `strands.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% strands.dtx (with options: `package')
8 %%
9 %% This is a generated file.
10 %%
11 %% Copyright (C) 2021 by Diego Arcis <[email protected]>
12 %% --------------------------------------------------------------------
13 %% This work may be distributed and/or modified under the conditions of
14 %% the LaTeX Project Public License, either version 1.3 of this license
15 %% or (at your option) any later version.
16 %%
17 %% The latest version of this license is in:
18 %% http://www.latex-project.org/lppl.txt
19 %%
20 %% and version 1.3 or later is part of all distributions of LaTeX, that
21 %% is, version 2005/12/01 or later.
22 %%
23 %% The Current Maintainer of this work is Diego Arcis.
24 %%
25 %% This work consists of the files strands.dtx and strands.ins and they
26 %% derive the filebase strands.sty.
27 %% --------------------------------------------------------------------
28 %%
29 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
30 \ProvidesPackage{strands}[2021/07/11 v1.1 Strands]
31
32 \RequirePackage{forarray}
33 \RequirePackage{ifthen}
34 \RequirePackage{tikz}
35 \RequirePackage{xfp}
36 \RequirePackage{xstring}
37 \RequirePackage{xkeyval}
38
39 \usetikzlibrary{snakes}
40
41 \newcommand{\getelem}[3]{ % \getelem{list}{index}{\name}
42 \StrBetween[#2,\fpeval{#2+1}]{,#1,}{,}{,}[#3]
43 }
44
45 \makeatletter
46 \define@cmdkey[str]{strands}{backcolor}{}
47 \define@cmdkey[str]{strands}{bend}{}
48 \define@cmdkey[str]{strands}{bendbraid}{}
49 \define@cmdkey[str]{strands}{bendtangle}{}
50 \define@cmdkey[str]{strands}{bulletsize}{}
51 \define@cmdkey[str]{strands}{braidcross}{}
52 \define@cmdkey[str]{strands}{braidsingcross}{}
53 \define@cmdkey[str]{strands}{braidvirtcross}{}
54 \define@cmdkey[str]{strands}{coverunion}{}
55 \define@cmdkey[str]{strands}{direction}{}
56 \define@cmdkey[str]{strands}{externalize}{}
57 \define@cmdkey[str]{strands}{font}{}
58 \define@cmdkey[str]{strands}{gencharposbraid}{}
59 \define@cmdkey[str]{strands}{gencharnegbraid}{}
60 \define@cmdkey[str]{strands}{gencharvirtual}{}
61 \define@cmdkey[str]{strands}{gencharsingular}{}
62 \define@cmdkey[str]{strands}{genchartangle}{}
63 \define@cmdkey[str]{strands}{genchartie}{}
64 \define@cmdkey[str]{strands}{genchartiedtangle}{}
65 \define@cmdkey[str]{strands}{genchartrivial}{}
66 \define@cmdkey[str]{strands}{height}{}
67 \define@cmdkey[str]{strands}{labelver}{}
68 \define@cmdkey[str]{strands}{labelhor}{}
69 \define@cmdkey[str]{strands}{norma}{}
70 \define@cmdkey[str]{strands}{normb}{}
71 \define@cmdkey[str]{strands}{normcolor}{}
72 \define@cmdkey[str]{strands}{normsymbol}{}
73 \define@cmdkey[str]{strands}{nstr}{}
74 \define@cmdkey[str]{strands}{num}{}
75 \define@cmdkey[str]{strands}{rotate}{}
76 \define@cmdkey[str]{strands}{scale}{}
77 \define@cmdkey[str]{strands}{strwidth}{}
78 \define@cmdkey[str]{strands}{tiebend}{}
79 \define@cmdkey[str]{strands}{tiebull}{}
80 \define@cmdkey[str]{strands}{tiebullsize}{}
81 \define@cmdkey[str]{strands}{tiecolor}{}
82 \define@cmdkey[str]{strands}{tieheight}{}
83 \define@cmdkey[str]{strands}{tiesnake}{}
84 \define@cmdkey[str]{strands}{tiesnakeamp}{}
85 \define@cmdkey[str]{strands}{tiesnakends}{}
86 \define@cmdkey[str]{strands}{tiesnakelen}{}
87 \define@cmdkey[str]{strands}{tiestyle}{}
88 \define@cmdkey[str]{strands}{tiewidth}{}
89 \define@cmdkey[str]{strands}{timeswidth}{}
90 \define@cmdkey[str]{strands}{tkzpic}{}
91 \define@cmdkey[str]{strands}{width}{}
92
93 \presetkeys[str]{strands}{
94 backcolor=white, % color of the paper.
95 bend=45, % bend of partitions.
96 bendbraid=30, % bend for braid crossings.
97 bendtangle=45, % bend for tangles.
98 braidcross=3, % size of the braid crossing.
99 braidsingcross=1.6, % size of the singular braid crossing.
100 braidvirtcross=8, % size of the virtual braid crossing.
101 bulletsize=0.04,
102 coverunion=0.001, % extra length to cover the union of strands.
103 direction=1,
104 externalize=0, % use 1 to transform images to PDF.
105 font=0.7, % size of the fonts for labels.
106 gencharposbraid=p,
107 gencharnegbraid=n,
108 gencharvirtual=v,
109 gencharsingular=s,
110 genchartangle=t,
111 genchartie=e,
112 genchartiedtangle=f,
113 genchartrivial=i,
114 height=1, % to set the height of strands.
115 labelver=0.2,
116 labelhor=0.03,
117 norma=0, % to normalize the height above.
118 normb=0, % to normalize the height below.
119 normcolor=transparent,
120 normsymbol=-,
121 nstr=0, % number of strands.
122 num=0, % number of dots for arc partitions.
123 rotate=0, % to rotate all pictures.
124 scale=1, % to scale all pictures.
125 strwidth=0.7, % to set the width of the strands.
126 tiebend=0, % to set bend of ties.
127 tiebull=0, % bullets for ties.
128 tiebullsize=0.04,
129 tiecolor=red, % to set color of the ties.
130 tieheight=0.5, % height of ties respect to the global height.
131 tiesnake=false,
132 tiesnakeamp=1,
133 tiesnakends=0,
134 tiesnakelen=3,
135 tiestyle=dashed, % to set the type of the tie lines.
136 tiewidth=0.5, % to set the width of tie lines.
137 timeswidth=3,
138 tkzpic=1,
139 width=0.6, % to set the width between strands.
140 }{}
141
142 \setkeys[str]{strands}{}
143
144 \DeclareOptionX{backcolor}{\renewcommand{\cmdstr@strands@backcolor}{#1}}
145 \DeclareOptionX{bend}{\renewcommand{\cmdstr@strands@bend}{#1}}
146 \DeclareOptionX{bendbraid}{\renewcommand{\cmdstr@strands@bendbraid}{#1}}
147 \DeclareOptionX{bendtangle}{\renewcommand{\cmdstr@strands@bendtangle}{#1}}
148 \DeclareOptionX{braidcross}{\renewcommand{\cmdstr@strands@braidcross}{#1}}
149 \DeclareOptionX{braidsingcross}{\renewcommand{\cmdstr@strands@braidsingcross}{#1}}
150 \DeclareOptionX{braidvirtcross}{\renewcommand{\cmdstr@strands@braidvirtcross}{#1}}
151 \DeclareOptionX{bulletsize}{\renewcommand{\cmdstr@strands@bulletsize}{#1}}
152 \DeclareOptionX{coverunion}{\renewcommand{\cmdstr@strands@coverunion}{#1}}
153 \DeclareOptionX{direction}{\renewcommand{\cmdstr@strands@direction}{#1}}
154 \DeclareOptionX{externalize}{\renewcommand{\cmdstr@strands@externalize}{#1}}
155 \DeclareOptionX{font}{\renewcommand{\cmdstr@strands@font}{#1}}
156 \DeclareOptionX{gencharposbraid}{\renewcommand{\cmdstr@strands@gencharposbraid}{#1}}
157 \DeclareOptionX{gencharnegbraid}{\renewcommand{\cmdstr@strands@gencharnegbraid}{#1}}
158 \DeclareOptionX{gencharvirtual}{\renewcommand{\cmdstr@strands@gencharvirtual}{#1}}
159 \DeclareOptionX{gencharsingular}{\renewcommand{\cmdstr@strands@gencharsingular}{#1}}
160 \DeclareOptionX{genchartangle}{\renewcommand{\cmdstr@strands@genchartangle}{#1}}
161 \DeclareOptionX{genchartie}{\renewcommand{\cmdstr@strands@genchartie}{#1}}
162 \DeclareOptionX{genchartiedtangle}{\renewcommand{\cmdstr@strands@genchartiedtangle}{#1}}
163 \DeclareOptionX{height}{\renewcommand{\cmdstr@strands@height}{#1}}
164 \DeclareOptionX{labelver}{\renewcommand{\cmdstr@strands@labelver}{#1}}
165 \DeclareOptionX{labelhor}{\renewcommand{\cmdstr@strands@labelhor}{#1}}
166 \DeclareOptionX{norma}{\renewcommand{\cmdstr@strands@norma}{#1}}
167 \DeclareOptionX{normb}{\renewcommand{\cmdstr@strands@normb}{#1}}
168 \DeclareOptionX{normcolor}{\renewcommand{\cmdstr@strands@normcolor}{#1}}
169 \DeclareOptionX{nstr}{\renewcommand{\cmdstr@strands@nstr}{#1}}
170 \DeclareOptionX{num}{\renewcommand{\cmdstr@strands@num}{#1}}
171 \DeclareOptionX{rotate}{\renewcommand{\cmdstr@strands@rotate}{#1}}
172 \DeclareOptionX{scale}{\renewcommand{\cmdstr@strands@scale}{#1}}
173 \DeclareOptionX{strwidth}{\renewcommand{\cmdstr@strands@strwidth}{#1}}
174 \DeclareOptionX{tiebend}{\renewcommand{\cmdstr@strands@tiebend}{#1}}
175 \DeclareOptionX{tiebull}{\renewcommand{\cmdstr@strands@tiebull}{#1}}
176 \DeclareOptionX{tiebullsize}{\renewcommand{\cmdstr@strands@tiebullsize}{#1}}
177 \DeclareOptionX{tiecolor}{\renewcommand{\cmdstr@strands@tiecolor}{#1}}
178 \DeclareOptionX{tiesnake}{\renewcommand{\cmdstr@strands@tiesnake}{#1}}
179 \DeclareOptionX{tiestyle}{\renewcommand{\cmdstr@strands@tiestyle}{#1}}
180 \DeclareOptionX{tiewidth}{\renewcommand{\cmdstr@strands@tiewidth}{#1}}
181 \DeclareOptionX{timeswidth}{\renewcommand{\cmdstr@strands@timeswidth}{#1}}
182 \DeclareOptionX{tkzpic}{\renewcommand{\cmdstr@strands@tkzpic}{#1}}
183 \DeclareOptionX{width}{\renewcommand{\cmdstr@strands@width}{#1}}
184 \DeclareOptionX*{\PackageWarning{strands}{`\CurrentOption' ignored}} % ignore unknown options.
185 \ProcessOptionsX\relax
186
187 \ifnum\cmdstr@strands@externalize=1
188 \usetikzlibrary{external}
189 \tikzexternalize[optimize=false,prefix=strpack]
190 \fi
191
192
193 \makeatletter
194 \define@cmdkey[str]{decor}{bulla}{}
195 \define@cmdkey[str]{decor}{bullb}{}
196 \define@cmdkey[str]{decor}{bulletends}{}
197 \define@cmdkey[str]{decor}{floor}{}
198 \define@cmdkey[str]{decor}{font}{}
199 \define@cmdkey[str]{decor}{height}{}
200 \define@cmdkey[str]{decor}{labelver}{}
201 \define@cmdkey[str]{decor}{labelhor}{}
202 \define@cmdkey[str]{decor}{nstr}{}
203 \define@cmdkey[str]{decor}{type}{}
204 \define@cmdkey[str]{decor}{width}{}
205
206 \presetkeys[str]{decor}{
207 bulla=1,
208 bullb=1,
209 bulletends=\cmdstr@strands@bulletsize,
210 floor=0,
211 font=\cmdstr@strands@font,
212 height=\cmdstr@strands@height,
213 labelver=\cmdstr@strands@labelver,
214 labelhor=\cmdstr@strands@labelhor,
215 nstr=\cmdstr@strands@nstr,
216 type=3,
217 width=\cmdstr@strands@width
218 }{}
219
220 \newcommand{\decoratestrands}[1][]{
221 \setkeys[str]{decor}{#1} % set variables.
222 \foreach\ind in{0,...,\fpeval{\cmdstr@decor@nstr-1}}{
223 \ifnum \cmdstr@decor@bulla=1 % bullets above.
224 \filldraw(\fpeval{\ind*\cmdstr@decor@width},
225 \fpeval{(\cmdstr@decor@floor+1)*\cmdstr@decor@height})circle(\cmdstr@decor@bulletends);
226 \fi
227 \ifnum \cmdstr@decor@bullb=1 % bullets below.
228 \filldraw(\fpeval{\ind*\cmdstr@decor@width},
229 \fpeval{\cmdstr@decor@floor*\cmdstr@decor@height})circle(\cmdstr@decor@bulletends);
230 \fi
231 \ifnum \cmdstr@decor@type<5;
232 \ifnum \cmdstr@decor@type>0 % labels above from 1 to n.
233 \node[scale=\cmdstr@decor@font]at
234 (\fpeval{\ind*\cmdstr@decor@width},
235 \fpeval{(\cmdstr@decor@floor+1)*\cmdstr@decor@height+\cmdstr@decor@labelver})
236 {$\fpeval{\ind+1}$};
237 \fi
238 \node[scale=\cmdstr@decor@font]at
239 (\fpeval{\ind*\cmdstr@decor@width},
240 \fpeval{\cmdstr@decor@floor*\cmdstr@decor@height-\cmdstr@decor@labelver})
241 {$\ifnum\fpeval{(\cmdstr@decor@type+1)*(\cmdstr@decor@type-2)}=0{
242 \fpeval{\ind+1}
243 }\else{\ifnum\fpeval{abs(\cmdstr@decor@type)}=3{
244 \fpeval{\ind+\cmdstr@decor@nstr+1}
245 }\else{\ifnum\fpeval{abs(\cmdstr@decor@type)}=4{
246 \fpeval{\ind+1}'
247 }\fi}\fi}\fi$};
248 \fi
249 \ifnum \cmdstr@decor@type=5
250 \ifnum\ind<\fpeval{\cmdstr@decor@nstr/2} % labels from -2n to 2n.
251 \node[scale=\cmdstr@decor@font]at
252 (\fpeval{(\ind+\cmdstr@decor@nstr/2)*\cmdstr@decor@width},
253 \fpeval{(\cmdstr@decor@floor+1)*\cmdstr@decor@height+\cmdstr@decor@labelver})
254 {$\fpeval{\ind+1}$};
255 \node[scale=\cmdstr@decor@font]at
256 (\fpeval{\ind*\cmdstr@decor@width-\cmdstr@decor@labelhor},
257 \fpeval{(\cmdstr@decor@floor+1)*\cmdstr@decor@height+\cmdstr@decor@labelver})
258 {-$\fpeval{\cmdstr@decor@nstr/2-\ind}$};
259 \node[scale=\cmdstr@decor@font]at
260 (\fpeval{(\ind+\cmdstr@decor@nstr/2)*\cmdstr@decor@width},
261 \fpeval{\cmdstr@decor@floor*\cmdstr@decor@height-\cmdstr@decor@labelver})
262 {$\fpeval{\ind+\cmdstr@decor@nstr/2+1}$};
263 \node[scale=\cmdstr@decor@font]at
264 (\fpeval{\ind*\cmdstr@decor@width-\cmdstr@decor@labelhor},
265 \fpeval{\cmdstr@decor@floor*\cmdstr@decor@height-\cmdstr@decor@labelver})
266 {-$\fpeval{\cmdstr@decor@nstr-\ind}$};
267 \fi
268 \fi
269 }
270 }
271
272
273
274
275
276 \makeatletter
277 \define@cmdkey[str]{vvpart}{bend}{}
278 \define@cmdkey[str]{vvpart}{bulla}{}
279 \define@cmdkey[str]{vvpart}{bullb}{}
280 \define@cmdkey[str]{vvpart}{bulletends}{}
281 \define@cmdkey[str]{vvpart}{floor}{}
282 \define@cmdkey[str]{vvpart}{font}{}
283 \define@cmdkey[str]{vvpart}{height}{}
284 \define@cmdkey[str]{vvpart}{labelver}{}
285 \define@cmdkey[str]{vvpart}{labelhor}{}
286 \define@cmdkey[str]{vvpart}{norma}{}
287 \define@cmdkey[str]{vvpart}{normb}{}
288 \define@cmdkey[str]{vvpart}{nstr}{}
289 \define@cmdkey[str]{vvpart}{permut}{}
290 \define@cmdkey[str]{vvpart}{reflect}{}
291 \define@cmdkey[str]{vvpart}{strwidth}{}
292 \define@cmdkey[str]{vvpart}{type}{}
293 \define@cmdkey[str]{vvpart}{width}{}
294
295 \presetkeys[str]{vvpart}{
296 bend=\cmdstr@strands@bend,
297 bulla=1,
298 bullb=1,
299 bulletends=\cmdstr@strands@bulletsize,
300 floor=0,
301 font=\cmdstr@strands@font,
302 height=\cmdstr@strands@height,
303 labelver=\cmdstr@strands@labelver,
304 labelhor=\cmdstr@strands@labelhor,
305 norma=\cmdstr@strands@norma,
306 normb=\cmdstr@strands@normb,
307 nstr=\cmdstr@strands@nstr,
308 permut=0, % use 1 to draw permutations (to use with \permutation).
309 reflect=0,
310 strwidth=\cmdstr@strands@strwidth,
311 type=3,
312 width=\cmdstr@strands@width
313 }{}
314
315 \newcommand{\vvpartition}[2][]{
316 \setkeys[str]{vvpart}{#1} % set variables.
317 \node[\cmdstr@strands@normcolor]at(0,\cmdstr@vvpart@norma){\cmdstr@strands@normsymbol};
318 \node[\cmdstr@strands@normcolor]at(0,\cmdstr@vvpart@normb){\cmdstr@strands@normsymbol};
319 \StrRemoveBraces{#2}[\nobracespart]
320 \let\oldnumstrands\cmdstr@vvpart@nstr
321 \renewcommand{\cmdstr@vvpart@nstr}
322 {\fpeval{max(abs(min(\nobracespart)),abs(max(\nobracespart)),\fpeval{abs(\oldnumstrands)})}}
323 \decoratestrands[
324 bulla=\cmdstr@vvpart@bulla,
325 bullb=\cmdstr@vvpart@bullb,
326 bulletends=\cmdstr@vvpart@bulletends,
327 floor=\cmdstr@vvpart@floor,
328 font=\cmdstr@vvpart@font,
329 height=\cmdstr@vvpart@height,
330 labelver=\cmdstr@vvpart@labelver,
331 labelhor=\cmdstr@vvpart@labelhor,
332 nstr=\cmdstr@vvpart@nstr,
333 type=\cmdstr@vvpart@type,
334 width=\cmdstr@vvpart@width
335 ]
336 \foreach\ind in{0,...,\fpeval{\cmdstr@vvpart@nstr-1}}{
337 \ifnum\cmdstr@vvpart@permut=1
338 \getelem{#2}{\fpeval{\ind+1}}{\index}
339 \draw[line width=\cmdstr@vvpart@strwidth](\fpeval{\ind*\cmdstr@vvpart@width},
340 \fpeval{\cmdstr@vvpart@height+\cmdstr@vvpart@floor*\cmdstr@vvpart@height})to
341 (\fpeval{(\ifnum\fpeval{\index+0}>0 \index\else\fpeval{\ind+1}\fi-1)*
342 \cmdstr@vvpart@width},\cmdstr@vvpart@floor*\cmdstr@vvpart@height);
343 \fi
344 }
345 \ifnum\cmdstr@vvpart@permut=0 \foreach\block in{#2}{
346 \StrCount{\block}{,}[\numcom]
347 \ifnum\numcom>0\foreach\ind in {2,...,\fpeval{\numcom+1}}{
348 \getelem{\block}{\fpeval{\ind-1}}{\firbul}
349 \getelem{\block}{\ind}{\secbul}
350 \ifnum \cmdstr@vvpart@reflect=1 % reflect connections vertically.
351 \let\oldfirbul\firbul
352 \renewcommand{\firbul}{-\oldfirbul}
353 \let\oldsecbul\secbul
354 \renewcommand{\secbul}{-\oldsecbul}
355 \fi
356 \draw[line width=\cmdstr@vvpart@strwidth]
357 (\fpeval{(abs(\firbul)-1)*\cmdstr@vvpart@width},
358 \ifnum\firbul>0
359 \fpeval{(\cmdstr@vvpart@floor+1)*\cmdstr@vvpart@height}
360 \else
361 \fpeval{\cmdstr@vvpart@floor*\cmdstr@vvpart@height}
362 \fi
363 )
364 to[bend right=\ifnum \fpeval{\firbul*\secbul}>0
365 \fpeval{(\firbul/abs(\firbul))*((abs(\secbul)-abs(\firbul))/
366 abs(abs(\secbul)-abs(\firbul)))*\cmdstr@vvpart@bend}
367 \else
368 0
369 \fi]
370 (\fpeval{(abs(\secbul)-1)*\cmdstr@vvpart@width},
371 \ifnum\secbul>0
372 \fpeval{(\cmdstr@vvpart@floor+1)*\cmdstr@vvpart@height}
373 \else
374 \fpeval{\cmdstr@vvpart@floor*\cmdstr@vvpart@height}
375 \fi
376 );
377 }\fi
378 }\fi
379 }
380
381 \makeatletter
382 \define@cmdkey[str]{vpart}{bend}{}
383 \define@cmdkey[str]{vpart}{bulla}{}
384 \define@cmdkey[str]{vpart}{bullb}{}
385 \define@cmdkey[str]{vpart}{bulletends}{}
386 \define@cmdkey[str]{vpart}{floor}{}
387 \define@cmdkey[str]{vpart}{font}{}
388 \define@cmdkey[str]{vpart}{height}{}
389 \define@cmdkey[str]{vpart}{labelver}{}
390 \define@cmdkey[str]{vpart}{labelhor}{}
391 \define@cmdkey[str]{vpart}{norma}{}
392 \define@cmdkey[str]{vpart}{normb}{}
393 \define@cmdkey[str]{vpart}{nstr}{}
394 \define@cmdkey[str]{vpart}{permut}{}
395 \define@cmdkey[str]{vpart}{reflect}{}
396 \define@cmdkey[str]{vpart}{rotate}{}
397 \define@cmdkey[str]{vpart}{scale}{}
398 \define@cmdkey[str]{vpart}{strwidth}{}
399 \define@cmdkey[str]{vpart}{tkzpic}{}
400 \define@cmdkey[str]{vpart}{type}{}
401 \define@cmdkey[str]{vpart}{width}{}
402
403 \presetkeys[str]{vpart}{
404 bend=\cmdstr@strands@bend,
405 bulla=1,
406 bullb=1,
407 bulletends=\cmdstr@strands@bulletsize,
408 floor=0,
409 font=\cmdstr@strands@font,
410 height=\cmdstr@strands@height,
411 labelver=\cmdstr@strands@labelver,
412 labelhor=\cmdstr@strands@labelhor,
413 norma=\cmdstr@strands@norma,
414 normb=\cmdstr@strands@normb,
415 nstr=\cmdstr@strands@nstr,
416 permut=0, % use 1 to draw permutations (to use with \permutation).
417 reflect=0,
418 rotate=\cmdstr@strands@rotate,
419 scale=\cmdstr@strands@scale,
420 strwidth=\cmdstr@strands@strwidth,
421 tkzpic=\cmdstr@strands@tkzpic,
422 type=3,
423 width=\cmdstr@strands@width
424 }{}
425
426 \newcommand{\vpartition}[2][]{
427 \setkeys[str]{vpart}{#1} % set variables.
428 \ifthenelse{\equal{\cmdstr@vpart@tkzpic}{1}}{
429 \begin{tikzpicture}[rotate=\cmdstr@vpart@rotate,scale=\cmdstr@vpart@scale]
430 \vvpartition[
431 bend=\cmdstr@vpart@bend,
432 bulla=\cmdstr@vpart@bulla,
433 bullb=\cmdstr@vpart@bullb,
434 bulletends=\cmdstr@vpart@bulletends,
435 floor=\cmdstr@vpart@floor,
436 font=\cmdstr@vpart@font,
437 height=\cmdstr@vpart@height,
438 labelver=\cmdstr@vpart@labelver,
439 labelhor=\cmdstr@vpart@labelhor,
440 norma=\cmdstr@vpart@norma,
441 normb=\cmdstr@vpart@normb,
442 nstr=\cmdstr@vpart@nstr,
443 permut=\cmdstr@vpart@permut,
444 reflect=\cmdstr@vpart@reflect,
445 strwidth=\cmdstr@vpart@strwidth,
446 type=\cmdstr@vpart@type,
447 width=\cmdstr@vpart@width
448 ]{#2}
449 \end{tikzpicture}
450 }{
451 \vvpartition[
452 bend=\cmdstr@vpart@bend,
453 bulla=\cmdstr@vpart@bulla,
454 bullb=\cmdstr@vpart@bullb,
455 bulletends=\cmdstr@vpart@bulletends,
456 floor=\cmdstr@vpart@floor,
457 font=\cmdstr@vpart@font,
458 height=\cmdstr@vpart@height,
459 labelver=\cmdstr@vpart@labelver,
460 labelhor=\cmdstr@vpart@labelhor,
461 norma=\cmdstr@vpart@norma,
462 normb=\cmdstr@vpart@normb,
463 nstr=\cmdstr@vpart@nstr,
464 permut=\cmdstr@vpart@permut,
465 reflect=\cmdstr@vpart@reflect,
466 strwidth=\cmdstr@vpart@strwidth,
467 type=\cmdstr@vpart@type,
468 width=\cmdstr@vpart@width
469 ]{#2}
470 }
471 }
472
473
474
475
476
477 \makeatletter
478 \define@cmdkey[str]{apart}{bend}{}
479 \define@cmdkey[str]{apart}{bull}{}
480 \define@cmdkey[str]{apart}{bulletsize}{}
481 \define@cmdkey[str]{apart}{floor}{}
482 \define@cmdkey[str]{apart}{font}{}
483 \define@cmdkey[str]{apart}{labelver}{}
484 \define@cmdkey[str]{apart}{labelhor}{}
485 \define@cmdkey[str]{apart}{norma}{}
486 \define@cmdkey[str]{apart}{normb}{}
487 \define@cmdkey[str]{apart}{num}{}
488 \define@cmdkey[str]{apart}{rotate}{}
489 \define@cmdkey[str]{apart}{scale}{}
490 \define@cmdkey[str]{apart}{strwidth}{}
491 \define@cmdkey[str]{apart}{tkzpic}{}
492 \define@cmdkey[str]{apart}{type}{}
493 \define@cmdkey[str]{apart}{width}{}
494
495 \presetkeys[str]{apart}{
496 bend=\cmdstr@strands@bend,
497 bull=1,
498 bulletsize=\cmdstr@strands@bulletsize,
499 floor=0,
500 font=\cmdstr@strands@font,
501 labelver=\cmdstr@strands@labelver,
502 labelhor=\cmdstr@strands@labelhor,
503 norma=\cmdstr@strands@norma,
504 normb=\cmdstr@strands@normb,
505 num=\cmdstr@strands@num,
506 rotate=\cmdstr@strands@rotate,
507 scale=\cmdstr@strands@scale,
508 strwidth=\cmdstr@strands@strwidth,
509 tkzpic=\cmdstr@strands@tkzpic,
510 type=1,
511 width=\cmdstr@strands@width
512 }{}
513
514 \newcommand{\arcpartition}[2][]{
515 \setkeys[str]{apart}{#1}
516 \vpartition[
517 bend=\cmdstr@apart@bend,
518 bulla=0, % no bullets above.
519 bullb=\cmdstr@apart@bull,
520 bulletends=\cmdstr@apart@bulletsize,
521 floor=\cmdstr@apart@floor,
522 font=\cmdstr@apart@font,
523 labelver=\cmdstr@apart@labelver,
524 labelhor=\cmdstr@apart@labelhor,
525 norma=\cmdstr@apart@norma,
526 normb=\cmdstr@apart@normb,
527 nstr=\cmdstr@apart@num,
528 reflect=1, % put connections below.
529 rotate=\cmdstr@apart@rotate,
530 scale=\cmdstr@apart@scale,
531 strwidth=\cmdstr@apart@strwidth,
532 tkzpic=\cmdstr@apart@tkzpic,
533 type=-\cmdstr@apart@type,
534 width=\cmdstr@apart@width
535 ]{#2}
536 }
537
538
539
540
541
542 \makeatletter
543 \define@cmdkey[str]{perm}{bulla}{}
544 \define@cmdkey[str]{perm}{bullb}{}
545 \define@cmdkey[str]{perm}{bulletends}{}
546 \define@cmdkey[str]{perm}{floor}{}
547 \define@cmdkey[str]{perm}{font}{}
548 \define@cmdkey[str]{perm}{height}{}
549 \define@cmdkey[str]{perm}{labelver}{}
550 \define@cmdkey[str]{perm}{labelhor}{}
551 \define@cmdkey[str]{perm}{norma}{}
552 \define@cmdkey[str]{perm}{normb}{}
553 \define@cmdkey[str]{perm}{nstr}{}
554 \define@cmdkey[str]{perm}{rotate}{}
555 \define@cmdkey[str]{perm}{scale}{}
556 \define@cmdkey[str]{perm}{strwidth}{}
557 \define@cmdkey[str]{perm}{tkzpic}{}
558 \define@cmdkey[str]{perm}{type}{}
559 \define@cmdkey[str]{perm}{width}{}
560
561 \presetkeys[str]{perm}{
562 bulla=1,
563 bullb=1,
564 bulletends=\cmdstr@strands@bulletsize,
565 floor=0,
566 font=\cmdstr@strands@font,
567 height=\cmdstr@strands@height,
568 labelver=\cmdstr@strands@labelver,
569 labelhor=\cmdstr@strands@labelhor,
570 norma=\cmdstr@strands@norma,
571 normb=\cmdstr@strands@normb,
572 nstr=\cmdstr@strands@nstr,
573 rotate=\cmdstr@strands@rotate,
574 scale=\cmdstr@strands@scale,
575 strwidth=\cmdstr@strands@strwidth,
576 tkzpic=\cmdstr@strands@tkzpic,
577 type=2,
578 width=\cmdstr@strands@width
579 }{}
580
581 \newcommand{\permutation}[2][]{
582 \setkeys[str]{perm}{#1}
583 \vpartition[
584 bulla=\cmdstr@perm@bulla,
585 bullb=\cmdstr@perm@bullb,
586 bulletends=\cmdstr@perm@bulletends,
587 floor=\cmdstr@perm@floor,
588 font=\cmdstr@perm@font,
589 height=\cmdstr@perm@height,
590 labelver=\cmdstr@perm@labelver,
591 labelhor=\cmdstr@perm@labelhor,
592 norma=\cmdstr@perm@norma,
593 normb=\cmdstr@perm@normb,
594 nstr=\cmdstr@perm@nstr,
595 permut=1, % permutation.
596 rotate=\cmdstr@perm@rotate,
597 scale=\cmdstr@perm@scale,
598 strwidth=\cmdstr@perm@strwidth,
599 tkzpic=\cmdstr@perm@tkzpic,
600 type=\cmdstr@perm@type,
601 width=\cmdstr@perm@width
602 ]{#2}
603 }
604
605
606
607
608
609 \makeatletter
610 \define@cmdkey[str]{tpair}{above}{}
611 \define@cmdkey[str]{tpair}{bend}{}
612 \define@cmdkey[str]{tpair}{bulla}{}
613 \define@cmdkey[str]{tpair}{bullb}{}
614 \define@cmdkey[str]{tpair}{bulletends}{}
615 \define@cmdkey[str]{tpair}{floor}{}
616 \define@cmdkey[str]{tpair}{font}{}
617 \define@cmdkey[str]{tpair}{height}{}
618 \define@cmdkey[str]{tpair}{labelver}{}
619 \define@cmdkey[str]{tpair}{labelhor}{}
620 \define@cmdkey[str]{tpair}{norma}{}
621 \define@cmdkey[str]{tpair}{normb}{}
622 \define@cmdkey[str]{tpair}{nstr}{}
623 \define@cmdkey[str]{tpair}{rotate}{}
624 \define@cmdkey[str]{tpair}{scale}{}
625 \define@cmdkey[str]{tpair}{strwidth}{}
626 \define@cmdkey[str]{tpair}{tkzpic}{}
627 \define@cmdkey[str]{tpair}{type}{}
628 \define@cmdkey[str]{tpair}{width}{}
629
630 \presetkeys[str]{tpair}{
631 above=1,
632 bend=\cmdstr@strands@bend,
633 bulla=1,
634 bullb=1,
635 bulletends=\cmdstr@strands@bulletsize,
636 floor=0,
637 font=\cmdstr@strands@font,
638 height=\cmdstr@strands@height,
639 labelver=\cmdstr@strands@labelver,
640 labelhor=\cmdstr@strands@labelhor,
641 norma=\cmdstr@strands@norma,
642 normb=\cmdstr@strands@normb,
643 nstr=\cmdstr@strands@nstr,
644 rotate=\cmdstr@strands@rotate,
645 scale=\cmdstr@strands@scale,
646 strwidth=\cmdstr@strands@strwidth,
647 tkzpic=\cmdstr@strands@tkzpic,
648 type=-1,
649 width=\cmdstr@strands@width
650 }{}
651
652 \newcommand{\tiedpair}[3][]{
653 \setkeys[str]{tpair}{#1}
654 \ifthenelse{\equal{\cmdstr@tpair@tkzpic}{1}}{
655 \begin{tikzpicture}[rotate=\cmdstr@tpair@rotate,scale=\cmdstr@tpair@scale]
656 \permutation[
657 bulla=\cmdstr@tpair@bulla,
658 bullb=\cmdstr@tpair@bullb,
659 bulletends=\cmdstr@tpair@bulletends,
660 floor=\cmdstr@tpair@floor,
661 font=\cmdstr@tpair@font,
662 height=\cmdstr@tpair@height,
663 labelver=\cmdstr@tpair@labelver,
664 labelhor=\cmdstr@tpair@labelhor,
665 norma=\cmdstr@tpair@norma,
666 normb=\cmdstr@tpair@normb,
667 nstr=\cmdstr@tpair@nstr,
668 strwidth=\cmdstr@tpair@strwidth,
669 tkzpic=0,
670 type=\cmdstr@tpair@type,
671 width=\cmdstr@tpair@width
672 ]{#2}
673 \arcpartition[
674 bend=\cmdstr@tpair@bend,
675 bull=0, % no bullets.
676 bulletsize=\cmdstr@tpair@bulletsize,
677 floor=\fpeval{\cmdstr@tpair@floor+\cmdstr@tpair@above*\cmdstr@tpair@height},
678 tkzpic=0,
679 type=0, % no labels.
680 strwidth=\cmdstr@tpair@strwidth,
681 width=\cmdstr@tpair@width
682 ]{#3}
683 \end{tikzpicture}
684 }{
685 \permutation[
686 bulla=\cmdstr@tpair@bulla,
687 bullb=\cmdstr@tpair@bullb,
688 bulletends=\cmdstr@tpair@bulletends,
689 floor=\cmdstr@tpair@floor,
690 font=\cmdstr@tpair@font,
691 height=\cmdstr@tpair@height,
692 labelver=\cmdstr@tpair@labelver,
693 labelhor=\cmdstr@tpair@labelhor,
694 norma=\cmdstr@tpair@norma,
695 normb=\cmdstr@tpair@normb,
696 nstr=\cmdstr@tpair@nstr,
697 strwidth=\cmdstr@tpair@strwidth,
698 tkzpic=0,
699 type=\cmdstr@tpair@type,
700 width=\cmdstr@tpair@width
701 ]{#2}
702 \arcpartition[
703 bend=\cmdstr@tpair@bend,
704 bull=0, % no bullets.
705 floor=\fpeval{\cmdstr@tpair@floor+\cmdstr@tpair@above*\cmdstr@tpair@height},
706 tkzpic=0,
707 type=0, % no labels.
708 strwidth=\cmdstr@tpair@strwidth,
709 width=\cmdstr@tpair@width
710 ]{#3}
711 }
712 }
713
714
715
716 \makeatletter
717 \define@cmdkey[str]{tie}{bend}{}
718 \define@cmdkey[str]{tie}{bull}{}
719 \define@cmdkey[str]{tie}{bulletie}{}
720 \define@cmdkey[str]{tie}{floor}{}
721 \define@cmdkey[str]{tie}{height}{}
722 \define@cmdkey[str]{tie}{color}{}
723 \define@cmdkey[str]{tie}{snake}{}
724 \define@cmdkey[str]{tie}{snakeamp}{}
725 \define@cmdkey[str]{tie}{snakends}{}
726 \define@cmdkey[str]{tie}{snakelen}{}
727 \define@cmdkey[str]{tie}{style}{}
728 \define@cmdkey[str]{tie}{tieheight}{}
729 \define@cmdkey[str]{tie}{tiewidth}{}
730 \define@cmdkey[str]{tie}{width}{}
731
732 \presetkeys[str]{tie}{
733 bend=\cmdstr@strands@tiebend, % bend of the ties.
734 bull=1, % use 1 to use bullets, 0 otherwise.
735 bulletie=\cmdstr@strands@bulletsize,
736 color=\cmdstr@strands@tiecolor, % color of the ties.
737 floor=0, % the picture starts at floor*height.
738 height=\cmdstr@strands@height, % height of the strands.
739 snake=\cmdstr@strands@tiesnake, % true or false to snake the tie line.
740 snakeamp=\cmdstr@strands@tiesnakeamp, % snake amplitude.
741 snakends=\cmdstr@strands@tiesnakends, % snake lengths of ends.
742 snakelen=\cmdstr@strands@tiesnakelen, % snake lengths.
743 style=\cmdstr@strands@tiestyle, % type of the tie (solid, dashed, dotted, etc).
744 tieheight=\cmdstr@strands@tieheight, % height of the tie respect to the global height.
745 tiewidth=\cmdstr@strands@tiewidth, % width of the tie line.
746 width=\cmdstr@strands@width % width between strands.
747 }{}
748
749 \newcommand{\tie}[2][]{
750 \setkeys[str]{tie}{#1}
751 \foreach\elem[count=\ind]in{#2}{
752 \StrRemoveBraces{\elem}[\nobrace]
753 \getelem{\nobrace}{1}{\elemwidth} % get width of elem.
754 \getelem{\nobrace}{2}{\elemheight} % get height of elem.
755 \StrCount{\nobrace}{,}[\elemcoms]
756 \ifnum\elemcoms=0 \renewcommand{\elemheight}{\cmdstr@tie@tieheight}\fi % update height of elem.
757 \ifnum \cmdstr@tie@bull=1
758 \filldraw[\cmdstr@tie@color](\fpeval{(\elemwidth-1)*\cmdstr@tie@width},
759 \fpeval{\elemheight*\cmdstr@tie@height+\cmdstr@tie@floor*\cmdstr@tie@height})
760 circle(\cmdstr@tie@bulletie);
761 \fi
762 \ifnum\ind>1
763 \getelem{#2}{\fpeval{\ind-1}}{\prevelem}
764 \StrRemoveBraces{\prevelem}[\prevnobrace]
765 \getelem{\prevnobrace}{1}{\prevelemwidth}
766 \getelem{\prevnobrace}{2}{\prevelemheight}
767 \StrCount{\prevnobrace}{,}[\prevelemcoms]
768 \ifnum\prevelemcoms=0 \renewcommand{\prevelemheight}{\cmdstr@tie@tieheight}\fi
769 \draw[
770 bend right=\cmdstr@tie@bend,
771 color=\cmdstr@tie@color,
772 line width=\cmdstr@tie@tiewidth,
773 decorate=\cmdstr@tie@snake,
774 decoration={
775 snake,
776 amplitude=\cmdstr@tie@snakeamp,
777 post length=\cmdstr@tie@snakends,
778 pre length=\cmdstr@tie@snakends,
779 segment length=\cmdstr@tie@snakelen
780 },
781 style=\cmdstr@tie@style
782 ]
783 (\fpeval{(\elemwidth-1)*\cmdstr@tie@width},
784 \fpeval{\elemheight*\cmdstr@tie@height+\cmdstr@tie@floor*\cmdstr@tie@height})to
785 (\fpeval{(\prevelemwidth-1)*\cmdstr@tie@width},
786 \fpeval{\prevelemheight*\cmdstr@tie@height+\cmdstr@tie@floor*\cmdstr@tie@height});
787 \fi
788 }
789 }
790
791
792 \makeatletter
793 \define@cmdkey[str]{bbackstr}{cdnx}{}
794 \define@cmdkey[str]{bbackstr}{cdny}{}
795 \define@cmdkey[str]{bbackstr}{color}{}
796 \define@cmdkey[str]{bbackstr}{height}{}
797 \define@cmdkey[str]{bbackstr}{strwidth}{}
798 \define@cmdkey[str]{bbackstr}{timeswidth}{}
799 \define@cmdkey[str]{bbackstr}{width}{}
800
801 \presetkeys[str]{bbackstr}{
802 cdnx=nothing,
803 cdny=nothing,
804 height=\cmdstr@strands@height,
805 strwidth=\cmdstr@strands@strwidth,
806 timeswidth=\cmdstr@strands@timeswidth, % times the width of the back line is bigger.
807 width=\cmdstr@strands@width
808 }{}
809
810 \newcommand{\bbackstrands}[1][]{ %
811 \setkeys[str]{bbackstr}{#1}
812 \draw[
813 color=\cmdstr@strands@backcolor,
814 line width=\fpeval{\cmdstr@bbackstr@timeswidth*\cmdstr@bbackstr@strwidth}pt
815 ](\cmdstr@bbackstr@cdnx,\cmdstr@bbackstr@cdny)
816 to(\cmdstr@bbackstr@cdnx,\fpeval{\cmdstr@bbackstr@cdny-\cmdstr@bbackstr@height});
817 \draw[
818 color=\cmdstr@strands@backcolor,
819 line width=\fpeval{\cmdstr@bbackstr@timeswidth*\cmdstr@bbackstr@strwidth}pt
820 ](\fpeval{\cmdstr@bbackstr@cdnx+\cmdstr@bbackstr@width},\cmdstr@bbackstr@cdny)
821 to(\fpeval{\cmdstr@bbackstr@cdnx+\cmdstr@bbackstr@width},
822 \fpeval{\cmdstr@bbackstr@cdny-\cmdstr@bbackstr@height});
823 }
824
825
826 \makeatletter
827 \define@cmdkey[str]{lleftstr}{bend}{}
828 \define@cmdkey[str]{lleftstr}{cdnx}{}
829 \define@cmdkey[str]{lleftstr}{cdny}{}
830 \define@cmdkey[str]{lleftstr}{color}{}
831 \define@cmdkey[str]{lleftstr}{height}{}
832 \define@cmdkey[str]{lleftstr}{strwidth}{}
833 \define@cmdkey[str]{lleftstr}{width}{}
834
835 \presetkeys[str]{lleftstr}{
836 bend=\cmdstr@strands@bendbraid,
837 cdnx=nothing,
838 cdny=nothing,
839 color=black,
840 height=\cmdstr@strands@height,
841 strwidth=\cmdstr@strands@strwidth,
842 width=\cmdstr@strands@width
843 }{}
844
845 \newcommand{\lleftstrand}[1][]{
846 \setkeys[str]{lleftstr}{#1}
847 \draw[
848 color=\cmdstr@lleftstr@color,
849 line width=\cmdstr@lleftstr@strwidth pt
850 ](\cmdstr@lleftstr@cdnx,\fpeval{\cmdstr@lleftstr@cdny+\cmdstr@strands@coverunion})
851 to[bend right=\cmdstr@lleftstr@bend]
852 (\fpeval{\cmdstr@lleftstr@cdnx+\cmdstr@lleftstr@width/2},
853 \fpeval{\cmdstr@lleftstr@cdny-\cmdstr@lleftstr@height/2})
854 to[bend left=\cmdstr@lleftstr@bend]
855 (\fpeval{\cmdstr@lleftstr@cdnx+\cmdstr@lleftstr@width},
856 \fpeval{\cmdstr@lleftstr@cdny-\cmdstr@lleftstr@height-\cmdstr@strands@coverunion});
857 }
858
859
860 \makeatletter
861 \define@cmdkey[str]{rrightstr}{bend}{}
862 \define@cmdkey[str]{rrightstr}{cdnx}{}
863 \define@cmdkey[str]{rrightstr}{cdny}{}
864 \define@cmdkey[str]{rrightstr}{color}{}
865 \define@cmdkey[str]{rrightstr}{floor}{}
866 \define@cmdkey[str]{rrightstr}{height}{}
867 \define@cmdkey[str]{rrightstr}{strwidth}{}
868 \define@cmdkey[str]{rrightstr}{width}{}
869
870 \presetkeys[str]{rrightstr}{
871 bend=\cmdstr@strands@bendbraid,
872 cdnx=nothing,
873 cdny=nothing,
874 color=black,
875 floor=0,
876 height=\cmdstr@strands@height,
877 strwidth=\cmdstr@strands@strwidth,
878 width=\cmdstr@strands@width
879 }{}
880
881 \newcommand{\rrightstrand}[1][]{ % color / init-x-coordinate / init-y-coordinate.
882 \setkeys[str]{rrightstr}{#1}
883 \draw[
884 color=\cmdstr@rrightstr@color,
885 line width=\cmdstr@rrightstr@strwidth pt
886 ](\fpeval{\cmdstr@rrightstr@cdnx+\cmdstr@rrightstr@width},
887 \fpeval{\cmdstr@rrightstr@cdny+\cmdstr@strands@coverunion})
888 to[bend left=\cmdstr@rrightstr@bend]
889 (\fpeval{\cmdstr@rrightstr@cdnx+\cmdstr@rrightstr@width/2},
890 \fpeval{\cmdstr@rrightstr@cdny-\cmdstr@rrightstr@height/2})
891 to[bend right=\cmdstr@rrightstr@bend]
892 (\cmdstr@rrightstr@cdnx,
893 \fpeval{\cmdstr@rrightstr@cdny-\cmdstr@rrightstr@height-\cmdstr@strands@coverunion});
894 }
895
896
897 \makeatletter
898 \define@cmdkey[str]{ccrossback}{cdnx}{}
899 \define@cmdkey[str]{ccrossback}{cdny}{}
900 \define@cmdkey[str]{ccrossback}{height}{}
901 \define@cmdkey[str]{ccrossback}{width}{}
902
903 \presetkeys[str]{ccrossback}{
904 cdnx=nothing,
905 cdny=nothing,
906 height=\cmdstr@strands@height,
907 width=\cmdstr@strands@width
908 }{}
909
910 \newcommand{\ccrossback}[1][]{
911 \setkeys[str]{ccrossback}{#1}
912 \filldraw[\cmdstr@strands@backcolor]
913 (\fpeval{\cmdstr@ccrossback@cdnx+\cmdstr@ccrossback@width/2},
914 \fpeval{\cmdstr@ccrossback@cdny-\cmdstr@ccrossback@height/2})
915 circle(\cmdstr@strands@braidcross pt);
916 }
917
918
919 \makeatletter
920 \define@cmdkey[str]{bbraidgen}{bend}{}
921 \define@cmdkey[str]{bbraidgen}{cdnx}{}
922 \define@cmdkey[str]{bbraidgen}{cdny}{}
923 \define@cmdkey[str]{bbraidgen}{colorleft}{}
924 \define@cmdkey[str]{bbraidgen}{coloright}{}
925 \define@cmdkey[str]{bbraidgen}{colorsingular}{}
926 \define@cmdkey[str]{bbraidgen}{colorvirtual}{}
927 \define@cmdkey[str]{bbraidgen}{height}{}
928 \define@cmdkey[str]{bbraidgen}{strwidth}{}
929 \define@cmdkey[str]{bbraidgen}{type}{}
930 \define@cmdkey[str]{bbraidgen}{width}{}
931
932 \presetkeys[str]{bbraidgen}{
933 bend=\cmdstr@strands@bendbraid,
934 cdnx=0,
935 cdny=0,
936 colorleft=black,
937 coloright=black,
938 colorsingular=black,
939 colorvirtual=black,
940 height=\cmdstr@strands@height,
941 strwidth=\cmdstr@strands@strwidth,
942 type=1, % negative-braid=-1 | positive-braid=1 | virtual-braid=2 | singular-braid=3
943 width=\cmdstr@strands@width
944 }{}
945
946 \tikzset{
947 cross/.style={ % node style to draw x--crosses inside nodes.
948 path picture={
949 \draw[black]
950 (path picture bounding box.south east)--
951 (path picture bounding box.north west)
952 (path picture bounding box.south west)--
953 (path picture bounding box.north east);
954 }
955 }
956 }
957
958 \newcommand{\bbraidgen}[1][]{
959 \setkeys[str]{bbraidgen}{#1}
960 \bbackstrands[ % trivial two-strands-braid.
961 cdnx=\cmdstr@bbraidgen@cdnx,
962 cdny=\cmdstr@bbraidgen@cdny,
963 height=\cmdstr@bbraidgen@height,
964 strwidth=\cmdstr@bbraidgen@strwidth,
965 width=\cmdstr@bbraidgen@width
966 ]
967 \ifnum\cmdstr@bbraidgen@type<1 % negative generator.
968 \rrightstrand[
969 bend=\cmdstr@bbraidgen@bend,
970 cdnx=\cmdstr@bbraidgen@cdnx,
971 cdny=\cmdstr@bbraidgen@cdny,
972 color=\cmdstr@bbraidgen@coloright,
973 height=\cmdstr@bbraidgen@height,
974 strwidth=\cmdstr@bbraidgen@strwidth,
975 width=\cmdstr@bbraidgen@width
976 ]
977 \ifnum\cmdstr@bbraidgen@type<2
978 \ccrossback[
979 cdnx=\cmdstr@bbraidgen@cdnx,
980 cdny=\cmdstr@bbraidgen@cdny,
981 height=\cmdstr@bbraidgen@height,
982 width=\cmdstr@bbraidgen@width
983 ]
984 \fi
985 \lleftstrand[
986 bend=\cmdstr@bbraidgen@bend,
987 cdnx=\cmdstr@bbraidgen@cdnx,
988 cdny=\cmdstr@bbraidgen@cdny,
989 color=\cmdstr@bbraidgen@colorleft,
990 height=\cmdstr@bbraidgen@height,
991 strwidth=\cmdstr@bbraidgen@strwidth,
992 width=\cmdstr@bbraidgen@width
993 ]
994 \else % positive generator.
995 \lleftstrand[
996 bend=\cmdstr@bbraidgen@bend,
997 cdnx=\cmdstr@bbraidgen@cdnx,
998 cdny=\cmdstr@bbraidgen@cdny,
999 color=\cmdstr@bbraidgen@colorleft,
1000 height=\cmdstr@bbraidgen@height,
1001 strwidth=\cmdstr@bbraidgen@strwidth,
1002 width=\cmdstr@bbraidgen@width
1003 ]
1004 \ifnum\cmdstr@bbraidgen@type<2 % over-under circle only if type is one.
1005 \ccrossback[
1006 cdnx=\cmdstr@bbraidgen@cdnx,
1007 cdny=\cmdstr@bbraidgen@cdny,
1008 height=\cmdstr@bbraidgen@height,
1009 width=\cmdstr@bbraidgen@width
1010 ]
1011 \fi
1012 \rrightstrand[
1013 bend=\cmdstr@bbraidgen@bend,
1014 cdnx=\cmdstr@bbraidgen@cdnx,
1015 cdny=\cmdstr@bbraidgen@cdny,
1016 color=\cmdstr@bbraidgen@coloright,
1017 height=\cmdstr@bbraidgen@height,
1018 strwidth=\cmdstr@bbraidgen@strwidth,
1019 width=\cmdstr@bbraidgen@width
1020 ]
1021 \ifnum\cmdstr@bbraidgen@type=2 % virtual crossing.
1022 \node[
1023 circle,
1024 cross,
1025 draw=\cmdstr@bbraidgen@colorvirtual,
1026 fill=\cmdstr@strands@backcolor,
1027 inner sep=0,
1028 line width=\cmdstr@bbraidgen@strwidth,
1029 minimum width=\cmdstr@strands@braidvirtcross
1030 ]
1031 at(\fpeval{\cmdstr@bbraidgen@cdnx+\cmdstr@bbraidgen@width/2},
1032 \fpeval{\cmdstr@bbraidgen@cdny-\cmdstr@bbraidgen@height/2}){};
1033 \fi
1034 \ifnum\cmdstr@bbraidgen@type=3 % singular crossing.
1035 \filldraw[\cmdstr@bbraidgen@colorsingular]
1036 (\fpeval{\cmdstr@bbraidgen@cdnx+\cmdstr@bbraidgen@width/2},
1037 \fpeval{\cmdstr@bbraidgen@cdny-\cmdstr@bbraidgen@height/2})
1038 circle(\cmdstr@strands@braidsingcross pt);
1039 \fi
1040 \fi
1041 }
1042
1043
1044 \makeatletter
1045 \define@cmdkey[str]{ttanglegen}{bend}{}
1046 \define@cmdkey[str]{ttanglegen}{cdnx}{}
1047 \define@cmdkey[str]{ttanglegen}{cdny}{}
1048 \define@cmdkey[str]{ttanglegen}{color}{}
1049 \define@cmdkey[str]{ttanglegen}{height}{}
1050 \define@cmdkey[str]{ttanglegen}{strwidth}{}
1051 \define@cmdkey[str]{ttanglegen}{tiecolor}{}
1052 \define@cmdkey[str]{ttanglegen}{tied}{}
1053 \define@cmdkey[str]{ttanglegen}{tiesnake}{}
1054 \define@cmdkey[str]{ttanglegen}{tiesnakeamp}{}
1055 \define@cmdkey[str]{ttanglegen}{tiesnakelen}{}
1056 \define@cmdkey[str]{ttanglegen}{tiesnakends}{}
1057 \define@cmdkey[str]{ttanglegen}{tiestyle}{}
1058 \define@cmdkey[str]{ttanglegen}{tiewidth}{}
1059 \define@cmdkey[str]{ttanglegen}{width}{}
1060
1061 \presetkeys[str]{ttanglegen}{
1062 bend=\cmdstr@strands@bendtangle,
1063 cdnx=0,
1064 cdny=0,
1065 color=black,
1066 height=\cmdstr@strands@height,
1067 strwidth=\cmdstr@strands@strwidth,
1068 tiecolor=\cmdstr@strands@tiecolor,
1069 tied=0,
1070 tiesnake=\cmdstr@strands@tiesnake,
1071 tiesnakeamp=\cmdstr@strands@tiesnakeamp,
1072 tiesnakelen=\cmdstr@strands@tiesnakelen,
1073 tiesnakends=\cmdstr@strands@tiesnakends,
1074 tiestyle=\cmdstr@strands@tiestyle,
1075 tiewidth=\cmdstr@strands@tiewidth,
1076 width=\cmdstr@strands@width
1077 }{}
1078
1079 \newcommand{\ttanglegen}[1][]{
1080 \setkeys[str]{ttanglegen}{#1}
1081 \bbackstrands[ % trivial two-strands-braid.
1082 cdnx=\cmdstr@ttanglegen@cdnx,
1083 cdny=\cmdstr@ttanglegen@cdny,
1084 height=\cmdstr@ttanglegen@height,
1085 strwidth=\cmdstr@ttanglegen@strwidth,
1086 width=\cmdstr@ttanglegen@width
1087 ]
1088 \draw[
1089 bend right=\cmdstr@strands@bendtangle,
1090 color=\cmdstr@ttanglegen@color,
1091 line width=\cmdstr@strands@strwidth
1092 ](\cmdstr@ttanglegen@cdnx,\fpeval{\cmdstr@ttanglegen@cdny+\cmdstr@strands@coverunion})
1093 to(\fpeval{\cmdstr@ttanglegen@cdnx+\cmdstr@ttanglegen@width/2},
1094 \fpeval{\cmdstr@ttanglegen@cdny-\cmdstr@ttanglegen@height/3+0.03})
1095 to(\fpeval{\cmdstr@ttanglegen@cdnx+\cmdstr@ttanglegen@width},
1096 \fpeval{\cmdstr@ttanglegen@cdny+\cmdstr@strands@coverunion});
1097 \draw[
1098 bend left=\cmdstr@strands@bendtangle,
1099 color=\cmdstr@ttanglegen@color,
1100 line width=\cmdstr@strands@strwidth
1101 ](\cmdstr@ttanglegen@cdnx,
1102 \fpeval{\cmdstr@ttanglegen@cdny-\cmdstr@ttanglegen@height-\cmdstr@strands@coverunion})
1103 to(\fpeval{\cmdstr@ttanglegen@cdnx+\cmdstr@ttanglegen@width/2},
1104 \fpeval{\cmdstr@ttanglegen@cdny-(2*\cmdstr@ttanglegen@height)/3-0.03})
1105 to(\fpeval{\cmdstr@ttanglegen@cdnx+\cmdstr@ttanglegen@width},
1106 \fpeval{\cmdstr@ttanglegen@cdny-\cmdstr@ttanglegen@height-\cmdstr@strands@coverunion});
1107 \ifnum\cmdstr@ttanglegen@tied=1 % tied version.
1108 \draw[
1109 color=\cmdstr@ttanglegen@tiecolor,
1110 line width=\cmdstr@ttanglegen@tiewidth,
1111 decorate=\cmdstr@ttanglegen@tiesnake,
1112 decoration={
1113 snake,
1114 amplitude=\cmdstr@ttanglegen@tiesnakeamp,
1115 post length=\cmdstr@ttanglegen@tiesnakends,
1116 pre length=\cmdstr@ttanglegen@tiesnakends,
1117 segment length=\cmdstr@ttanglegen@tiesnakelen
1118 },
1119 style=\cmdstr@ttanglegen@tiestyle
1120 ](\fpeval{\cmdstr@ttanglegen@cdnx+\cmdstr@ttanglegen@width/2},
1121 \fpeval{\cmdstr@ttanglegen@cdny-\cmdstr@ttanglegen@height/3+0.03})
1122 to(\fpeval{\cmdstr@ttanglegen@cdnx+\cmdstr@ttanglegen@width/2},
1123 \fpeval{\cmdstr@ttanglegen@cdny-(2*\cmdstr@ttanglegen@height)/3-0.03});
1124 \fi
1125 }
1126
1127
1128 \makeatletter
1129 \define@cmdkey[str]{aaddgen}{bendbraid}{}
1130 \define@cmdkey[str]{aaddgen}{bendtangle}{}
1131 \define@cmdkey[str]{aaddgen}{direction}{}
1132 \define@cmdkey[str]{aaddgen}{floor}{}
1133 \define@cmdkey[str]{aaddgen}{generator}{}
1134 \define@cmdkey[str]{aaddgen}{height}{}
1135 \define@cmdkey[str]{aaddgen}{level}{}
1136 \define@cmdkey[str]{aaddgen}{numlevs}{}
1137 \define@cmdkey[str]{aaddgen}{posx}{}
1138 \define@cmdkey[str]{aaddgen}{posy}{}
1139 \define@cmdkey[str]{aaddgen}{strwidth}{}
1140 \define@cmdkey[str]{aaddgen}{tiebull}{}
1141 \define@cmdkey[str]{aaddgen}{tiebullsize}{}
1142 \define@cmdkey[str]{aaddgen}{tiecolor}{}
1143 \define@cmdkey[str]{aaddgen}{tieheight}{}
1144 \define@cmdkey[str]{aaddgen}{tiesnake}{}
1145 \define@cmdkey[str]{aaddgen}{tiesnakeamp}{}
1146 \define@cmdkey[str]{aaddgen}{tiesnakends}{}
1147 \define@cmdkey[str]{aaddgen}{tiesnakelen}{}
1148 \define@cmdkey[str]{aaddgen}{tiestyle}{}
1149 \define@cmdkey[str]{aaddgen}{tiewidth}{}
1150 \define@cmdkey[str]{aaddgen}{width}{}
1151
1152 \presetkeys[str]{aaddgen}{
1153 bendbraid=\cmdstr@strands@bendbraid,
1154 bendtangle=\cmdstr@strands@bendtangle,
1155 direction=\cmdstr@strands@direction,
1156 floor=0,
1157 generator=s1,
1158 height=\cmdstr@strands@height,
1159 level=0,
1160 numlevs=0,
1161 posx=nothing, % internal.
1162 posy=nothing, % internal.
1163 strwidth=\cmdstr@strands@strwidth,
1164 tiebull=\cmdstr@strands@tiebull,
1165 tiebullsize=\cmdstr@strands@tiebullsize,
1166 tiecolor=\cmdstr@strands@tiecolor,
1167 tieheight=\cmdstr@strands@tieheight,
1168 tiesnake=\cmdstr@strands@tiesnake,
1169 tiesnakeamp=\cmdstr@strands@tiesnakeamp,
1170 tiesnakends=\cmdstr@strands@tiesnakends,
1171 tiesnakelen=\cmdstr@strands@tiesnakelen,
1172 tiestyle=\cmdstr@strands@tiestyle,
1173 tiewidth=\cmdstr@strands@tiewidth,
1174 width=\cmdstr@strands@width
1175 }{}
1176
1177 \newcommand{\aaddgen}[1][]{
1178 \setkeys[str]{aaddgen}{#1}
1179 \StrChar{\cmdstr@aaddgen@generator}{1}[\firstchar]
1180 \StrBehind{\cmdstr@aaddgen@generator}{\firstchar}[\numstrand]
1181 \renewcommand{\cmdstr@aaddgen@posx}{\fpeval{(\numstrand-1)*\cmdstr@aaddgen@width}}
1182 \ifnum\cmdstr@aaddgen@direction=1
1183 \renewcommand{\cmdstr@aaddgen@posy}{\fpeval{(\cmdstr@aaddgen@numlevs+2+\cmdstr@aaddgen@floor-\cmdstr@aaddgen@level)*\cmdstr@aaddgen@height}}
1184 \fi
1185 \ifnum\cmdstr@aaddgen@direction=0
1186 \renewcommand{\cmdstr@aaddgen@posy}{\fpeval{\cmdstr@aaddgen@level*\cmdstr@aaddgen@height}}
1187 \fi
1188 \ifthenelse{\equal{\firstchar}{\cmdstr@strands@gencharnegbraid}}{
1189 \bbraidgen[
1190 bend=\cmdstr@aaddgen@bendbraid,
1191 cdnx=\cmdstr@aaddgen@posx,
1192 cdny=\cmdstr@aaddgen@posy,
1193 height=\cmdstr@aaddgen@height,
1194 strwidth=\cmdstr@aaddgen@strwidth,
1195 type=-1,
1196 width=\cmdstr@aaddgen@width
1197 ]
1198 }{\ifthenelse{\equal{\firstchar}{\cmdstr@strands@gencharposbraid}}{
1199 \bbraidgen[
1200 bend=\cmdstr@aaddgen@bendbraid,
1201 cdnx=\cmdstr@aaddgen@posx,
1202 cdny=\cmdstr@aaddgen@posy,
1203 height=\cmdstr@aaddgen@height,
1204 strwidth=\cmdstr@aaddgen@strwidth,
1205 type=1,
1206 width=\cmdstr@aaddgen@width
1207 ]
1208 }{\ifthenelse{\equal{\firstchar}{\cmdstr@strands@gencharvirtual}}{
1209 \bbraidgen[
1210 bend=\cmdstr@aaddgen@bendbraid,
1211 cdnx=\cmdstr@aaddgen@posx,
1212 cdny=\cmdstr@aaddgen@posy,
1213 height=\cmdstr@aaddgen@height,
1214 strwidth=\cmdstr@aaddgen@strwidth,
1215 type=2,
1216 width=\cmdstr@aaddgen@width
1217 ]
1218 }{\ifthenelse{\equal{\firstchar}{\cmdstr@strands@gencharsingular}}{
1219 \bbraidgen[
1220 bend=\cmdstr@aaddgen@bendbraid,
1221 cdnx=\cmdstr@aaddgen@posx,
1222 cdny=\cmdstr@aaddgen@posy,
1223 height=\cmdstr@aaddgen@height,
1224 strwidth=\cmdstr@aaddgen@strwidth,
1225 type=3,
1226 width=\cmdstr@aaddgen@width
1227 ]
1228 }{\ifthenelse{\equal{\firstchar}{\cmdstr@strands@genchartangle}}{
1229 \ttanglegen[
1230 bend=\cmdstr@aaddgen@bendtangle,
1231 cdnx=\cmdstr@aaddgen@posx,
1232 cdny=\cmdstr@aaddgen@posy,
1233 height=\cmdstr@aaddgen@height,
1234 strwidth=\cmdstr@aaddgen@strwidth,
1235 tied=0,
1236 width=\cmdstr@aaddgen@width
1237 ]
1238 }{\ifthenelse{\equal{\firstchar}{\cmdstr@strands@genchartie}}{
1239 \tie[
1240 bull=\cmdstr@aaddgen@tiebull,
1241 bulletie=\cmdstr@aaddgen@tiebullsize,
1242 color=\cmdstr@aaddgen@tiecolor,
1243 height=\cmdstr@aaddgen@height,
1244 floor=\fpeval{\cmdstr@aaddgen@posy-1},
1245 snake=\cmdstr@aaddgen@tiesnake,
1246 snakeamp=\cmdstr@aaddgen@tiesnakeamp,
1247 snakelen=\cmdstr@aaddgen@tiesnakelen,
1248 snakends=\cmdstr@aaddgen@tiesnakends,
1249 style=\cmdstr@aaddgen@tiestyle,
1250 tieheight=\cmdstr@aaddgen@tieheight,
1251 tiewidth=\cmdstr@aaddgen@tiewidth,
1252 width=\cmdstr@aaddgen@width
1253 ]{\numstrand,\fpeval{\numstrand+1}}
1254 }{\ifthenelse{\equal{\firstchar}{\cmdstr@strands@genchartiedtangle}}{
1255 \ttanglegen[
1256 bend=\cmdstr@aaddgen@bendtangle,
1257 cdnx=\cmdstr@aaddgen@posx,
1258 cdny=\cmdstr@aaddgen@posy,
1259 height=\cmdstr@aaddgen@height,
1260 strwidth=\cmdstr@aaddgen@strwidth,
1261 tiecolor=\cmdstr@aaddgen@tiecolor,
1262 tied=1,
1263 tiesnake=\cmdstr@aaddgen@tiesnake,
1264 tiesnakeamp=\cmdstr@aaddgen@tiesnakeamp,
1265 tiesnakelen=\cmdstr@aaddgen@tiesnakelen,
1266 tiesnakends=\cmdstr@aaddgen@tiesnakends,
1267 tiestyle=\cmdstr@aaddgen@tiestyle,
1268 tiewidth=\cmdstr@aaddgen@tiewidth,
1269 width=\cmdstr@aaddgen@width
1270 ]
1271 }{DO NOTHING!}}}}}}} % \ifthenelse always use "else", so it will do nothing if other letter.
1272 }
1273
1274
1275 \makeatletter
1276 \define@cmdkey[str]{ggens}{bendbraid}{}
1277 \define@cmdkey[str]{ggens}{bendtangle}{}
1278 \define@cmdkey[str]{ggens}{bulla}{}
1279 \define@cmdkey[str]{ggens}{bullb}{}
1280 \define@cmdkey[str]{ggens}{bulletends}{}
1281 \define@cmdkey[str]{ggens}{direction}{}
1282 \define@cmdkey[str]{ggens}{floor}{}
1283 \define@cmdkey[str]{ggens}{font}{}
1284 \define@cmdkey[str]{ggens}{height}{}
1285 \define@cmdkey[str]{ggens}{labelver}{}
1286 \define@cmdkey[str]{ggens}{labelhor}{}
1287 \define@cmdkey[str]{ggens}{nstr}{}
1288 \define@cmdkey[str]{ggens}{nstrsave}{}
1289 \define@cmdkey[str]{ggens}{strwidth}{}
1290 \define@cmdkey[str]{ggens}{tiebull}{}
1291 \define@cmdkey[str]{ggens}{tiebullsize}{}
1292 \define@cmdkey[str]{ggens}{tiecolor}{}
1293 \define@cmdkey[str]{ggens}{tieheight}{}
1294 \define@cmdkey[str]{ggens}{tiesnake}{}
1295 \define@cmdkey[str]{ggens}{tiesnakeamp}{}
1296 \define@cmdkey[str]{ggens}{tiesnakends}{}
1297 \define@cmdkey[str]{ggens}{tiesnakelen}{}
1298 \define@cmdkey[str]{ggens}{tiestyle}{}
1299 \define@cmdkey[str]{ggens}{tiewidth}{}
1300 \define@cmdkey[str]{ggens}{type}{}
1301 \define@cmdkey[str]{ggens}{width}{}
1302
1303 \presetkeys[str]{ggens}{
1304 bendbraid=\cmdstr@strands@bendbraid,
1305 bendtangle=\cmdstr@strands@bendtangle,
1306 bulla=1,
1307 bullb=1,
1308 bulletends=\cmdstr@strands@bulletsize,
1309 direction=\cmdstr@strands@direction,
1310 floor=0,
1311 font=\cmdstr@strands@font,
1312 height=\cmdstr@strands@height,
1313 labelver=\cmdstr@strands@labelver,
1314 labelhor=\cmdstr@strands@labelhor,
1315 nstr=0,
1316 nstrsave=0,
1317 strwidth=\cmdstr@strands@strwidth,
1318 tiebull=\cmdstr@strands@tiebull,
1319 tiebullsize=\cmdstr@strands@tiebullsize,
1320 tiecolor=\cmdstr@strands@tiecolor,
1321 tieheight=\cmdstr@strands@tieheight,
1322 tiesnake=\cmdstr@strands@tiesnake,
1323 tiesnakeamp=\cmdstr@strands@tiesnakeamp,
1324 tiesnakends=\cmdstr@strands@tiesnakends,
1325 tiesnakelen=\cmdstr@strands@tiesnakelen,
1326 tiestyle=\cmdstr@strands@tiestyle,
1327 tiewidth=\cmdstr@strands@tiewidth,
1328 type=3,
1329 width=\cmdstr@strands@width
1330 }{}
1331
1332 \newcounter{levelscounter} % count levels.
1333
1334 \newcommand{\sstrands}[2][]{
1335 \setkeys[str]{ggens}{#1}
1336 \StrSubstitute{#2}{ }{}[\cmdstr@ggens@nstrsave] % remove whitespaces.
1337 \StrSubstitute{\cmdstr@ggens@nstrsave}{\cmdstr@strands@gencharposbraid}{}[\cmdstr@ggens@nstrsave]
1338 \StrSubstitute{\cmdstr@ggens@nstrsave}{\cmdstr@strands@gencharnegbraid}{}[\cmdstr@ggens@nstrsave]
1339 \StrSubstitute{\cmdstr@ggens@nstrsave}{\cmdstr@strands@gencharvirtual}{}[\cmdstr@ggens@nstrsave]
1340 \StrSubstitute{\cmdstr@ggens@nstrsave}{\cmdstr@strands@gencharsingular}{}[\cmdstr@ggens@nstrsave]
1341 \StrSubstitute{\cmdstr@ggens@nstrsave}{\cmdstr@strands@genchartangle}{}[\cmdstr@ggens@nstrsave]
1342 \StrSubstitute{\cmdstr@ggens@nstrsave}{\cmdstr@strands@genchartie}{}[\cmdstr@ggens@nstrsave]
1343 \StrSubstitute{\cmdstr@ggens@nstrsave}{\cmdstr@strands@genchartiedtangle}{}[\cmdstr@ggens@nstrsave]
1344 \StrSubstitute{\cmdstr@ggens@nstrsave}{\cmdstr@strands@genchartrivial}{}[\cmdstr@ggens@nstrsave]
1345 \StrSubstitute{\cmdstr@ggens@nstrsave}{*}{,}[\cmdstr@ggens@nstrsave]
1346 \StrSubstitute{\cmdstr@ggens@nstrsave}{-}{,}[\cmdstr@ggens@nstrsave]
1347 \let\oldnstr\cmdstr@ggens@nstr
1348 \renewcommand{\cmdstr@ggens@nstr}{\fpeval{max(max(\cmdstr@ggens@nstrsave)+1,\oldnstr)}}
1349 \StrCount{#2}{*}[\numlevs]
1350 \permutation[ % backstrands.
1351 bulla=0,
1352 bullb=0,
1353 floor=\fpeval{\cmdstr@ggens@floor/((\numlevs+1)*\cmdstr@ggens@height)}, % ??????????????
1354 height=\fpeval{(\numlevs+1)*\cmdstr@ggens@height},
1355 nstr=\cmdstr@ggens@nstr,
1356 tkzpic=0,
1357 type=0
1358 ]{1}
1359 \setcounter{levelscounter}{0}
1360 \ForEach{*}{ % for each level.
1361 \stepcounter{levelscounter}
1362 \ForEachSublevel{-}{ % for each generator in level.
1363 \aaddgen[ % add the generator.
1364 bendbraid=\cmdstr@ggens@bendbraid,
1365 bendtangle=\cmdstr@ggens@bendtangle,
1366 direction=\cmdstr@ggens@direction,
1367 floor=\cmdstr@ggens@floor,
1368 generator=\thislevelitem,
1369 height=\cmdstr@ggens@height,
1370 level=\thelevelscounter,
1371 numlevs=\numlevs,
1372 strwidth=\cmdstr@ggens@strwidth,
1373 tiebull=\cmdstr@ggens@tiebull,
1374 tiebullsize=\cmdstr@ggens@tiebullsize,
1375 tiecolor=\cmdstr@ggens@tiecolor,
1376 tieheight=\cmdstr@ggens@tieheight,
1377 tiesnake=\cmdstr@ggens@tiesnake,
1378 tiesnakeamp=\cmdstr@ggens@tiesnakeamp,
1379 tiesnakends=\cmdstr@ggens@tiesnakends,
1380 tiesnakelen=\cmdstr@ggens@tiesnakelen,
1381 tiestyle=\cmdstr@ggens@tiestyle,
1382 tiewidth=\cmdstr@ggens@tiewidth,
1383 width=\cmdstr@ggens@width
1384 ]
1385 }
1386 }{#2}
1387 \decoratestrands[
1388 bulla=\cmdstr@ggens@bulla,
1389 bullb=\cmdstr@ggens@bullb,
1390 bulletends=\cmdstr@ggens@bulletends,
1391 floor=\fpeval{\cmdstr@ggens@floor/((\numlevs+1)*\cmdstr@ggens@height)},
1392 font=\cmdstr@ggens@font,
1393 height=\fpeval{(\numlevs+1)*\cmdstr@ggens@height},
1394 labelver=\cmdstr@ggens@labelver,
1395 labelhor=\cmdstr@ggens@labelhor,
1396 nstr=\cmdstr@ggens@nstr,
1397 type=\cmdstr@ggens@type,
1398 width=\cmdstr@ggens@width
1399 ]
1400 }
1401
1402 \makeatletter
1403 \define@cmdkey[str]{gens}{bendbraid}{}
1404 \define@cmdkey[str]{gens}{bendtangle}{}
1405 \define@cmdkey[str]{gens}{bulla}{}
1406 \define@cmdkey[str]{gens}{bullb}{}
1407 \define@cmdkey[str]{gens}{bulletends}{}
1408 \define@cmdkey[str]{gens}{direction}{}
1409 \define@cmdkey[str]{gens}{floor}{}
1410 \define@cmdkey[str]{gens}{font}{}
1411 \define@cmdkey[str]{gens}{height}{}
1412 \define@cmdkey[str]{gens}{labelver}{}
1413 \define@cmdkey[str]{gens}{labelhor}{}
1414 \define@cmdkey[str]{gens}{nstr}{}
1415 \define@cmdkey[str]{gens}{nstrsave}{}
1416 \define@cmdkey[str]{gens}{rotate}{}
1417 \define@cmdkey[str]{gens}{scale}{}
1418 \define@cmdkey[str]{gens}{strwidth}{}
1419 \define@cmdkey[str]{gens}{tiebull}{}
1420 \define@cmdkey[str]{gens}{tiebullsize}{}
1421 \define@cmdkey[str]{gens}{tiecolor}{}
1422 \define@cmdkey[str]{gens}{tieheight}{}
1423 \define@cmdkey[str]{gens}{tiesnake}{}
1424 \define@cmdkey[str]{gens}{tiesnakeamp}{}
1425 \define@cmdkey[str]{gens}{tiesnakends}{}
1426 \define@cmdkey[str]{gens}{tiesnakelen}{}
1427 \define@cmdkey[str]{gens}{tiestyle}{}
1428 \define@cmdkey[str]{gens}{tiewidth}{}
1429 \define@cmdkey[str]{gens}{tkzpic}{}
1430 \define@cmdkey[str]{gens}{type}{}
1431 \define@cmdkey[str]{gens}{width}{}
1432
1433 \presetkeys[str]{gens}{
1434 bendbraid=\cmdstr@strands@bendbraid,
1435 bendtangle=\cmdstr@strands@bendtangle,
1436 bulla=1,
1437 bullb=1,
1438 bulletends=\cmdstr@strands@bulletsize,
1439 direction=\cmdstr@strands@direction,
1440 floor=0,
1441 font=\cmdstr@strands@font,
1442 height=\cmdstr@strands@height,
1443 labelver=\cmdstr@strands@labelver,
1444 labelhor=\cmdstr@strands@labelhor,
1445 nstr=0,
1446 nstrsave=0,
1447 rotate=\cmdstr@strands@rotate,
1448 scale=\cmdstr@strands@scale,
1449 strwidth=\cmdstr@strands@strwidth,
1450 tiebull=\cmdstr@strands@tiebull,
1451 tiebullsize=\cmdstr@strands@tiebullsize,
1452 tiecolor=\cmdstr@strands@tiecolor,
1453 tieheight=\cmdstr@strands@tieheight,
1454 tiesnake=\cmdstr@strands@tiesnake,
1455 tiesnakeamp=\cmdstr@strands@tiesnakeamp,
1456 tiesnakends=\cmdstr@strands@tiesnakends,
1457 tiesnakelen=\cmdstr@strands@tiesnakelen,
1458 tiestyle=\cmdstr@strands@tiestyle,
1459 tiewidth=\cmdstr@strands@tiewidth,
1460 tkzpic=\cmdstr@strands@tkzpic,
1461 type=3,
1462 width=\cmdstr@strands@width
1463 }{}
1464
1465 \newcommand{\strands}[2][]{
1466 \setkeys[str]{gens}{#1}
1467 \ifthenelse{\equal{\cmdstr@gens@tkzpic}{1}}{
1468 \begin{tikzpicture}[rotate=\cmdstr@gens@rotate,scale=\cmdstr@gens@scale]
1469 \sstrands[
1470 bendbraid=\cmdstr@gens@bendbraid,
1471 bendtangle=\cmdstr@gens@bendtangle,
1472 bulla=\cmdstr@gens@bulla,
1473 bullb=\cmdstr@gens@bullb,
1474 bulletends=\cmdstr@gens@bulletends,
1475 direction=\cmdstr@gens@direction,
1476 floor=\cmdstr@gens@floor,
1477 font=\cmdstr@gens@font,
1478 height=\cmdstr@gens@height,
1479 labelver=\cmdstr@gens@labelver,
1480 labelhor=\cmdstr@gens@labelhor,
1481 nstr=\cmdstr@gens@nstr,
1482 nstrsave=\cmdstr@gens@nstrsave,
1483 strwidth=\cmdstr@gens@strwidth,
1484 tiebull=\cmdstr@gens@tiebull,
1485 tiebullsize=\cmdstr@gens@tiebullsize,
1486 tiecolor=\cmdstr@gens@tiecolor,
1487 tieheight=\cmdstr@gens@tieheight,
1488 tiesnake=\cmdstr@gens@tiesnake,
1489 tiesnakeamp=\cmdstr@gens@tiesnakeamp,
1490 tiesnakends=\cmdstr@gens@tiesnakends,
1491 tiesnakelen=\cmdstr@gens@tiesnakelen,
1492 tiestyle=\cmdstr@gens@tiestyle,
1493 tiewidth=\cmdstr@gens@tiewidth,
1494 type=\cmdstr@gens@type,
1495 width=\cmdstr@gens@width
1496 ]{#2}
1497 \end{tikzpicture}
1498 }{
1499 \sstrands[
1500 bendbraid=\cmdstr@gens@bendbraid,
1501 bendtangle=\cmdstr@gens@bendtangle,
1502 bulla=\cmdstr@gens@bulla,
1503 bullb=\cmdstr@gens@bullb,
1504 bulletends=\cmdstr@gens@bulletends,
1505 direction=\cmdstr@gens@direction,
1506 floor=\cmdstr@gens@floor,
1507 font=\cmdstr@gens@font,
1508 height=\cmdstr@gens@height,
1509 labelver=\cmdstr@gens@labelver,
1510 labelhor=\cmdstr@gens@labelhor,
1511 nstr=\cmdstr@gens@nstr,
1512 nstrsave=\cmdstr@gens@nstrsave,
1513 strwidth=\cmdstr@gens@strwidth,
1514 tiebull=\cmdstr@gens@tiebull,
1515 tiebullsize=\cmdstr@gens@tiebullsize,
1516 tiecolor=\cmdstr@gens@tiecolor,
1517 tieheight=\cmdstr@gens@tieheight,
1518 tiesnake=\cmdstr@gens@tiesnake,
1519 tiesnakeamp=\cmdstr@gens@tiesnakeamp,
1520 tiesnakends=\cmdstr@gens@tiesnakends,
1521 tiesnakelen=\cmdstr@gens@tiesnakelen,
1522 tiestyle=\cmdstr@gens@tiestyle,
1523 tiewidth=\cmdstr@gens@tiewidth,
1524 type=\cmdstr@gens@type,
1525 width=\cmdstr@gens@width
1526 ]{#2}
1527 }
1528 }
1529
1530 \endinput
1531 %%
1532 %% End of file `strands.sty'.