% (find-LATEX "2022tikzwd-1.tex")
% (defun c () (interactive) (find-LATEXsh "lualatex -record 2022tikzwd-1.tex" :end))
% (defun C () (interactive) (find-LATEXSH "lualatex 2022tikzwd-1.tex" "Success!!!"))
% (defun D () (interactive) (find-pdf-page      "~/LATEX/2022tikzwd-1.pdf"))
% (defun d () (interactive) (find-pdftools-page "~/LATEX/2022tikzwd-1.pdf"))
% (defun e () (interactive) (find-LATEX "2022tikzwd-1.tex"))
% (defun u () (interactive) (find-latex-upload-links "2022tikzwd-1"))
% (defun v () (interactive) (find-2a '(e) '(d)))
% (defun cv () (interactive) (C) (ee-kill-this-buffer) (v) (g))
% (defun d0 () (interactive) (find-ebuffer "2022tikzwd-1.pdf"))
%          (code-eec-LATEX "2022tikzwd-1")
% (find-pdf-page   "~/LATEX/2022tikzwd-1.pdf")
% (find-sh0 "cp -v  ~/LATEX/2022tikzwd-1.pdf /tmp/")
% (find-sh0 "cp -v  ~/LATEX/2022tikzwd-1.pdf /tmp/pen/")
%   file:///home/edrx/LATEX/2022tikzwd-1.pdf
%               file:///tmp/2022tikzwd-1.pdf
%           file:///tmp/pen/2022tikzwd-1.pdf
% http://angg.twu.net/LATEX/2022tikzwd-1.pdf
% (find-LATEX "2019.mk")
% (find-lualatex-links "2022tikzwd-1" "twd")

\documentclass[11pt,oneside,article]{memoir}
%\usepackage[colorlinks,citecolor=DarkRed,urlcolor=DarkRed]{hyperref} % (find-es "tex" "hyperref")
\usepackage[colorlinks,citecolor=red,urlcolor=red]{hyperref} % (find-es "tex" "hyperref")
%\usepackage{amsmath}
%\usepackage{amsfonts}
%\usepackage{amssymb}
%\usepackage{pict2e}
%\usepackage[x11names,svgnames]{xcolor} % (find-es "tex" "xcolor")
%\usepackage[]{xcolor} % (find-es "tex" "xcolor")
\usepackage{colorweb}                  % (find-es "tex" "colorweb")
%\usepackage{tikz}
%
\usepackage{amsthm}
\usepackage{newpxtext}
\usepackage[varg,bigdelims]{newpxmath}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
%
\usepackage{edrx21}               % (find-LATEX "edrx21.sty")
\input edrxaccents.tex            % (find-LATEX "edrxaccents.tex")
\input edrx21chars.tex            % (find-LATEX "edrx21chars.tex")
\input edrxheadfoot.tex           % (find-LATEX "edrxheadfoot.tex")
%\input edrxgac2.tex               % (find-LATEX "edrxgac2.tex")
%
\usetikzlibrary{
	%cd,
	%math,
	decorations.markings,
	%decorations.pathreplacing,
	positioning,
	%arrows.meta,
	%circuits.logic.US,
	%shapes,
	calc,
	fit,
	quotes}
%
% (find-es "tex" "geometry")

\newcommand{\tn}{\textnormal}
\newcommand{\inp}[1]{#1^{\tn{in}}}
\newcommand{\outp}[1]{#1^{\tn{out}}}
\newcommand{\upd}[1]{#1^{\tn{upd}}}
\newcommand{\rdt}[1]{#1^{\tn{rdt}}}


  \tikzset{
     oriented WD/.style={%everything after equals replaces "oriented WD" in key.
        every to/.style={out=0,in=180,draw},
        label/.style={
           font=\everymath\expandafter{\the\everymath\scriptstyle},
           inner sep=0pt,
           node distance=2pt and -2pt},
        semithick,
        node distance=1 and 1,
        decoration={markings, mark=at position \stringdecpos with \stringdec},
        ar/.style={postaction={decorate}},
        execute at begin picture={\tikzset{
           x=\bbx, y=\bby,
           every fit/.style={inner xsep=\bbx, inner ysep=\bby}}}
        },
     string decoration/.store in=\stringdec,
     string decoration={\arrow{stealth};},
     string decoration pos/.store in=\stringdecpos,
     string decoration pos=.7,
     bbx/.store in=\bbx,
     bbx = 1.5cm,
     bby/.store in=\bby,
     bby = 1.5ex,
     bb port sep/.store in=\bbportsep,
     bb port sep=1.5,
     bb port length/.store in=\bbportlen,
     bb port length=4pt,
     bb penetrate/.store in=\bbpenetrate,
     bb penetrate=0,
     bb min width/.store in=\bbminwidth,
     bb min width=1cm,
     bb rounded corners/.store in=\bbcorners,
     bb rounded corners=2pt,
     bb small/.style={bb port sep=1, bb port length=2.5pt, bbx=.4cm, bb min width=.4cm, bby=.7ex},
     bb medium/.style={bb port sep=1, bb port length=2.5pt, bbx=.4cm, bb min width=.4cm, bby=.9ex},
     bb/.code 2 args={%When you see this key, run the code below:
        \pgfmathsetlengthmacro{\bbheight}{\bbportsep * (max(#1,#2)+1) * \bby}
        \pgfkeysalso{draw,minimum height=\bbheight,minimum width=\bbminwidth,outer sep=0pt,
           rounded corners=\bbcorners,thick,
           prefix after command={\pgfextra{\let\fixname\tikzlastnode}},
           append after command={\pgfextra{\draw
              \ifnum #1=0{} \else foreach \i in {1,...,#1} {
                 ($(\fixname.north west)!{\i/(#1+1)}!(\fixname.south west)$) +(-\bbportlen,0) 
                 coordinate (\fixname_in\i) -- +(\bbpenetrate,0) coordinate (\fixname_in\i')}
              \fi 
              % Define the endpoints of tickmarks
              \ifnum #2=0{} \else foreach \i in {1,...,#2} {
                 ($(\fixname.north east)!{\i/(#2+1)}!(\fixname.south east)$) +(-\bbpenetrate,0) 
                 coordinate (\fixname_out\i') -- +(\bbportlen,0) coordinate (\fixname_out\i)}
              \fi;
           }}}
     },
     bb name/.style={append after command={\pgfextra{\node[anchor=north] at (\fixname.north) {#1};}}}
  }


  \tikzset{
        %unoriented WD/.style={
        %        every to/.style={draw},
        %        shorten <=-\penetration, shorten >=-\penetration,
        %        label distance=-2pt,
        %        thick,
        %        node distance=\spacing,
        %        execute at begin picture={\tikzset{
        %                x=\spacing, y=\spacing}}
        %        },
  	pack size/.store in=\psize,
  	pack size = 8pt,
  	spacing/.store in=\spacing,
  	spacing = 8pt,
  	link size/.store in=\lsize,
  	%link size = 2pt,
	%	penetration/.store in=\penetration,
	%	penetration = 2pt,
  	pack color/.store in=\pcolor,
  	pack color = blue,
  	pack inside color/.store in=\picolor,
  	pack inside color=blue!20,
  	pack outside color/.store in=\pocolor,
  	pack outside color=blue!50!black,
  	surround sep/.store in=\ssep,
  	surround sep=8pt,
  	link/.style={
  		circle, 
  		draw=black, 
  		fill=black,
  		inner sep=0pt, 
  		minimum size=\lsize
  	},
  	%pack/.style={
  	%	circle, 
  	%	draw = \pocolor, 
  	%	fill = \picolor,
  	%	inner sep = .25*\psize,
  	%	minimum size = \psize
  	%},
  	%outer pack/.style={
  	%	ellipse, 
  	%	draw,
  	%	inner sep=\ssep,
  	%	color=\pocolor,
  	%},
  	%intermediate pack/.style={
  	%	ellipse,
  	%	dashed, 
  	%	draw,
  	%	inner sep=\ssep,
  	%	color=\pocolor,
  	%},
  }


\settrims{0pt}{0pt} % page and stock same size
\settypeblocksize{*}{35pc}{*} % {height}{width}{ratio}
\setlrmargins{*}{*}{1} % {spine}{edge}{ratio}
\setulmarginsandblock{1in}{1in}{*} % height of typeblock computed
\setheadfoot{\onelineskip}{2\onelineskip} % {headheight}{footskip}
\setheaderspaces{*}{1.5\onelineskip}{*} % {headdrop}{headsep}{ratio}
\checkandfixthelayout

\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{1}
%\pagestyle{ruled}
\renewcommand*{\chaptitlefont}{\bfseries\Large}
\setsecheadstyle{\bfseries\large\raggedright}
\setsubsecheadstyle{\bfseries\raggedright}




\begin{document}

Some diagrams from:

{\footnotesize

\url{https://github.com/appliedcategorytheory/TikZWD}

}

\bsk


%\begin{equation}\label{eqn.overview}\tag{overview}
\begin{tikzpicture}
\begin{scope}[font=\footnotesize, text height=1.5ex, text depth=.5ex]
  \begin{scope}[oriented WD, bb port sep=1, bb port length=2.5pt, bb min width=.4cm,
                bby=.2cm, inner xsep=.2cm, x=.5cm, y=.3cm]
    \begin{scope}[color=red]
  	\node[bb={1}{1}] (Catf) {$f$};
  	\node[bb={1}{1}, right=1 of Catf] (Catg) {$g$};
  	\node[bb={0}{0}, fit=(Catf) (Catg)] (Cat) {};
  	\node[coordinate] at (Cat.west|-Catf_in1) (Cat_in1) {};
  	\node[coordinate] at (Cat.east|-Catg_out1) (Cat_out1) {};
  	\draw[shorten <=-2pt] (Cat_in1) -- (Catf_in1);
  	\draw (Catf_out1) -- (Catg_in1);
  	\draw[shorten >=-2pt] (Catg_out1) -- (Cat_out1);
    \end{scope}
  %
    \begin{scope}[color=orange]
  	\node[bb={1}{2}, above right=-1.5 and 4 of Catf] (Monf) {$f$};
  	\node[bb={2}{1}, below right=-1 and 1 of Monf] (Mong) {$g$};
  	\node[bb={0}{0}, fit=(Monf) (Mong)] (Mon) {};
  	\node[coordinate] at (Mon.west|-Monf_in1) (Mon_in1) {};
  	\node[coordinate] at (Mon.west|-Mong_in2) (Mon_in2) {};
  	\node[coordinate] at (Mon.east|-Monf_out1) (Mon_out1) {};
  	\node[coordinate] at (Mon.east|-Mong_out1) (Mon_out2) {};
  	\draw[shorten <=-2pt] (Mon_in1) -- (Monf_in1);
  	\draw[shorten >=-2pt] (Monf_out1) -- (Mon_out1);
  	\draw (Monf_out2) to (Mong_in1);
  	\draw[shorten <=-2pt] (Mon_in2) -- (Mong_in2);
  	\draw[shorten >=-2pt] (Mong_out1) -- (Mon_out2);
    \end{scope}
  %
    %\node[bb={2}{1}, right= 4.5 of Monf] (Trf) {$f$};
    %\node[bb={2}{2}, below right=-1 and 1 of Trf] (Trg) {$g$};
    %\node[bb={0}{0}, fit={($(Trf.north west)+(-.5,1)$) ($(Trg.south east)+(.5,-1)$)}] (Tr) {};
    %\node[coordinate] at (Tr.west|-Trf_in2) (Tr_in1) {};
    %\node[coordinate] at (Tr.west|-Trg_in2) (Tr_in2) {};
    %\node[coordinate] at (Tr.east|-Trf_out1) (Tr_out1) {};
    %\node[coordinate] at (Tr.east|-Trg_out2) (Tr_out2) {};
    %\draw[shorten <=-2pt] (Tr_in1) -- (Trf_in2);
    %\draw (Trf_out1) to (Trg_in1);
    %\draw[shorten <=-2pt] (Tr_in2) -- (Trg_in2);
    %\draw[shorten >=-2pt] (Trg_out2) -- (Tr_out2);
    %\draw let \p1=(Trg.east), \p2=(Trf.north west), \n1=\bbportlen, \n2=\bby in
    %  (Trg_out1) to[in=0] (\x1+\n1,\y2+\n2) -- (\x2-\n1,\y2+\n2) to[out=180] (Trf_in1);
  %
  \end{scope}
  %\begin{scope}[penetration=0, unoriented WD, pack outside color=black, pack inside color=white]
  %  \begin{scope}[color=orange]
  %	\node[pack, right=2.9 of Trf] (Hypf) {$f$};
  %	\node[pack, below right=0 and .5 of Hypf] (Hypg) {$g$};
  %	\node[outer pack, inner sep=5pt, fit=(Hypf) (Hypg)] (Hyp) {};
  %	\node[coordinate] at ($(Hypg.-30)!.5!(Hyp.-30)$) (link) {};
  %	\draw (Hypf) to[bend left] (Hypg);
  %	\draw (Hypf) to[bend right] (Hypg);
  %	\draw (Hypg) -- (link);
  %	\draw[shorten >= -2pt] (link) to[bend left] (Hyp.-20);
  %	\draw[shorten >= -2pt] (link) to[bend right] (Hyp.-45);
  %	\draw[shorten >= -2pt] (Hypf) -- (Hyp);
  %  \end{scope}
  %\end{scope}
  %\begin{scope}[circuit logic US, thick, every to/.style={out=0,in=180}]
  %      \node[and gate, draw, right=2.5 of Hypf] (Opdf) {$f$};
  %      \node[and gate, draw, below right=0 and 0.5 of Opdf] (Opdg) {$g$};
  %              \node[and gate, inner sep=1pt, draw, fit=(Opdf) (Opdg)] (Opd) {};
  %              \draw[shorten <=-2pt] (Opd.input 1|-Opdf.west) to (Opdf.west);
  %              \draw[shorten <=-2pt] (Opd.input 1|-Opdg.input 2) to (Opdg.input 2);
  %              \draw (Opdf.output) to (Opdg.input 1);
  %              \draw[shorten >=-2pt] (Opdg.output) to (Opd.output);
  %\end{scope}
  \node[below=.65 of Cat.south] (Cat name) {category};
  \node[text width=1.5cm] at (Cat name-|Mon) {monoidal category};
  %\node[text width=2.5cm] at (Cat name-|Tr) {traced monoidal category};
  %\node[text width=2cm] at (Cat name-|Hyp) {hypergraph category};
  %\node at (Cat name-|Opd) {operad};
\end{scope}
\end{tikzpicture}
%\end{equation}




\GenericWarning{Success:}{Success!!!}  % Used by `M-x cv'

\end{document}


% Local Variables:
% coding: utf-8-unix
% ee-tla: "twd"
% indent-tabs-mode: nil
% End:
