texlive[69398] Master/texmf-dist: braids (12jan24)
commits+karl at tug.org
commits+karl at tug.org
Fri Jan 12 22:43:19 CET 2024
Revision: 69398
https://tug.org/svn/texlive?view=revision&revision=69398
Author: karl
Date: 2024-01-12 22:43:19 +0100 (Fri, 12 Jan 2024)
Log Message:
-----------
braids (12jan24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/braids/README.txt
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/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/braids/README.txt 2024-01-12 21:43:05 UTC (rev 69397)
+++ trunk/Master/texmf-dist/doc/latex/braids/README.txt 2024-01-12 21:43:19 UTC (rev 69398)
@@ -1,10 +1,13 @@
----------------------------------------------------------------
-braids --- a style file for drawing braid diagrams with TikZ/PGF
-E-mail: loopspace at mathforge.org
+braids --- a TikZ library for drawing braid diagrams
+bundle version: v2.3 2024/01/09
+E-mail: Andrew Stacey <loopspace at mathforge.org>
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------
-This package defines some commands for drawing braid diagrams with TikZ/PGF.
-The initial idea of this package came from a question and answer on the site http://tex.stackexchange.com.
+This library defines some commands for drawing braid diagrams with TikZ/PGF.
+The initial idea of this package came from a question and answer on the site https://tex.stackexchange.com.
+The package comes in two versions: a package (braids.sty) and a TikZ library (tikzlibrarybraids.code.tex). The original package (braids.sty) is depreciated and has been frozen at version 1.1. The TikZ library is maintained and should be used in preference, except for legacy code.
+
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 2024-01-12 21:43:05 UTC (rev 69397)
+++ trunk/Master/texmf-dist/doc/latex/braids/braids.tex 2024-01-12 21:43:19 UTC (rev 69398)
@@ -3,8 +3,12 @@
\usepackage{lmodern}
\usepackage{morefloats}
\usepackage{tikz}
-\usepackage{braids}
-\usetikzlibrary{braids}
+\usepackage[nowarning]{braids}
+\usetikzlibrary{
+ braids,
+ calc,
+ decorations.markings
+}
\usepackage[numbered]{hypdoc}
\definecolor{lstbgcolor}{rgb}{0.9,0.9,0.9}
@@ -23,21 +27,48 @@
\usepackage{fancyvrb}
\newenvironment{example}
- {\VerbatimEnvironment
- \begin{VerbatimOut}{example.out}}
- {\end{VerbatimOut}
- \begin{center}
- \setlength{\parindent}{0pt}
- \fbox{\begin{minipage}{.9\linewidth}
- \lstinputlisting[]{example.out}
- \end{minipage}}
+{\VerbatimEnvironment
+ \begin{VerbatimOut}{example.out}}
+{\end{VerbatimOut}
+ \begin{center}
+ \setlength{\parindent}{0pt}
+ \fbox{\begin{minipage}{.9\linewidth}
+ \lstinputlisting[]{example.out}
+ \end{minipage}}
- \fbox{\begin{minipage}{.9\linewidth}
- \input{example.out}
- \end{minipage}}
-\end{center}
+ \fbox{\begin{minipage}{.9\linewidth}
+ \centering
+ \input{example.out}
+ \end{minipage}}
+ \end{center}
}
+\newenvironment{justexample}
+{\VerbatimEnvironment
+ \begin{VerbatimOut}{example.out}}
+{\end{VerbatimOut}
+ \begin{center}
+ \setlength{\parindent}{0pt}
+ \fbox{\begin{minipage}{.9\linewidth}
+ \lstinputlisting[]{example.out}
+ \end{minipage}}
+ \end{center}
+}
+
+\usepgfmodule{nonlineartransformations}
+\makeatletter
+\def\polartransformation{%
+ % \pgf at x will contain the radius
+ % \pgf at y will contain the distance
+ \pgfmathsincos@{\pgf at sys@tonumber\pgf at x}%
+ % pgfmathresultx is now the cosine of radius and
+ % pgfmathresulty is the sine of radius
+ \pgf at x=\pgfmathresultx\pgf at y%
+ \pgf at y=\pgfmathresulty\pgf at y%
+}
+\makeatother
+
+
\providecommand*{\url}{\texttt}
\GetFileInfo{tikzlibrarybraids.code.tex}
@@ -57,7 +88,7 @@
line cap=round,
braid/.cd,
width=.75cm,
- height=.5cm,
+ crossing height=.5cm,
strand 3/.style={gray,line width=1pt},
strand 6/.style={gray,line width=1pt},
strand 7/.style={gray,line width=1pt},
@@ -90,6 +121,17 @@
\end{center}
\end{example}
+This is actually the documentation for two packages: a \emph{package} and a TikZ \emph{library}.
+If your preamble contains \Verb+\usepackage{braids}+ then you are using the package, if \Verb+\usetikzlibrary{braids}+ then the library.
+
+The package was the original version, and then with the advent of \Verb+pic+s I rewrote it as a TikZ library.
+If you are starting afresh then you should use the library, but I recognise that people might have figured out how to get what they want with the old package and don't need to switch.
+So although the original package should be considered \emph{depreciated}, it is not (yet) obsolete.
+I will continue to fix bugs for the original package, but new features only go in the TikZ library.
+
+The best place to report bugs or make suggestions for improvements is on \href{https://github.com/loopspace/braids}{github}.
+There have been several excellent suggestions made there, and for v2.3 I am particularly indebted to \href{https://github.com/nilesjohnson}{Niles Johnson} who not only contributed ideas but also helped considerably with clarifying the documentation.
+
\section{TikZ Library Usage}
Version 2.0 changed the implementation to use the TikZ \Verb+pic+ syntax.
@@ -113,7 +155,10 @@
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.
-The subscript determines how the strands cross, as follows:
+The subscript and superscript determine how the strands cross.
+The following describes the default behaviour and is written from the viewpoint that the braid flows down the page.
+This default behaviour can be altered by using the \Verb+crossing convention+ or \Verb+flip crossing convention+ keys (described in a moment).
+%
\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.
@@ -144,11 +189,11 @@
\item To draw a \emph{floor} -- which is a rectangle behind the braid occupying some number of levels (the default being one level) -- precede the braid element by a vertical line, as in \Verb+s_1 | s_2+.
The floor is itself a pic which, by default, consists of a rectangle and two horizontal lines.
-The rectangle picks up any \Verb+fill+ options and the lines any \Verb+draw+ options that are set in the \Verb+braid/every floor+ and \Verb+braid/floor <n>+ styles.
+The rectangle picks up any \Verb+fill+ options and the lines any \Verb+draw+ options that are set in the \Verb+braid/every floor+ and \Verb+braid/floor <n>+ styles, which are documented below (with an example of changing the pic).
The \Verb+n+ is the level number, starting at \(1\).
More general floors can be drawn using the key \Verb+braid/add floor+.
-This takes one argument which is a comma separated list of parameters that specifies the position and size floor:
+This takes one argument which is a comma separated list of parameters that specifies the position and size of the floor:
%
\begin{verbatim}
braid/add floor={x,y,width,height,name}
@@ -159,7 +204,15 @@
Replacing the floor pic will change how it is drawn.
The coordinate system is set up for the floor pic so that the floor is a unit square with lower left corner at the origin.
+The default definition is:
+\begin{lstlisting}
+ floor/.pic={
+ \path[pic actions, draw=none] (0,0) rectangle (1,1);
+ \path[pic actions, fill=none] (0,0) -- (1,0) (0,1) -- (1,1);
+ }
+\end{lstlisting}
+
\item The identity element can occur in the braid-word.
It is represented by \Verb+1+.
This inserts the identity which corresponds to no crossing.
@@ -167,11 +220,67 @@
\end{enumerate}
+The crossing behaviour can be modified by use of one of the following keys.
+All are in the \Verb+/tikz/braid/+ namespace.
+
+\DescribeMacro{crossing convention, flip crossing convention, set symbols, flip symbols} These keys determine the behaviour of the braid symbols.
+Both \Verb+crossing convention+ and \Verb+set symbols+ take an option, which is one of \Verb+over+, \Verb+under+, \Verb+down+, or \Verb+up+; in this list \Verb+over+ and \Verb+down+ are synonyms for each other, as are \Verb+under+ and \Verb+up+.
+The default for both is \Verb+over+.
+Then \Verb+flip crossing convention+ and \Verb+flip symbols+ reverses the current behaviour of the corresponding setting key.
+
+These have similar but not identical behaviours.
+The \Verb+crossing convention+ keys set whether the standard crossings are over or under (the alternatives, \Verb+down+ and \Verb+up+, are based on visualising the braid as travelling down or up the page).
+The \Verb+set symbols+ keys can be used to invert the braid element represented by each symbol.
+
+For the generators, such as \(s_1\), these have the same effect since \(s_1^{-1}\) is obtained from \(s_1\) by swapping the crossing type.
+But for the other symbols, such as \(s_{1-3}\), then these achieve different things.
+With the \Verb+crossing convention+ set to \Verb+under+ then \(s_{1-3}\) still moves strands \(1\) and \(2\) to the right.
+But with \Verb+set symbols+ set to \Verb+under+ then these strands now move to the left.
+
+To see the effect of these options, consider \(s_{1-3}\).
+The equivalences of this, as a braid element, under the various options is in Table~\ref{tab:overunder}.
+In this table each row corresponds to a different setting while the central column gives how to achieve the same result as \(s_{1-3}\) but with the default settings.
+
+\begin{table}
+\begin{center}
+\begin{tabular}{lcc}
+Defaults & \(s_2 s_1\) & \tikz[baseline=(defaults.east)]{ \pic[scale=.5,draw,thin] (defaults) {braid={s_{1-3}}}; \path (defaults.south) +(0,-.1); } \\
+\Verb+crossing convention=under+ & \(s_2^{-1} s_1^{-1}\) & \tikz[baseline=(convention.east)]{ \pic[scale=.5,draw,thin,braid/crossing convention=under] (convention) {braid={s_{1-3}}}; \path (convention.south) +(0,-.1); } \\
+\Verb+set symbols=under+ & \(s_1^{-1} s_2^{-1}\) & \tikz[baseline=(symbols.east)]{ \pic[scale=.5,draw,thin,braid/set symbols=under] (symbols) {braid={s_{1-3}}}; \path (symbols.south) +(0,-.1); }\\
+Both & \(s_1 s_2\) & \tikz[baseline=(symbols.east)]{ \pic[scale=.5,draw,thin,braid/set symbols=under, braid/crossing convention=under] (symbols) {braid={s_{1-3}}}; \path (symbols.south) +(0,-.1); }\\
+\end{tabular}
+\caption{Equivalences of \(s_{1-3}\)}
+\label{tab:overunder}
+\end{center}
+
+\end{table}
+
+
+Any strands not involved in the crossing, for example strands \(2\) and \(3\) in \(s_{1,4}\), stay behind the crossing regardless of these settings.
+This is partially because implementing them as over strands is more complicated to code, and partially because the idea of \(s_{1,4}\) is that strands \(2\) and \(3\) are not involved.
+
+\begin{example}
+\begin{tikzpicture}[
+ braid/.cd,
+ strand 1/.style={red},
+ strand 2/.style={green},
+ strand 3/.style={blue},
+ strand 4/.style={magenta},
+]
+\pic at (0,0) {braid={s_1 s_{1-4} s_{1,3,4}}};
+\pic[braid/crossing convention=under] at (4,0) {braid={s_1 s_{1-4} s_{1,3,4}}};
+\pic[braid/set symbols=under] at (8,0) {braid={s_1 s_{1-4} s_{1,3,4}}};
+\end{tikzpicture}
+\end{example}
+
\subsection{Style Options}
\label{sec:picstyleopts}
There are various keys that change the behaviour or rendering of the braid.
All of these are in the \Verb+/tikz/braid/+ namespace.
+Many of the examples use the key \Verb+braid/.cd+ to switch to this namespace, meaning that multiple \Verb+braid+ keys can be given without the \Verb+braid+ prefix.
+Any unknown keys are dropped back to the \Verb+tikz+ namespace.
+See the TikZ/pgf documentation for more details on key handling.
\DescribeMacro{number of strands} The key \Verb+number of strands+ sets the minimum number of strands for the braid.
The number of strands will grow according to the terms in the braid word so this merely sets a lower bound.
@@ -178,12 +287,41 @@
If not set, the number of strands will be determined by the terms in the braid word.
\DescribeMacro{height}
-The key \Verb+height+ sets the height of the piece of the braid corresponding to an element in the group.
-This can be negative.
+The key \Verb+height+ is used to set the height of the piece of the braid corresponding to a single element in the group.
+This can be negative, and indeed the default value is negative because the default is for a braid to flow down the page.
+This key is depreciated and is only kept for backwards compatibility, the fact that the default is negative proved confusing.
+Therefore the following key should be used in its place.
+
+\DescribeMacro{crossing height}
+The key \Verb+crossing height+ also sets the height of the piece of the braid corresponding to an element in the group.
+The sign of this is ignored.
+
+The correct way to get a braid to flow in a different direction to the default is to use a transformation on the \Verb+pic+, such as in the following example.
+
+\begin{example}
+\begin{tikzpicture}[
+ every braid/.style={
+ ultra thick,
+ braid/strand 1/.style=red,
+ braid/strand 2/.style=green,
+ braid/strand 3/.style=blue,
+ braid/anchor=center,
+ }
+ ]
+\pic {braid={s_1 s_2^{-1}}};
+\pic[rotate=90] at (3,0) {braid={s_1 s_2^{-1}}};
+\pic[rotate=180] at (6,0) {braid={s_1 s_2^{-1}}};
+\pic[yscale=-1] at (9,0) {braid={s_1 s_2^{-1}}};
+\end{tikzpicture}
+\end{example}
+
+The \Verb+crossing height+ and \Verb+height+ keys shouldn't be used together.
+If they are then a message will be printed on the console and the value for \Verb+crossing height+ will be used.
+
\DescribeMacro{width}
The key \Verb+width+ sets the separation of the strands in the braid.
-This can be negative.
+This can be negative (though the effect of a negative width would be better achieved with a transformation of `xscale=-1`).
\DescribeMacro{border height}
The key \Verb+border height+ adds a little extra length to the strands at the start and end of the braid.
@@ -191,10 +329,10 @@
\DescribeMacro{gap}
The key \Verb+gap+ is used to determine how much of a gap to leave in the under strand at a crossing.
This should be a number strictly between 0 and .5.
-The curve is drawn using a cubic bezier and the gap is in terms of the time parameter, so the gap will not increase exactly proportionally to the value given by this key, though that is a reasonable approximation.
+The curve is drawn using a cubic b\'ezier and the gap is in terms of the time parameter, so the gap will not increase exactly proportionally to the value given by this key, though that is a reasonable approximation.
\DescribeMacro{control factor}
-As just said, the parts of the strands involved in a crossing are drawn using a cubic bezier curve.
+As just said, the parts of the strands involved in a crossing are drawn using a cubic b\'ezier curve.
The control points are vertically above or below their respective end point.
This key determines that vertical separation.
It is multiplied by the \Verb+height+ so that it scales properly.
@@ -210,6 +348,43 @@
Note that this does not change the height of a crossing.
Rather, it nudges the height at which the strands start to cross over.
+\bigskip
+
+The following example illustrates the above keys.
+
+\begin{example}
+\begin{tikzpicture}
+\pic[
+ draw,
+ ultra thick,
+ magenta,
+ braid/.cd,
+ border height=3mm,
+ nudge factor=.2,
+ gap=.3
+] (lengths) {braid={s_1 s_2}};
+\draw (lengths-1-s) -- +(-1,0) coordinate (a);
+\draw (lengths-1-0) -- +(-1,0) coordinate (b);
+\draw (lengths-3-1) -- +(1,0) coordinate (c);
+\draw (lengths-1-2) -- +(1,0) coordinate (d);
+\draw (lengths-1-s) -- +(0,1) coordinate (e);
+\draw (lengths-2-s) -- +(0,1) coordinate (f);
+\draw (lengths-2-1) -- +(-1,0) coordinate (g);
+\draw ($(lengths-2-1)!.2!(lengths-1-0)$) -- +(-1,0) coordinate (h);
+\draw (lengths-1-1) -- +(.5,0) coordinate (i);
+\draw ($(lengths-1-1)!.5!(lengths-2-0)$) -- +(.5,0) coordinate (j);
+\draw[|<->|] (a) -- node[left] {border height} (b);
+\draw[|<->|] (c) -- node[right] {crossing height} (d);
+\draw[|<->|] (e) -- node[above] {width} (f);
+\draw[|<->|] (g) -- node[left] {nudge factor} (h);
+\draw[|<->|] (i) -- node[right] {control factor} (j);
+\end{tikzpicture}
+\end{example}
+
+\DescribeMacro{every braid}
+This style is invoked on a scope that surrounds the actual braid.
+It can be used to set defaults for a group of braids.
+
\DescribeMacro{every strand, strand <n>}
The style of the strands are controlled by two types of option.
Style options that are set on the \Verb+pic+ are passed to every strand.
@@ -219,43 +394,90 @@
\DescribeMacro{every floor, floor <n>}
When a floor is requested behind a crossing, it is rendered as a pic.
These keys control how the floor is styled.
+They can even be used to change the \Verb+pic+ used to draw individual floors.
+The \Verb+n+ is the level number, starting at \(1\).
+\begin{example}
+\begin{tikzpicture}
+\pic[
+ braid/floor 3/.style={
+ floor/.pic={
+ \path[pic actions, draw=none] (.5,.5) circle[x radius=.5, y radius=.5];
+ \path[pic actions, fill=none, dashed] (0,0) -- (1,0);
+ \path[pic actions, fill=none, dotted] (0,1) -- (1,1);
+ },
+ },
+ braid/every floor/.style={
+ fill=yellow,
+ draw=black
+ }
+] {braid={| s_1 s_2 | s_1^{-1}}};
+\end{tikzpicture}
+\end{example}
+
\subsection{Coordinates and Anchors}
+\label{sec:coords}
The braid is littered with coordinates.
Each strand gets a coordinate at each end, and at every level between crossings.
These are labelled and numbered by the initial strand position and the crossing level.
They are also labelled and numbered by the final strand position with the prefix \Verb+rev+.
-With a \Verb+name prefix+, the coordinate names look like the following:
+If the braid has been named, the coordinate names look like the following:
%
-\begin{verbatim}
-<name prefix>-<strand number>-<crossing number>
-<name prefix>-rev-<strand number>-<crossing number>
-\end{verbatim}
+\begin{lstlisting}
+ <braid name>-<strand number>-<crossing number>
+ <braid name>-rev-<strand number>-<crossing number>
+\end{lstlisting}
%
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.
+\begin{example}
+\begin{tikzpicture}
+\pic[draw,braid/strand 1/.style={red}] (coords) {braid={s_1}};
+\node[at=(coords-1-s),pin=west:strand 1 start] {};
+\node[at=(coords-1-e),pin=east:strand 1 end] {};
+\end{tikzpicture}
+\end{example}
+
+See Section~\ref{sec:picexamples} for more examples using these anchors.
+
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.
+This node is not defined in the standard way, so -- for example -- it can't directly be used to draw a border, but TikZ behaves afterwards as if it were.
+In particular its anchors can be used to define locations around the edge of the braid.
+\begin{example}
+\begin{tikzpicture}[ultra thick]
+\pic (anchors) at (1,2) {braid={s_1 s_2}};
+\draw[<-,cyan] (anchors.east) -- +(1,0) node[right] {east};
+\draw[<-,cyan] (anchors.west) -- +(-1,0) node[left] {west};
+\draw[<-,cyan] (anchors.north) -- +(0,1) node[above] {north};
+\draw[<-,cyan] (anchors.south) -- +(0,-1) node[below] {south};
+\end{tikzpicture}
+\end{example}
+
\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.
-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 contains a hyphen then it is assumed to refer to a point on a strand with the same interpretation as the coordinates.
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)+
+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}
\begin{center}
\begin{tikzpicture}
\fill[purple] (1,1) circle[radius=3mm];
-\pic[braid/anchor=3-2,rotate=90] at (1,1) {braid={s_2 s_1 s_2 s_1}};
+\pic[
+ rotate=90,
+ braid/anchor=3-2,
+ braid/strand 3/.style={red},
+] at (1,1) {braid={s_2 s_1 s_2 s_1}};
\end{tikzpicture}
\end{center}
\end{example}
-\section{Examples}
+\subsection{Examples}
+\label{sec:picexamples}
Here are more detailed examples.
@@ -271,13 +493,13 @@
braid/strand 3/.style={green},
braid/add floor={2,4,3,2,a},
braid/floor a/.style={fill=pink},
- name prefix=braid,
+ name=coordinates,
] at (2,0) {braid={| s_1-s_3-s_5 | s_2^{-1}-s_4| s_1-s_4 s_2^{-1} s_1-s_3 s_2^{-1}-s_4^{-1}}};
\fill[yellow] (2,0) circle (4pt);
-\node[at=(braid-3-s),pin=north west:strand 3 start] {};
-\node[at=(braid-3-e),pin=south west:strand 3 end] {};
-\node[at=(braid-rev-3-s),pin=north east:strand 3 (from bottom) start] {};
-\node[at=(braid-rev-3-e),pin=south east:strand 3 (from bottom) end] {};
+\node[at=(coordinates-3-s),pin=north west:strand 3 start] {};
+\node[at=(coordinates-3-e),pin=south west:strand 3 end] {};
+\node[at=(coordinates-rev-3-s),pin=north east:strand 3 (from bottom) start] {};
+\node[at=(coordinates-rev-3-e),pin=south east:strand 3 (from bottom) end] {};
\end{tikzpicture}
\end{center}
\end{example}
@@ -295,11 +517,11 @@
gap=0.1,
control factor=0,
nudge factor=0,
- name prefix=braid,
+ name=symbols,
] {braid={a_2 a_1 a_2^{-1} a_1}};
-\node[circle,draw,fill=white,inner sep=0pt] at (braid-2-1) {\(+\)};
-\node[circle,draw,fill=white,inner sep=0pt] at (braid-3-1) {\(-\)};
-\node[circle,draw,fill=white,inner sep=0pt] at (braid-2-3) {\(+\)};
+\node[circle,draw,fill=white,inner sep=0pt] at (symbols-2-1) {\(+\)};
+\node[circle,draw,fill=white,inner sep=0pt] at (symbols-3-1) {\(-\)};
+\node[circle,draw,fill=white,inner sep=0pt] at (symbols-2-3) {\(+\)};
\end{tikzpicture}
\end{center}
@@ -316,9 +538,6 @@
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}
@@ -325,8 +544,149 @@
\end{example}
+The next example uses the nonlinear transformations pgf module with the following definition.
+
+\begin{lstlisting}
+ \usepgfmodule{nonlineartransformations}
+ \makeatletter
+ \def\polartransformation{%
+ % \pgf at x will contain the radius
+ % \pgf at y will contain the distance
+ \pgfmathsincos@{\pgf at sys@tonumber\pgf at x}%
+ % pgfmathresultx is now the cosine of radius and
+ % pgfmathresulty is the sine of radius
+ \pgf at x=\pgfmathresultx\pgf at y%
+ \pgf at y=\pgfmathresulty\pgf at y%
+ }
+ \makeatother
+\end{lstlisting}
+
+\begin{example}
+\begin{tikzpicture}[scale=.5]
+\begin{scope}
+\pgftransformnonlinear{\polartransformation}% see above
+\pic[
+ rotate=90,
+ braid/.cd,
+ every strand/.style={line width=6pt,magenta!67},
+ border height=0cm,
+ crossing height=15.7pt,
+ gap=.2,
+ nudge factor=0.01,
+] at (0,5) {braid=%
+ s_2^{-1} s_3 s_1 s_3 s_2^{-1} s_3 s_1 s_3
+ s_2^{-1} s_3 s_1 s_2^{-1} s_3 s_1 s_2^{-1}
+ s_1 s_3 s_1 s_2^{-1} s_1 s_3 s_1 s_2^{-1}
+};
+\end{scope}
+
+\end{tikzpicture}
+\end{example}
+
\newpage
+Here's an example using a decoration library to style the strands.
+
+\begin{justexample}
+\begin{tikzpicture}[remember picture, overlay]
+\pic[
+ decoration={
+ markings,
+ mark=between positions 2mm and 1 step 5mm with {
+ \draw[black,thick] (-2mm,-1.5mm) .. controls +(4mm,0) and +(-4mm,0) .. (2mm,1.5mm);
+ }
+ },
+ braid/number of strands=10,
+ braid/gap=.15,
+ braid/every strand/.style={
+ line width=3mm,
+ draw,
+ brown!50,
+ postaction={
+ decorate,
+ },
+ preaction={
+ draw,
+ black,
+ line width=3.3mm,
+ }
+ },
+ braid/every floor/.style={
+ draw
+ },
+ braid/height=-3cm,
+ braid/width=2cm,
+ braid/anchor=1-0,
+]
+at ([shift={(2,-2)}]current page.north west)
+{braid={
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+}};
+\begin{scope}[shift={([shift={(1,-2)}]current page.north west)}]
+\draw (0,0) grid[xstep=4cm,ystep=3cm] ++(20,-24.1);
+\draw (18,0) -- +(0,-24.1);
+\end{scope}
+\end{tikzpicture}
+\end{justexample}
+
+\newpage
+
+\begin{tikzpicture}[remember picture, overlay]
+\pic[
+ decoration={
+ markings,
+ mark=between positions 2mm and 1 step 5mm with {
+ \draw[black,thick] (-2mm,-1.5mm) .. controls +(4mm,0) and +(-4mm,0) .. (2mm,1.5mm);
+ }
+ },
+ braid/number of strands=10,
+ braid/gap=.15,
+ braid/every strand/.style={
+ line width=3mm,
+ draw,
+ brown!50,
+ postaction={
+ decorate,
+ },
+ preaction={
+ draw,
+ black,
+ line width=3.3mm,
+ }
+ },
+ braid/every floor/.style={
+ draw
+ },
+ braid/height=-3cm,
+ braid/width=2cm,
+ braid/anchor=1-0,
+]
+at ([shift={(2,-2)}]current page.north west)
+{braid={
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+ s_1-s_3-s_5^{-1}-s_7^{-1}
+}};
+\begin{scope}[shift={([shift={(1,-2)}]current page.north west)}]
+\draw (0,0) grid[xstep=4cm,ystep=3cm] ++(20,-24.1);
+\draw (18,0) -- +(0,-24.1);
+\end{scope}
+\end{tikzpicture}
+
+\newpage
+
\section{Original Package Usage (Depreciated)}
The original version was as a separate package.
@@ -337,6 +697,14 @@
\usepackage{braids}
\end{verbatim}
+This will generate a warning saying that it is preferable to use the TikZ library version.
+To suppress this warning use the \Verb+nowarning+ option:
+
+\begin{verbatim}
+\usepackage[nowarning]{braids}
+\end{verbatim}
+
+
\DescribeMacro{\braid}
A braid is specified by the command \Verb+\braid+.
The syntax for this command is as follows:
@@ -422,10 +790,10 @@
\DescribeMacro{gap}
The key \Verb+gap+ is used to determine how much of a gap to leave in the under strand at a crossing.
This should be a number strictly between 0 and .5.
-The curve is drawn using a cubic bezier and the gap is in terms of the time parameter, so the gap will not increase exactly proportionally to the value given by this key, though that is a reasonable approximation.
+The curve is drawn using a cubic b\'ezier and the gap is in terms of the time parameter, so the gap will not increase exactly proportionally to the value given by this key, though that is a reasonable approximation.
\DescribeMacro{control factor}
-As just said, the parts of the strands involved in a crossing are drawn using a cubic bezier curve.
+As just said, the parts of the strands involved in a crossing are drawn using a cubic b\'ezier curve.
The control points are vertically above or below their respective end point.
This key determines that vertical separation.
It is multiplied by the \Verb+height+ so that it scales properly.
@@ -469,7 +837,8 @@
Any other style options are passed to the underlying TikZ/PGF system and so may influence how the braid is drawn (but note that not all keys make sense due to the implementation).
-\section{Examples}
+\subsection{Examples}
+\label{sec:pkgexamples}
Here are more detailed examples.
@@ -487,13 +856,13 @@
style strands={1}{red},
style strands={2}{blue},
style strands={3}{green}
-] (braid) at (2,0) | s_1-s_3-s_5 | s_2^{-1}-s_4| s_1-s_4 s_2^{-1} s_1-s_3 s_2^{-1}-s_4^{-1};
+] (strands) at (2,0) | s_1-s_3-s_5 | s_2^{-1}-s_4| s_1-s_4 s_2^{-1} s_1-s_3 s_2^{-1}-s_4^{-1};
\fill[yellow] (2,0) circle (4pt);
-\fill[purple] (braid) circle (4pt);
-\node[at=(braid-3-s),pin=north west:strand 3] {};
-\node[at=(braid-3-e),pin=south west:strand 3] {};
-\node[at=(braid-rev-3-s),pin=north east:strand 3 (from bottom)] {};
-\node[at=(braid-rev-3-e),pin=south east:strand 3 (from bottom)] {};
+\fill[purple] (strands) circle (4pt);
+\node[at=(strands-3-s),pin=north west:strand 3] {};
+\node[at=(strands-3-e),pin=south west:strand 3] {};
+\node[at=(strands-rev-3-s),pin=north east:strand 3 (from bottom)] {};
+\node[at=(strands-rev-3-e),pin=south east:strand 3 (from bottom)] {};
\end{tikzpicture}
\end{center}
\end{example}
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 2024-01-12 21:43:05 UTC (rev 69397)
+++ trunk/Master/texmf-dist/source/latex/braids/braids_code.dtx 2024-01-12 21:43:19 UTC (rev 69398)
@@ -4,14 +4,17 @@
%</internal>
%<*readme>
----------------------------------------------------------------
-braids --- a style file for drawing braid diagrams with TikZ/PGF
-E-mail: loopspace at mathforge.org
+braids --- a TikZ library for drawing braid diagrams
+bundle version: v2.3 2024/01/09
+E-mail: Andrew Stacey <loopspace at mathforge.org>
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------
-This package defines some commands for drawing braid diagrams with TikZ/PGF.
-The initial idea of this package came from a question and answer on the site http://tex.stackexchange.com.
+This library defines some commands for drawing braid diagrams with TikZ/PGF.
+The initial idea of this package came from a question and answer on the site https://tex.stackexchange.com.
+
+The package comes in two versions: a package (braids.sty) and a TikZ library (tikzlibrarybraids.code.tex). The original package (braids.sty) is depreciated and has been frozen at version 1.1. The TikZ library is maintained and should be used in preference, except for legacy code.
%</readme>
%<*internal>
\fi
@@ -26,8 +29,9 @@
\askforoverwritefalse
\preamble
----------------------------------------------------------------
-braids --- a style file for drawing braid diagrams with TikZ/PGF
-E-mail: loopspace at mathforge.org
+braids --- a TikZ library for drawing braid diagrams
+bundle version: v2.3 2024/01/09
+E-mail: Andrew Stacey <loopspace at mathforge.org>
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------
@@ -35,7 +39,7 @@
\endpreamble
\postamble
-Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
+Copyright (C) 2011-2024 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
@@ -82,16 +86,12 @@
\expandafter\endgroup
\fi
%</internal>
-%<*package>
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{braids}[2011/10/18 v1.1 Tikz/PGF commands for drawing braid diagrams]
-%</package>
%<*driver>
\documentclass{l3doc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
-\usepackage{braids}
+\usepackage[nowarning]{braids}
\usetikzlibrary{braids}
\EnableCrossrefs
@@ -103,7 +103,7 @@
%</driver>
% \fi
%
-% \CheckSum{2352}
+% \CheckSum{2401}
%
% \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
@@ -127,6 +127,7 @@
% \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}
+% \changes{2.3}{2024/01/09}{Disambiguated height}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
@@ -162,9 +163,21 @@
%
% Issue a notice that this is a depreciated version of the braids package.
% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{braids}[2011/10/18 v1.1 Tikz/PGF commands for drawing braid diagrams (depreciated package)]
+\newif\if at braids@warning@
+\@braids at warning@true
+\DeclareOption{nowarning}{%
+\@braids at warning@false
+}
+
+\ProcessOptions
+
+\if at braids@warning@
\PackageWarning{braids}{%
- This package has been reimplemented as a TikZ library; if starting with a fresh document, please consider using that instead.%
+ This package is frozen at v1.1 from 2011/10/18 and has been reimplemented as a TikZ library; if starting with a fresh document, please consider using that instead.%
}%
+\fi
% \end{macrocode}
%
% \begin{macro}[internal]{\ge at addto@macro}
@@ -1183,7 +1196,7 @@
% Life is so much easier with \LaTeX3.
% \begin{macrocode}
\ProvidesFile{tikzlibrarybraids.code.tex}[%
- 2022/10/26 v2.2 Tikz/PGF library for drawing braid diagrams%
+ 2024/01/09 v2.3 Tikz/PGF library for drawing braid diagrams%
]
\RequirePackage{expl3}
\ExplSyntaxOn
@@ -1227,33 +1240,33 @@
\seq_new:N \l_@@_anchor_seq
\seq_new:N \l_@@_floors_seq
\str_new:N \l_@@_tmpa_str
-\str_new:N \l_@@_sup_str
-\str_set:Nn \l_@@_sup_str {^}
-\str_new:N \l_@@_sub_str
-\str_set:Nn \l_@@_sub_str {_}
-\str_new:N \l_@@_hyphen_str
-\str_set:Nn \l_@@_hyphen_str {-}
-\str_new:N \l_@@_bar_str
-\str_set:Nn \l_@@_bar_str {|}
-\str_new:N \l_@@_one_str
-\str_set:Nn \l_@@_one_str {1}
\bool_new:N \l_@@_step_level_bool
\bool_new:N \l_@@_swap_crossing_bool
+\bool_new:N \l_@@_default_crossing_bool
+\bool_new:N \l_@@_default_symbol_bool
+\bool_set_true:N \l_@@_default_crossing_bool
+\bool_set_true:N \l_@@_default_symbol_bool
\bool_new:N \l_@@_floor_bool
+\bool_new:N \l_@@_height_bool
+\bool_new:N \l_@@_crossing_height_bool
\prop_new:N \l_@@_strands_prop
\prop_new:N \l_@@_permutation_prop
\prop_new:N \l_@@_crossing_permutation_prop
\prop_new:N \l_@@_inverse_prop
\prop_new:N \l_@@_anchor_prop
+\msg_new:nnn {braids} {height} {The~ keys~ "height"~ and~ "crossing~ height"~ shouldn't~ be~ used~ together~ (the~ setting~ for~ "crossing~ height"~ will~ be~ used)}
\cs_generate_variant:Nn \seq_set_split:Nnn {NVn}
+\cs_generate_variant:Nn \str_compare:nNnTF {VNnTF}
% \end{macrocode}
% Our interface is through a TikZ pic.
% \begin{macrocode}
\tikzset{
braid/.pic={
+ \begin{scope}[every~ braid/.try]
\@@_parse_word:n {#1}
\@@_count:
\@@_render:
+ \end{scope}
},
floor/.pic={
\path[pic~ actions, draw=none] (0,0) rectangle (1,1);
@@ -1276,9 +1289,86 @@
% \begin{macrocode}
number~ of~ strands/.initial=0,
% \end{macrocode}
-% \Verb+height+ is the distance between crossings (can be negative).
+%
+% These keys determine whether crossings are over or under by default.
% \begin{macrocode}
+ crossing~ convention/.is~choice,
+ crossing~ convention/over/.code={
+ \bool_set_true:N \l_@@_default_crossing_bool
+ },
+ crossing~ convention/down/.code={
+ \bool_set_true:N \l_@@_default_crossing_bool
+ },
+ crossing~ convention/under/.code={
+ \bool_set_false:N \l_@@_default_crossing_bool
+ },
+ crossing~ convention/up/.code={
+ \bool_set_false:N \l_@@_default_crossing_bool
+ },
+ crossing~ convention/.default=over,
+% \end{macrocode}
+%
+% \begin{macrocode}
+ flip~ crossing~ convention/.code={
+ \bool_set_inverse:N \l_@@_default_crossing_bool
+ },
+% \end{macrocode}
+%
+% These keys determine whether elements should be inverted by default.
+% \begin{macrocode}
+ set~ symbols/.is~choice,
+ set~ symbols/over/.code={
+ \bool_set_true:N \l_@@_default_symbol_bool
+ },
+ set~ symbols/down/.code={
+ \bool_set_true:N \l_@@_default_symbol_bool
+ },
+ set~ symbols/under/.code={
+ \bool_set_false:N \l_@@_default_symbol_bool
+ },
+ set~ symbols/up/.code={
+ \bool_set_false:N \l_@@_default_symbol_bool
+ },
+ set~ symbols/.default=over,
+% \end{macrocode}
+%
+% \begin{macrocode}
+ flip~ symbols/.code={
+ \bool_set_inverse:N \l_@@_default_symbol_bool
+ },
+% \end{macrocode}
+%
+% The next two keys are used to control the separation between the crossings.
+% The original braid package used the \Verb+height+ as part of how it determined the direction of the braid on the page.
+% In particular, the \Verb+height+ could be negative, and indeed the default is for it to be so since a vertical braid usually flows from top to bottom.
+% Now that the drawing is reimplemented as a \Verb+pic+ then the direction is better controlled using transformations.
+% So then \Verb+height+ should be simply to set the gap between crossings in whatever orientation.
+% In particular, \Verb+height+ should be a positive length.
+%
+% To avoid backwards incompatibility, the original (counter-intuitive) version of \Verb+height+ is retained but a new key, \Verb+crossing height+, is introduced which can only be positive (rather, the code will take its absolute value so you can \emph{declare} it to be negative but the code will laugh at you and ignore the sign).
+%
+% To ensure that \Verb+crossing height+ wins, we use a boolean to see if it has been invoked by the user.
+% \begin{macrocode}
height/.initial=-1cm,
+ height/.code={
+ \bool_if:NTF \l_@@_crossing_height_bool
+ {
+ \msg_term:nn {braids} {height}
+ }
+ {
+ \pgfkeyssetvalue{/tikz/braid/height}{#1}
+ \bool_set_true:N \l_@@_height_bool
+ }
+ },
+ crossing~ height/.code={
+ \bool_if:NT \l_@@_height_bool
+ {
+ \msg_term:nn {braids} {height}
+ }
+ \exp_args:Nnx \pgfkeyssetvalue {/tikz/braid/height}
+ {\dim_eval:n {-\dim_abs:n{#1}}}
+ \bool_set_true:N \l_@@_crossing_height_bool
+ },
% \end{macrocode}
% \Verb+width+ is the distance between strands (can be negative).
% \begin{macrocode}
@@ -1464,7 +1554,7 @@
{
\seq_put_right:Nx \l_@@_crossing_seq {\int_eval:n {#1 + 1} }
}
- \bool_if:NF \l_@@_swap_crossing_bool
+ \bool_xor:nnT {\l_@@_swap_crossing_bool} {\l_@@_default_symbol_bool}
{
\seq_reverse:N \l_@@_crossing_seq
}
@@ -1473,7 +1563,7 @@
% \end{macro}
%
% \begin{macro}{\@@_parse_exponent:n}
-% Parse an exponent, basically testing to see if it is \(-1\) in which case our crossing numbers should be reversed..
+% Parse an exponent, basically testing to see if it is \(-1\) in which case our crossing numbers should be reversed.
% \begin{macrocode}
\cs_new_nopar:Npn \@@_parse_exponent:n #1
{
@@ -1838,7 +1928,7 @@
\fp_zero:N \l_@@_height_fp
\fp_zero:N \l_@@_nudge_fp
\fp_zero:N \l_@@_control_fp
-% \end{macrocode}
+% \end{macrocode}
% This holds our current \Verb+height+ of our strands.
% \begin{macrocode}
\fp_set:Nn \l_@@_height_fp
@@ -2008,8 +2098,15 @@
% \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}
+ \bool_if:NTF \l_@@_default_crossing_bool
+ {
+ \int_set:Nn \l_@@_tmpa_int {####1}
+ \int_set:Nn \l_@@_tmpb_int {####1 - 1}
+ }
+ {
+ \int_set:Nn \l_@@_tmpa_int {####1 - 1}
+ \int_set:Nn \l_@@_tmpb_int {####1}
+ }
% \end{macrocode}
% Keep track of the current permutation.
% \begin{macrocode}
Modified: trunk/Master/texmf-dist/source/latex/braids/braids_code.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/braids/braids_code.ins 2024-01-12 21:43:05 UTC (rev 69397)
+++ trunk/Master/texmf-dist/source/latex/braids/braids_code.ins 2024-01-12 21:43:19 UTC (rev 69398)
@@ -6,8 +6,9 @@
%%
%% braids_code.dtx (with options: `install')
%% ----------------------------------------------------------------
-%% braids --- a style file for drawing braid diagrams with TikZ/PGF
-%% E-mail: loopspace at mathforge.org
+%% braids --- a TikZ library for drawing braid diagrams
+%% bundle version: v2.3 2024/01/09
+%% E-mail: Andrew Stacey <loopspace at mathforge.org>
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
@@ -17,8 +18,9 @@
\askforoverwritefalse
\preamble
----------------------------------------------------------------
-braids --- a style file for drawing braid diagrams with TikZ/PGF
-E-mail: loopspace at mathforge.org
+braids --- a TikZ library for drawing braid diagrams
+bundle version: v2.3 2024/01/09
+E-mail: Andrew Stacey <loopspace at mathforge.org>
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------
@@ -26,7 +28,7 @@
\endpreamble
\postamble
-Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
+Copyright (C) 2011-2024 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 +60,7 @@
\endbatchfile
%%
-%% Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
+%% Copyright (C) 2011-2024 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 2024-01-12 21:43:05 UTC (rev 69397)
+++ trunk/Master/texmf-dist/tex/latex/braids/braids.sty 2024-01-12 21:43:19 UTC (rev 69398)
@@ -6,17 +6,28 @@
%%
%% braids_code.dtx (with options: `package')
%% ----------------------------------------------------------------
-%% braids --- a style file for drawing braid diagrams with TikZ/PGF
-%% E-mail: loopspace at mathforge.org
+%% braids --- a TikZ library for drawing braid diagrams
+%% bundle version: v2.3 2024/01/09
+%% E-mail: Andrew Stacey <loopspace at 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/10/18 v1.1 Tikz/PGF commands for drawing braid diagrams]
+\ProvidesPackage{braids}[2011/10/18 v1.1 Tikz/PGF commands for drawing braid diagrams (depreciated package)]
+\newif\if at braids@warning@
+\@braids at warning@true
+\DeclareOption{nowarning}{%
+\@braids at warning@false
+}
+
+\ProcessOptions
+
+\if at braids@warning@
\PackageWarning{braids}{%
- This package has been reimplemented as a TikZ library; if starting with a fresh document, please consider using that instead.%
+ This package is frozen at v1.1 from 2011/10/18 and has been reimplemented as a TikZ library; if starting with a fresh document, please consider using that instead.%
}%
+\fi
\long\def\ge at addto@macro#1#2{%
\begingroup
\toks@\expandafter\expandafter\expandafter{\expandafter#1#2}%
@@ -561,7 +572,7 @@
\pgfkeys{/pgf/braid/.cd,#1}}
%%
-%% Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
+%% Copyright (C) 2011-2024 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 2024-01-12 21:43:05 UTC (rev 69397)
+++ trunk/Master/texmf-dist/tex/latex/braids/tikzlibrarybraids.code.tex 2024-01-12 21:43:19 UTC (rev 69398)
@@ -6,14 +6,15 @@
%%
%% braids_code.dtx (with options: `library')
%% ----------------------------------------------------------------
-%% braids --- a style file for drawing braid diagrams with TikZ/PGF
-%% E-mail: loopspace at mathforge.org
+%% braids --- a TikZ library for drawing braid diagrams
+%% bundle version: v2.3 2024/01/09
+%% E-mail: Andrew Stacey <loopspace at mathforge.org>
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%%
\ProvidesFile{tikzlibrarybraids.code.tex}[%
- 2022/10/26 v2.2 Tikz/PGF library for drawing braid diagrams%
+ 2024/01/09 v2.3 Tikz/PGF library for drawing braid diagrams%
]
\RequirePackage{expl3}
\ExplSyntaxOn
@@ -54,30 +55,30 @@
\seq_new:N \l__braid_anchor_seq
\seq_new:N \l__braid_floors_seq
\str_new:N \l__braid_tmpa_str
-\str_new:N \l__braid_sup_str
-\str_set:Nn \l__braid_sup_str {^}
-\str_new:N \l__braid_sub_str
-\str_set:Nn \l__braid_sub_str {_}
-\str_new:N \l__braid_hyphen_str
-\str_set:Nn \l__braid_hyphen_str {-}
-\str_new:N \l__braid_bar_str
-\str_set:Nn \l__braid_bar_str {|}
-\str_new:N \l__braid_one_str
-\str_set:Nn \l__braid_one_str {1}
\bool_new:N \l__braid_step_level_bool
\bool_new:N \l__braid_swap_crossing_bool
+\bool_new:N \l__braid_default_crossing_bool
+\bool_new:N \l__braid_default_symbol_bool
+\bool_set_true:N \l__braid_default_crossing_bool
+\bool_set_true:N \l__braid_default_symbol_bool
\bool_new:N \l__braid_floor_bool
+\bool_new:N \l__braid_height_bool
+\bool_new:N \l__braid_crossing_height_bool
\prop_new:N \l__braid_strands_prop
\prop_new:N \l__braid_permutation_prop
\prop_new:N \l__braid_crossing_permutation_prop
\prop_new:N \l__braid_inverse_prop
\prop_new:N \l__braid_anchor_prop
+\msg_new:nnn {braids} {height} {The~ keys~ "height"~ and~ "crossing~ height"~ shouldn't~ be~ used~ together~ (the~ setting~ for~ "crossing~ height"~ will~ be~ used)}
\cs_generate_variant:Nn \seq_set_split:Nnn {NVn}
+\cs_generate_variant:Nn \str_compare:nNnTF {VNnTF}
\tikzset{
braid/.pic={
+ \begin{scope}[every~ braid/.try]
\__braid_parse_word:n {#1}
\__braid_count:
\__braid_render:
+ \end{scope}
},
floor/.pic={
\path[pic~ actions, draw=none] (0,0) rectangle (1,1);
@@ -87,7 +88,60 @@
braid/.cd,
anchor/.initial=1-s,
number~ of~ strands/.initial=0,
+ crossing~ convention/.is~choice,
+ crossing~ convention/over/.code={
+ \bool_set_true:N \l__braid_default_crossing_bool
+ },
+ crossing~ convention/down/.code={
+ \bool_set_true:N \l__braid_default_crossing_bool
+ },
+ crossing~ convention/under/.code={
+ \bool_set_false:N \l__braid_default_crossing_bool
+ },
+ crossing~ convention/up/.code={
+ \bool_set_false:N \l__braid_default_crossing_bool
+ },
+ crossing~ convention/.default=over,
+ flip~ crossing~ convention/.code={
+ \bool_set_inverse:N \l__braid_default_crossing_bool
+ },
+ set~ symbols/.is~choice,
+ set~ symbols/over/.code={
+ \bool_set_true:N \l__braid_default_symbol_bool
+ },
+ set~ symbols/down/.code={
+ \bool_set_true:N \l__braid_default_symbol_bool
+ },
+ set~ symbols/under/.code={
+ \bool_set_false:N \l__braid_default_symbol_bool
+ },
+ set~ symbols/up/.code={
+ \bool_set_false:N \l__braid_default_symbol_bool
+ },
+ set~ symbols/.default=over,
+ flip~ symbols/.code={
+ \bool_set_inverse:N \l__braid_default_symbol_bool
+ },
height/.initial=-1cm,
+ height/.code={
+ \bool_if:NTF \l__braid_crossing_height_bool
+ {
+ \msg_term:nn {braids} {height}
+ }
+ {
+ \pgfkeyssetvalue{/tikz/braid/height}{#1}
+ \bool_set_true:N \l__braid_height_bool
+ }
+ },
+ crossing~ height/.code={
+ \bool_if:NT \l__braid_height_bool
+ {
+ \msg_term:nn {braids} {height}
+ }
+ \exp_args:Nnx \pgfkeyssetvalue {/tikz/braid/height}
+ {\dim_eval:n {-\dim_abs:n{#1}}}
+ \bool_set_true:N \l__braid_crossing_height_bool
+ },
width/.initial=1cm,
gap/.initial=.05,
border~ height/.initial=.25cm,
@@ -205,7 +259,7 @@
{
\seq_put_right:Nx \l__braid_crossing_seq {\int_eval:n {#1 + 1} }
}
- \bool_if:NF \l__braid_swap_crossing_bool
+ \bool_xor:nnT {\l__braid_swap_crossing_bool} {\l__braid_default_symbol_bool}
{
\seq_reverse:N \l__braid_crossing_seq
}
@@ -606,8 +660,15 @@
}
\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}
+ \bool_if:NTF \l__braid_default_crossing_bool
+ {
+ \int_set:Nn \l__braid_tmpa_int {####1}
+ \int_set:Nn \l__braid_tmpb_int {####1 - 1}
+ }
+ {
+ \int_set:Nn \l__braid_tmpa_int {####1 - 1}
+ \int_set:Nn \l__braid_tmpb_int {####1}
+ }
\prop_get:NxN \l__braid_crossing_permutation_prop
{\seq_item:Nn \l__braid_crossing_seq {\l__braid_tmpa_int}} \l__braid_tmpa_tl
\prop_get:NxN \l__braid_crossing_permutation_prop
@@ -1173,7 +1234,7 @@
\ExplSyntaxOff
%%
-%% Copyright (C) 2011-2022 by Andrew Stacey <loopspace at mathforge.org>
+%% Copyright (C) 2011-2024 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.