0

I need to draw the following diagramenter image description here

using the style of this second diagram enter image description here

In other words, I need all boxes to be of the same shape (square or rectangular) and all wires to be as thin as those in the second diagram. Labels for the wires are not necessary. What would be the most efficient way to do this in tikz?

My code for the second picture is

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,positioning}
\newcommand{\catname}[1]{\mathbf{#1}}
\begin{document}

\begin{tikzpicture}[arr/.style={
            postaction={decorate},          
            decoration={
            markings,
            mark=at position #1 with {\arrow{>}}}}]


\node at (0,0) [rectangle, draw, minimum size= 10 mm] (f) {\emph{John}};
\node at (0,2) [rectangle] (h) {};
\draw[arr=0.6] (0, 0.5) -- (0, 1.5) node[pos=0.3,right]{$\catname{n_m}$};
        \draw (0,1.5) to[out=90,in=90,looseness=2] (1,1.5);
        \draw[arr=0.5] (1,1.5) -- (1,0.5)node[pos=0.6,right]{$\catname{n^r}$};


\node at (1.5,0) [rectangle, draw, minimum size= 10 mm] (f) {\emph{likes}};
\node at (3,2) [rectangle] (h) {};
\draw [->] (1.6,0.5) -- (1.6,2) node[above, left] {$\catname{s_1}$};
\draw[arr=0.6] (2, 1.5) -- (2, 0.5) node[pos=0.6,right]{$\catname{n^l}$};
        \draw (2,1.5) to[out=90,in=90,looseness=2] (3,1.5);
        \draw[arr=0.5] (3,0.5) -- (3,1.5)node[pos=0.4,right]{$\catname{n^f}$};

\node at (3,0) [rectangle, draw, minimum size= 10 mm] (f) {\emph{Mary}};

\end{tikzpicture}
\end{document}

I would like to reproduce the first picture, for which I think I can use a similar technique to that of the second picture. However, what I find most difficult is to draw the the two arcs after the first triangle labelled with $\nu$, which I cannot make one on top of the other. Any hints?

4
  • 3
    Can you provide the code of what you have so far? Where are you stuck?
    – Roland
    Commented Sep 20, 2021 at 11:57
  • 1
    What do you mean by using the style? Is it putting arrows that you want? Please at least make it clear so taht we could know in what direction we can go.
    – SebGlav
    Commented Sep 20, 2021 at 17:18
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Commented Sep 21, 2021 at 21:12
  • Thank you, now it should be compilable.
    – cip
    Commented Sep 22, 2021 at 6:38

1 Answer 1

1

Is there a particular reason why the wires connecting $\nu$ and $\Psi$ zig-zag so much? If you're considering string diagrams up to isotopy, you can considerably simplify the drawing by "straightening" all the wires in this way:

enter image description here

\documentclass[margin=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,positioning}
\newcommand{\catname}[1]{\mathbf{#1}}
\begin{document}

\tikzset{
 arr/.style={ postaction={decorate}
            , decoration={ markings
                         , mark=at position #1 with {\arrow{>}}
                         }
            },
 arr/.default=0.5,
 rarr/.style 2 args={ rounded corners= #1
             , postaction={decorate}
             , decoration={ markings
                         , mark=at position #2 with {\arrow{>}}
                         }
            },
% the `rarr` style adds an argument for the roundedness of the corners
% `rarr` defaults at {4mm}{0.5}, and `arr` at 0.5:
 rarr/.default={4mm}{0.5},
 leaf/.style={ rectangle
             , draw
             %==
             , thick
             , fill=gray!10
             %== improves readability
             , minimum size= 10 mm
             },
}

\begin{tikzpicture}
\node[leaf] (nu) at (0,0) {$\nu$};
% ...is this a \nu or a `v`? Considering that the other is a `w`...
% anyway, first draw all the nodes:
\node[leaf] (not) at (4,0) {\emph{not}};
\node[leaf] (psi) at (6,0) {$\Psi$};
\node[leaf]   (w) at (8,0) {$w$};
% now the wires:
\draw[rarr] (psi.-50)
  %               ↑
  % note that the starting point of the wire is at -45 degress \pm an offset;
  % in this case, 5 degrees. Same for the left wire exiting from \Psi.
  |-      ++(1.5,-.5) 
  --        (w.south);
\draw[rarr] (psi.south) 
  |-         ++(-2,-.5) 
  --        (not.south);
\draw[rarr={2mm}{0.75}] (psi.-130) 
  % here's where the possibility to adjust `rarr` first parameter comes in handy.
  |-                  ++(-.5,-.25) 
  --                   ++(-.05, 3) 
  -|                        (2,-1) 
  --                        (0,-1) 
  --                    (nu.south);
\draw[rarr={1mm}{.75}] (not.north) 
  |-                      ++(-1,1) 
  -|                   ++(-.25,-3);
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .