2

I'm trying to reproduce the following tikz graph: graph to reproduce

I managed to create the nodes and the arrows but can't understand how to draw the arrows below the nodes.

This is my result for now with the following code (for graph on the left):

\begin{tikzpicture}[align = center, node distance = 9em, auto, thick]
    \node [circlenode] (a) {$a$};
    \node [circlenode, xshift=+2cm] (b) {$b$};
    \node [circlenode, xshift=+4cm] (c) {$c$};

    \draw [->] (a) edge [] node {} node[] {} (b);
    \draw [->] (b) edge [] node {} node[] {} (c);
\end{tikzpicture}

my graph until now

Are those arrows inserted in a label or new \draw lines are introduced?

Thanks

2

You can use the calc library.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows.meta}
\begin{document}
\begin{tikzpicture}[align = center, node distance = 9em, auto, thick,>=latex,
circlenode/.style={circle,draw,text width=1em}] % https://tex.stackexchange.com/a/327060/121799
    \node [circlenode] (a) {$a$};
    \node [circlenode, xshift=+2cm] (b) {$b$};
    \node [circlenode, xshift=+4cm] (c) {$c$};

    \draw [->] (a) edge [] node {} node[] {} (b);
    \draw [->] (b) edge [] node {} node[] {} (c);
    \draw [->|] ($(a.south east)+(1em,-1em)$) -- ($(b.south west)+(-1em,-1em)$);
    \draw [|<-] ($(b.south east)+(1em,-1em)$) -- ($(c.south west)+(-1em,-1em)$);
\end{tikzpicture}
\end{document}

enter image description here

  • Nice. I didn't know about this library. And I can use it also to draw the double arrow in the second example right? – Daniele Jan 31 '18 at 21:06
  • @Daniele Sure. ` \draw [->] ($(b.south west)+(0,-1em)$) -- ($(b.south east)+(0,-1em)$); \draw [<-] ($(b.south west)+(0,-2em)$) -- ($(b.south east)+(0,-2em)$);` – user121799 Jan 31 '18 at 21:14
2

You could make use of the anchors of the nodes and shift the starting and ending points of the arrows:

\documentclass[tikz]{standalone}

\begin{document}

\begin{tikzpicture}[minimum width=5mm]
 \node [circle,draw,label=above:{$X$}] (a) {};
 \node [circle,draw,label=above:{$Y$},xshift=+15mm] (b) {};
 \node [circle,draw,label=above:{$Z$},xshift=+30mm] (c) {};

 \draw [->] (a) -- (b);
 \draw [->] (b) -- (c);

 \draw [->|] ([xshift=2mm,yshift=-3mm]a.east) -- ([xshift=-2mm,yshift=-3mm]b.west);
 \draw [|<-] ([xshift=2mm,yshift=-3mm]b.east) -- ([xshift=-2mm,yshift=-3mm]c.west);

 \draw [->] ([yshift=-4mm]b.west) -- ([yshift=-4mm]b.east);
 \draw [<-] ([yshift=-5mm]b.west) -- ([yshift=-5mm]b.east);
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.