diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/braids/braids.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/braids/braids.sty | 296 |
1 files changed, 242 insertions, 54 deletions
diff --git a/Master/texmf-dist/tex/latex/braids/braids.sty b/Master/texmf-dist/tex/latex/braids/braids.sty index f7edd15f724..d9976eec067 100644 --- a/Master/texmf-dist/tex/latex/braids/braids.sty +++ b/Master/texmf-dist/tex/latex/braids/braids.sty @@ -4,21 +4,19 @@ %% %% The original source files were: %% -%% braids.dtx (with options: `package') +%% braids_code.dtx (with options: `package') %% ---------------------------------------------------------------- %% braids --- a style file for drawing braid diagrams with TikZ/PGF -%% E-mail: stacey@math.ntnu.no +%% E-mail: loopspace@mathforge.org %% Released under the LaTeX Project Public License v1.3c or later %% See http://www.latex-project.org/lppl.txt %% ---------------------------------------------------------------- %% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{braids}[2011/05/07 v1.0 Tikz/PGF commands for drawing braid diagrams] -\def\braid@pgfversion{2.10}% -\ifx\pgfversion\braid@pgfversion -\else -\PackageWarning{braids}{This package was designed using PGF2.10; you are using \pgfversion.}% -\fi +\ProvidesPackage{braids}[2011/10/18 v1.1 Tikz/PGF commands for drawing braid diagrams] +\PackageWarning{braids}{% + This package has been reimplemented as a TikZ library; if starting with a fresh document, please consider using that instead.% +}% \long\def\ge@addto@macro#1#2{% \begingroup \toks@\expandafter\expandafter\expandafter{\expandafter#1#2}% @@ -71,7 +69,14 @@ \ifx\braid@token- \braid@increase@levelfalse \else - \ifx\braid@token[ + \ifx\braid@token1% + \ifbraid@increase@level + \stepcounter{braid@level} + \fi + \braid@increase@leveltrue + \ge@addto@macro\braid@label{\braid@token}% + \else + \ifx\braid@token[% \let\braid@next=\braid@process@options \else \ifx\braid@token\braid@bar @@ -84,6 +89,12 @@ \ifx\braid@token\egroup \braid@endscope \else + \ifx\braid@token\braid@olabel@strand + \let\braid@next=\braid@olabel@strand + \else + \ifx\braid@token\braid@clabel@strand + \let\braid@next=\braid@clabel@strand + \else \ge@addto@macro\braid@label{\braid@token}% \fi \fi @@ -93,6 +104,9 @@ \fi \fi \fi + \fi + \fi + \fi \braid@next% } \def\braid@maybe@locate{% @@ -140,9 +154,18 @@ \tikzset{#1}% \braid@process% } -\def\braid@sup#1_#2{\g@addto@macro\braid@label{_{#2}^{#1}}\braid@add@crossing{#2}{#1}} -\def\braid@sub#1{\@ifnextchar^{\braid@@sub{#1}}{\g@addto@macro\braid@label{_{#1}}\braid@add@crossing{#1}{1}}} -\def\braid@@sub#1^#2{\g@addto@macro\braid@label{_{#1}^{#2}}\braid@add@crossing{#1}{#2}} +\def\braid@sup#1_#2{% + \g@addto@macro\braid@label{_{#2}^{#1}}% + \braid@add@crossing{#2}{#1}% +} +\def\braid@sub#1{% + \@ifnextchar^{\braid@@sub{#1}}% + {\g@addto@macro\braid@label{_{#1}}\braid@add@crossing{#1}{1}}% +} +\def\braid@@sub#1^#2{% + \g@addto@macro\braid@label{_{#1}^{#2}}% + \braid@add@crossing{#1}{#2}% +} \def\braid@ne{1} \def\braid@add@crossing#1#2{% \edef\braid@crossing@type{#2}% @@ -159,60 +182,197 @@ \braid@ny=\braid@ty \advance\braid@nx by \braid@width \advance\braid@ny by \braid@height + \advance\braid@ty by \braid@nf\braid@height + \advance\braid@ny by -\braid@nf\braid@height \braid@cy=\braid@ty \braid@dy=\braid@ny - \advance\braid@cy by .5\braid@height - \advance\braid@dy by -.5\braid@height - \advance\braid@ty by .05\braid@height - \advance\braid@ny by -.05\braid@height - \expandafter\let\expandafter\braid@this@path@origin\csname braid@strand@\braid@this@strand @origin\endcsname + \advance\braid@cy by \braid@cf\braid@height + \advance\braid@dy by -\braid@cf\braid@height + \expandafter\let\expandafter\braid@this@path@origin% + \csname braid@strand@\braid@this@strand @origin\endcsname \ifx\braid@this@path@origin\relax \let\braid@this@path@origin\braid@this@strand \pgfsyssoftpath@setcurrentpath{\@empty} \pgfpathmoveto{\pgfpoint{\braid@tx}{0pt}} \pgfsyssoftpath@getcurrentpath{\braid@this@path} \else - \expandafter\let\expandafter\braid@this@path\csname braid@strand@\braid@this@path@origin\endcsname + \expandafter\let\expandafter\braid@this@path% + \csname braid@strand@\braid@this@path@origin\endcsname \fi - \expandafter\let\expandafter\braid@next@path@origin\csname braid@strand@\braid@next@strand @origin\endcsname + \expandafter\let\expandafter\braid@next@path@origin% + \csname braid@strand@\braid@next@strand @origin\endcsname \ifx\braid@next@path@origin\relax \let\braid@next@path@origin\braid@next@strand \pgfsyssoftpath@setcurrentpath{\@empty} \pgfpathmoveto{\pgfpoint{\braid@nx}{0pt}} \pgfsyssoftpath@getcurrentpath{\braid@next@path} \else - \expandafter\let\expandafter\braid@next@path\csname braid@strand@\braid@next@path@origin\endcsname + \expandafter\let\expandafter\braid@next@path% + \csname braid@strand@\braid@next@path@origin\endcsname \fi \pgfsyssoftpath@setcurrentpath{\braid@this@path} \pgfpathlineto{\pgfqpoint{\braid@tx}{\braid@ty}} +\pgfmathsetmacro{\braid@gst}{0.5 - \pgfkeysvalueof{/pgf/braid/gap}}% +\pgfmathsetmacro{\braid@gend}{0.5 + \pgfkeysvalueof{/pgf/braid/gap}}% \ifx\braid@crossing@type\braid@over@cross -\pgfpathcurveto{\pgfqpoint{\braid@tx}{\braid@cy}}{\pgfqpoint{\braid@nx}{\braid@dy}}{\pgfqpoint{\braid@nx}{\braid@ny}} + \pgfpathcurveto{\pgfqpoint{\braid@tx}{\braid@cy}}% + {\pgfqpoint{\braid@nx}{\braid@dy}}% + {\pgfqpoint{\braid@nx}{\braid@ny}} \else -\pgfpathcurvebetweentimecontinue{0}{.4}{\pgfqpoint{\braid@tx}{\braid@ty}}{\pgfqpoint{\braid@tx}{\braid@cy}}{\pgfqpoint{\braid@nx}{\braid@dy}}{\pgfqpoint{\braid@nx}{\braid@ny}} -\pgfpathcurvebetweentime{.6}{1}{\pgfqpoint{\braid@tx}{\braid@ty}}{\pgfqpoint{\braid@tx}{\braid@cy}}{\pgfqpoint{\braid@nx}{\braid@dy}}{\pgfqpoint{\braid@nx}{\braid@ny}} + \pgfpathcurvebetweentimecontinue{0}{\braid@gst}% + {\pgfqpoint{\braid@tx}{\braid@ty}}% + {\pgfqpoint{\braid@tx}{\braid@cy}}% + {\pgfqpoint{\braid@nx}{\braid@dy}}% + {\pgfqpoint{\braid@nx}{\braid@ny}}% + \pgfpathcurvebetweentime{\braid@gend}{1}% + {\pgfqpoint{\braid@tx}{\braid@ty}}% + {\pgfqpoint{\braid@tx}{\braid@cy}}% + {\pgfqpoint{\braid@nx}{\braid@dy}}% + {\pgfqpoint{\braid@nx}{\braid@ny}} \fi \pgfsyssoftpath@getcurrentpath{\braid@this@path} \pgfsyssoftpath@setcurrentpath{\braid@next@path} \pgfpathlineto{\pgfqpoint{\braid@nx}{\braid@ty}} \ifx\braid@crossing@type\braid@over@cross -\pgfpathcurvebetweentimecontinue{0}{.4}{\pgfqpoint{\braid@nx}{\braid@ty}}{\pgfqpoint{\braid@nx}{\braid@cy}}{\pgfqpoint{\braid@tx}{\braid@dy}}{\pgfqpoint{\braid@tx}{\braid@ny}} -\pgfpathcurvebetweentime{.6}{1}{\pgfqpoint{\braid@nx}{\braid@ty}}{\pgfqpoint{\braid@nx}{\braid@cy}}{\pgfqpoint{\braid@tx}{\braid@dy}}{\pgfqpoint{\braid@tx}{\braid@ny}} + \pgfpathcurvebetweentimecontinue{0}{\braid@gst}% + {\pgfqpoint{\braid@nx}{\braid@ty}}% + {\pgfqpoint{\braid@nx}{\braid@cy}}% + {\pgfqpoint{\braid@tx}{\braid@dy}}% + {\pgfqpoint{\braid@tx}{\braid@ny}} + \pgfpathcurvebetweentime{\braid@gend}{1}% + {\pgfqpoint{\braid@nx}{\braid@ty}}% + {\pgfqpoint{\braid@nx}{\braid@cy}}% + {\pgfqpoint{\braid@tx}{\braid@dy}}% + {\pgfqpoint{\braid@tx}{\braid@ny}} \else - \pgfpathcurveto{\pgfqpoint{\braid@nx}{\braid@cy}}{\pgfqpoint{\braid@tx}{\braid@dy}}{\pgfqpoint{\braid@tx}{\braid@ny}} + \pgfpathcurveto{\pgfqpoint{\braid@nx}{\braid@cy}}% + {\pgfqpoint{\braid@tx}{\braid@dy}}% + {\pgfqpoint{\braid@tx}{\braid@ny}} \fi \pgfsyssoftpath@getcurrentpath{\braid@next@path} - \expandafter\let\csname braid@strand@\braid@this@path@origin \endcsname\braid@this@path - \expandafter\let\csname braid@strand@\braid@next@path@origin \endcsname\braid@next@path - \expandafter\let\csname braid@strand@\braid@this@strand @origin\endcsname\braid@next@path@origin - \expandafter\let\csname braid@strand@\braid@next@strand @origin\endcsname\braid@this@path@origin - \pgfmathparse{\value{braid@strands} < \braid@next@strand ? "\noexpand\setcounter{braid@strands}{\braid@next@strand}" : ""} + \expandafter\let% + \csname braid@strand@\braid@this@path@origin \endcsname% + \braid@this@path + \expandafter\let% + \csname braid@strand@\braid@next@path@origin \endcsname% + \braid@next@path + \expandafter\let% + \csname braid@strand@\braid@this@strand @origin\endcsname% + \braid@next@path@origin + \expandafter\let% + \csname braid@strand@\braid@next@strand @origin\endcsname% + \braid@this@path@origin + \pgfmathparse{\value{braid@strands} < \braid@next@strand ? + "\noexpand\setcounter{braid@strands}{\braid@next@strand}" : ""} \pgfmathresult \braid@process% } +\newcommand{\braid@olabel@strand}[3][]{% + \edef\braid@tmp{{\the\value{braid@level}}}% + \expandafter\ifx\csname braid@strand@#2@origin\endcsname\relax + \g@addto@macro\braid@tmp{{#2}}% + \else + \edef\braid@tmpa{{\csname braid@strand@#2@origin\endcsname}}% + \ge@addto@macro\braid@tmp{\braid@tmpa}% + \fi + \g@addto@macro\braid@tmp{{#3}{#1}}% + \ge@addto@macro{\braid@strand@labels}{\braid@tmp}% + \braid@process% +} +\newcommand{\braid@clabel@strand}[3][]{% + \edef\braid@tmp{{\the\value{braid@level}}}% + \g@addto@macro\braid@tmp{{#2}{#3}{#1}}% + \ge@addto@macro{\braid@strand@labels}{\braid@tmp}% + \braid@process% +} \def\braid@floors@trim,{} \def\braid@render@floor{% \draw (\floorsx,\floorsy) rectangle (\floorex,\floorey); } +\def\braid@render@strand@labels#1{% + \def\braid@tmp{#1}% + \ifx\braid@tmp\pgfutil@empty + \let\braid@next=\pgfutil@gobble + \else + \let\braid@next=\braid@@render@strand@labels + \fi + \braid@next{#1}% +} +\def\braid@@render@strand@labels#1#2#3#4{% + \begingroup + \pgfscope + \let\tikz@options=\pgfutil@empty + \let\tikz@mode=\pgfutil@empty + \let\tik@transform=\pgfutil@empty + \let\tikz@fig@name=\pgfutil@empty + \tikzset{/pgf/braid/strand label,#4}% + \braid@nx=#2\braid@width + \braid@ny=#1\braid@height + \advance\braid@ny by \braid@eh + \advance\braid@ny by \braid@height + \pgftransformshift{\pgfqpoint{\braid@nx}{\braid@ny}}% + \tikz@options + \setbox\pgfnodeparttextbox=\hbox% + \bgroup% + \tikzset{every text node part/.try}% + \ifx\tikz@textopacity\pgfutil@empty% + \else% + \pgfsetfillopacity{\tikz@textopacity}% + \pgfsetstrokeopacity{\tikz@textopacity}% + \fi% + \pgfinterruptpicture% + \tikz@textfont% + \ifx\tikz@text@width\pgfutil@empty% + \else% + \begingroup% + \pgfmathsetlength{\pgf@x}{\tikz@text@width}% + \pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}% + \tikz@text@action% + \fi% + \tikz@atbegin@node% + \bgroup% + \aftergroup\unskip% + \ifx\tikz@textcolor\pgfutil@empty% + \else% + \pgfutil@colorlet{.}{\tikz@textcolor}% + \fi% + \pgfsetcolor{.}% + \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \tikz@uninstallcommands% + \tikz@halign@check% + \ignorespaces% + #3 + \egroup + \tikz@atend@node% + \ifx\tikz@text@width\pgfutil@empty% + \else% + \pgfutil@endminipage% + \endgroup% + \fi% + \endpgfinterruptpicture% + \egroup% + \ifx\tikz@text@width\pgfutil@empty% + \else% + \pgfmathsetlength{\pgf@x}{\tikz@text@width}% + \wd\pgfnodeparttextbox=\pgf@x% + \fi% + \ifx\tikz@text@height\pgfutil@empty% + \else% + \pgfmathsetlength{\pgf@x}{\tikz@text@height}% + \ht\pgfnodeparttextbox=\pgf@x% + \fi% + \ifx\tikz@text@depth\pgfutil@empty% + \else% + \pgfmathsetlength{\pgf@x}{\tikz@text@depth}% + \dp\pgfnodeparttextbox=\pgf@x% + \fi% + \pgfmultipartnode{\tikz@shape}{\tikz@anchor}{\tikz@fig@name}{% + {\begingroup\tikz@finish}% + }% + \endpgfscope + \endgroup + \braid@render@strand@labels% +} \def\braid@render{ \ifx\braid@floors\@empty \else @@ -237,7 +397,8 @@ \let\tikz@options=\pgfutil@empty \expandafter\tikzset\expandafter{\braid@floors@style} \pgfmathtruncatemacro{\braid@ff}{\braid@f+2} - \expandafter\let\expandafter\braid@floor@style\csname braid@options@floor@\braid@ff\endcsname + \expandafter\let\expandafter\braid@floor@style% + \csname braid@options@floor@\braid@ff\endcsname \ifx\braid@floor@style\relax \else \expandafter\tikzset\expandafter{\braid@floor@style}% @@ -257,18 +418,21 @@ \braid@tx=\braid@k\braid@width \braid@ty=\value{braid@level}\braid@height \advance\braid@ty by 2\braid@eh - \expandafter\let\expandafter\braid@path@origin\csname braid@strand@\braid@k @origin\endcsname + \expandafter\let\expandafter\braid@path@origin% + \csname braid@strand@\braid@k @origin\endcsname \ifx\braid@path@origin\relax \pgfsyssoftpath@setcurrentpath{\@empty} \pgfpathmoveto{\pgfqpoint{\braid@tx}{0pt}} \let\braid@path@origin\braid@k \else - \expandafter\let\expandafter\braid@path\csname braid@strand@\braid@path@origin\endcsname + \expandafter\let\expandafter\braid@path% + \csname braid@strand@\braid@path@origin\endcsname \pgfsyssoftpath@setcurrentpath{\braid@path} \fi \pgflineto{\pgfqpoint{\braid@tx}{\braid@ty}} \expandafter\tikzset\expandafter{\braid@style} - \expandafter\let\expandafter\braid@style\csname braid@options@strand@\braid@path@origin\endcsname + \expandafter\let\expandafter\braid@style% + \csname braid@options@strand@\braid@path@origin\endcsname \ifx\braid@style\relax \else \expandafter\tikzset\expandafter{\braid@style} @@ -300,25 +464,40 @@ \braid@ty=.5\braid@ty \coordinate (\braid@name) at (\braid@tx,\braid@ty); \fi + \ifx\braid@strand@labels\pgfutil@empty + \else + \expandafter\braid@render@strand@labels\braid@strand@labels{}% + \fi \pgfsys@endscope \endgroup} \def\braid@start#1{% - \pgfsys@beginscope - \setcounter{braid@level}{-1}% - \let\braid@label\@empty - \let\braid@floors\@empty - \let\braid@name\empty - \pgfkeys{/pgf/braid/.cd,#1} - \let\braid@options\tikz@options + \pgfsys@beginscope + \setcounter{braid@level}{-1}% + \let\braid@label\@empty + \let\braid@strand@labels\@empty + \let\braid@floors\@empty + \let\braid@name\empty + \let\clabel=\braid@clabel@strand + \let\olabel=\braid@olabel@strand + \pgfkeys{/pgf/braid/.cd,#1}% + \ifbraid@strand@labels@origin + \let\label=\braid@olabel@strand + \else + \let\label=\braid@clabel@strand + \fi + \let\braid@options\tikz@options \tikz@transform - \setcounter{braid@strands}{\pgfkeysvalueof{/pgf/braid/number of strands}}% - \braid@width=\pgfkeysvalueof{/pgf/braid/width} - \braid@height=\pgfkeysvalueof{/pgf/braid/height} - \braid@eh=\pgfkeysvalueof{/pgf/braid/border height} - \braid@height=-\braid@height - \braid@eh=-\braid@eh - \braid@increase@leveltrue - \braid@process@start + \setcounter{braid@strands}{% + \pgfkeysvalueof{/pgf/braid/number of strands}}% + \braid@width=\pgfkeysvalueof{/pgf/braid/width}% + \braid@height=\pgfkeysvalueof{/pgf/braid/height}% + \braid@eh=\pgfkeysvalueof{/pgf/braid/border height}% + \pgfkeysgetvalue{/pgf/braid/control factor}{\braid@cf}% + \pgfkeysgetvalue{/pgf/braid/nudge factor}{\braid@nf}% + \braid@height=-\braid@height + \braid@eh=-\braid@eh + \braid@increase@leveltrue + \braid@process@start } \newdimen\braid@width \newdimen\braid@height @@ -330,6 +509,7 @@ \newdimen\braid@dy \newdimen\braid@eh \newif\ifbraid@increase@level +\newif\ifbraid@strand@labels@origin \let\braid@style\pgfutil@empty \let\braid@floors@style\pgfutil@empty \def\braid@over@cross{1} @@ -342,7 +522,10 @@ number of strands/.initial=0, height/.initial=1cm, width/.initial=1cm, + gap/.initial=.1, border height/.initial=.25cm, + control factor/.initial=.5, + nudge factor/.initial=.05, name/.code={% \def\braid@name{#1}% }, @@ -357,24 +540,28 @@ \braidset{style each strand/.list={#1}}% }, style each strand/.code={% - \expandafter\edef\csname braid@options@strand@#1\endcsname{\braid@temp}% + \expandafter\edef% + \csname braid@options@strand@#1\endcsname{\braid@temp}% }, style floors/.code 2 args={% \def\braid@temp{#2}% \braidset{style each floor/.list={#1}}% }, style each floor/.code={% - \expandafter\edef\csname braid@options@floor@#1\endcsname{\braid@temp}% + \expandafter\edef% + \csname braid@options@floor@#1\endcsname{\braid@temp}% }, style all floors/.code={% \def\braid@floors@style{#1} - } + }, + strand label/.style={}, + strand label by origin/.is if=braid@strand@labels@origin, } \def\braidset#1{% \pgfkeys{/pgf/braid/.cd,#1}} %% -%% Copyright (C) 2011 by Andrew Stacey <stacey@math.ntnu.no> +%% Copyright (C) 2011-2019 by Andrew Stacey <loopspace@mathforge.org> %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License (LPPL), either @@ -392,6 +579,7 @@ %% braids.ins, %% braids.pdf, %% braids.sty, +%% tikzlibrarybraids.code.tex, %% braids_doc.pdf. %% %% |