summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/duotenzor/duotenzor.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/duotenzor/duotenzor.sty')
-rw-r--r--Master/texmf-dist/tex/latex/duotenzor/duotenzor.sty758
1 files changed, 758 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/duotenzor/duotenzor.sty b/Master/texmf-dist/tex/latex/duotenzor/duotenzor.sty
new file mode 100644
index 00000000000..0475b87f59d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/duotenzor/duotenzor.sty
@@ -0,0 +1,758 @@
+
+\ProvidesPackage{duotenzor}
+
+%% Version 1.00
+%%%%% This is the duotenzor package.
+
+%%%%%% I have written this sef of definitions to enable me to draw diagrams for operational cicuits and duotensor calculations. It is built on top of
+%%%%%% the Tikz drawing package.
+
+
+\usepackage{tikz}
+
+\usetikzlibrary{calc}
+\usetikzlibrary{arrows}
+
+\usepackage{xspace}
+
+ %% duotensor.sty
+ %% Copyright 2010 Lucien Hardy
+ %
+ % This work may be distributed and/or modified under the
+ % conditions of the LaTeX Project Public License, either version 1.3
+ % of this license or (at your option) any later version.
+ % The latest version of this license is in
+ % http://www.latex-project.org/lppl.txt
+ % and version 1.3 or later is part of all distributions of LaTeX
+ % version 2005/12/01 or later.
+ % This work consists of the files duotenzor.sty and duotenzormanual.pdf
+
+
+
+% Notes
+%
+% Every absolute coordinate should have the coordinate (XYshift) added to it.
+%
+% Font is placed at (fontlocation), or if \otherside is invoked, at (fontlocationb)
+%
+% If an opbox is named A then it has a point on the bottom left called (bottoml A) for inputs and a point on the top left called (topl A) corresponding % to input 1 and output 1 respectively. Other inputs/outputs are spaced at 0.8 intervals using a bit of code.
+% Similarly, a duoboxes named B has (leftt A) at left top and (rightt B) at right top.
+%
+% Op font is \operationalfont which is set, by default, to \mathsf
+% Duotensor font is \duotensorfont which is set, by default, to normal math font.
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fonts %%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% Default font choices (for internal use)
+
+\newcommand{\operationalfont}{\mathsf}
+
+\newcommand{\duotensorfont}{ {} }
+
+% These commands can be used to change the fonts used.
+
+\newcommand{\setoperationalfont}[1]{\renewcommand{\operationalfont}{#1}}
+
+\newcommand{\setduotensorfont}[1]{\renewcommand{\duotensorfont}{#1}}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% environments %%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%%%% diagram environment \begin{diagram}[scale] optional argument is scale. Default is 1=0.25cm
+
+
+\newenvironment{diagram}[1][1]{\begin{tikzpicture}[scale=#1*0.25]
+\path (0,0) coordinate (XYshift); }{\end{tikzpicture}}
+
+
+%%%%%% diagram environment \begin{Diagram}[scale]{Xshift}{voffset} has a verticle offset and a horizontal shift
+
+
+\newenvironment{Diagram}[3][1]{\begin{tikzpicture}
+[scale=#1*0.25, baseline=-5-#3cm]
+\path (0,0)+(#2*4/{#1},0) coordinate (XYshift);}{\end{tikzpicture}}
+
+\newenvironment{move}[2][1]{\begin{scope}[scale=#1] \path (XYshift) coordinate (XYshiftoriginal);
+\path (XYshift)+(#2) coordinate (XYshift);}{\path (XYshiftoriginal) coordinate (XYshift);\end{scope}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Grid %%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newcommand{\constructiongrid}[3][1]{\draw[step=#1cm, very thin] ($(#2)+(XYshift)$) grid ($(#3)+(XYshift)$);}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% \Opbox[hsize]{A}{x,y}
+%
+% plots operation A at (x,y) with symbol A in mathsf.
+% optional argument is hsize = max {number of inputs, number ofoutputs} default is 3.
+% Also defines coordinates bottomlA and bottomrA for reference for wires (for internal use).
+
+\newcommand{\Opbox}[3][3]{\draw[thick] ($(#3)+(XYshift)$) node (#2) {\ensuremath{\operationalfont #2}} +(-0.4*#1-0.15, -1) rectangle + (0.4*#1+0.15, 1); \path ($(#3)+(XYshift)+ (-0.4*#1+0.4,-1)$) coordinate (bottoml #2); \path ($(#3)+(XYshift)+(-0.4*#1+0.4, +1)$) coordinate (topl #2);
+\path (#2) coordinate (fontlocation);}
+
+
+% \opbox[hsize]{A1}{x,y}
+%
+% plots operation A1 at (x,y) - box empty. otherwise same as \Opbox (in which name and symbol were conflated for convenience)
+
+
+\newcommand{\opbox}[3][3]{\draw[thick] ($(#3)+(XYshift)$) node (#2) {{}} +(-0.4*#1-0.15, -1) rectangle + (+0.4*#1+0.15, 1);
+\path ($(#3)+(XYshift)+ (-0.4*#1+0.4,-1)$) coordinate (bottoml #2); \path ($(#3) +(XYshift)+(-0.4*#1+0.4, +1)$) coordinate (topl #2);\path ($(#3)+(XYshift)$) coordinate (fontlocation);}
+
+
+% \Duobox[vsize]{A}{x,y}
+%
+% plots rectangle at (x,y) with symbol A in regular math font.
+% optional argument is max( number inputs, number outputs) default is 3.
+% Also defines coordinates lefttA and righttA for reference links (for internal use}.
+
+
+\newcommand{\Duobox}[3][3]{\draw[thick] ($(#3)+(XYshift)$) node (#2) {\ensuremath{\duotensorfont #2}} +(-1, -0.4*#1-0.15) rectangle + (1, +0.4*#1+0.15);
+\path ($(#3)+(XYshift)+(-1, +0.4*#1-0.4)$) coordinate (leftt #2); \path ($(#3)+(XYshift)+(+1,+0.4*#1-0.4)$) coordinate (rightt #2); \path ($(#3)+(XYshift)$) coordinate (fontlocation);}
+
+% \duobox[vsize]{A1}{x}{y}{A}
+%
+% Plots rectangle A1 at (x,y). Otherwise same as \Duobox
+
+
+\newcommand{\duobox}[3][3]{\draw[thick] ($(#3)+(XYshift)$) node (#2) {{}} +(-1, -0.4*#1-0.15) rectangle + (1, +0.4*#1+0.15);
+\path ($(#3)+(XYshift)+(-1, +0.4*#1-0.4)$) coordinate (leftt #2); \path ($(#3)+(XYshift)+ (+1,+0.4*#1-0.4)$) coordinate (rightt #2);\path ($(#3)+(XYshift)$) coordinate (fontlocation);}
+
+
+
+% \Duoopbox{hsize}{vsize}{A}{x, y}
+%
+% Plots box A (in mathsf font) hsize by vsize at (x,y).
+% Also efines bottomlA, toplA, lefttA, righttA for internal use.
+
+\newcommand{\Opduobox}[4]{\draw[thick] ($(#4)+(XYshift)$) node (#3) {\ensuremath{\operationalfont #3}} +(-0.4*#1-0.15, -0.4*#2-0.15) rectangle + (+0.4*#1+0.15,+0.4*#2+0.15);
+\path ($(#4)+(XYshift)+ (-0.4*#1+0.4,-0.4*#2-0.15)$) coordinate (bottoml #3);
+\path ($(#4)+(XYshift)+(-0.4*#1+0.4,+0.4*#2+0.15)$) coordinate (topl #3);
+\path ($(#4)+(XYshift)+ (-0.4*#1-0.15, +0.4*#2-0.4)$) coordinate (leftt #3);
+\path ($(#4)+(XYshift)+(+0.4*#1+0.15,+0.4*#2-0.4)$) coordinate (rightt #3); \path ($(#4)+(XYshift)$) coordinate (fontlocation); }
+
+
+% \Opduobox{hsize}{vsize}{A}{x,y}{A}
+%
+% plots box A1 with the symbol A (in mathsf font). Otherwise same as \opduobox
+
+
+\newcommand{\opduobox}[4]{\draw[thick] ($(#4)+(XYshift)$) node (#3) {{}} +(-0.4*#1-0.15, -0.4*#2-0.15) rectangle + (+0.4*#1+0.15,+0.4*#2+0.15);
+\path ($(#4)+ (XYshift)+ (-0.4*#1+0.4,-0.4*#2-0.15)$) coordinate (bottoml #3);
+\path ($(#4)+(XYshift)+(-0.4*#1+0.4,+0.4*#2+0.15)$) coordinate (topl #3);
+\path ($(#4)+ (XYshift)+(-0.4*#1-0.15, +0.4*#2-0.4)$) coordinate (leftt #3);
+\path ($(#4)+ (XYshift)+(+0.4*#1+0.15,+0.4*#2-0.4)$) coordinate (rightt #3); \path ($(#4)+(XYshift)$) coordinate (fontlocation); }
+
+% \bbinsert[size]{g}{x,y} also \wwinsert, \wbinsert, \bwinsert.
+
+\newcommand{\bbinsert}[3][1]{
+\draw[thin, -o] ($(#3)+(XYshift)$)+ (-1.5*#1*2,0) coordinate (leftt #2) -- + ( -0.9*#1*2, 0);
+\draw[thin, *-*] ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) -- ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$);
+\draw[thin, -o] ($(#3)+(XYshift)$)+ (1.5*#1*2,0) coordinate (rightt #2) -- + ( 0.9*#1*2, 0);
+\path ($(#3)+(XYshift)+(0, 16pt)$) coordinate (fontlocation); \path ($(#3)+(XYshift)+(0, -16pt)$) coordinate (fontlocationb);
+}
+
+\newcommand{\wwinsert}[3][1]{
+\draw[thin, -*] ($(#3)+(XYshift)$)+ (-1.5*#1*2,0) coordinate (leftt #2) -- + ( -0.9*#1*2, 0);
+\draw[thin, o-o] ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) -- ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$);
+\draw[thin, -*] ($(#3)+(XYshift)$)+ (1.5*#1*2,0) coordinate (rightt #2) -- + ( 0.9*#1*2, 0);
+\path ($(#3)+(XYshift)+(0, 16pt)$) coordinate (fontlocation); \path ($(#3)+(XYshift)+(0, -16pt)$) coordinate (fontlocationb);
+}
+
+\newcommand{\bwinsert}[3][1]{
+\draw[thin, -o] ($(#3)+(XYshift)$)+ (-1.5*#1*2,0) coordinate (leftt #2) -- + ( -0.9*#1*2, 0);
+\draw[thin, *-o] ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) -- ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$);
+\draw[thin, -*] ($(#3)+(XYshift)$)+ (1.5*#1*2,0) coordinate (rightt #2) -- + ( 0.9*#1*2, 0);
+\path ($(#3)+(XYshift)+(0, 16pt)$) coordinate (fontlocation); \path ($(#3)+(XYshift)+(0, -16pt)$) coordinate (fontlocationb);
+}
+
+\newcommand{\wbinsert}[3][1]{
+\draw[thin, -*] ($(#3)+(XYshift)$)+ (-1.5*#1*2,0) coordinate (leftt #2) -- + ( -0.9*#1*2, 0);
+\draw[thin, o-*] ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) -- ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$);
+\draw[thin, -o] ($(#3)+(XYshift)$)+ (1.5*#1*2,0) coordinate (rightt #2) -- + ( 0.9*#1*2, 0);
+\path ($(#3)+(XYshift)+(0, 16pt)$) coordinate (fontlocation); \path ($(#3)+(XYshift)+(0, -16pt)$) coordinate (fontlocationb);
+}
+
+% \bbmetric[size]{g}{x,y}
+
+\newcommand{\bbmetric}[3][1]{
+\path ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) coordinate (leftt #2);
+\draw[thin, *-*] ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) -- ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$);
+\path ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$) coordinate (rightt #2);
+\path ($(#3)+(XYshift)+(0, 16pt)$) coordinate (fontlocation); \path ($(#3)+(XYshift)+(0, -16pt)$) coordinate (fontlocationb);
+}
+
+
+\newcommand{\bwmetric}[3][1]{
+\path ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) coordinate (leftt #2);
+\draw[thin, *-o] ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) -- ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$);
+\path ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$) coordinate (rightt #2);
+\path ($(#3)+(XYshift)+(0, 16pt)$) coordinate (fontlocation); \path ($(#3)+(XYshift)+(0, -16pt)$) coordinate (fontlocationb);
+}
+
+\newcommand{\wbmetric}[3][1]{
+\path ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) coordinate (leftt #2);
+\draw[thin, o-*] ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) -- ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$);
+\path ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$) coordinate (rightt #2);
+\path ($(#3)+(XYshift)+(0, 16pt)$) coordinate (fontlocation); \path ($(#3)+(XYshift)+(0, -16pt)$) coordinate (fontlocationb);
+}
+
+\newcommand{\wwmetric}[3][1]{
+\path ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) coordinate (leftt #2);
+\draw[thin, o-o] ($(#3)+(XYshift)+(-0.9*#1*2 + 0.2 ,0)$) -- ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$);
+\path ($(#3)+(XYshift)+ (0.9*#1*2 -0.2,0)$) coordinate (rightt #2);
+\path ($(#3)+(XYshift)+(0, 16pt)$) coordinate (fontlocation); \path ($(#3)+(XYshift)+(0, -16pt)$) coordinate (fontlocationb);
+}
+
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%% connecting wires and links %%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% \wire[fine tune shape]{A}{B}{1}{3} default finetuneshape is 1. 0 should make wire straight.
+%
+% Plots wire from output 1 of A to input 3 of B. Option of puting "a" for wire type to left of wire
+
+
+\newcommand{\wire}[5][1]{\path (topl #2)+(#4*0.8-0.8, 0) coordinate (bottom); \path (bottoml #3)+ (#5*0.8-0.8, 0) coordinate (top);
+\path (bottom) +(0, #1*1) coordinate (bc); \path (top) + (0, -1*#1) coordinate (tc); \draw (bottom) .. controls (bc) and (tc) .. (top);
+\coordinate (middle) at ($0.5*(bottom) + 0.5*(top)$);
+\coordinate (fontlocation) at ($(middle)!14pt!90:(top)$);
+\coordinate (fontlocationb) at ($(middle)!-14pt!90:(top)$); }
+
+
+% \doublewire[finetuneshape]{A}{B}{1}{3} Also \thikwire \thinwire
+%
+% A double wire. Otherwise same as \wire
+
+\newcommand{\doublewire}[5][1]{\path (topl #2)+(#4*0.8-0.8, 0) coordinate (bottom); \path (bottoml #3)+ (#5*0.8-0.8, 0) coordinate (top);
+\path (bottom) +(0, #1*1) coordinate (bc); \path (top) + (0, -1*#1) coordinate (tc); \draw[thick, double distance=0.4pt] (bottom) .. controls (bc) and (tc) .. (top);
+\coordinate (middle) at ($0.5*(bottom) + 0.5*(top)$);
+\coordinate (fontlocation) at ($(middle)!16pt!90:(top)$);
+\coordinate (fontlocationb) at ($(middle)!-16pt!90:(top)$); }
+
+\newcommand{\thickwire}[5][1]{\path (topl #2)+(#4*0.8-0.8, 0) coordinate (bottom); \path (bottoml #3)+ (#5*0.8-0.8, 0) coordinate (top);
+\path (bottom) +(0, #1*1) coordinate (bc); \path (top) + (0, -1*#1) coordinate (tc); \draw[thick] (bottom) .. controls (bc) and (tc) .. (top);
+\coordinate (middle) at ($0.5*(bottom) + 0.5*(top)$);
+\coordinate (fontlocation) at ($(middle)!15pt!90:(top)$);
+\coordinate (fontlocationb) at ($(middle)!-15pt!90:(top)$); }
+
+\newcommand{\thinwire}[5][1]{\path (topl #2)+(#4*0.8-0.8, 0) coordinate (bottom); \path (bottoml #3)+ (#5*0.8-0.8, 0) coordinate (top);
+\path (bottom) +(0, #1*1) coordinate (bc); \path (top) + (0, -1*#1) coordinate (tc); \draw[very thin] (bottom) .. controls (bc) and (tc) .. (top);
+\coordinate (middle) at ($0.5*(bottom) + 0.5*(top)$);
+\coordinate (fontlocation) at ($(middle)!14pt!90:(top)$);
+\coordinate (fontlocationb) at ($(middle)!-14pt!90:(top)$); }
+
+
+% \link[fine tune shape]{A}{B}{2}{4}
+%
+% Draws link from output index 2 of A to input index 4 of B
+
+
+\newcommand{\link}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+
+% \doubleink[finetuneshape]{A}{B}{2}{4}
+%
+% Double link. Otherwise same as \link
+
+\newcommand{\doublelink}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[thick, double distance=0.4pt] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!23pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-22pt!90:(right)$); }
+
+\newcommand{\thicklink}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[thick] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!20pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-19pt!90:(right)$); }
+
+\newcommand{\thinlink}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[very thin] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+
+
+\newcommand{\linkbw}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(0.5*#1, 0) coordinate (lc);
+\path (right) + (-0.5*#1, 0) coordinate (rc);
+\path ($0.5*(left) + 0.5*(right)$) coordinate (middle);
+\path ($0.501*(left) + 0.499*(right)$) coordinate (bmiddle);
+\draw[-*] (left) .. controls (lc) .. ($(bmiddle)!-1.5pt!(middle)$) ;
+\draw[-o] (right) .. controls (rc) .. ($(bmiddle)!1.5pt!(middle)$);
+\coordinate (fontlocation) at ($(middle)!24pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-23pt!90:(right)$); }
+
+\newcommand{\linkwb}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(0.5*#1, 0) coordinate (lc);
+\path (right) + (-0.5*#1, 0) coordinate (rc);
+\path ($0.5*(left) + 0.5*(right)$) coordinate (middle);
+\path ($0.501*(left) + 0.499*(right)$) coordinate (bmiddle);
+\draw[-o] (left) .. controls (lc) .. ($(bmiddle)!-1.5pt!(middle)$) ;
+\draw[-*] (right) .. controls (rc) .. ($(bmiddle)!1.5pt!(middle)$);
+\coordinate (fontlocation) at ($(middle)!24pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-23pt!90:(right)$); }
+
+\newcommand{\linkww}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(0.5*#1, 0) coordinate (lc);
+\path (right) + (-0.5*#1, 0) coordinate (rc);
+\path ($0.5*(left) + 0.5*(right)$) coordinate (middle);
+\path ($0.501*(left) + 0.499*(right)$) coordinate (bmiddle);
+\draw[-o] (left) .. controls (lc) .. ($(bmiddle)!-1.5pt!(middle)$) ;
+\draw[-o] (right) .. controls (rc) .. ($(bmiddle)!1.5pt!(middle)$);
+\coordinate (fontlocation) at ($(middle)!24pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-23pt!90:(right)$); }
+
+\newcommand{\linkbb}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(0.5*#1, 0) coordinate (lc);
+\path (right) + (-0.5*#1, 0) coordinate (rc);
+\path ($0.5*(left) + 0.5*(right)$) coordinate (middle);
+\path ($0.501*(left) + 0.499*(right)$) coordinate (bmiddle);
+\draw[-*] (left) .. controls (lc) .. ($(bmiddle)!-1.5pt!(middle)$) ;
+\draw[-*] (right) .. controls (rc) .. ($(bmiddle)!1.5pt!(middle)$);
+\coordinate (fontlocation) at ($(middle)!24pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-23pt!90:(right)$); }
+
+
+%%%%%% link with wbbw dots
+
+\newcommand{\linkwbbw}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(0.5*#1, 0) coordinate (lc);
+\path (right) + (-0.5*#1, 0) coordinate (rc);
+\path ($0.5*(left) + 0.5*(right)$) coordinate (middle);
+\path ($0.501*(left) + 0.499*(right)$) coordinate (bmiddle);
+\path ($0.501*(right) + 0.499*(left)$) coordinate (amiddle);
+\draw[-o] (left) .. controls (lc) .. ($(bmiddle)!-1.5cm-1.5pt!(amiddle)$) ;
+\draw[*-*] ($(bmiddle)!-1.5cm+1.5pt!(amiddle)$) -- ($(bmiddle)!1.5cm-1.5pt!(amiddle)$);
+\draw[-o] (right) .. controls (rc) .. ($(bmiddle)!1.5cm+1.5pt!(amiddle)$);
+\coordinate (fontlocation) at ($(middle)!24pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-23pt!90:(right)$); }
+
+\newcommand{\linkbwwb}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(0.5*#1, 0) coordinate (lc);
+\path (right) + (-0.5*#1, 0) coordinate (rc);
+\path ($0.5*(left) + 0.5*(right)$) coordinate (middle);
+\path ($0.501*(left) + 0.499*(right)$) coordinate (bmiddle);
+\path ($0.501*(right) + 0.499*(left)$) coordinate (amiddle);
+\draw[-*] (left) .. controls (lc) .. ($(bmiddle)!-1.5cm-1.5pt!(amiddle)$) ;
+\draw[o-o] ($(bmiddle)!-1.5cm+1.5pt!(amiddle)$) -- ($(bmiddle)!1.5cm-1.5pt!(amiddle)$);
+\draw[-*] (right) .. controls (rc) .. ($(bmiddle)!1.5cm+1.5pt!(amiddle)$);
+\coordinate (fontlocation) at ($(middle)!24pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-23pt!90:(right)$); }
+
+\newcommand{\linkwbwb}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(0.5*#1, 0) coordinate (lc);
+\path (right) + (-0.5*#1, 0) coordinate (rc);
+\path ($0.5*(left) + 0.5*(right)$) coordinate (middle);
+\path ($0.501*(left) + 0.499*(right)$) coordinate (bmiddle);
+\path ($0.501*(right) + 0.499*(left)$) coordinate (amiddle);
+\draw[-o] (left) .. controls (lc) .. ($(bmiddle)!-1.5cm-1.5pt!(amiddle)$) ;
+\draw[*-o] ($(bmiddle)!-1.5cm+1.5pt!(amiddle)$) -- ($(bmiddle)!1.5cm-1.5pt!(amiddle)$);
+\draw[-*] (right) .. controls (rc) .. ($(bmiddle)!1.5cm+1.5pt!(amiddle)$);
+\coordinate (fontlocation) at ($(middle)!24pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-23pt!90:(right)$); }
+
+\newcommand{\linkbwbw}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(0.5*#1, 0) coordinate (lc);
+\path (right) + (-0.5*#1, 0) coordinate (rc);
+\path ($0.5*(left) + 0.5*(right)$) coordinate (middle);
+\path ($0.501*(left) + 0.499*(right)$) coordinate (bmiddle);
+\path ($0.501*(right) + 0.499*(left)$) coordinate (amiddle);
+\draw[-*] (left) .. controls (lc) .. ($(bmiddle)!-1.5cm-1.5pt!(amiddle)$) ;
+\draw[o-*] ($(bmiddle)!-1.5cm+1.5pt!(amiddle)$) -- ($(bmiddle)!1.5cm-1.5pt!(amiddle)$);
+\draw[-o] (right) .. controls (rc) .. ($(bmiddle)!1.5cm+1.5pt!(amiddle)$);
+\coordinate (fontlocation) at ($(middle)!24pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-23pt!90:(right)$); }
+
+
+%%%% links with a black or white dot on one end or both:
+
+
+\newcommand{\blink}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[*-] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+\newcommand{\wlink}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[o-] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+\newcommand{\linkb}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[-*] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+\newcommand{\linkw}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[-o] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+\newcommand{\blinkb}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[*-*] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+\newcommand{\blinkw}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[*-o] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+\newcommand{\wlinkb}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[o-*] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+\newcommand{\wlinkw}[5][1]{\path (rightt #2)+(0, 0.8-#4*0.8) coordinate (left); \path (leftt #3) + (0, 0.8-#5*0.8) coordinate (right);
+\path (left) +(1*#1, 0) coordinate (lc); \path (right) + (-1*#1, 0) coordinate (rc); \draw[o-o] (left) .. controls (lc) and (rc) .. (right);
+\coordinate (middle) at ($0.5*(left) + 0.5*(right)$);
+\coordinate (fontlocation) at ($(middle)!19pt!90:(right)$);
+\coordinate (fontlocationb) at ($(middle)!-18pt!90:(right)$); }
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% inputs and outputs %%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%\outwire[bendyness]{A}{2} Also \inwire[bendyness]{A}{3}
+%
+% Draws an output wire from output 2 of operation A. Option of adding a (in san serif) just after wire.
+
+
+\newcommand{\outwire}[3][0]{\path (topl #2)+(#3*0.8-0.8, 0) coordinate (bottom);
+\path (bottom)+(#1*0.1, 1.5) coordinate (top);
+\path (bottom) +(0, 0.5) coordinate (bc);
+\draw (bottom) .. controls (bc) .. (top);
+\path[draw] (top) + (#1*0.06, 40pt) node (fontlocation) {{}}; }
+
+
+\newcommand{\inwire}[3][0]{\path (bottoml #2)+ (#3*0.8-0.8, 0) coordinate (top);
+\path (top)+ (#1*0.1, -1.5) coordinate (bottom);
+\path (top) +(0, -0.5) coordinate (tc);
+\draw (top) .. controls (tc) .. (bottom);
+\path[draw] (bottom) + (#1*0.06, 0pt) node (fontlocation) {{}}; }
+
+\newcommand{\closedoutwire}[3][0]{\path (topl #2)+(#3*0.8-0.8, 0) coordinate (bottom);
+\path (bottom)+(#1*0.1, 1.5) coordinate (top);
+\path (bottom) +(0, 0.5) coordinate (bc);
+\draw (bottom) .. controls (bc) .. (top);
+\path[draw,ultra thick] ($(top)!0.4cm!90:(bc)$) -- ($(top)!-0.4cm!90:(bc)$);
+\path[draw] (top) + (#1*0.06, 40pt) node (fontlocation) {{}}; }
+
+
+\newcommand{\closedinwire}[3][0]{\path (bottoml #2)+ (#3*0.8-0.8, 0) coordinate (top);
+\path (top)+ (#1*0.1, -1.5) coordinate (bottom);
+\path (top) +(0, -0.5) coordinate (tc);
+\draw (top) .. controls (tc) .. (bottom);
+\path[draw,ultra thick] ($(bottom)!0.4cm!90:(tc)$) -- ($(bottom)!-0.4cm!90:(tc)$);
+\path[draw] (bottom) + (#1*0.06, 0pt) node (fontlocation) {{}}; }
+
+
+
+%\outblack[bend]{A}{2} Also \outwhite, \inblack, \inwhite
+%
+% Draws an output wire with black dot from output 2 of A. Option bends wire down by bend.
+
+
+
+
+
+\newcommand{\outblack}[3][0]{\path (rightt #2)+(0, -#3*0.8 + 0.8) coordinate (start);
+\path (start) + (1.5, -#1*0.1) coordinate (end);
+\path (start) + (0.5, 0) coordinate (sc);
+\draw[ -* ] (start) .. controls (sc) .. (end);
+\path (end) + (25pt, -#1*0.06) node (fontlocation) {{}} ; }
+
+\newcommand{\outwhite}[3][0]{\path (rightt #2)+(0, -#3*0.8 + 0.8) coordinate (start);
+\path (start) + (1.5, -#1*0.1) coordinate (end);
+\path (start) + (0.5, 0) coordinate (sc);
+\draw[ -o ] (start) .. controls (sc) .. (end);
+\path (end) + (25pt, -#1*0.06) node (fontlocation) {{}} ; }
+
+\newcommand{\inblack}[3][0]{\path (leftt #2)+(0, -#3*0.8 + 0.8) coordinate (start);
+\path (start) + (-1.5, -#1*0.1) coordinate (end);
+\path (start) + (-0.5, 0) coordinate (sc);
+\draw[ -* ] (start) .. controls (sc) .. (end);
+\path (end) + (-5pt, -#1*0.06) node (fontlocation) {{}} ; }
+
+\newcommand{\inwhite}[3][0]{\path (leftt #2)+(0, -#3*0.8 + 0.8) coordinate (start);
+\path (start) + (-1.5, -#1*0.1) coordinate (end);
+\path (start) + (-0.5, 0) coordinate (sc);
+\draw[ -o ] (start) .. controls (sc) .. (end);
+\path (end) + (-5pt, -#1*0.06) node (fontlocation) {{}} ; }
+
+
+
+
+
+%%%% \linkedprep[size]{A}{3}{X}{absolute x}{rel y}, also \linkedeffect
+
+
+
+\newcommand{\linkedprep}[6][1]{\path (rightt #2)+(0, -#3*0.8 + 0.8) coordinate (start);
+\path ($(start)-(XYshift)$) coordinate (startraw);
+\path ($(0,0)!(startraw)!(0,1)$) coordinate (startycoord);
+\path[draw] (start) -- ($(startycoord)+(#5-#1*0.433012702, 0)+(XYshift)$) coordinate (end);
+\path[draw,thick] ($(end)+(30:#1*0.5)$) +(150:#1) -- +(30:#1)-- +(-90:#1) -- cycle;
+\path ($0.5*(start)+0.5*(end)+(0,16pt)$) coordinate (fontlocation);
+\path ($0.5*(start)+0.5*(end)-(0,16pt)$) coordinate (fontlocationb);
+\path ($(end)+(30:#1*0.5)+(90:#1*0.5)$) coordinate (topl #4);
+}
+
+
+\newcommand{\linkedeffect}[6][1]{\path (leftt #2)+(0, -#3*0.8 + 0.8) coordinate (start);
+\path ($(start)-(XYshift)$) coordinate (startraw);
+\path ($(0,0)!(startraw)!(0,1)$) coordinate (startycoord);
+\path[draw] (start) -- ($(startycoord)+(#5+#1*0.433012702, 0)+(XYshift)$) coordinate (end);
+\path[draw,thick] ($(end)+(-150:#1*0.5)$) +(90:#1) -- +(-30:#1)-- +(210:#1) -- cycle;
+\path ($0.5*(start)+0.5*(end)+(0,16pt)$) coordinate (fontlocation);
+\path ($0.5*(start)+0.5*(end)-(0,16pt)$) coordinate (fontlocationb);
+\path ($(end)+(-150:#1*0.5)+(-90:#1*0.5)$) coordinate (bottoml #4);
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%% type placement %%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%% \opsymbol[20pt, 10pt]{a_1} Also \duosymbol for regular font. Also \Opsymbol and \Duosymbol which justify font (good on inputs and outputs)
+%
+%
+%places a_2 in sans serif font at the (fontlocation) coordinate of the previous command (a guess as to what a good location is) but allows for fine %tuning (it can be moved by optional argument - in this case 20pt up and 10pt right
+
+
+\newcommand{\opsymbol}[2][0,0]{ \path ($0.0352777778*(#1)+(fontlocation)$) node {\ensuremath{\operationalfont{#2}}};}
+
+\newcommand{\duosymbol}[2][0,0]{\path ($0.0352777778*(#1)+(fontlocation)$) node {\ensuremath{\duotensorfont{#2}}};}
+
+\newcommand{\otherside}{\coordinate (fontlocation) at (fontlocationb);}
+
+\newcommand{\Opsymbol}[2][0,0]{ \path ($0.0352777778*(#1)+(fontlocation)$) node [text height = 1.7em,text depth=.25ex] {\ensuremath{\operationalfont{#2}}};}
+
+\newcommand{\Duosymbol}[2][0,0]{\path ($0.0352777778*(#1)+(fontlocation)$) node [text width = 1em]
+{\ensuremath{\duotensorfont{#2}}};}
+
+%% \putlatex[finetune]{Latex in here} puts it at the (fontlocation) of previous command.
+
+\newcommand{\putlatex}[2][0,0]{ \path ($0.0352777778*(#1)+(fontlocation)$) node {#2};}
+
+%% \placelatex[finetune]{x,y}{Latex in here}
+
+\newcommand{\placelatex}[3][0,0]{ \path ($(XYshift)+(#2)+0.0352777778*(#1)$) node {#3};}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%% Fiducials and terminals %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%% \fidprep[size]{X1}{x,y} Also \fideffect (but with bottoml X1)
+%
+% Draws triangle for fiducial prep labeled by X1 and placed at (x,y) Has topl X1, leftt X1, rightt X1 defined for internal use.
+
+
+\newcommand{\fidprep}[3][1]{\path[draw, thick] ($(#3)+(XYshift)$) coordinate (fontlocation) +(150:#1) -- +(30:#1)-- +(-90:#1) -- cycle + (90:#1*0.5) coordinate (topl #2) +(-30:#1*0.5) coordinate (rightt #2) + (210: #1*0.5) coordinate (leftt #2) ;}
+
+
+\newcommand{\fideffect}[3][1]{\path[draw, thick] ($(#3)+(XYshift)$) coordinate (fontlocation) +(90:#1) -- +(-30:#1)-- +(210:#1) -- cycle + (-90:#1*0.5) coordinate (bottoml #2) +(30:#1*0.5) coordinate (rightt #2) + (150: #1*0.5) coordinate (leftt #2) ;}
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%% Foliation lines %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\newenvironment{foliation}[2]{\path (#1,0)++ (XYshift) coordinate (foliateleft); \path (#1,1) ++ (XYshift) coordinate (leftup);
+\path (#2,0)++ (XYshift) coordinate (foliateright); \path (#2,1)++ (XYshift) coordinate (rightup);}{}
+
+
+
+\newcommand{\startfoliate}[4]{\path[draw, dashed]
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) +(-1,0)$) coordinate (start)
+..
+controls
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)+(-1,0)$)
+..
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)$) ..
+controls ($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)+(1,0)$) and}
+
+
+\newcommand{\continuefoliate}[4]{
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)+(-1,0)$)
+..
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)$)
+..
+controls
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)+(1,0)$) and}
+
+
+\newcommand{\finishfoliate}[4]{($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)+(-1,0)$)
+..
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)$)
+..
+controls
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0)+(1,0)$)
+..
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0) + 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + (1,0)$) coordinate (end);
+\path[draw, dashed] (start) ++ (-13pt, 0) -- ($(foliateleft)!(start)!(leftup)$) coordinate (start);
+\path[draw, dashed] (end)++ (13pt, 0) -- ($(foliateright)!(end)!(rightup)$) coordinate (end);
+\path ($(start)+ (-21pt,0)$) coordinate (fontlocation); \path ($(end) + (21pt,0)$) coordinate (fontlocationb);}
+
+
+\newcommand{\Startfoliate}[5]{\path[draw, dashed]
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0) +(-1,0)$)
+coordinate (start)
+..
+controls
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)+(-1,0)$)
+..
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)$)
+..
+controls ($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)+(1,0)$) and}
+
+
+\newcommand{\Continuefoliate}[5]{
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)+(-1,0)$)
+..
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)$)
+..
+controls
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)+(1,0)$) and}
+
+
+\newcommand{\Finishfoliate}[5]{($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)+(-1,0)$)
+..
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)$)
+..
+controls
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0)+(1,0)$)
+..
+($0.5*(topl #1)+ 0.5*(#3*0.8-0.8, 0)- #5*(topl #1) - #5*(#3*0.8-0.8, 0)
++ 0.5*(bottoml #2)+ 0.5*(#4*0.8-0.8, 0) + #5*(bottoml #2)+ #5*(#4*0.8-0.8, 0) + (1,0)$) coordinate (end) ;
+\path[draw, dashed] (start) ++ (-13pt, 0)-- ($(foliateleft)!(start)!(leftup)$) coordinate (start);
+\path[draw, dashed] (end)++ (13pt, 0) -- ($(foliateright)!(end)!(rightup)$) coordinate (end);
+\path ($(start)+ (-21pt,0)$) coordinate (fontlocation); \path ($(end) + (21pt,0)$) coordinate (fontlocationb);}
+
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%% Abstract symbols %%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% \thispoint[dx,dy]{A}{x,y}
+
+\newcommand{\thispoint}[3][0,0]{\path ($(XYshift)+0.03528*(#1) +(#3)$) coordinate (#2) coordinate (leftt #2) coordinate (rightt #2)
+coordinate (topl #2) coordinate (bottoml #2) coordinate (fontlocation) coordinate (fontlocationb);}
+
+
+%% \boundingbox{coord1}{coord2} defines bounding box for diagram.
+
+
+\newcommand{\boundingbox}[2]{\useasboundingbox ($(#2)+(XYshift)$) rectangle ($(#2)+(XYshift)$);}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% In text symbols %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%
+% \ultrathickdash
+
+\newcommand{\ultrathickdash}{\tikz[baseline=-3pt]\path[draw, ultra thick] (0,0) -- (2mm,0);\xspace}
+
+% \bbdots also \bwdots, \wbdots, \wwdots, \nbdots, \nwdots, \bndots, \wndots, \bbleftjump, \bbrightjump, \bwleftjump, etc.
+
+\newcommand{\bbdots}{\tikz[baseline=-3pt]\path[draw, *-*] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\bwdots}{\tikz[baseline=-3pt]\path[draw, *-o] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\wbdots}{\tikz[baseline=-3pt]\path[draw, o-*] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\wwdots}{\tikz[baseline=-3pt]\path[draw, o-o] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\nbdots}{\tikz[baseline=-3pt]\path[draw, -*] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\nwdots}{\tikz[baseline=-3pt]\path[draw, -o] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\bndots}{\tikz[baseline=-3pt]\path[draw, *-] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\wndots}{\tikz[baseline=-3pt]\path[draw, o-] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\nndots}{\tikz[baseline=-3pt]\path[draw, -] (0,0) -- (6mm,0);\xspace}
+
+\newcommand{\nndotslong}{\tikz[baseline=-3pt]\path[draw, -] (0,0) -- (9mm,0);\xspace}
+
+\newcommand{\bbleftjump}{\tikz[scale=0.18, xscale=1, rotate=90, baseline=-3pt]\path[draw, *-*] (-1,-0.8) -- (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0) -- (1,-0.8); \xspace}
+
+\newcommand{\bwleftjump}{\tikz[scale=0.18, xscale=1, rotate=90, baseline=-3pt]\path[draw, o-*] (-1,-0.8) -- (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0) -- (1,-0.8); \xspace}
+
+\newcommand{\wbleftjump}{\tikz[scale=0.18, xscale=1, rotate=90, baseline=-3pt]\path[draw, *-o] (-1,-0.8) -- (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0) -- (1,-0.8); \xspace}
+
+\newcommand{\wwleftjump}{\tikz[scale=0.18, xscale=1, rotate=90, baseline=-3pt]\path[draw, o-o] (-1,-0.8) -- (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0) -- (1,-0.8); \xspace}
+
+\newcommand{\bbrightjump}{\tikz[scale=0.18, xscale=-1, rotate=90, baseline=-3pt]\path[draw, *-*] (-1,-0.8) -- (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0) -- (1,-0.8); \xspace}
+
+\newcommand{\bwrightjump}{\tikz[scale=0.18, xscale=-1, rotate=90, baseline=-3pt]\path[draw, o-*] (-1,-0.8) -- (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0) -- (1,-0.8); \xspace}
+
+\newcommand{\wbrightjump}{\tikz[scale=0.18, xscale=-1, rotate=90, baseline=-3pt]\path[draw, *-o] (-1,-0.8) -- (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0) -- (1,-0.8); \xspace}
+
+\newcommand{\wwrightjump}{\tikz[scale=0.18, xscale=-1, rotate=90, baseline=-3pt]\path[draw, o-o] (-1,-0.8) -- (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0) -- (1,-0.8); \xspace}
+
+
+
+
+
+
+
+
+
+