2

My attempt:

\begin{tikzpicture}
  \node (n1) at (0,0)  {};
  \node (n2) at (0,1)  {};
  \node (n3) at (1,0)  {};
  \node (n4) at (1,1)  {};
  \foreach \from/\to in {}
    \draw (\from) -- (\to);
  \foreach \from/\to in {n1/n3,n4/n2}
    \draw (\from) edge [->] (\to);
     \foreach \from/\to in {n2/n3,n4/n1}
    \draw (\from) edge [->>] (\to);
     \foreach \from/\to in {n1/n4}
    \draw (\from) edge [->>>] (\to);
  \foreach \from/\to in {}
    \draw (\from) edge [bend right] (\to);
\end{tikzpicture}

doesn't work very well - this is what it outputs:

enter image description here

How can I get the arrow to not be at the tip, but rather in the middle of the edge?

David Carlisle
  • 757,742

1 Answers1

5

Two options:

  1. With TikZ, using a style with a decoration:

    \documentclass{article}
    \usepackage{tikz}
    \usetikzlibrary{decorations.markings}
    
    \def\Singlearrow{{\arrow[scale=1.5,xshift={0.5pt+2.25\pgflinewidth}]{>}}}
    \def\Doublearrow{{\arrow[scale=1.5,xshift=1.35pt +2.47\pgflinewidth]{>>}}}
    \def\Triplearrow{{\arrow[scale=1.5,xshift=1.75pt +2.47\pgflinewidth]{>>>}}}
    
    \begin{document}
    
    \begin{tikzpicture}[
    line cap=round,
    marr/.style={
      decoration={
        markings,
        mark=at position 0.5 with {#1}
        },
      postaction={decorate}
    }
    ] 
    \path
      coordinate (n1) at (0,0)
      coordinate (n2) at (0,2)
      coordinate (n3) at (2,0)
      coordinate (n4) at (2,2);
    \foreach \from/\to in {n1/n3,n4/n2}
        \draw[marr=\Singlearrow] (\from) -- (\to);
    \foreach \from/\to in {n1/n2,n3/n4}
        \draw[marr=\Doublearrow] (\from) -- (\to);
    \draw[marr=\Triplearrow] (n1) -- (n4);
    \draw[->]
      (0.35,1.3) arc (220:-40:8pt);
    \draw[->]
      (1.7,0.35) arc (-40:220:8pt);
    \end{tikzpicture}
    
    \end{document}
    

    enter image description here

    Some remarks

    • I used \coordinates instead of the original \nodes, so the lines will meet.
    • Changing the line cap to round gives better result at the verticae.
    • By default a decoration places the arrow tip, not its center, at the specified position. This produces ugly results (specially noticeable for composed arrows). Addressing this issue, there are some posts such as Position arrow decoration by center, not by tip, but the automatic answers there are, unfortunately, outdated. I used instead a manual approach similar to the answer by Kpym.
  2. Using tikz-cd:

    \documentclass{article}
    \usepackage{tikz-cd}
    \usetikzlibrary{decorations.markings,arrows.meta}
    \usetikzlibrary{backgrounds}
    
    \begin{document}
    
    \begin{tikzpicture}
    \end{tikzpicture}
    
    \begin{tikzcd}[
    sep=2cm,
    cells={shape=coordinate},
    ]
      \ar[draw=none,r, "{\tikz\node[rotate=90,inner sep=0pt] {\tikz\draw[->](0,0) ;};  }" description]
      \ar[dash,r] 
    & 
    {} 
    \\
      \ar[draw=none,r, "{\tikz\node[rotate=270,inner sep=0pt] {\tikz\draw[->](0,0) ;};  }" description] 
      \ar[draw=none,u, "{\tikz\node[inner sep=0pt] {\tikz\draw[->>](0,0) ;};  }" description] 
      \ar[draw=none,ur, "{\tikz\node[rotate=-45,inner sep=0pt] {\tikz\draw[->>>](0,0) ;};  }" description] 
      \ar[dash,r] 
      \ar[dash,u] 
      \ar[dash,ur] 
    & 
    {}
      \ar[draw=none,u, "{\tikz\node[inner sep=0pt] {\tikz\draw[->>](0,0) ;};  }" description]
        \ar[dash,u]  
    \end{tikzcd}
    
    \end{document}
    

enter image description here

Gonzalo Medina
  • 505,128