texlive[64817] Master/texmf-dist: braids (26oct22)

commits+karl at tug.org commits+karl at tug.org
Wed Oct 26 21:57:44 CEST 2022


Revision: 64817
          http://tug.org/svn/texlive?view=revision&revision=64817
Author:   karl
Date:     2022-10-26 21:57:44 +0200 (Wed, 26 Oct 2022)
Log Message:
-----------
braids (26oct22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/braids/braids.pdf
    trunk/Master/texmf-dist/doc/latex/braids/braids.tex
    trunk/Master/texmf-dist/doc/latex/braids/braids_code.pdf
    trunk/Master/texmf-dist/source/latex/braids/braids_code.dtx
    trunk/Master/texmf-dist/source/latex/braids/braids_code.ins
    trunk/Master/texmf-dist/tex/latex/braids/braids.sty
    trunk/Master/texmf-dist/tex/latex/braids/tikzlibrarybraids.code.tex

Modified: trunk/Master/texmf-dist/doc/latex/braids/braids.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/braids/braids.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/braids/braids.tex	2022-10-25 23:49:45 UTC (rev 64816)
+++ trunk/Master/texmf-dist/doc/latex/braids/braids.tex	2022-10-26 19:57:44 UTC (rev 64817)
@@ -10,7 +10,15 @@
  
 \usepackage{listings}
 \lstloadlanguages{[LaTeX]TeX}
-\lstset{breakatwhitespace=true,breaklines=true,language=TeX}
+ \lstset{
+  gobble=2,
+  breakatwhitespace=true,
+  breaklines=true,
+  language=[LaTeX]TeX,
+  basicstyle=\small\ttfamily,
+  keepspaces=true,
+  columns=fullflexible
+}
  
 \usepackage{fancyvrb}
 
@@ -21,7 +29,6 @@
    \begin{center}
    \setlength{\parindent}{0pt}
    \fbox{\begin{minipage}{.9\linewidth}
-     \lstset{breakatwhitespace=true,breaklines=true,language=TeX,basicstyle=\small}
      \lstinputlisting[]{example.out}
    \end{minipage}}
 
@@ -105,15 +112,27 @@
 \DescribeMacro{braid-word}
 The \Verb+braid-word+ is an expression in the braid group, such as \Verb+s_1 s_2^{-1} s_{3,5}+.
 The generator labels are not significant.
-If the subscript is a single number, as in \Verb+s_2+, the crossing goes from that number over the next.
-If the subscript is two numbers, as in \Verb+s_{2,4}+, the crossing goes from the first over the second, with both the crossing strands passing over all of the intervening strands.
+
+The subscript determines how the strands cross, as follows:
+\begin{enumerate}
+\item If the subscript is a single number, as in \Verb+s_2+, the crossing goes from that number over the next.
+\item If the subscript is two or more numbers separated by a comma, as in \Verb+s_{2,4}+ or \Verb+s_{1,3,5}+, imagine holding the numbered strands and moving each to the position of the next with the last strand moving under the others to where the first stands.
+Any intermediate non-specified strand is behind all those involved in the crossing.
+\item If the subscript is hyphenated, as in \Verb+s_{1-5}+, this is equivalent to \Verb+s_{1,2,3,4,5}+.
+This can be used as part of a list, as in \Verb+s_{1-3,5}+.
+\end{enumerate}
+
+All of these crossings take place in the same amount of vertical space.
+Be advised that crossings involving a lot of strands can get quite squashed.
+
 The exponent can be \Verb+1+, \Verb+{-1}+, or missing (in which case it defaults to \Verb+1+, note also that the exponent is read as a \TeX-token so \Verb+{1}+ is also legal).
-If the exponent is \(-1\) then the over and under strands swap.
+If the exponent is \(-1\) then the braid element represented by the crossing is inverted.
 
 \begin{itemize}
 \item \Verb+s_1+ is strand \(1\) over strand \(2\).
 \item \Verb+s_1^{-1}+ is strand \(2\) over strand \(1\).
 \item \Verb+s_{1,3}+ is strand \(1\) over strand \(3\), and both are over strand \(2\).
+\item \Verb+s_{1-3}+ is strand \(3\) under strand \(2\) and then under strand \(1\).
 \end{itemize}
 
 Certain other symbols are allowed in the \Verb+braid-word+ which control the rendering of the braid.
@@ -217,9 +236,13 @@
 The crossing number can also be either \Verb+s+ or \Verb+e+ for the start and end of the strand.
 Note that \Verb+-1-0+ and \Verb+-1-s+ are slightly different in that \Verb+s+ includes the border height.
 
+In addition, if the braid is named then a rectangular node is defined that fits around the whole braid.
+This node is not actually rendered but its anchors can be used afterwards as if it had been.
+
 \DescribeMacro{anchor}
 The key \Verb+anchor+ (in the \Verb+braid+ name space) can be used to shift the braid so that a different part of it is at the specified location.
-It uses the same syntax as the coordinates, except without the \Verb+<name prefix>-+.
+If the argument contains a hyphen then it is assumed to refer to a point on a strand with the same interpretation as the coordinates (except without the \Verb+<name prefix>-+, of course).
+If the argument does not contain a hyphen then it is taken to be an anchor of a surrounding rectangular node (the node might not itself exist -- if the braid isn't named -- but that doesn't affect the positioning).
 In the following example, the braid is shifted so that where the third strand starts the second level is at the position \Verb+(1,1)+
 
 \begin{example}
@@ -282,6 +305,26 @@
 
 \end{example}
 
+\begin{example}
+\begin{center}
+\begin{tikzpicture}
+\pic[
+  braid/.cd,
+  number of strands=3,
+  ultra thick,
+  strand 1/.style={red},
+  strand 2/.style={green},
+  strand 3/.style={blue},
+  gap=0.1,
+%  control factor=0,
+%  nudge factor=0,
+  name prefix=braid,
+] {braid={a_{1-3} a_{1,3}}};
+\end{tikzpicture}
+\end{center}
+
+\end{example}
+
 \newpage
 
 \section{Original Package Usage (Depreciated)}

Modified: trunk/Master/texmf-dist/doc/latex/braids/braids_code.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/braids/braids_code.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/braids/braids_code.dtx	2022-10-25 23:49:45 UTC (rev 64816)
+++ trunk/Master/texmf-dist/source/latex/braids/braids_code.dtx	2022-10-26 19:57:44 UTC (rev 64817)
@@ -35,7 +35,7 @@
 \endpreamble
 \postamble
 
-Copyright (C) 2011-2019 by Andrew Stacey <loopspace at mathforge.org>
+Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
 
 This work may be distributed and/or modified under the
 conditions of the LaTeX Project Public License (LPPL), either
@@ -103,7 +103,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{1949}
+% \CheckSum{2352}
 %
 % \CharacterTable
 %  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -125,6 +125,8 @@
 % \changes{1.0}{2011/05/03}{Converted to DTX file}
 % \changes{1.1}{2011/05/03}{Extended syntax}
 % \changes{2.0}{2019/03/20}{Converted TikZ library}
+% \changes{2.1}{2019/08/14}{Extended crossing capability}
+% \changes{2.2}{2022/10/26}{Advanced positioning}
 %
 % \DoNotIndex{\newcommand,\newenvironment}
 %
@@ -1181,7 +1183,7 @@
 % Life is so much easier with \LaTeX3.
 %    \begin{macrocode}
 \ProvidesFile{tikzlibrarybraids.code.tex}[%
-  2019/03/20 v2.0 Tikz/PGF library for drawing braid diagrams%
+  2022/10/26 v2.2 Tikz/PGF library for drawing braid diagrams%
 ]
 \RequirePackage{expl3}
 \ExplSyntaxOn
@@ -1207,11 +1209,19 @@
 \fp_new:N \l_@@_anchor_x_fp
 \fp_new:N \l_@@_anchor_y_fp
 \int_new:N \l_@@_tmpa_int
+\int_new:N \l_@@_tmpb_int
 \int_new:N \l_@@_length_int
 \int_new:N \l_@@_strands_int
 \int_new:N \l_@@_crossing_int
+\int_new:N \l_@@_crossing_start_int
+\int_new:N \l_@@_crossing_end_int
+\int_new:N \l_@@_crossing_width_int
+\int_new:N \l_@@_crossing_long_int
+\int_new:N \l_@@_crossing_start_factor_int
+\int_new:N \l_@@_crossing_end_factor_int
 \int_new:N \l_@@_anchor_level_int
 \int_new:N \l_@@_floor_int
+\seq_new:N \l_@@_tmpa_seq
 \seq_new:N \l_@@_word_seq
 \seq_new:N \l_@@_crossing_seq
 \seq_new:N \l_@@_anchor_seq
@@ -1235,22 +1245,19 @@
 \prop_new:N \l_@@_crossing_permutation_prop
 \prop_new:N \l_@@_inverse_prop
 \prop_new:N \l_@@_anchor_prop
+\cs_generate_variant:Nn \seq_set_split:Nnn {NVn}
 %    \end{macrocode}
 % Our interface is through a TikZ pic.
 %    \begin{macrocode}
 \tikzset{
    braid/.pic={
-     code={
-       \@@_parse_word:n {#1}
-       \@@_count:
-       \@@_render:
-     }
+     \@@_parse_word:n {#1}
+     \@@_count:
+     \@@_render:
    },
    floor/.pic={
-     code={
-       \path[pic~ actions, draw=none] (0,0) rectangle (1,1);
-       \path[pic~ actions, fill=none] (0,0) -- (1,0) (0,1) -- (1,1);
-     }
+     \path[pic~ actions, draw=none] (0,0) rectangle (1,1);
+     \path[pic~ actions, fill=none] (0,0) -- (1,0) (0,1) -- (1,1);
    },
    /tikz/braid/.search~ also={/tikz},
    braid/.cd,
@@ -1431,15 +1438,35 @@
 %    \begin{macrocode}
 \cs_new_nopar:Npn \@@_parse_index:n #1
 {
-  \seq_set_from_clist:Nn \l_@@_crossing_seq {#1}
+  \seq_clear:N \l_@@_crossing_seq
+  \clist_map_inline:nn {#1}
+  {
+    \tl_if_in:nnTF {##1} {-}
+    {
+      \seq_set_split:Nnn \l_@@_tmpa_seq {-} {##1}
+      \int_compare:nTF {\seq_item:Nn \l_@@_tmpa_seq {1} < \seq_item:Nn \l_@@_tmpa_seq {2} }
+      {
+        \int_set:Nn \l_@@_tmpa_int {1}
+      }
+      {
+        \int_set:Nn \l_@@_tmpa_int {-1}
+      }
+      \int_step_inline:nnnn {\seq_item:Nn \l_@@_tmpa_seq {1}} {\l_@@_tmpa_int} {\seq_item:Nn \l_@@_tmpa_seq {2}}
+      {
+        \seq_put_right:Nn \l_@@_crossing_seq {####1}
+      }
+    }
+    {
+      \seq_put_right:Nn \l_@@_crossing_seq {##1}
+    }
+  }
   \int_compare:nT {\seq_count:N \l_@@_crossing_seq == 1}
   {
     \seq_put_right:Nx \l_@@_crossing_seq {\int_eval:n {#1 + 1} }
   }
-  \bool_if:NT \l_@@_swap_crossing_bool
+  \bool_if:NF \l_@@_swap_crossing_bool
   {
-    \seq_pop_left:NN \l_@@_crossing_seq \l_@@_tmpa_tl
-    \seq_put_right:NV \l_@@_crossing_seq \l_@@_tmpa_tl
+    \seq_reverse:N \l_@@_crossing_seq
   }
 }
 %    \end{macrocode}
@@ -1507,16 +1534,12 @@
 %    \begin{macrocode}
     \seq_if_empty:NF \l_@@_crossing_seq
     {
-      \int_set:Nn \l_@@_strands_int
+      \seq_map_inline:Nn \l_@@_crossing_seq
       {
-        \int_max:nn
+        \int_set:Nn \l_@@_strands_int
         {
-          \int_max:nn {\l_@@_strands_int}
-          { \seq_item:Nn \l_@@_crossing_seq {1}}
+          \int_max:nn {\l_@@_strands_int} {####1}
         }
-        {
-          \seq_item:Nn \l_@@_crossing_seq {2}
-        }
       }
     }
   }
@@ -1534,38 +1557,51 @@
 % Now we step through the braid word again and record the permutations so that we can calculate the overall permutation defined by the braid.
 %
 % We will also figure out our shift from the anchor, so first we need to get some information about the anchor.
+%
+% If the anchor specification has a hyphen then it is of the form strand-level, otherwise it is an anchor as if the whole braid were contained in a rectangular node.  
 %    \begin{macrocode}
   \tl_set:Nx \l_@@_tmpa_tl {\@@_value:n {anchor}}
-  \seq_set_split:NnV \l_@@_anchor_seq {-} \l_@@_tmpa_tl
+  \tl_if_in:NnTF \l_@@_tmpa_tl {-}
+  {
+    \seq_set_split:NnV \l_@@_anchor_seq {-} \l_@@_tmpa_tl
 
-  \tl_set:Nx \l_@@_tmpa_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
-  \tl_if_eq:VnTF \l_@@_tmpa_tl {rev}
-  {
-    \tl_set:Nx \l_@@_anchor_strand_tl {\seq_item:Nn \l_@@_anchor_seq {2}}
-    \tl_set:Nx \l_@@_anchor_level_tl {\seq_item:Nn \l_@@_anchor_seq {3}}
-  }
-  {
-    \tl_set:Nx \l_@@_anchor_strand_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
-    \tl_set:Nx \l_@@_anchor_level_tl {\seq_item:Nn \l_@@_anchor_seq {2}}
-  }
+    \tl_set:Nx \l_@@_tmpa_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
+    \tl_if_eq:VnTF \l_@@_tmpa_tl {rev}
+    {
+      \tl_set:Nx \l_@@_anchor_strand_tl {\seq_item:Nn \l_@@_anchor_seq {2}}
+      \tl_set:Nx \l_@@_anchor_level_tl {\seq_item:Nn \l_@@_anchor_seq {3}}
+    }
+    {
+      \tl_set:Nx \l_@@_anchor_strand_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
+      \tl_set:Nx \l_@@_anchor_level_tl {\seq_item:Nn \l_@@_anchor_seq {2}}
+    }
 %    \end{macrocode}
 % The important information is as to the level at which the requested anchor resides.
 % If it is at the end or start of a strand, we set the level to \(-1\) so that it never matches a level number. 
 %    \begin{macrocode}
-  \tl_if_eq:VnTF \l_@@_anchor_level_tl {s}
-  {
-    \int_set:Nn \l_@@_anchor_level_int {-1}
-  }
-  {
-    \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+    \tl_if_eq:VnTF \l_@@_anchor_level_tl {s}
     {
       \int_set:Nn \l_@@_anchor_level_int {-1}
     }
     {
-      \int_set:Nn \l_@@_anchor_level_int
-      {\tl_use:N \l_@@_anchor_level_tl}
+      \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+      {
+        \int_set:Nn \l_@@_anchor_level_int {-1}
+      }
+      {
+        \int_set:Nn \l_@@_anchor_level_int
+        {\tl_use:N \l_@@_anchor_level_tl}
+      }
     }
   }
+  {
+%    \end{macrocode}
+% There wasn't a hyphen in the anchor specification, so assume it's an anchor on a node surrounding the entire braid.
+% For now, set the anchor strand and level to \(-1\).
+%    \begin{macrocode}
+    \int_set:Nn \l_@@_anchor_level_int {-1}
+    \tl_set:Nn \l_@@_anchor_strand_tl {-1}
+  }
   
   \int_zero:N \l_@@_crossing_int
   \int_incr:N \l_@@_crossing_int
@@ -1580,23 +1616,29 @@
     ##1
     \seq_if_empty:NF \l_@@_crossing_seq
     {
-      \prop_get:NxN \l_@@_permutation_prop
+      \int_step_inline:nnn {2} {\seq_count:N \l_@@_crossing_seq}
       {
-        \seq_item:Nn \l_@@_crossing_seq {1}
-      } \l_@@_tmpa_tl
-      \prop_get:NxN \l_@@_permutation_prop
-      {
-        \seq_item:Nn \l_@@_crossing_seq {2}
-      } \l_@@_tmpb_tl
+        \int_set:Nn \l_@@_tmpa_int {####1}
+        \int_set:Nn \l_@@_tmpb_int {####1 - 1}
 
-      \prop_put:NxV \l_@@_permutation_prop
-      {
-        \seq_item:Nn \l_@@_crossing_seq {2}
-      } \l_@@_tmpa_tl
-      \prop_put:NxV \l_@@_permutation_prop
-      {
-        \seq_item:Nn \l_@@_crossing_seq {1}
-      } \l_@@_tmpb_tl
+        \prop_get:NxN \l_@@_permutation_prop
+        {
+          \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+        } \l_@@_tmpa_tl
+        \prop_get:NxN \l_@@_permutation_prop
+        {
+          \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}
+        } \l_@@_tmpb_tl
+
+        \prop_put:NxV \l_@@_permutation_prop
+        {
+          \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}
+        } \l_@@_tmpa_tl
+        \prop_put:NxV \l_@@_permutation_prop
+        {
+          \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+        } \l_@@_tmpb_tl
+      }
     }
 %    \end{macrocode}
 % See if the current level is what was requested by the anchor.
@@ -1629,24 +1671,30 @@
   }
 %    \end{macrocode}
 % Now that we have the inverse, we can figure out our anchor.
-% First, see if we requested a strand by its position at the end of the braid.
+% If the strand was recorded as \(-1\), then we want to figure out the position from the braid as a whole so we don't bother with processing.
 %    \begin{macrocode}
-  \tl_set:Nx \l_@@_tmpa_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
-  \tl_if_eq:VnT \l_@@_tmpa_tl {rev}
+  \tl_if_eq:VnF \l_@@_anchor_strand_tl {-1}
   {
-    \prop_get:NVN \l_@@_permutation_prop
-    \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
-  }
-  \tl_if_eq:VnF \l_@@_anchor_level_tl {s}
-  {
-    \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+%    \end{macrocode}
+% Now, see if we requested a strand by its position at the end of the braid.
+%    \begin{macrocode}
+    \tl_set:Nx \l_@@_tmpa_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
+    \tl_if_eq:VnT \l_@@_tmpa_tl {rev}
     {
-      \prop_get:NVN \l_@@_inverse_prop
+      \prop_get:NVN \l_@@_permutation_prop
       \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
     }
+    \tl_if_eq:VnF \l_@@_anchor_level_tl {s}
     {
-      \prop_get:NVN \l_@@_anchor_prop
-      \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
+      \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+      {
+        \prop_get:NVN \l_@@_inverse_prop
+        \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
+      }
+      {
+        \prop_get:NVN \l_@@_anchor_prop
+        \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
+      }
     }
   }
 %    \end{macrocode}
@@ -1684,29 +1732,92 @@
 \cs_new_nopar:Npn \@@_render:
 {
 %    \end{macrocode}
-%
+% Start by figuring out our anchor.
 %    \begin{macrocode}
-  \fp_set:Nn \l_@@_anchor_x_fp { - 1 * (\tl_use:N \l_@@_anchor_strand_tl - 1) * \@@_dim_value:n {width} }
-
-  \tl_if_eq:VnTF \l_@@_anchor_level_tl {s}
+  \tl_if_eq:VnTF \l_@@_anchor_strand_tl {-1}
   {
-    \fp_set:Nn \l_@@_anchor_y_fp {0}
+%    \end{macrocode}
+% The strand is \(-1\) then we're working with the braid as if a node.
+% We'll redefine this node later anyway.
+%    \begin{macrocode}
+    \tl_set:cn {pgf at sh@ns at temporary braid node}{rectangle}
+    \tl_set:cx {pgf at sh@np at temporary braid node}{%
+      \exp_not:N\def
+      \exp_not:N\southwest
+      {
+        \exp_not:N\pgfqpoint
+        {0pt}
+        {0pt}
+      }
+      \exp_not:N\def
+      \exp_not:N\northeast
+      {
+        \exp_not:N\pgfqpoint
+        {
+          \fp_to_dim:n
+          {
+            (\l_@@_strands_int - 1)
+            *
+            abs(\@@_dim_value:n {width})
+          }
+        }
+        {
+          \fp_to_dim:n
+          {
+            \l_@@_length_int * abs(\@@_dim_value:n {height})
+            + 2 * \@@_dim_value:n {border~ height}
+          }
+        }
+      }
+    }%
+    \pgfgettransform\l_@@_tmpa_tl
+    \tl_set:cV {pgf at sh@nt at temporary braid node} \l_@@_tmpa_tl
+    \tl_set:cV {pgf at sh@pi at temporary braid node} \pgfpictureid
+    \pgfpointanchor{temporary braid node} {\@@_value:n {anchor}}
+%    \end{macrocode}
+% Adjustments due to the possibility of negative widths/heights
+%    \begin{macrocode}
+    \fp_set:Nn \l_@@_anchor_x_fp {
+      - \dim_use:c {pgf at x}
+      - (1 - sign(\@@_dim_value:n {width})) / 2
+      * (\l_@@_strands_int - 1)
+      * \@@_dim_value:n {width}
+    }
+    \fp_set:Nn \l_@@_anchor_y_fp {
+      - \dim_use:c {pgf at y}
+      - (1 - sign(\@@_dim_value:n {height})) / 2
+      * (
+      \l_@@_length_int * abs(\@@_dim_value:n {height})
+      + 2 * \@@_dim_value:n {border~ height} 
+      ) * sign(\@@_dim_value:n {height})
+    }
   }
   {
-    \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+%    \end{macrocode}
+% The strand is not \(-1\) so we're setting the anchor via strand and level numbers.
+%    \begin{macrocode}
+    \fp_set:Nn \l_@@_anchor_x_fp { - 1 * (\tl_use:N \l_@@_anchor_strand_tl - 1) * \@@_dim_value:n {width} }
+
+    \tl_if_eq:VnTF \l_@@_anchor_level_tl {s}
     {
-      \fp_set:Nn \l_@@_anchor_y_fp {
-        -1 * \l_@@_length_int * \@@_dim_value:n {height}
-        - sign(\@@_dim_value:n {height})
-        * 2 * \@@_dim_value:n {border~ height}
-      }
+      \fp_set:Nn \l_@@_anchor_y_fp {0}
     }
     {
-      \fp_set:Nn \l_@@_anchor_y_fp {
-        -1 * \l_@@_anchor_level_tl * \@@_dim_value:n {height}
-        - sign(\@@_dim_value:n {height})
-        * \@@_dim_value:n {border~ height}
+      \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+      {
+        \fp_set:Nn \l_@@_anchor_y_fp {
+          -1 * \l_@@_length_int * \@@_dim_value:n {height}
+          - sign(\@@_dim_value:n {height})
+          * 2 * \@@_dim_value:n {border~ height}
+        }
       }
+      {
+        \fp_set:Nn \l_@@_anchor_y_fp {
+          -1 * \l_@@_anchor_level_tl * \@@_dim_value:n {height}
+          - sign(\@@_dim_value:n {height})
+          * \@@_dim_value:n {border~ height}
+        }
+      }
     }
   }
   
@@ -1860,28 +1971,92 @@
 %    \begin{macrocode}
     \seq_if_empty:NF \l_@@_crossing_seq
     {
+      \int_set:Nn \l_@@_crossing_long_int
+      {
+        %        \seq_item:Nn \l_@@_crossing_seq {\seq_count:N \l_@@_crossing_seq}
+        \seq_item:Nn \l_@@_crossing_seq {1}
+      }
+      \int_set:Nn \l_@@_crossing_start_int
+      {
+        \int_min:nn
+        {
+          \seq_item:Nn \l_@@_crossing_seq {1}
+        }
+        {
+          \seq_item:Nn \l_@@_crossing_seq {\seq_count:N \l_@@_crossing_seq}          
+        }
+      }
+      \int_set:Nn \l_@@_crossing_end_int
+      {
+        \int_max:nn
+        {
+          \seq_item:Nn \l_@@_crossing_seq {1}
+        }
+        {
+          \seq_item:Nn \l_@@_crossing_seq {\seq_count:N \l_@@_crossing_seq}          
+        }
+
+      }
+      \int_set:Nn \l_@@_crossing_width_int
+      {
+        \l_@@_crossing_end_int
+        -
+        \l_@@_crossing_start_int
+      }
 %    \end{macrocode}
+% Step through the crossing
+%    \begin{macrocode}
+      \int_step_inline:nnn {2} {\seq_count:N \l_@@_crossing_seq}
+      {
+        \int_set:Nn \l_@@_tmpa_int {####1}
+        \int_set:Nn \l_@@_tmpb_int {####1 - 1}
+%    \end{macrocode}
 % Keep track of the current permutation.      
 %    \begin{macrocode}
       \prop_get:NxN \l_@@_crossing_permutation_prop
-      {\seq_item:Nn \l_@@_crossing_seq {1}} \l_@@_tmpa_tl
+      {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}} \l_@@_tmpa_tl
       \prop_get:NxN \l_@@_crossing_permutation_prop
-      {\seq_item:Nn \l_@@_crossing_seq {2}} \l_@@_tmpb_tl
+      {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}} \l_@@_tmpb_tl
 
       \prop_put:NxV \l_@@_crossing_permutation_prop
-      {\seq_item:Nn \l_@@_crossing_seq {2}} \l_@@_tmpa_tl
+      {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}} \l_@@_tmpa_tl
       \prop_put:NxV \l_@@_crossing_permutation_prop
-      {\seq_item:Nn \l_@@_crossing_seq {1}} \l_@@_tmpb_tl
+      {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}} \l_@@_tmpb_tl
 %    \end{macrocode}
 % Now get the strands corresponding to the ones involved in the crossing.
 %    \begin{macrocode}
       \prop_get:NxN \l_@@_strands_prop
-      {\seq_item:Nn \l_@@_crossing_seq {1}} \l_@@_tmpa_tl
+      {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}} \l_@@_tmpa_tl
       \prop_get:NxN \l_@@_strands_prop
-      {\seq_item:Nn \l_@@_crossing_seq {2}} \l_@@_tmpb_tl
+      {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}} \l_@@_tmpb_tl
 %    \end{macrocode}
 % The over-strand is easy as that's a single curve.
 %    \begin{macrocode}
+%      \int_set:Nn \l_@@_crossing_start_factor_int {1}
+%     \int_set:Nn \l_@@_crossing_end_factor_int {1}
+%      \int_compare:nT {
+%        \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+%        =
+%        \l_@@_crossing_long_int
+%      }
+%      {
+        \int_set:Nn \l_@@_crossing_start_factor_int {0}
+        \int_set:Nn \l_@@_crossing_end_factor_int {0}
+
+        \int_compare:nT {
+          ####1 = \seq_count:N \l_@@_crossing_seq
+        }
+        {
+          \int_set:Nn \l_@@_crossing_end_factor_int {1}
+        }
+        \int_compare:nT {
+          ####1 = 2
+        }
+        {
+          \int_set:Nn \l_@@_crossing_start_factor_int {1}
+        }
+%      }
+
       \tl_put_right:Nx \l_@@_tmpa_tl
       {
         \exp_not:N \@@_lineto:nn
@@ -1888,23 +2063,29 @@
       
         {\fp_eval:n
           {
-            (\seq_item:Nn \l_@@_crossing_seq {1} - 1)
+            (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int} - 1)
             * \@@_dim_value:n {width}
           }
         }
-        {\fp_eval:n { \l_@@_height_fp + \l_@@_nudge_fp } }
+        {\fp_eval:n { \l_@@_height_fp + \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+            + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
+ } }
 
         \exp_not:N \@@_curveto:nnnnnn
 
         {0}
-        {\fp_eval:n { \l_@@_control_fp}}
+        {\fp_eval:n { \l_@@_control_fp
+%            * \l_@@_crossing_start_factor_int
+            * 1/(\seq_count:N \l_@@_crossing_seq - 1)}}
 
         {0}
-        {\fp_eval:n {- \l_@@_control_fp}}
+        {\fp_eval:n {- \l_@@_control_fp
+%            * \l_@@_crossing_end_factor_int
+            * 1/(\seq_count:N \l_@@_crossing_seq - 1)}}
 
         {\fp_eval:n
           {
-            (\seq_item:Nn \l_@@_crossing_seq {2} - 1)
+            (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int} - 1)
             * \@@_dim_value:n {width}
           }
         }
@@ -1911,8 +2092,8 @@
         {\fp_eval:n
           {
             \l_@@_height_fp
-            + \@@_dim_value:n {height}
-            - \l_@@_nudge_fp
+            + \@@_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l_@@_crossing_seq - 1)
+            - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
           }
         }
       }
@@ -1919,6 +2100,31 @@
 %    \end{macrocode}
 % The under-strand is a bit more complicated as we need to break it in the middle.
 %    \begin{macrocode}
+%      \int_set:Nn \l_@@_crossing_start_factor_int {1}
+%      \int_set:Nn \l_@@_crossing_end_factor_int {1}
+%      \int_compare:nT {
+%        \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}
+%        =
+%        \l_@@_crossing_long_int
+%      }
+%      {
+        \int_set:Nn \l_@@_crossing_start_factor_int {0}
+        \int_set:Nn \l_@@_crossing_end_factor_int {0}
+
+        \int_compare:nT {
+          ####1 = \seq_count:N \l_@@_crossing_seq
+        }
+        {
+          \int_set:Nn \l_@@_crossing_end_factor_int {1}
+        }
+        \int_compare:nT {
+          ####1 = 2
+        }
+        {
+          \int_set:Nn \l_@@_crossing_start_factor_int {1}
+        }
+%      }
+
       \tl_put_right:Nx \l_@@_tmpb_tl
       {
         \exp_not:N \@@_lineto:nn
@@ -1925,36 +2131,40 @@
       
         {\fp_eval:n
           {
-            (\seq_item:Nn \l_@@_crossing_seq {2} - 1)
+            (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int} - 1)
             * \@@_dim_value:n {width}
           }
         }
-        {\fp_eval:n { \l_@@_height_fp + \l_@@_nudge_fp } }
+        {\fp_eval:n { \l_@@_height_fp + \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+            + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
 
+        } }
+
         \exp_not:N \@@_curveto:nnnnnn
 
         {0}
         {
           \fp_eval:n {
-            \l_@@_control_fp  * (.5 - \@@_value:n {gap} )
+            \l_@@_control_fp  * (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%            * \l_@@_crossing_start_factor_int
           }
         }
 
         {
           \fp_eval:n {
-            - (.5 - \@@_value:n {gap} ) / 3 *
+            - (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) / 3 *
             \@@_bezier_tangent:nnnnn
-            {.5 - \@@_value:n {gap} }
+            {.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
             {0}
             {0}
             {
-              (\seq_item:Nn \l_@@_crossing_seq {1}
-              - \seq_item:Nn \l_@@_crossing_seq {2})
+              (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+              - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
               * \@@_dim_value:n {width}
             }
             {
-              (\seq_item:Nn \l_@@_crossing_seq {1}
-              - \seq_item:Nn \l_@@_crossing_seq {2})
+              (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+              - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
               * \@@_dim_value:n {width}
             }
           }
@@ -1961,36 +2171,45 @@
         }
         {
           \fp_eval:n {
-            -(.5 - \@@_value:n {gap} ) / 3 *
+            -(.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) / 3 *
             \@@_bezier_tangent:nnnnn
-            {.5 - \@@_value:n {gap} }
+            {.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
             {0}
-            {\l_@@_control_fp}
             {
-              \@@_dim_value:n {height}
-              - 2* \l_@@_nudge_fp
-              - \l_@@_control_fp
+              \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%              * \l_@@_crossing_start_factor_int
             }
-            {\@@_dim_value:n {height} - 2* \l_@@_nudge_fp}
+            {
+              \@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+              - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+              - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+              - \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%              * \l_@@_crossing_end_factor_int
+            }
+            {
+              \@@_dim_value:n {height} *  1/(\seq_count:N \l_@@_crossing_seq - 1)
+              - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+              - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+            }
           }
         }
 
         {
           \fp_eval:n {
-            (\seq_item:Nn \l_@@_crossing_seq {2} - 1)
+            (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int} - 1)
             * \@@_dim_value:n {width} +
             \@@_bezier_point:nnnnn
-            {.5 - \@@_value:n {gap} }
+            {.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
             {0}
             {0}
             {
-              (\seq_item:Nn \l_@@_crossing_seq {1}
-              - \seq_item:Nn \l_@@_crossing_seq {2})
+              (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+              - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
               * \@@_dim_value:n {width}
             }
             {
-              (\seq_item:Nn \l_@@_crossing_seq {1}
-              - \seq_item:Nn \l_@@_crossing_seq {2})
+              (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+              - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
               * \@@_dim_value:n {width}
             }
           }
@@ -1997,17 +2216,28 @@
         }
         {
           \fp_eval:n {
-          \l_@@_height_fp + \l_@@_nudge_fp +
+            \l_@@_height_fp
+            + \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+            + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
+            + 
             \@@_bezier_point:nnnnn
-            {.5 - \@@_value:n {gap} }
+            {.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
             {0}
-            {\l_@@_control_fp}
             {
-              \@@_dim_value:n {height}
-              - 2* \l_@@_nudge_fp
-              - \l_@@_control_fp
+              \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%              * \l_@@_crossing_start_factor_int
             }
-            {\@@_dim_value:n {height} - 2* \l_@@_nudge_fp}
+            {
+              \@@_dim_value:n {height} *  1/(\seq_count:N \l_@@_crossing_seq - 1)
+              - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+              - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+              - \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%              * \l_@@_crossing_end_factor_int
+            }
+            {\@@_dim_value:n {height} *  1/(\seq_count:N \l_@@_crossing_seq - 1)
+              - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+              - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+            }
           }
         }
 
@@ -2014,20 +2244,20 @@
         \exp_not:N \@@_moveto:nn
         {
           \fp_eval:n {
-            (\seq_item:Nn \l_@@_crossing_seq {2} - 1)
+            (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int} - 1)
             * \@@_dim_value:n {width} +
             \@@_bezier_point:nnnnn
-            {.5 + \@@_value:n {gap} }
+            {.5 + \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
             {0}
             {0}
             {
-              (\seq_item:Nn \l_@@_crossing_seq {1}
-              - \seq_item:Nn \l_@@_crossing_seq {2})
+              (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+              - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
               * \@@_dim_value:n {width}
             }
             {
-              (\seq_item:Nn \l_@@_crossing_seq {1}
-              - \seq_item:Nn \l_@@_crossing_seq {2})
+              (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+              - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
               * \@@_dim_value:n {width}
             }
           }
@@ -2034,16 +2264,28 @@
         }
         {
           \fp_eval:n {
-          \l_@@_height_fp + \l_@@_nudge_fp +
+            \l_@@_height_fp
+            + \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+            + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
+            + 
             \@@_bezier_point:nnnnn
-            {.5 + \@@_value:n {gap} }
+            {.5 + \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
             {0}
-            {\l_@@_control_fp}
             {
-              \@@_dim_value:n {height} - 2* \l_@@_nudge_fp
-              - \l_@@_control_fp
+              \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%              * \l_@@_crossing_start_factor_int
             }
-            {\@@_dim_value:n {height} - 2* \l_@@_nudge_fp}
+            {
+              \@@_dim_value:n {height} *  1/(\seq_count:N \l_@@_crossing_seq - 1)
+              - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+              - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+              - \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%              * \l_@@_crossing_end_factor_int
+            }
+            {\@@_dim_value:n {height} *  1/(\seq_count:N \l_@@_crossing_seq - 1)
+              - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+              - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+            }
           }
         }
 
@@ -2051,19 +2293,19 @@
 
         {
           \fp_eval:n {
-            (.5 - \@@_value:n {gap} ) / 3 *
+            (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) / 3 *
             \@@_bezier_tangent:nnnnn
-            {.5 + \@@_value:n {gap} }
+            {.5 + \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
             {0}
             {0}
             {
-              (\seq_item:Nn \l_@@_crossing_seq {1}
-              - \seq_item:Nn \l_@@_crossing_seq {2})
+              (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+              - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
               * \@@_dim_value:n {width}
             }
             {
-              (\seq_item:Nn \l_@@_crossing_seq {1}
-              - \seq_item:Nn \l_@@_crossing_seq {2})
+              (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+              - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
               * \@@_dim_value:n {width}
             }
           }
@@ -2070,36 +2312,46 @@
         }
         {
           \fp_eval:n {
-            (.5 - \@@_value:n {gap} ) / 3 *
+            (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) / 3 *
             \@@_bezier_tangent:nnnnn
-            {.5 + \@@_value:n {gap} }
+            {.5 + \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
             {0}
-            {\l_@@_control_fp}
             {
-              \@@_dim_value:n {height} - 2* \l_@@_nudge_fp
-              - \l_@@_control_fp
+              \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%              * \l_@@_crossing_start_factor_int
             }
-            {\@@_dim_value:n {height} - 2* \l_@@_nudge_fp}
+            {
+              \@@_dim_value:n {height} *  1/(\seq_count:N \l_@@_crossing_seq - 1)
+              - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+              - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+              - \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+%              * \l_@@_crossing_end_factor_int
+            }
+            {\@@_dim_value:n {height} *  1/(\seq_count:N \l_@@_crossing_seq - 1)
+              - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+              - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+            }
           }
         }
 
         {0}
-        { \fp_eval:n {
-            -\l_@@_control_fp  * (.5 - \@@_value:n {gap} )
-          }
+        {\fp_eval:n {
+            - \l_@@_control_fp  * (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) )
+%            * \l_@@_crossing_end_factor_int
+            * 1/(\seq_count:N \l_@@_crossing_seq - 1)}
         }
 
-
         {\fp_eval:n
           {
-            (\seq_item:Nn \l_@@_crossing_seq {1} - 1)
+            (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int} - 1)
             * \@@_dim_value:n {width}
           }
         }
         {\fp_eval:n
           {
-            \l_@@_height_fp + \@@_dim_value:n {height}
-            - \l_@@_nudge_fp
+            \l_@@_height_fp
+            + \@@_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l_@@_crossing_seq - 1)
+            - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
           }
         }
         
@@ -2108,9 +2360,9 @@
 % Now put those new strands back in the prop.
 %    \begin{macrocode}
       \prop_put:NxV \l_@@_strands_prop
-      {\seq_item:Nn \l_@@_crossing_seq {2}} \l_@@_tmpa_tl
+      {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}} \l_@@_tmpa_tl
       \prop_put:NxV \l_@@_strands_prop
-      {\seq_item:Nn \l_@@_crossing_seq {1}} \l_@@_tmpb_tl
+      {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}} \l_@@_tmpb_tl
 %    \end{macrocode}
 % If the strands are more than one apart, the intermediate strands need to be broken as well.
 %    \begin{macrocode}
@@ -2118,18 +2370,18 @@
       {
         \int_max:nn
         {
-          \seq_item:Nn \l_@@_crossing_seq {1}
+          \seq_item:Nn \l_@@_crossing_seq {####1 - 1}
         }
         {
-          \seq_item:Nn \l_@@_crossing_seq {2}
+          \seq_item:Nn \l_@@_crossing_seq {####1}
         }
         -
         \int_min:nn
         {
-          \seq_item:Nn \l_@@_crossing_seq {1}
+          \seq_item:Nn \l_@@_crossing_seq {####1 - 1}
         }
         {
-          \seq_item:Nn \l_@@_crossing_seq {2}
+          \seq_item:Nn \l_@@_crossing_seq {####1}
         }
         > 1
       }
@@ -2138,10 +2390,10 @@
         {
           \int_min:nn
           {
-            \seq_item:Nn \l_@@_crossing_seq {1}
+            \seq_item:Nn \l_@@_crossing_seq {####1 - 1}
           }
           {
-            \seq_item:Nn \l_@@_crossing_seq {2}
+            \seq_item:Nn \l_@@_crossing_seq {####1}
           }
           + 1}
         {1}
@@ -2148,39 +2400,68 @@
         {
           \int_max:nn
           {
-            \seq_item:Nn \l_@@_crossing_seq {1}
+            \seq_item:Nn \l_@@_crossing_seq {####1 - 1}
           }
           {
-            \seq_item:Nn \l_@@_crossing_seq {2}
+            \seq_item:Nn \l_@@_crossing_seq {####1}
           }
           - 1
         }
         {
 
-          \prop_get:NnN \l_@@_strands_prop {####1} \l_@@_tmpa_tl
+          \prop_get:NnN \l_@@_strands_prop {########1} \l_@@_tmpa_tl
           \tl_put_right:Nx \l_@@_tmpa_tl
             {
               \exp_not:N \@@_lineto:nn
-              {\fp_eval:n {(####1 - 1) * \@@_dim_value:n {width} }}
+              {\fp_eval:n {(########1 - 1) * \@@_dim_value:n {width} }}
               {\fp_eval:n
                 {
                   \l_@@_height_fp + \l_@@_nudge_fp
-                  + .5 * \l_@@_control_fp
+                  + .5 * \l_@@_control_fp / (\seq_count:N \l_@@_crossing_seq - 1)
+                  + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
                 }
               }
               \exp_not:N \@@_moveto:nn
-              {\fp_eval:n {(####1 - 1) * \@@_dim_value:n {width} }}
+              {\fp_eval:n {(########1 - 1) * \@@_dim_value:n {width} }}
               {\fp_eval:n
                 {
-                  \l_@@_height_fp + \@@_dim_value:n {height}
-                  - \l_@@_nudge_fp - .5 * \l_@@_control_fp
+                  \l_@@_height_fp
+                  - \l_@@_nudge_fp - .5 * \l_@@_control_fp / (\seq_count:N \l_@@_crossing_seq - 1)
+                  + \@@_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l_@@_crossing_seq - 1)
                 }
               }
             }
 
-            \prop_put:NnV \l_@@_strands_prop {####1} \l_@@_tmpa_tl
+            \prop_put:NnV \l_@@_strands_prop {########1} \l_@@_tmpa_tl
           }
       }
+%    \end{macrocode}
+% Reset the current long 
+%    \begin{macrocode}
+      \int_compare:nTF
+      {
+        \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+        =
+        \l_@@_crossing_long_int
+      }
+      {
+        \int_set:Nn \l_@@_crossing_long_int {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}}
+      }
+      {
+      \int_compare:nT
+      {
+        \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}
+        =
+        \l_@@_crossing_long_int
+      }
+      {
+        \int_set:Nn \l_@@_crossing_long_int {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}}
+      }
+      
+      }
+%    \end{macrocode}
+%    \begin{macrocode}
+      }
     }
 %    \end{macrocode}
 % If we're to step the level, increase the height and add a load of coordinates. 
@@ -2239,6 +2520,68 @@
     \prop_get:NnN \l_@@_strands_prop {##1} \l_@@_tmpa_tl
     \tl_use:N \l_@@_tmpa_tl
   }
+%    \end{macrocode}
+% Finally, put a node around the whole braid if it's been named
+%    \begin{macrocode}
+  \tl_if_empty:cF {tikz at fig@name}
+  {
+    \tl_gset:cn {pgf at sh@ns@ \tl_use:c{tikz at fig@name} }{rectangle}
+    \tl_gset:cx {pgf at sh@np@ \tl_use:c{tikz at fig@name} }{%
+      \exp_not:N\def
+      \exp_not:N\southwest
+      {
+        \exp_not:N\pgfqpoint
+        {
+          \fp_to_dim:n
+          {
+            min(0,
+            (\l_@@_strands_int - 1)
+            *
+            (\@@_dim_value:n {width})
+            )
+          }
+        }
+        {
+          \fp_to_dim:n
+          {
+            min(0,
+            \l_@@_length_int * (\@@_dim_value:n {height})
+            + 2 * sign(\@@_dim_value:n {height}) *
+            \@@_dim_value:n {border~ height}
+            )
+          }
+        }
+      }
+      \exp_not:N\def
+      \exp_not:N\northeast
+      {
+        \exp_not:N\pgfqpoint
+        {
+          \fp_to_dim:n
+          {
+            max(0,
+            (\l_@@_strands_int - 1)
+            *
+            (\@@_dim_value:n {width})
+            )
+          }
+        }
+        {
+          \fp_to_dim:n
+          {
+            max(0,
+            \l_@@_length_int * (\@@_dim_value:n {height})
+            + 2 * sign(\@@_dim_value:n {height}) *
+            \@@_dim_value:n {border~ height}
+            )
+          }
+        }
+      }
+    }%
+    \pgfgettransform\l_@@_tmpa_tl
+    \tl_gset:cV {pgf at sh@nt@ \tl_use:c{tikz at fig@name} } \l_@@_tmpa_tl
+    \tl_gset:cV {pgf at sh@pi@ \tl_use:c{tikz at fig@name} } \pgfpictureid
+  }
   \end{scope}
 }
 %    \end{macrocode}
@@ -2257,6 +2600,8 @@
 }
 \cs_new_nopar:Npn \@@_curveto:nnnnnn #1#2#3#4#5#6
 {
+%  -- +(5 pt, 0) -- +(0 pt, 0pt)
+%  -- +(#1 pt, #2 pt) -- (#5 pt + #3 pt, #6 pt + #4 pt) -- (#5 pt, #6 pt)
   .. controls +(#1 pt, #2 pt) and +(#3 pt, #4 pt)
   .. (#5 pt, #6 pt)
 }

Modified: trunk/Master/texmf-dist/source/latex/braids/braids_code.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/braids/braids_code.ins	2022-10-25 23:49:45 UTC (rev 64816)
+++ trunk/Master/texmf-dist/source/latex/braids/braids_code.ins	2022-10-26 19:57:44 UTC (rev 64817)
@@ -26,7 +26,7 @@
 \endpreamble
 \postamble
 
-Copyright (C) 2011-2019 by Andrew Stacey <loopspace at mathforge.org>
+Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
 
 This work may be distributed and/or modified under the
 conditions of the LaTeX Project Public License (LPPL), either
@@ -58,7 +58,7 @@
 \endbatchfile
 
 %% 
-%% Copyright (C) 2011-2019 by Andrew Stacey <loopspace at mathforge.org>
+%% Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
 %% 
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License (LPPL), either

Modified: trunk/Master/texmf-dist/tex/latex/braids/braids.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/braids/braids.sty	2022-10-25 23:49:45 UTC (rev 64816)
+++ trunk/Master/texmf-dist/tex/latex/braids/braids.sty	2022-10-26 19:57:44 UTC (rev 64817)
@@ -561,7 +561,7 @@
   \pgfkeys{/pgf/braid/.cd,#1}}
 
 %% 
-%% Copyright (C) 2011-2019 by Andrew Stacey <loopspace at mathforge.org>
+%% Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
 %% 
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License (LPPL), either

Modified: trunk/Master/texmf-dist/tex/latex/braids/tikzlibrarybraids.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/braids/tikzlibrarybraids.code.tex	2022-10-25 23:49:45 UTC (rev 64816)
+++ trunk/Master/texmf-dist/tex/latex/braids/tikzlibrarybraids.code.tex	2022-10-26 19:57:44 UTC (rev 64817)
@@ -13,7 +13,7 @@
 %% ----------------------------------------------------------------
 %% 
 \ProvidesFile{tikzlibrarybraids.code.tex}[%
-  2019/03/20 v2.0 Tikz/PGF library for drawing braid diagrams%
+  2022/10/26 v2.2 Tikz/PGF library for drawing braid diagrams%
 ]
 \RequirePackage{expl3}
 \ExplSyntaxOn
@@ -36,11 +36,19 @@
 \fp_new:N \l__braid_anchor_x_fp
 \fp_new:N \l__braid_anchor_y_fp
 \int_new:N \l__braid_tmpa_int
+\int_new:N \l__braid_tmpb_int
 \int_new:N \l__braid_length_int
 \int_new:N \l__braid_strands_int
 \int_new:N \l__braid_crossing_int
+\int_new:N \l__braid_crossing_start_int
+\int_new:N \l__braid_crossing_end_int
+\int_new:N \l__braid_crossing_width_int
+\int_new:N \l__braid_crossing_long_int
+\int_new:N \l__braid_crossing_start_factor_int
+\int_new:N \l__braid_crossing_end_factor_int
 \int_new:N \l__braid_anchor_level_int
 \int_new:N \l__braid_floor_int
+\seq_new:N \l__braid_tmpa_seq
 \seq_new:N \l__braid_word_seq
 \seq_new:N \l__braid_crossing_seq
 \seq_new:N \l__braid_anchor_seq
@@ -64,19 +72,16 @@
 \prop_new:N \l__braid_crossing_permutation_prop
 \prop_new:N \l__braid_inverse_prop
 \prop_new:N \l__braid_anchor_prop
+\cs_generate_variant:Nn \seq_set_split:Nnn {NVn}
 \tikzset{
    braid/.pic={
-     code={
-       \__braid_parse_word:n {#1}
-       \__braid_count:
-       \__braid_render:
-     }
+     \__braid_parse_word:n {#1}
+     \__braid_count:
+     \__braid_render:
    },
    floor/.pic={
-     code={
-       \path[pic~ actions, draw=none] (0,0) rectangle (1,1);
-       \path[pic~ actions, fill=none] (0,0) -- (1,0) (0,1) -- (1,1);
-     }
+     \path[pic~ actions, draw=none] (0,0) rectangle (1,1);
+     \path[pic~ actions, fill=none] (0,0) -- (1,0) (0,1) -- (1,1);
    },
    /tikz/braid/.search~ also={/tikz},
    braid/.cd,
@@ -174,15 +179,35 @@
 }
 \cs_new_nopar:Npn \__braid_parse_index:n #1
 {
-  \seq_set_from_clist:Nn \l__braid_crossing_seq {#1}
+  \seq_clear:N \l__braid_crossing_seq
+  \clist_map_inline:nn {#1}
+  {
+    \tl_if_in:nnTF {##1} {-}
+    {
+      \seq_set_split:Nnn \l__braid_tmpa_seq {-} {##1}
+      \int_compare:nTF {\seq_item:Nn \l__braid_tmpa_seq {1} < \seq_item:Nn \l__braid_tmpa_seq {2} }
+      {
+        \int_set:Nn \l__braid_tmpa_int {1}
+      }
+      {
+        \int_set:Nn \l__braid_tmpa_int {-1}
+      }
+      \int_step_inline:nnnn {\seq_item:Nn \l__braid_tmpa_seq {1}} {\l__braid_tmpa_int} {\seq_item:Nn \l__braid_tmpa_seq {2}}
+      {
+        \seq_put_right:Nn \l__braid_crossing_seq {####1}
+      }
+    }
+    {
+      \seq_put_right:Nn \l__braid_crossing_seq {##1}
+    }
+  }
   \int_compare:nT {\seq_count:N \l__braid_crossing_seq == 1}
   {
     \seq_put_right:Nx \l__braid_crossing_seq {\int_eval:n {#1 + 1} }
   }
-  \bool_if:NT \l__braid_swap_crossing_bool
+  \bool_if:NF \l__braid_swap_crossing_bool
   {
-    \seq_pop_left:NN \l__braid_crossing_seq \l__braid_tmpa_tl
-    \seq_put_right:NV \l__braid_crossing_seq \l__braid_tmpa_tl
+    \seq_reverse:N \l__braid_crossing_seq
   }
 }
 \cs_new_nopar:Npn \__braid_parse_exponent:n #1
@@ -219,16 +244,12 @@
     }
     \seq_if_empty:NF \l__braid_crossing_seq
     {
-      \int_set:Nn \l__braid_strands_int
+      \seq_map_inline:Nn \l__braid_crossing_seq
       {
-        \int_max:nn
+        \int_set:Nn \l__braid_strands_int
         {
-          \int_max:nn {\l__braid_strands_int}
-          { \seq_item:Nn \l__braid_crossing_seq {1}}
+          \int_max:nn {\l__braid_strands_int} {####1}
         }
-        {
-          \seq_item:Nn \l__braid_crossing_seq {2}
-        }
       }
     }
   }
@@ -239,32 +260,39 @@
     \prop_put:Nnn \l__braid_crossing_permutation_prop {##1} {##1}
   }
   \tl_set:Nx \l__braid_tmpa_tl {\__braid_value:n {anchor}}
-  \seq_set_split:NnV \l__braid_anchor_seq {-} \l__braid_tmpa_tl
+  \tl_if_in:NnTF \l__braid_tmpa_tl {-}
+  {
+    \seq_set_split:NnV \l__braid_anchor_seq {-} \l__braid_tmpa_tl
 
-  \tl_set:Nx \l__braid_tmpa_tl {\seq_item:Nn \l__braid_anchor_seq {1}}
-  \tl_if_eq:VnTF \l__braid_tmpa_tl {rev}
-  {
-    \tl_set:Nx \l__braid_anchor_strand_tl {\seq_item:Nn \l__braid_anchor_seq {2}}
-    \tl_set:Nx \l__braid_anchor_level_tl {\seq_item:Nn \l__braid_anchor_seq {3}}
-  }
-  {
-    \tl_set:Nx \l__braid_anchor_strand_tl {\seq_item:Nn \l__braid_anchor_seq {1}}
-    \tl_set:Nx \l__braid_anchor_level_tl {\seq_item:Nn \l__braid_anchor_seq {2}}
-  }
-  \tl_if_eq:VnTF \l__braid_anchor_level_tl {s}
-  {
-    \int_set:Nn \l__braid_anchor_level_int {-1}
-  }
-  {
-    \tl_if_eq:VnTF \l__braid_anchor_level_tl {e}
+    \tl_set:Nx \l__braid_tmpa_tl {\seq_item:Nn \l__braid_anchor_seq {1}}
+    \tl_if_eq:VnTF \l__braid_tmpa_tl {rev}
     {
+      \tl_set:Nx \l__braid_anchor_strand_tl {\seq_item:Nn \l__braid_anchor_seq {2}}
+      \tl_set:Nx \l__braid_anchor_level_tl {\seq_item:Nn \l__braid_anchor_seq {3}}
+    }
+    {
+      \tl_set:Nx \l__braid_anchor_strand_tl {\seq_item:Nn \l__braid_anchor_seq {1}}
+      \tl_set:Nx \l__braid_anchor_level_tl {\seq_item:Nn \l__braid_anchor_seq {2}}
+    }
+    \tl_if_eq:VnTF \l__braid_anchor_level_tl {s}
+    {
       \int_set:Nn \l__braid_anchor_level_int {-1}
     }
     {
-      \int_set:Nn \l__braid_anchor_level_int
-      {\tl_use:N \l__braid_anchor_level_tl}
+      \tl_if_eq:VnTF \l__braid_anchor_level_tl {e}
+      {
+        \int_set:Nn \l__braid_anchor_level_int {-1}
+      }
+      {
+        \int_set:Nn \l__braid_anchor_level_int
+        {\tl_use:N \l__braid_anchor_level_tl}
+      }
     }
   }
+  {
+    \int_set:Nn \l__braid_anchor_level_int {-1}
+    \tl_set:Nn \l__braid_anchor_strand_tl {-1}
+  }
 
   \int_zero:N \l__braid_crossing_int
   \int_incr:N \l__braid_crossing_int
@@ -276,23 +304,29 @@
     ##1
     \seq_if_empty:NF \l__braid_crossing_seq
     {
-      \prop_get:NxN \l__braid_permutation_prop
+      \int_step_inline:nnn {2} {\seq_count:N \l__braid_crossing_seq}
       {
-        \seq_item:Nn \l__braid_crossing_seq {1}
-      } \l__braid_tmpa_tl
-      \prop_get:NxN \l__braid_permutation_prop
-      {
-        \seq_item:Nn \l__braid_crossing_seq {2}
-      } \l__braid_tmpb_tl
+        \int_set:Nn \l__braid_tmpa_int {####1}
+        \int_set:Nn \l__braid_tmpb_int {####1 - 1}
 
-      \prop_put:NxV \l__braid_permutation_prop
-      {
-        \seq_item:Nn \l__braid_crossing_seq {2}
-      } \l__braid_tmpa_tl
-      \prop_put:NxV \l__braid_permutation_prop
-      {
-        \seq_item:Nn \l__braid_crossing_seq {1}
-      } \l__braid_tmpb_tl
+        \prop_get:NxN \l__braid_permutation_prop
+        {
+          \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+        } \l__braid_tmpa_tl
+        \prop_get:NxN \l__braid_permutation_prop
+        {
+          \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int}
+        } \l__braid_tmpb_tl
+
+        \prop_put:NxV \l__braid_permutation_prop
+        {
+          \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int}
+        } \l__braid_tmpa_tl
+        \prop_put:NxV \l__braid_permutation_prop
+        {
+          \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+        } \l__braid_tmpb_tl
+      }
     }
     \int_compare:nT {\l__braid_crossing_int = \l__braid_anchor_level_int}
     {
@@ -314,22 +348,25 @@
     \prop_get:NnN \l__braid_permutation_prop {##1} \l__braid_tmpa_tl
     \prop_put:NVn \l__braid_inverse_prop \l__braid_tmpa_tl {##1}
   }
-  \tl_set:Nx \l__braid_tmpa_tl {\seq_item:Nn \l__braid_anchor_seq {1}}
-  \tl_if_eq:VnT \l__braid_tmpa_tl {rev}
+  \tl_if_eq:VnF \l__braid_anchor_strand_tl {-1}
   {
-    \prop_get:NVN \l__braid_permutation_prop
-    \l__braid_anchor_strand_tl \l__braid_anchor_strand_tl
-  }
-  \tl_if_eq:VnF \l__braid_anchor_level_tl {s}
-  {
-    \tl_if_eq:VnTF \l__braid_anchor_level_tl {e}
+    \tl_set:Nx \l__braid_tmpa_tl {\seq_item:Nn \l__braid_anchor_seq {1}}
+    \tl_if_eq:VnT \l__braid_tmpa_tl {rev}
     {
-      \prop_get:NVN \l__braid_inverse_prop
+      \prop_get:NVN \l__braid_permutation_prop
       \l__braid_anchor_strand_tl \l__braid_anchor_strand_tl
     }
+    \tl_if_eq:VnF \l__braid_anchor_level_tl {s}
     {
-      \prop_get:NVN \l__braid_anchor_prop
-      \l__braid_anchor_strand_tl \l__braid_anchor_strand_tl
+      \tl_if_eq:VnTF \l__braid_anchor_level_tl {e}
+      {
+        \prop_get:NVN \l__braid_inverse_prop
+        \l__braid_anchor_strand_tl \l__braid_anchor_strand_tl
+      }
+      {
+        \prop_get:NVN \l__braid_anchor_prop
+        \l__braid_anchor_strand_tl \l__braid_anchor_strand_tl
+      }
     }
   }
 }
@@ -349,27 +386,80 @@
 
 \cs_new_nopar:Npn \__braid_render:
 {
-  \fp_set:Nn \l__braid_anchor_x_fp { - 1 * (\tl_use:N \l__braid_anchor_strand_tl - 1) * \__braid_dim_value:n {width} }
-
-  \tl_if_eq:VnTF \l__braid_anchor_level_tl {s}
+  \tl_if_eq:VnTF \l__braid_anchor_strand_tl {-1}
   {
-    \fp_set:Nn \l__braid_anchor_y_fp {0}
+    \tl_set:cn {pgf at sh@ns at temporary braid node}{rectangle}
+    \tl_set:cx {pgf at sh@np at temporary braid node}{%
+      \exp_not:N\def
+      \exp_not:N\southwest
+      {
+        \exp_not:N\pgfqpoint
+        {0pt}
+        {0pt}
+      }
+      \exp_not:N\def
+      \exp_not:N\northeast
+      {
+        \exp_not:N\pgfqpoint
+        {
+          \fp_to_dim:n
+          {
+            (\l__braid_strands_int - 1)
+            *
+            abs(\__braid_dim_value:n {width})
+          }
+        }
+        {
+          \fp_to_dim:n
+          {
+            \l__braid_length_int * abs(\__braid_dim_value:n {height})
+            + 2 * \__braid_dim_value:n {border~ height}
+          }
+        }
+      }
+    }%
+    \pgfgettransform\l__braid_tmpa_tl
+    \tl_set:cV {pgf at sh@nt at temporary braid node} \l__braid_tmpa_tl
+    \tl_set:cV {pgf at sh@pi at temporary braid node} \pgfpictureid
+    \pgfpointanchor{temporary braid node} {\__braid_value:n {anchor}}
+    \fp_set:Nn \l__braid_anchor_x_fp {
+      - \dim_use:c {pgf at x}
+      - (1 - sign(\__braid_dim_value:n {width})) / 2
+      * (\l__braid_strands_int - 1)
+      * \__braid_dim_value:n {width}
+    }
+    \fp_set:Nn \l__braid_anchor_y_fp {
+      - \dim_use:c {pgf at y}
+      - (1 - sign(\__braid_dim_value:n {height})) / 2
+      * (
+      \l__braid_length_int * abs(\__braid_dim_value:n {height})
+      + 2 * \__braid_dim_value:n {border~ height}
+      ) * sign(\__braid_dim_value:n {height})
+    }
   }
   {
-    \tl_if_eq:VnTF \l__braid_anchor_level_tl {e}
+    \fp_set:Nn \l__braid_anchor_x_fp { - 1 * (\tl_use:N \l__braid_anchor_strand_tl - 1) * \__braid_dim_value:n {width} }
+
+    \tl_if_eq:VnTF \l__braid_anchor_level_tl {s}
     {
-      \fp_set:Nn \l__braid_anchor_y_fp {
-        -1 * \l__braid_length_int * \__braid_dim_value:n {height}
-        - sign(\__braid_dim_value:n {height})
-        * 2 * \__braid_dim_value:n {border~ height}
-      }
+      \fp_set:Nn \l__braid_anchor_y_fp {0}
     }
     {
-      \fp_set:Nn \l__braid_anchor_y_fp {
-        -1 * \l__braid_anchor_level_tl * \__braid_dim_value:n {height}
-        - sign(\__braid_dim_value:n {height})
-        * \__braid_dim_value:n {border~ height}
+      \tl_if_eq:VnTF \l__braid_anchor_level_tl {e}
+      {
+        \fp_set:Nn \l__braid_anchor_y_fp {
+          -1 * \l__braid_length_int * \__braid_dim_value:n {height}
+          - sign(\__braid_dim_value:n {height})
+          * 2 * \__braid_dim_value:n {border~ height}
+        }
       }
+      {
+        \fp_set:Nn \l__braid_anchor_y_fp {
+          -1 * \l__braid_anchor_level_tl * \__braid_dim_value:n {height}
+          - sign(\__braid_dim_value:n {height})
+          * \__braid_dim_value:n {border~ height}
+        }
+      }
     }
   }
 
@@ -482,19 +572,71 @@
     }
     \seq_if_empty:NF \l__braid_crossing_seq
     {
+      \int_set:Nn \l__braid_crossing_long_int
+      {
+        %        \seq_item:Nn \l__braid_crossing_seq {\seq_count:N \l__braid_crossing_seq}
+        \seq_item:Nn \l__braid_crossing_seq {1}
+      }
+      \int_set:Nn \l__braid_crossing_start_int
+      {
+        \int_min:nn
+        {
+          \seq_item:Nn \l__braid_crossing_seq {1}
+        }
+        {
+          \seq_item:Nn \l__braid_crossing_seq {\seq_count:N \l__braid_crossing_seq}
+        }
+      }
+      \int_set:Nn \l__braid_crossing_end_int
+      {
+        \int_max:nn
+        {
+          \seq_item:Nn \l__braid_crossing_seq {1}
+        }
+        {
+          \seq_item:Nn \l__braid_crossing_seq {\seq_count:N \l__braid_crossing_seq}
+        }
+
+      }
+      \int_set:Nn \l__braid_crossing_width_int
+      {
+        \l__braid_crossing_end_int
+        -
+        \l__braid_crossing_start_int
+      }
+      \int_step_inline:nnn {2} {\seq_count:N \l__braid_crossing_seq}
+      {
+        \int_set:Nn \l__braid_tmpa_int {####1}
+        \int_set:Nn \l__braid_tmpb_int {####1 - 1}
       \prop_get:NxN \l__braid_crossing_permutation_prop
-      {\seq_item:Nn \l__braid_crossing_seq {1}} \l__braid_tmpa_tl
+      {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}} \l__braid_tmpa_tl
       \prop_get:NxN \l__braid_crossing_permutation_prop
-      {\seq_item:Nn \l__braid_crossing_seq {2}} \l__braid_tmpb_tl
+      {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int}} \l__braid_tmpb_tl
 
       \prop_put:NxV \l__braid_crossing_permutation_prop
-      {\seq_item:Nn \l__braid_crossing_seq {2}} \l__braid_tmpa_tl
+      {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int}} \l__braid_tmpa_tl
       \prop_put:NxV \l__braid_crossing_permutation_prop
-      {\seq_item:Nn \l__braid_crossing_seq {1}} \l__braid_tmpb_tl
+      {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}} \l__braid_tmpb_tl
       \prop_get:NxN \l__braid_strands_prop
-      {\seq_item:Nn \l__braid_crossing_seq {1}} \l__braid_tmpa_tl
+      {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}} \l__braid_tmpa_tl
       \prop_get:NxN \l__braid_strands_prop
-      {\seq_item:Nn \l__braid_crossing_seq {2}} \l__braid_tmpb_tl
+      {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int}} \l__braid_tmpb_tl
+        \int_set:Nn \l__braid_crossing_start_factor_int {0}
+        \int_set:Nn \l__braid_crossing_end_factor_int {0}
+
+        \int_compare:nT {
+          ####1 = \seq_count:N \l__braid_crossing_seq
+        }
+        {
+          \int_set:Nn \l__braid_crossing_end_factor_int {1}
+        }
+        \int_compare:nT {
+          ####1 = 2
+        }
+        {
+          \int_set:Nn \l__braid_crossing_start_factor_int {1}
+        }
+
       \tl_put_right:Nx \l__braid_tmpa_tl
       {
         \exp_not:N \__braid_lineto:nn
@@ -501,23 +643,27 @@
 
         {\fp_eval:n
           {
-            (\seq_item:Nn \l__braid_crossing_seq {1} - 1)
+            (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int} - 1)
             * \__braid_dim_value:n {width}
           }
         }
-        {\fp_eval:n { \l__braid_height_fp + \l__braid_nudge_fp } }
+        {\fp_eval:n { \l__braid_height_fp + \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+            + \__braid_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l__braid_crossing_seq - 1)
+ } }
 
         \exp_not:N \__braid_curveto:nnnnnn
 
         {0}
-        {\fp_eval:n { \l__braid_control_fp}}
+        {\fp_eval:n { \l__braid_control_fp
+            * 1/(\seq_count:N \l__braid_crossing_seq - 1)}}
 
         {0}
-        {\fp_eval:n {- \l__braid_control_fp}}
+        {\fp_eval:n {- \l__braid_control_fp
+            * 1/(\seq_count:N \l__braid_crossing_seq - 1)}}
 
         {\fp_eval:n
           {
-            (\seq_item:Nn \l__braid_crossing_seq {2} - 1)
+            (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int} - 1)
             * \__braid_dim_value:n {width}
           }
         }
@@ -524,11 +670,27 @@
         {\fp_eval:n
           {
             \l__braid_height_fp
-            + \__braid_dim_value:n {height}
-            - \l__braid_nudge_fp
+            + \__braid_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l__braid_crossing_seq - 1)
+            - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
           }
         }
       }
+        \int_set:Nn \l__braid_crossing_start_factor_int {0}
+        \int_set:Nn \l__braid_crossing_end_factor_int {0}
+
+        \int_compare:nT {
+          ####1 = \seq_count:N \l__braid_crossing_seq
+        }
+        {
+          \int_set:Nn \l__braid_crossing_end_factor_int {1}
+        }
+        \int_compare:nT {
+          ####1 = 2
+        }
+        {
+          \int_set:Nn \l__braid_crossing_start_factor_int {1}
+        }
+
       \tl_put_right:Nx \l__braid_tmpb_tl
       {
         \exp_not:N \__braid_lineto:nn
@@ -535,36 +697,39 @@
 
         {\fp_eval:n
           {
-            (\seq_item:Nn \l__braid_crossing_seq {2} - 1)
+            (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int} - 1)
             * \__braid_dim_value:n {width}
           }
         }
-        {\fp_eval:n { \l__braid_height_fp + \l__braid_nudge_fp } }
+        {\fp_eval:n { \l__braid_height_fp + \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+            + \__braid_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l__braid_crossing_seq - 1)
 
+        } }
+
         \exp_not:N \__braid_curveto:nnnnnn
 
         {0}
         {
           \fp_eval:n {
-            \l__braid_control_fp  * (.5 - \__braid_value:n {gap} )
+            \l__braid_control_fp  * (.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) ) * 1/(\seq_count:N \l__braid_crossing_seq - 1)
           }
         }
 
         {
           \fp_eval:n {
-            - (.5 - \__braid_value:n {gap} ) / 3 *
+            - (.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) ) / 3 *
             \__braid_bezier_tangent:nnnnn
-            {.5 - \__braid_value:n {gap} }
+            {.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) }
             {0}
             {0}
             {
-              (\seq_item:Nn \l__braid_crossing_seq {1}
-              - \seq_item:Nn \l__braid_crossing_seq {2})
+              (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+              - \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int})
               * \__braid_dim_value:n {width}
             }
             {
-              (\seq_item:Nn \l__braid_crossing_seq {1}
-              - \seq_item:Nn \l__braid_crossing_seq {2})
+              (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+              - \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int})
               * \__braid_dim_value:n {width}
             }
           }
@@ -571,36 +736,43 @@
         }
         {
           \fp_eval:n {
-            -(.5 - \__braid_value:n {gap} ) / 3 *
+            -(.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) ) / 3 *
             \__braid_bezier_tangent:nnnnn
-            {.5 - \__braid_value:n {gap} }
+            {.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) }
             {0}
-            {\l__braid_control_fp}
             {
-              \__braid_dim_value:n {height}
-              - 2* \l__braid_nudge_fp
-              - \l__braid_control_fp
+              \l__braid_control_fp * 1/(\seq_count:N \l__braid_crossing_seq - 1)
             }
-            {\__braid_dim_value:n {height} - 2* \l__braid_nudge_fp}
+            {
+              \__braid_dim_value:n {height} * 1/(\seq_count:N \l__braid_crossing_seq - 1)
+              - \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+              - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
+              - \l__braid_control_fp * 1/(\seq_count:N \l__braid_crossing_seq - 1)
+            }
+            {
+              \__braid_dim_value:n {height} *  1/(\seq_count:N \l__braid_crossing_seq - 1)
+              - \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+              - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
+            }
           }
         }
 
         {
           \fp_eval:n {
-            (\seq_item:Nn \l__braid_crossing_seq {2} - 1)
+            (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int} - 1)
             * \__braid_dim_value:n {width} +
             \__braid_bezier_point:nnnnn
-            {.5 - \__braid_value:n {gap} }
+            {.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) }
             {0}
             {0}
             {
-              (\seq_item:Nn \l__braid_crossing_seq {1}
-              - \seq_item:Nn \l__braid_crossing_seq {2})
+              (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+              - \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int})
               * \__braid_dim_value:n {width}
             }
             {
-              (\seq_item:Nn \l__braid_crossing_seq {1}
-              - \seq_item:Nn \l__braid_crossing_seq {2})
+              (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+              - \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int})
               * \__braid_dim_value:n {width}
             }
           }
@@ -607,17 +779,26 @@
         }
         {
           \fp_eval:n {
-          \l__braid_height_fp + \l__braid_nudge_fp +
+            \l__braid_height_fp
+            + \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+            + \__braid_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l__braid_crossing_seq - 1)
+            +
             \__braid_bezier_point:nnnnn
-            {.5 - \__braid_value:n {gap} }
+            {.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) }
             {0}
-            {\l__braid_control_fp}
             {
-              \__braid_dim_value:n {height}
-              - 2* \l__braid_nudge_fp
-              - \l__braid_control_fp
+              \l__braid_control_fp * 1/(\seq_count:N \l__braid_crossing_seq - 1)
             }
-            {\__braid_dim_value:n {height} - 2* \l__braid_nudge_fp}
+            {
+              \__braid_dim_value:n {height} *  1/(\seq_count:N \l__braid_crossing_seq - 1)
+              - \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+              - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
+              - \l__braid_control_fp * 1/(\seq_count:N \l__braid_crossing_seq - 1)
+            }
+            {\__braid_dim_value:n {height} *  1/(\seq_count:N \l__braid_crossing_seq - 1)
+              - \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+              - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
+            }
           }
         }
 
@@ -624,20 +805,20 @@
         \exp_not:N \__braid_moveto:nn
         {
           \fp_eval:n {
-            (\seq_item:Nn \l__braid_crossing_seq {2} - 1)
+            (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int} - 1)
             * \__braid_dim_value:n {width} +
             \__braid_bezier_point:nnnnn
-            {.5 + \__braid_value:n {gap} }
+            {.5 + \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) }
             {0}
             {0}
             {
-              (\seq_item:Nn \l__braid_crossing_seq {1}
-              - \seq_item:Nn \l__braid_crossing_seq {2})
+              (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+              - \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int})
               * \__braid_dim_value:n {width}
             }
             {
-              (\seq_item:Nn \l__braid_crossing_seq {1}
-              - \seq_item:Nn \l__braid_crossing_seq {2})
+              (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+              - \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int})
               * \__braid_dim_value:n {width}
             }
           }
@@ -644,16 +825,26 @@
         }
         {
           \fp_eval:n {
-          \l__braid_height_fp + \l__braid_nudge_fp +
+            \l__braid_height_fp
+            + \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+            + \__braid_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l__braid_crossing_seq - 1)
+            +
             \__braid_bezier_point:nnnnn
-            {.5 + \__braid_value:n {gap} }
+            {.5 + \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) }
             {0}
-            {\l__braid_control_fp}
             {
-              \__braid_dim_value:n {height} - 2* \l__braid_nudge_fp
-              - \l__braid_control_fp
+              \l__braid_control_fp * 1/(\seq_count:N \l__braid_crossing_seq - 1)
             }
-            {\__braid_dim_value:n {height} - 2* \l__braid_nudge_fp}
+            {
+              \__braid_dim_value:n {height} *  1/(\seq_count:N \l__braid_crossing_seq - 1)
+              - \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+              - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
+              - \l__braid_control_fp * 1/(\seq_count:N \l__braid_crossing_seq - 1)
+            }
+            {\__braid_dim_value:n {height} *  1/(\seq_count:N \l__braid_crossing_seq - 1)
+              - \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+              - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
+            }
           }
         }
 
@@ -661,19 +852,19 @@
 
         {
           \fp_eval:n {
-            (.5 - \__braid_value:n {gap} ) / 3 *
+            (.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) ) / 3 *
             \__braid_bezier_tangent:nnnnn
-            {.5 + \__braid_value:n {gap} }
+            {.5 + \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) }
             {0}
             {0}
             {
-              (\seq_item:Nn \l__braid_crossing_seq {1}
-              - \seq_item:Nn \l__braid_crossing_seq {2})
+              (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+              - \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int})
               * \__braid_dim_value:n {width}
             }
             {
-              (\seq_item:Nn \l__braid_crossing_seq {1}
-              - \seq_item:Nn \l__braid_crossing_seq {2})
+              (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+              - \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int})
               * \__braid_dim_value:n {width}
             }
           }
@@ -680,59 +871,67 @@
         }
         {
           \fp_eval:n {
-            (.5 - \__braid_value:n {gap} ) / 3 *
+            (.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) ) / 3 *
             \__braid_bezier_tangent:nnnnn
-            {.5 + \__braid_value:n {gap} }
+            {.5 + \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) }
             {0}
-            {\l__braid_control_fp}
             {
-              \__braid_dim_value:n {height} - 2* \l__braid_nudge_fp
-              - \l__braid_control_fp
+              \l__braid_control_fp * 1/(\seq_count:N \l__braid_crossing_seq - 1)
             }
-            {\__braid_dim_value:n {height} - 2* \l__braid_nudge_fp}
+            {
+              \__braid_dim_value:n {height} *  1/(\seq_count:N \l__braid_crossing_seq - 1)
+              - \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+              - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
+              - \l__braid_control_fp * 1/(\seq_count:N \l__braid_crossing_seq - 1)
+            }
+            {\__braid_dim_value:n {height} *  1/(\seq_count:N \l__braid_crossing_seq - 1)
+              - \l__braid_nudge_fp * \l__braid_crossing_start_factor_int
+              - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
+            }
           }
         }
 
         {0}
-        { \fp_eval:n {
-            -\l__braid_control_fp  * (.5 - \__braid_value:n {gap} )
-          }
+        {\fp_eval:n {
+            - \l__braid_control_fp  * (.5 - \__braid_value:n {gap} * (\seq_count:N \l__braid_crossing_seq - 1) )
+            * 1/(\seq_count:N \l__braid_crossing_seq - 1)}
         }
 
         {\fp_eval:n
           {
-            (\seq_item:Nn \l__braid_crossing_seq {1} - 1)
+            (\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int} - 1)
             * \__braid_dim_value:n {width}
           }
         }
         {\fp_eval:n
           {
-            \l__braid_height_fp + \__braid_dim_value:n {height}
-            - \l__braid_nudge_fp
+            \l__braid_height_fp
+            + \__braid_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l__braid_crossing_seq - 1)
+            - \l__braid_nudge_fp * \l__braid_crossing_end_factor_int
           }
         }
 
       }
       \prop_put:NxV \l__braid_strands_prop
-      {\seq_item:Nn \l__braid_crossing_seq {2}} \l__braid_tmpa_tl
+      {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int}} \l__braid_tmpa_tl
       \prop_put:NxV \l__braid_strands_prop
-      {\seq_item:Nn \l__braid_crossing_seq {1}} \l__braid_tmpb_tl
+      {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}} \l__braid_tmpb_tl
       \int_compare:nT
       {
         \int_max:nn
         {
-          \seq_item:Nn \l__braid_crossing_seq {1}
+          \seq_item:Nn \l__braid_crossing_seq {####1 - 1}
         }
         {
-          \seq_item:Nn \l__braid_crossing_seq {2}
+          \seq_item:Nn \l__braid_crossing_seq {####1}
         }
         -
         \int_min:nn
         {
-          \seq_item:Nn \l__braid_crossing_seq {1}
+          \seq_item:Nn \l__braid_crossing_seq {####1 - 1}
         }
         {
-          \seq_item:Nn \l__braid_crossing_seq {2}
+          \seq_item:Nn \l__braid_crossing_seq {####1}
         }
         > 1
       }
@@ -741,10 +940,10 @@
         {
           \int_min:nn
           {
-            \seq_item:Nn \l__braid_crossing_seq {1}
+            \seq_item:Nn \l__braid_crossing_seq {####1 - 1}
           }
           {
-            \seq_item:Nn \l__braid_crossing_seq {2}
+            \seq_item:Nn \l__braid_crossing_seq {####1}
           }
           + 1}
         {1}
@@ -751,39 +950,63 @@
         {
           \int_max:nn
           {
-            \seq_item:Nn \l__braid_crossing_seq {1}
+            \seq_item:Nn \l__braid_crossing_seq {####1 - 1}
           }
           {
-            \seq_item:Nn \l__braid_crossing_seq {2}
+            \seq_item:Nn \l__braid_crossing_seq {####1}
           }
           - 1
         }
         {
 
-          \prop_get:NnN \l__braid_strands_prop {####1} \l__braid_tmpa_tl
+          \prop_get:NnN \l__braid_strands_prop {########1} \l__braid_tmpa_tl
           \tl_put_right:Nx \l__braid_tmpa_tl
             {
               \exp_not:N \__braid_lineto:nn
-              {\fp_eval:n {(####1 - 1) * \__braid_dim_value:n {width} }}
+              {\fp_eval:n {(########1 - 1) * \__braid_dim_value:n {width} }}
               {\fp_eval:n
                 {
                   \l__braid_height_fp + \l__braid_nudge_fp
-                  + .5 * \l__braid_control_fp
+                  + .5 * \l__braid_control_fp / (\seq_count:N \l__braid_crossing_seq - 1)
+                  + \__braid_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l__braid_crossing_seq - 1)
                 }
               }
               \exp_not:N \__braid_moveto:nn
-              {\fp_eval:n {(####1 - 1) * \__braid_dim_value:n {width} }}
+              {\fp_eval:n {(########1 - 1) * \__braid_dim_value:n {width} }}
               {\fp_eval:n
                 {
-                  \l__braid_height_fp + \__braid_dim_value:n {height}
-                  - \l__braid_nudge_fp - .5 * \l__braid_control_fp
+                  \l__braid_height_fp
+                  - \l__braid_nudge_fp - .5 * \l__braid_control_fp / (\seq_count:N \l__braid_crossing_seq - 1)
+                  + \__braid_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l__braid_crossing_seq - 1)
                 }
               }
             }
 
-            \prop_put:NnV \l__braid_strands_prop {####1} \l__braid_tmpa_tl
+            \prop_put:NnV \l__braid_strands_prop {########1} \l__braid_tmpa_tl
           }
       }
+      \int_compare:nTF
+      {
+        \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}
+        =
+        \l__braid_crossing_long_int
+      }
+      {
+        \int_set:Nn \l__braid_crossing_long_int {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int}}
+      }
+      {
+      \int_compare:nT
+      {
+        \seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpb_int}
+        =
+        \l__braid_crossing_long_int
+      }
+      {
+        \int_set:Nn \l__braid_crossing_long_int {\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}}
+      }
+
+      }
+      }
     }
     \bool_if:NT \l__braid_step_level_bool
     {
@@ -833,6 +1056,65 @@
     \prop_get:NnN \l__braid_strands_prop {##1} \l__braid_tmpa_tl
     \tl_use:N \l__braid_tmpa_tl
   }
+  \tl_if_empty:cF {tikz at fig@name}
+  {
+    \tl_gset:cn {pgf at sh@ns@ \tl_use:c{tikz at fig@name} }{rectangle}
+    \tl_gset:cx {pgf at sh@np@ \tl_use:c{tikz at fig@name} }{%
+      \exp_not:N\def
+      \exp_not:N\southwest
+      {
+        \exp_not:N\pgfqpoint
+        {
+          \fp_to_dim:n
+          {
+            min(0,
+            (\l__braid_strands_int - 1)
+            *
+            (\__braid_dim_value:n {width})
+            )
+          }
+        }
+        {
+          \fp_to_dim:n
+          {
+            min(0,
+            \l__braid_length_int * (\__braid_dim_value:n {height})
+            + 2 * sign(\__braid_dim_value:n {height}) *
+            \__braid_dim_value:n {border~ height}
+            )
+          }
+        }
+      }
+      \exp_not:N\def
+      \exp_not:N\northeast
+      {
+        \exp_not:N\pgfqpoint
+        {
+          \fp_to_dim:n
+          {
+            max(0,
+            (\l__braid_strands_int - 1)
+            *
+            (\__braid_dim_value:n {width})
+            )
+          }
+        }
+        {
+          \fp_to_dim:n
+          {
+            max(0,
+            \l__braid_length_int * (\__braid_dim_value:n {height})
+            + 2 * sign(\__braid_dim_value:n {height}) *
+            \__braid_dim_value:n {border~ height}
+            )
+          }
+        }
+      }
+    }%
+    \pgfgettransform\l__braid_tmpa_tl
+    \tl_gset:cV {pgf at sh@nt@ \tl_use:c{tikz at fig@name} } \l__braid_tmpa_tl
+    \tl_gset:cV {pgf at sh@pi@ \tl_use:c{tikz at fig@name} } \pgfpictureid
+  }
   \end{scope}
 }
 \cs_new_nopar:Npn \__braid_moveto:nn #1#2
@@ -891,7 +1173,7 @@
 \ExplSyntaxOff
 
 %% 
-%% Copyright (C) 2011-2019 by Andrew Stacey <loopspace at mathforge.org>
+%% Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
 %% 
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License (LPPL), either



More information about the tex-live-commits mailing list.