summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/braids/braids.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/braids/braids.tex')
-rw-r--r--graphics/pgf/contrib/braids/braids.tex479
1 files changed, 424 insertions, 55 deletions
diff --git a/graphics/pgf/contrib/braids/braids.tex b/graphics/pgf/contrib/braids/braids.tex
index fa99fd937b..4486b2ab30 100644
--- a/graphics/pgf/contrib/braids/braids.tex
+++ b/graphics/pgf/contrib/braids/braids.tex
@@ -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}}
-
- \fbox{\begin{minipage}{.9\linewidth}
- \input{example.out}
- \end{minipage}}
-\end{center}
+{\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}
+ \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@x will contain the radius
+ % \pgf@y will contain the distance
+ \pgfmathsincos@{\pgf@sys@tonumber\pgf@x}%
+ % pgfmathresultx is now the cosine of radius and
+ % pgfmathresulty is the sine of radius
+ \pgf@x=\pgfmathresultx\pgf@y%
+ \pgf@y=\pgfmathresulty\pgf@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 @@ An example follows.
\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 usual syntax for this is as follows:
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 @@ For example, \Verb+s_1-s_3+.
\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,6 +204,14 @@ The \Verb+name+ is optional and if given can be used to style the floor in that
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+.
@@ -167,23 +220,108 @@ However, it takes the same amount of space as if there were a crossing.
\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.
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 @@ The key \Verb+border height+ adds a little extra length to the strands at the st
\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 @@ For the aforementioned reason, it should not be set to 0 (the default is 0.05).
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 @@ The strands are numbered by their starting position.
\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 @@ Here are more detailed examples.
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 @@ Here are more detailed examples.
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,15 +538,153 @@ Here are more detailed examples.
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}
+The next example uses the nonlinear transformations pgf module with the following definition.
+
+\begin{lstlisting}
+ \usepgfmodule{nonlineartransformations}
+ \makeatletter
+ \def\polartransformation{%
+ % \pgf@x will contain the radius
+ % \pgf@y will contain the distance
+ \pgfmathsincos@{\pgf@sys@tonumber\pgf@x}%
+ % pgfmathresultx is now the cosine of radius and
+ % pgfmathresulty is the sine of radius
+ \pgf@x=\pgfmathresultx\pgf@y%
+ \pgf@y=\pgfmathresulty\pgf@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)}
@@ -337,6 +697,14 @@ To use this package, you need to put the following in the preamble.
\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 @@ The key \Verb+border height+ adds a little extra length to the strands at the st
\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 @@ Anything specified in the \Verb+floor command+ will take precedence over both of
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 @@ Here are more detailed examples.
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}