%shorthand for tikz picture with correct vertical alignment
\newcommand{\tik}[1]{\begin{tikzpicture}[baseline=(current bounding box.center)] #1 \end{tikzpicture} }

%style for crossings (on a white background)
\tikzstyle cross=[preaction={draw=white, -, line width=4pt}, thick]

%various styles
\tikzstyle normal=[thick]
\tikzstyle chord=[densely dotted, thick]
\tikzstyle point=[draw,circle,inner sep=1.5,fill=black]

%In all of the commands below, the optional argument is to add an arrow, i.e.
% \positive[->]{0}{0}
% draw a positive crossing with top corner positionned at (0,0) with arrows pointing down

%crossings
\newcommand{\negative}[3][-]{\draw[normal,#1] (#2+1,-#3).. controls (#2+1,-#3-0.3) and (#2,-#3-0.7)..(#2,-#3-1);
	\draw[cross,#1] (#2,-#3).. controls (#2,-#3-0.3) and (#2+1,-#3-0.7)..(#2+1,-#3-1);}
\newcommand{\positive}[3][-]{ \draw[normal,#1] (#2,-#3).. controls (#2,-#3-0.3) and (#2+1,-#3-0.7)..(#2+1,-#3-1);
	\draw[cross,#1] (#2+1,-#3).. controls (#2+1,-#3-0.3) and (#2,-#3-0.7)..(#2,-#3-1);}
\newcommand{\sing}[3][-]{ \draw[normal,#1] (#2,-#3).. controls (#2,-#3-0.3) and (#2+1,-#3-0.7)..(#2+1,-#3-1);
	\draw[normal,#1] (#2+1,-#3).. controls (#2+1,-#3-0.3) and (#2,-#3-0.7)..(#2,-#3-1);
		\node[point] at (#2+0.5,-#3-0.5) {}; }
\newcommand{\perm}[3][-]{ \draw[normal,#1] (#2,-#3).. controls (#2,-#3-0.3) and (#2+1,-#3-0.7)..(#2+1,-#3-1);
	\draw[normal,#1] (#2+1,-#3).. controls (#2+1,-#3-0.3) and (#2,-#3-0.7)..(#2,-#3-1); }
\newcommand{\straight}[3][-]{\draw[normal,#1] (#2,-#3) -- (#2,-#3-1);}
	
%twist and its inverse
\newcommand{\twist}[3][-]{
	\begin{scope}[xshift=#2cm,yshift=-#3cm,yscale=0.5,xscale=0.8]
		\draw[normal] (0,0)..controls (0,-1) and (0.5,-1).. (0.5,-0.5);
		\draw[cross,#1] (0.5,-0.5)..controls (0.5,0) and (0,0).. (0,-1);
	\end{scope}
}
\newcommand{\twistinv}[3][-]{
	\begin{scope}[xshift=#2cm,yshift=-#3cm,yscale=0.5,xscale=0.8]
		\draw[normal,#1] (0.5,-0.5)..controls (0.5,0) and (0,0).. (0,-1);
		\draw[cross] (0,0)..controls (0,-1) and (0.5,-1).. (0.5,-0.5);
	\end{scope}
}

%cup and caps
\newcommand{\up}[3][-]{ 
\draw[normal,#1] (#2,-#3).. controls (#2,-#3-0.3) and (#2+0.2,-#3-0.5).. (#2+0.5,-#3-0.5);
\draw[normal] (#2+0.5,-#3-0.5).. controls (#2+0.8,-#3-0.5) and (#2+1,-#3-0.3).. (#2+1,-#3);}
\newcommand{\ap}[3][-]{ %"cap" is already taken
\draw[normal,#1] (#2,-#3-1).. controls (#2,-#3-0.7) and (#2+0.2,-#3-0.5).. (#2+0.5,-#3-0.5);
\draw[normal] (#2+0.5,-#3-0.5).. controls (#2+0.8,-#3-0.5) and (#2+1,-#3-0.7).. (#2+1,-#3-1);}

%associators
\def\len{21}
\def\courbasso{1}
\newcommand{\assoc}[2]{ 
	\draw[normal] (#1,-#2).. controls (#1,-#2-\courbasso) and (#1+\len,-#2+1-\courbasso)..(#1+\len,-#2-1);}
\newcommand{\assocback}[2]{ 
	\draw[normal] (#1+\len,-#2).. controls (#1+\len,-#2-\courbasso) and (#1,-#2+1-\courbasso)..(#1,-#2-1);}
	
%chord diagrams
\newcommand{\hori}[4][-]{
	\draw[normal,#1] (#2,-#3)--(#2,-#3-1);\draw[normal,#1] (#2+#4,-#3)--(#2+#4,-#3-1);
	\draw[chord] (#2,-#3-0.5)--(#2+#4,-#3-0.5);}
\newcommand{\labhori}[6][-]{
	\draw[normal,#1] (#2,-#3)--(#2,-#3-1);\draw[normal,#1] (#2+#4,-#3)--(#2+#4,-#3-1);
	\draw[chord] (#2,-#3-0.5)--(#2+#4,-#3-0.5);
\node[point,label=left:$#5$] at (#2,-#3) {};\node[point,label=left:$#6$] at (#2,-#3-1) {};
}