I have drawn 4 nodes with
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[node distance=2cm]
% nodes
\node [draw] (A) {A};
\node [draw, right=of A] (B) {B};
\node [draw, right=of B] (C) {C};
\node [draw, right=of C] (D) {D};
% arrows
\draw [->] (A) -- (B) -- (C) -- (D);
\end{tikzpicture}
\end{document}
I am trying to draw an arrow between each node.
If I use
\draw [->] (A) -- (B) -- (C) -- (D);
I get lines between each node but only an arrow from C to D.
Can I, in one line, draw arrows between all of the nodes?
Best Answer
edge
can be used to put the arrows in one\draw
command:The usage of
-|
as path foredge
is also possible via optionto path
: