| 1 |
%% |
| 2 |
%% This is file `braids.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% braids_code.dtx (with options: `package') |
| 8 |
%% ---------------------------------------------------------------- |
| 9 |
%% braids --- a TikZ library for drawing braid diagrams |
| 10 |
%% bundle version: v2.3 2024/01/09 |
| 11 |
%% E-mail: Andrew Stacey <[email protected]> |
| 12 |
%% Released under the LaTeX Project Public License v1.3c or later |
| 13 |
%% See http://www.latex-project.org/lppl.txt |
| 14 |
%% ---------------------------------------------------------------- |
| 15 |
%% |
| 16 |
\NeedsTeXFormat{LaTeX2e} |
| 17 |
\ProvidesPackage{braids}[2011/10/18 v1.1 Tikz/PGF commands for drawing braid diagrams (depreciated package)] |
| 18 |
\newif\if@braids@warning@ |
| 19 |
\@braids@warning@true |
| 20 |
\DeclareOption{nowarning}{% |
| 21 |
\@braids@warning@false |
| 22 |
} |
| 23 |
|
| 24 |
\ProcessOptions |
| 25 |
|
| 26 |
\if@braids@warning@ |
| 27 |
\PackageWarning{braids}{% |
| 28 |
This package is frozen at v1.1 from 2011/10/18 and has been reimplemented as a TikZ library; if starting with a fresh document, please consider using that instead.% |
| 29 |
}% |
| 30 |
\fi |
| 31 |
\long\def\ge@addto@macro#1#2{% |
| 32 |
\begingroup |
| 33 |
\toks@\expandafter\expandafter\expandafter{\expandafter#1#2}% |
| 34 |
\xdef#1{\the\toks@}% |
| 35 |
\endgroup} |
| 36 |
\newcommand{\braid}[1][]{% |
| 37 |
\begingroup |
| 38 |
\braid@start{#1}} |
| 39 |
\def\braid@process{% |
| 40 |
\afterassignment\braid@handle\let\braid@token=% |
| 41 |
} |
| 42 |
\def\braid@process@start{% |
| 43 |
\afterassignment\braid@handle@start\let\braid@token=% |
| 44 |
} |
| 45 |
\def\braid@handle@start{% |
| 46 |
\let\braid@next=\braid@handle |
| 47 |
\ifx\braid@token a |
| 48 |
\let\braid@next=\braid@maybe@locate |
| 49 |
\else |
| 50 |
\ifx\braid@token(%) |
| 51 |
\iffalse)\fi %Indentation hack! |
| 52 |
\let\braid@next=\braid@assign@name |
| 53 |
\else |
| 54 |
\ifx\braid@token\@sptoken |
| 55 |
\let\braid@next=\braid@process@start |
| 56 |
\fi |
| 57 |
\fi |
| 58 |
\fi |
| 59 |
\braid@next% |
| 60 |
} |
| 61 |
\let\braid@semicolon=; |
| 62 |
\let\braid@bar=| |
| 63 |
\def\braid@handle{% |
| 64 |
\let\braid@next=\braid@process |
| 65 |
\ifnum\the\catcode`\;=\active |
| 66 |
\expandafter\let\expandafter\braid@semicolon\tikz@activesemicolon |
| 67 |
\fi |
| 68 |
\ifnum\the\catcode`\|=\active |
| 69 |
\expandafter\let\expandafter\braid@bar\tikz@activebar |
| 70 |
\fi |
| 71 |
\ifx\braid@token\braid@semicolon |
| 72 |
\let\braid@next=\braid@render |
| 73 |
\else |
| 74 |
\ifx\braid@token^ |
| 75 |
\let\braid@next=\braid@sup |
| 76 |
\else |
| 77 |
\ifx\braid@token_ |
| 78 |
\let\braid@next=\braid@sub |
| 79 |
\else |
| 80 |
\ifx\braid@token- |
| 81 |
\braid@increase@levelfalse |
| 82 |
\else |
| 83 |
\ifx\braid@token1% |
| 84 |
\ifbraid@increase@level |
| 85 |
\stepcounter{braid@level} |
| 86 |
\fi |
| 87 |
\braid@increase@leveltrue |
| 88 |
\ge@addto@macro\braid@label{\braid@token}% |
| 89 |
\else |
| 90 |
\ifx\braid@token[% |
| 91 |
\let\braid@next=\braid@process@options |
| 92 |
\else |
| 93 |
\ifx\braid@token\braid@bar |
| 94 |
\edef\braid@tmp{,\expandafter\the\value{braid@level}}% |
| 95 |
\ge@addto@macro\braid@floors\braid@tmp% |
| 96 |
\else |
| 97 |
\ifx\braid@token\bgroup |
| 98 |
\braid@beginscope |
| 99 |
\else |
| 100 |
\ifx\braid@token\egroup |
| 101 |
\braid@endscope |
| 102 |
\else |
| 103 |
\ifx\braid@token\braid@olabel@strand |
| 104 |
\let\braid@next=\braid@olabel@strand |
| 105 |
\else |
| 106 |
\ifx\braid@token\braid@clabel@strand |
| 107 |
\let\braid@next=\braid@clabel@strand |
| 108 |
\else |
| 109 |
\ge@addto@macro\braid@label{\braid@token}% |
| 110 |
\fi |
| 111 |
\fi |
| 112 |
\fi |
| 113 |
\fi |
| 114 |
\fi |
| 115 |
\fi |
| 116 |
\fi |
| 117 |
\fi |
| 118 |
\fi |
| 119 |
\fi |
| 120 |
\fi |
| 121 |
\braid@next% |
| 122 |
} |
| 123 |
\def\braid@maybe@locate{% |
| 124 |
\afterassignment\braid@@maybe@locate\let\braid@token=% |
| 125 |
} |
| 126 |
\def\braid@@maybe@locate{% |
| 127 |
\let\braid@next=\braid@handle |
| 128 |
\ifx\braid@token t |
| 129 |
\let\braid@next=\braid@find@location |
| 130 |
\fi |
| 131 |
\braid@next% |
| 132 |
} |
| 133 |
\def\braid@find@location{% |
| 134 |
\afterassignment\braid@@find@location\let\braid@token=% |
| 135 |
} |
| 136 |
\def\braid@@find@location{% |
| 137 |
\let\braid@next=\braid@location@error |
| 138 |
\ifx\braid@token(%) |
| 139 |
\let\braid@next=\braid@locate |
| 140 |
\else |
| 141 |
\ifx\braid@token\@sptoken |
| 142 |
\let\braid@next=\braid@find@location |
| 143 |
\fi |
| 144 |
\fi |
| 145 |
\braid@next% |
| 146 |
} |
| 147 |
\def\braid@location@error{% |
| 148 |
\PackageWarning{braids}{Could not figure out location for braid}% |
| 149 |
\braid@process@start% |
| 150 |
} |
| 151 |
\def\braid@locate#1){% |
| 152 |
\tikz@scan@one@point\braid@relocate(#1)% |
| 153 |
} |
| 154 |
\def\braid@relocate#1{% |
| 155 |
#1\relax |
| 156 |
\advance\pgf@x by -\braid@width |
| 157 |
\pgftransformshift{\pgfqpoint{\pgf@x}{\pgf@y}} |
| 158 |
\braid@process@start% |
| 159 |
} |
| 160 |
\def\braid@assign@name#1){% |
| 161 |
\def\braid@name{#1}% |
| 162 |
\braid@process@start% |
| 163 |
} |
| 164 |
\def\braid@process@options#1]{% |
| 165 |
\tikzset{#1}% |
| 166 |
\braid@process% |
| 167 |
} |
| 168 |
\def\braid@sup#1_#2{% |
| 169 |
\g@addto@macro\braid@label{_{#2}^{#1}}% |
| 170 |
\braid@add@crossing{#2}{#1}% |
| 171 |
} |
| 172 |
\def\braid@sub#1{% |
| 173 |
\@ifnextchar^{\braid@@sub{#1}}% |
| 174 |
{\g@addto@macro\braid@label{_{#1}}\braid@add@crossing{#1}{1}}% |
| 175 |
} |
| 176 |
\def\braid@@sub#1^#2{% |
| 177 |
\g@addto@macro\braid@label{_{#1}^{#2}}% |
| 178 |
\braid@add@crossing{#1}{#2}% |
| 179 |
} |
| 180 |
\def\braid@ne{1} |
| 181 |
\def\braid@add@crossing#1#2{% |
| 182 |
\edef\braid@crossing@type{#2}% |
| 183 |
\edef\braid@this@strand{#1}% |
| 184 |
\pgfmathtruncatemacro{\braid@next@strand}{#1+1} |
| 185 |
\ifbraid@increase@level |
| 186 |
\stepcounter{braid@level} |
| 187 |
\fi |
| 188 |
\braid@increase@leveltrue |
| 189 |
\braid@tx=\braid@this@strand\braid@width |
| 190 |
\braid@ty=\value{braid@level}\braid@height |
| 191 |
\advance\braid@ty by \braid@eh |
| 192 |
\braid@nx=\braid@tx |
| 193 |
\braid@ny=\braid@ty |
| 194 |
\advance\braid@nx by \braid@width |
| 195 |
\advance\braid@ny by \braid@height |
| 196 |
\advance\braid@ty by \braid@nf\braid@height |
| 197 |
\advance\braid@ny by -\braid@nf\braid@height |
| 198 |
\braid@cy=\braid@ty |
| 199 |
\braid@dy=\braid@ny |
| 200 |
\advance\braid@cy by \braid@cf\braid@height |
| 201 |
\advance\braid@dy by -\braid@cf\braid@height |
| 202 |
\expandafter\let\expandafter\braid@this@path@origin% |
| 203 |
\csname braid@strand@\braid@this@strand @origin\endcsname |
| 204 |
\ifx\braid@this@path@origin\relax |
| 205 |
\let\braid@this@path@origin\braid@this@strand |
| 206 |
\pgfsyssoftpath@setcurrentpath{\@empty} |
| 207 |
\pgfpathmoveto{\pgfpoint{\braid@tx}{0pt}} |
| 208 |
\pgfsyssoftpath@getcurrentpath{\braid@this@path} |
| 209 |
\else |
| 210 |
\expandafter\let\expandafter\braid@this@path% |
| 211 |
\csname braid@strand@\braid@this@path@origin\endcsname |
| 212 |
\fi |
| 213 |
\expandafter\let\expandafter\braid@next@path@origin% |
| 214 |
\csname braid@strand@\braid@next@strand @origin\endcsname |
| 215 |
\ifx\braid@next@path@origin\relax |
| 216 |
\let\braid@next@path@origin\braid@next@strand |
| 217 |
\pgfsyssoftpath@setcurrentpath{\@empty} |
| 218 |
\pgfpathmoveto{\pgfpoint{\braid@nx}{0pt}} |
| 219 |
\pgfsyssoftpath@getcurrentpath{\braid@next@path} |
| 220 |
\else |
| 221 |
\expandafter\let\expandafter\braid@next@path% |
| 222 |
\csname braid@strand@\braid@next@path@origin\endcsname |
| 223 |
\fi |
| 224 |
\pgfsyssoftpath@setcurrentpath{\braid@this@path} |
| 225 |
\pgfpathlineto{\pgfqpoint{\braid@tx}{\braid@ty}} |
| 226 |
\pgfmathsetmacro{\braid@gst}{0.5 - \pgfkeysvalueof{/pgf/braid/gap}}% |
| 227 |
\pgfmathsetmacro{\braid@gend}{0.5 + \pgfkeysvalueof{/pgf/braid/gap}}% |
| 228 |
\ifx\braid@crossing@type\braid@over@cross |
| 229 |
\pgfpathcurveto{\pgfqpoint{\braid@tx}{\braid@cy}}% |
| 230 |
{\pgfqpoint{\braid@nx}{\braid@dy}}% |
| 231 |
{\pgfqpoint{\braid@nx}{\braid@ny}} |
| 232 |
\else |
| 233 |
\pgfpathcurvebetweentimecontinue{0}{\braid@gst}% |
| 234 |
{\pgfqpoint{\braid@tx}{\braid@ty}}% |
| 235 |
{\pgfqpoint{\braid@tx}{\braid@cy}}% |
| 236 |
{\pgfqpoint{\braid@nx}{\braid@dy}}% |
| 237 |
{\pgfqpoint{\braid@nx}{\braid@ny}}% |
| 238 |
\pgfpathcurvebetweentime{\braid@gend}{1}% |
| 239 |
{\pgfqpoint{\braid@tx}{\braid@ty}}% |
| 240 |
{\pgfqpoint{\braid@tx}{\braid@cy}}% |
| 241 |
{\pgfqpoint{\braid@nx}{\braid@dy}}% |
| 242 |
{\pgfqpoint{\braid@nx}{\braid@ny}} |
| 243 |
\fi |
| 244 |
\pgfsyssoftpath@getcurrentpath{\braid@this@path} |
| 245 |
\pgfsyssoftpath@setcurrentpath{\braid@next@path} |
| 246 |
\pgfpathlineto{\pgfqpoint{\braid@nx}{\braid@ty}} |
| 247 |
\ifx\braid@crossing@type\braid@over@cross |
| 248 |
\pgfpathcurvebetweentimecontinue{0}{\braid@gst}% |
| 249 |
{\pgfqpoint{\braid@nx}{\braid@ty}}% |
| 250 |
{\pgfqpoint{\braid@nx}{\braid@cy}}% |
| 251 |
{\pgfqpoint{\braid@tx}{\braid@dy}}% |
| 252 |
{\pgfqpoint{\braid@tx}{\braid@ny}} |
| 253 |
\pgfpathcurvebetweentime{\braid@gend}{1}% |
| 254 |
{\pgfqpoint{\braid@nx}{\braid@ty}}% |
| 255 |
{\pgfqpoint{\braid@nx}{\braid@cy}}% |
| 256 |
{\pgfqpoint{\braid@tx}{\braid@dy}}% |
| 257 |
{\pgfqpoint{\braid@tx}{\braid@ny}} |
| 258 |
\else |
| 259 |
\pgfpathcurveto{\pgfqpoint{\braid@nx}{\braid@cy}}% |
| 260 |
{\pgfqpoint{\braid@tx}{\braid@dy}}% |
| 261 |
{\pgfqpoint{\braid@tx}{\braid@ny}} |
| 262 |
\fi |
| 263 |
\pgfsyssoftpath@getcurrentpath{\braid@next@path} |
| 264 |
\expandafter\let% |
| 265 |
\csname braid@strand@\braid@this@path@origin \endcsname% |
| 266 |
\braid@this@path |
| 267 |
\expandafter\let% |
| 268 |
\csname braid@strand@\braid@next@path@origin \endcsname% |
| 269 |
\braid@next@path |
| 270 |
\expandafter\let% |
| 271 |
\csname braid@strand@\braid@this@strand @origin\endcsname% |
| 272 |
\braid@next@path@origin |
| 273 |
\expandafter\let% |
| 274 |
\csname braid@strand@\braid@next@strand @origin\endcsname% |
| 275 |
\braid@this@path@origin |
| 276 |
\pgfmathparse{\value{braid@strands} < \braid@next@strand ? |
| 277 |
"\noexpand\setcounter{braid@strands}{\braid@next@strand}" : ""} |
| 278 |
\pgfmathresult |
| 279 |
\braid@process% |
| 280 |
} |
| 281 |
\newcommand{\braid@olabel@strand}[3][]{% |
| 282 |
\edef\braid@tmp{{\the\value{braid@level}}}% |
| 283 |
\expandafter\ifx\csname braid@strand@#2@origin\endcsname\relax |
| 284 |
\g@addto@macro\braid@tmp{{#2}}% |
| 285 |
\else |
| 286 |
\edef\braid@tmpa{{\csname braid@strand@#2@origin\endcsname}}% |
| 287 |
\ge@addto@macro\braid@tmp{\braid@tmpa}% |
| 288 |
\fi |
| 289 |
\g@addto@macro\braid@tmp{{#3}{#1}}% |
| 290 |
\ge@addto@macro{\braid@strand@labels}{\braid@tmp}% |
| 291 |
\braid@process% |
| 292 |
} |
| 293 |
\newcommand{\braid@clabel@strand}[3][]{% |
| 294 |
\edef\braid@tmp{{\the\value{braid@level}}}% |
| 295 |
\g@addto@macro\braid@tmp{{#2}{#3}{#1}}% |
| 296 |
\ge@addto@macro{\braid@strand@labels}{\braid@tmp}% |
| 297 |
\braid@process% |
| 298 |
} |
| 299 |
\def\braid@floors@trim,{} |
| 300 |
\def\braid@render@floor{% |
| 301 |
\draw (\floorsx,\floorsy) rectangle (\floorex,\floorey); |
| 302 |
} |
| 303 |
\def\braid@render@strand@labels#1{% |
| 304 |
\def\braid@tmp{#1}% |
| 305 |
\ifx\braid@tmp\pgfutil@empty |
| 306 |
\let\braid@next=\pgfutil@gobble |
| 307 |
\else |
| 308 |
\let\braid@next=\braid@@render@strand@labels |
| 309 |
\fi |
| 310 |
\braid@next{#1}% |
| 311 |
} |
| 312 |
\def\braid@@render@strand@labels#1#2#3#4{% |
| 313 |
\begingroup |
| 314 |
\pgfscope |
| 315 |
\let\tikz@options=\pgfutil@empty |
| 316 |
\let\tikz@mode=\pgfutil@empty |
| 317 |
\let\tik@transform=\pgfutil@empty |
| 318 |
\let\tikz@fig@name=\pgfutil@empty |
| 319 |
\tikzset{/pgf/braid/strand label,#4}% |
| 320 |
\braid@nx=#2\braid@width |
| 321 |
\braid@ny=#1\braid@height |
| 322 |
\advance\braid@ny by \braid@eh |
| 323 |
\advance\braid@ny by \braid@height |
| 324 |
\pgftransformshift{\pgfqpoint{\braid@nx}{\braid@ny}}% |
| 325 |
\tikz@options |
| 326 |
\setbox\pgfnodeparttextbox=\hbox% |
| 327 |
\bgroup% |
| 328 |
\tikzset{every text node part/.try}% |
| 329 |
\ifx\tikz@textopacity\pgfutil@empty% |
| 330 |
\else% |
| 331 |
\pgfsetfillopacity{\tikz@textopacity}% |
| 332 |
\pgfsetstrokeopacity{\tikz@textopacity}% |
| 333 |
\fi% |
| 334 |
\pgfinterruptpicture% |
| 335 |
\tikz@textfont% |
| 336 |
\ifx\tikz@text@width\pgfutil@empty% |
| 337 |
\else% |
| 338 |
\begingroup% |
| 339 |
\pgfmathsetlength{\pgf@x}{\tikz@text@width}% |
| 340 |
\pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}% |
| 341 |
\tikz@text@action% |
| 342 |
\fi% |
| 343 |
\tikz@atbegin@node% |
| 344 |
\bgroup% |
| 345 |
\aftergroup\unskip% |
| 346 |
\ifx\tikz@textcolor\pgfutil@empty% |
| 347 |
\else% |
| 348 |
\pgfutil@colorlet{.}{\tikz@textcolor}% |
| 349 |
\fi% |
| 350 |
\pgfsetcolor{.}% |
| 351 |
\setbox\tikz@figbox=\box\pgfutil@voidb@x% |
| 352 |
\tikz@uninstallcommands% |
| 353 |
\tikz@halign@check% |
| 354 |
\ignorespaces% |
| 355 |
#3 |
| 356 |
\egroup |
| 357 |
\tikz@atend@node% |
| 358 |
\ifx\tikz@text@width\pgfutil@empty% |
| 359 |
\else% |
| 360 |
\pgfutil@endminipage% |
| 361 |
\endgroup% |
| 362 |
\fi% |
| 363 |
\endpgfinterruptpicture% |
| 364 |
\egroup% |
| 365 |
\ifx\tikz@text@width\pgfutil@empty% |
| 366 |
\else% |
| 367 |
\pgfmathsetlength{\pgf@x}{\tikz@text@width}% |
| 368 |
\wd\pgfnodeparttextbox=\pgf@x% |
| 369 |
\fi% |
| 370 |
\ifx\tikz@text@height\pgfutil@empty% |
| 371 |
\else% |
| 372 |
\pgfmathsetlength{\pgf@x}{\tikz@text@height}% |
| 373 |
\ht\pgfnodeparttextbox=\pgf@x% |
| 374 |
\fi% |
| 375 |
\ifx\tikz@text@depth\pgfutil@empty% |
| 376 |
\else% |
| 377 |
\pgfmathsetlength{\pgf@x}{\tikz@text@depth}% |
| 378 |
\dp\pgfnodeparttextbox=\pgf@x% |
| 379 |
\fi% |
| 380 |
\pgfmultipartnode{\tikz@shape}{\tikz@anchor}{\tikz@fig@name}{% |
| 381 |
{\begingroup\tikz@finish}% |
| 382 |
}% |
| 383 |
\endpgfscope |
| 384 |
\endgroup |
| 385 |
\braid@render@strand@labels% |
| 386 |
} |
| 387 |
\def\braid@render{ |
| 388 |
\ifx\braid@floors\@empty |
| 389 |
\else |
| 390 |
\pgfsys@beginscope |
| 391 |
\pgfsyssoftpath@setcurrentpath{\empty} |
| 392 |
\edef\braid@floors{\expandafter\braid@floors@trim\braid@floors} |
| 393 |
\braid@tx=\braid@width |
| 394 |
\advance\braid@tx by \braid@eh |
| 395 |
\braid@nx=\value{braid@strands}\braid@width |
| 396 |
\advance\braid@nx by -\braid@eh |
| 397 |
\foreach \braid@f in \braid@floors { |
| 398 |
\pgfsys@beginscope |
| 399 |
\braid@ty=\braid@f\braid@height |
| 400 |
\advance\braid@ty by \braid@eh |
| 401 |
\advance\braid@ty by \braid@height |
| 402 |
\braid@ny=\braid@ty |
| 403 |
\advance\braid@ny by \braid@height |
| 404 |
\edef\floorsx{\the\braid@tx} |
| 405 |
\edef\floorsy{\the\braid@ty} |
| 406 |
\edef\floorex{\the\braid@nx} |
| 407 |
\edef\floorey{\the\braid@ny} |
| 408 |
\let\tikz@options=\pgfutil@empty |
| 409 |
\expandafter\tikzset\expandafter{\braid@floors@style} |
| 410 |
\pgfmathtruncatemacro{\braid@ff}{\braid@f+2} |
| 411 |
\expandafter\let\expandafter\braid@floor@style% |
| 412 |
\csname braid@options@floor@\braid@ff\endcsname |
| 413 |
\ifx\braid@floor@style\relax |
| 414 |
\else |
| 415 |
\expandafter\tikzset\expandafter{\braid@floor@style}% |
| 416 |
\fi |
| 417 |
\tikz@options |
| 418 |
\braid@render@floor |
| 419 |
\pgfsys@endscope |
| 420 |
} |
| 421 |
\pgfsys@endscope |
| 422 |
\fi |
| 423 |
\stepcounter{braid@level} |
| 424 |
\foreach \braid@k in {1,...,\value{braid@strands}} { |
| 425 |
\pgfsys@beginscope |
| 426 |
\tikz@mode@drawtrue% |
| 427 |
\let\tikz@mode=\pgfutil@empty |
| 428 |
\let\tikz@options=\pgfutil@empty |
| 429 |
\braid@tx=\braid@k\braid@width |
| 430 |
\braid@ty=\value{braid@level}\braid@height |
| 431 |
\advance\braid@ty by 2\braid@eh |
| 432 |
\expandafter\let\expandafter\braid@path@origin% |
| 433 |
\csname braid@strand@\braid@k @origin\endcsname |
| 434 |
\ifx\braid@path@origin\relax |
| 435 |
\pgfsyssoftpath@setcurrentpath{\@empty} |
| 436 |
\pgfpathmoveto{\pgfqpoint{\braid@tx}{0pt}} |
| 437 |
\let\braid@path@origin\braid@k |
| 438 |
\else |
| 439 |
\expandafter\let\expandafter\braid@path% |
| 440 |
\csname braid@strand@\braid@path@origin\endcsname |
| 441 |
\pgfsyssoftpath@setcurrentpath{\braid@path} |
| 442 |
\fi |
| 443 |
\pgflineto{\pgfqpoint{\braid@tx}{\braid@ty}} |
| 444 |
\expandafter\tikzset\expandafter{\braid@style} |
| 445 |
\expandafter\let\expandafter\braid@style% |
| 446 |
\csname braid@options@strand@\braid@path@origin\endcsname |
| 447 |
\ifx\braid@style\relax |
| 448 |
\else |
| 449 |
\expandafter\tikzset\expandafter{\braid@style} |
| 450 |
\fi |
| 451 |
\braid@options |
| 452 |
\tikz@mode |
| 453 |
\tikz@options |
| 454 |
\edef\tikz@temp{\noexpand\pgfusepath{% |
| 455 |
\iftikz@mode@draw draw\fi% |
| 456 |
}}% |
| 457 |
\tikz@temp |
| 458 |
\ifx\braid@name\pgfutil@empty |
| 459 |
\else |
| 460 |
\coordinate (\braid@name-\braid@path@origin-e) at (\braid@tx,\braid@ty); |
| 461 |
\coordinate (\braid@name-rev-\braid@k-e) at (\braid@tx,\braid@ty); |
| 462 |
\braid@nx=\braid@path@origin\braid@width |
| 463 |
\coordinate (\braid@name-\braid@path@origin-s) at (\braid@nx,0pt); |
| 464 |
\coordinate (\braid@name-rev-\braid@k-s) at (\braid@nx,0pt); |
| 465 |
\fi |
| 466 |
\pgfsys@endscope |
| 467 |
} |
| 468 |
\ifx\braid@name\pgfutil@empty |
| 469 |
\else |
| 470 |
\braid@tx=\value{braid@strands}\braid@width |
| 471 |
\braid@ty=\value{braid@level}\braid@height |
| 472 |
\advance\braid@ty by 2\braid@eh |
| 473 |
\advance\braid@tx by \braid@width |
| 474 |
\braid@tx=.5\braid@tx |
| 475 |
\braid@ty=.5\braid@ty |
| 476 |
\coordinate (\braid@name) at (\braid@tx,\braid@ty); |
| 477 |
\fi |
| 478 |
\ifx\braid@strand@labels\pgfutil@empty |
| 479 |
\else |
| 480 |
\expandafter\braid@render@strand@labels\braid@strand@labels{}% |
| 481 |
\fi |
| 482 |
\pgfsys@endscope |
| 483 |
\endgroup} |
| 484 |
\def\braid@start#1{% |
| 485 |
\pgfsys@beginscope |
| 486 |
\setcounter{braid@level}{-1}% |
| 487 |
\let\braid@label\@empty |
| 488 |
\let\braid@strand@labels\@empty |
| 489 |
\let\braid@floors\@empty |
| 490 |
\let\braid@name\empty |
| 491 |
\let\clabel=\braid@clabel@strand |
| 492 |
\let\olabel=\braid@olabel@strand |
| 493 |
\pgfkeys{/pgf/braid/.cd,#1}% |
| 494 |
\ifbraid@strand@labels@origin |
| 495 |
\let\label=\braid@olabel@strand |
| 496 |
\else |
| 497 |
\let\label=\braid@clabel@strand |
| 498 |
\fi |
| 499 |
\let\braid@options\tikz@options |
| 500 |
\tikz@transform |
| 501 |
\setcounter{braid@strands}{% |
| 502 |
\pgfkeysvalueof{/pgf/braid/number of strands}}% |
| 503 |
\braid@width=\pgfkeysvalueof{/pgf/braid/width}% |
| 504 |
\braid@height=\pgfkeysvalueof{/pgf/braid/height}% |
| 505 |
\braid@eh=\pgfkeysvalueof{/pgf/braid/border height}% |
| 506 |
\pgfkeysgetvalue{/pgf/braid/control factor}{\braid@cf}% |
| 507 |
\pgfkeysgetvalue{/pgf/braid/nudge factor}{\braid@nf}% |
| 508 |
\braid@height=-\braid@height |
| 509 |
\braid@eh=-\braid@eh |
| 510 |
\braid@increase@leveltrue |
| 511 |
\braid@process@start |
| 512 |
} |
| 513 |
\newdimen\braid@width |
| 514 |
\newdimen\braid@height |
| 515 |
\newdimen\braid@tx |
| 516 |
\newdimen\braid@ty |
| 517 |
\newdimen\braid@nx |
| 518 |
\newdimen\braid@ny |
| 519 |
\newdimen\braid@cy |
| 520 |
\newdimen\braid@dy |
| 521 |
\newdimen\braid@eh |
| 522 |
\newif\ifbraid@increase@level |
| 523 |
\newif\ifbraid@strand@labels@origin |
| 524 |
\let\braid@style\pgfutil@empty |
| 525 |
\let\braid@floors@style\pgfutil@empty |
| 526 |
\def\braid@over@cross{1} |
| 527 |
\newcounter{braid@level} |
| 528 |
\newcounter{braid@strands} |
| 529 |
\pgfkeys{ |
| 530 |
/tikz/braid/.search also={/pgf}, |
| 531 |
/pgf/braid/.search also={/pgf,/tikz}, |
| 532 |
/pgf/braid/.cd, |
| 533 |
number of strands/.initial=0, |
| 534 |
height/.initial=1cm, |
| 535 |
width/.initial=1cm, |
| 536 |
gap/.initial=.1, |
| 537 |
border height/.initial=.25cm, |
| 538 |
control factor/.initial=.5, |
| 539 |
nudge factor/.initial=.05, |
| 540 |
name/.code={% |
| 541 |
\def\braid@name{#1}% |
| 542 |
}, |
| 543 |
at/.code={% |
| 544 |
\braid@relocate{#1}% |
| 545 |
}, |
| 546 |
floor command/.code={% |
| 547 |
\def\braid@render@floor{#1}% |
| 548 |
}, |
| 549 |
style strands/.code 2 args={% |
| 550 |
\def\braid@temp{#2}% |
| 551 |
\braidset{style each strand/.list={#1}}% |
| 552 |
}, |
| 553 |
style each strand/.code={% |
| 554 |
\expandafter\edef% |
| 555 |
\csname braid@options@strand@#1\endcsname{\braid@temp}% |
| 556 |
}, |
| 557 |
style floors/.code 2 args={% |
| 558 |
\def\braid@temp{#2}% |
| 559 |
\braidset{style each floor/.list={#1}}% |
| 560 |
}, |
| 561 |
style each floor/.code={% |
| 562 |
\expandafter\edef% |
| 563 |
\csname braid@options@floor@#1\endcsname{\braid@temp}% |
| 564 |
}, |
| 565 |
style all floors/.code={% |
| 566 |
\def\braid@floors@style{#1} |
| 567 |
}, |
| 568 |
strand label/.style={}, |
| 569 |
strand label by origin/.is if=braid@strand@labels@origin, |
| 570 |
} |
| 571 |
\def\braidset#1{% |
| 572 |
\pgfkeys{/pgf/braid/.cd,#1}} |
| 573 |
|
| 574 |
%% |
| 575 |
%% Copyright (C) 2011-2024 by Andrew Stacey <[email protected]> |
| 576 |
%% |
| 577 |
%% This work may be distributed and/or modified under the |
| 578 |
%% conditions of the LaTeX Project Public License (LPPL), either |
| 579 |
%% version 1.3c of this license or (at your option) any later |
| 580 |
%% version. The latest version of this license is in the file: |
| 581 |
%% |
| 582 |
%% http://www.latex-project.org/lppl.txt |
| 583 |
%% |
| 584 |
%% This work is "maintained" (as per LPPL maintenance status) by |
| 585 |
%% Andrew Stacey. |
| 586 |
%% |
| 587 |
%% This work consists of the files braids.dtx |
| 588 |
%% braids_doc.tex |
| 589 |
%% and the derived files README.txt, |
| 590 |
%% braids.ins, |
| 591 |
%% braids.pdf, |
| 592 |
%% braids.sty, |
| 593 |
%% tikzlibrarybraids.code.tex, |
| 594 |
%% braids_doc.pdf. |
| 595 |
%% |
| 596 |
%% |
| 597 |
%% End of file `braids.sty'. |