Instead of drawing each arrow separately, I am interested in a quicker way to draw arrows along a path in a flowchart.
Let's look at some code first, MWE:
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{pgf,tikz}
\usetikzlibrary{chains,positioning,arrows,shapes.geometric,quotes,fit,calc}
\tikzstyle{startstop} = [%
rectangle,
rounded corners,
% minimum width=3cm,
% max width=2cm,
minimum height=1cm,
text centered,
text width=2cm,
line width=1pt,
draw=DarkBlue,
fill=DarkBlue!30
]
\tikzstyle{process} = [%
rectangle,
% minimum width=3cm,
% max width=2cm,
minimum height=1cm,
text centered,
text width=2cm,
draw=orange,
fill=orange!30
]
\tikzstyle{arrow} = [%
thick,
->,
>=stealth,
]
\tikzstyle{mainarrow} = [%
ultra thick,
->,
>=stealth,
]
\begin{document}
\begin{tikzpicture}
\node (mycenternode) [startstop] {Isgrind};
\node (mynorthnode) [process, above=of mycenternode] {Sami};
\node (mysouthnode) [process, below=of mycenternode] {Romrike};
\node (mywestnode) [process, left=of mycenternode] {Rykinmaa};
\node (myeastnode) [process, right=of mycenternode] {Lukinsola};
\draw [mainarrow] (mynorthnode) -- (mycenternode);
\draw [mainarrow] (mycenternode) -- node[anchor=west] {kuf} (mysouthnode);
\draw [arrow] (mywestnode) -- node[anchor=south] {ders} (mycenternode);
\draw [arrow] (mycenternode) -- node[anchor=south] {olan} (myeastnode);
\path [arrow] (mywestnode) |- node[anchor=south] {punrot} (mynorthnode) -| (myeastnode);
\end{tikzpicture}
\end{document}
Instead of having to say
\draw [mainarrow] (mynorthnode) -- (mycenternode);
\draw [mainarrow] (mycenternode) -- node[anchor=west] {kuf} (mysouthnode);
\draw [arrow] (mywestnode) -- node[anchor=south] {ders} (mycenternode);
\draw [arrow] (mycenternode) -- node[anchor=south] {olan} (myeastnode);
I wonder how to shorten that to something like
\path [mainarrow] (mynorthnode) -- (mycenternode) -- node[anchor=west] {kuf} (mysouthnode);
\path [arrow] (mywestnode) -- node[anchor=south] {ders} (mycenternode) -- node[anchor=south] {olan} (myeastnode);
EXTRA:
In the last few lines, you can discern a \path
. I don't really understand why it's not drawing anything.
\path
and\draw
are two different things.\path
does not draw unless you say\path[draw,...]
. Also consider using\tikzset{blabla/.style={...}
instead of\tikzstyle{blabla}=[...]
.