# Tikz Arrows and Blocks

I'm currently writing my Bachelor's thesis using LaTex and Tikz and I'm currently stuck. Even though my older posts helped me very much with so many things regarding tikz, there are always new difficulties for the unexperienced user...

I would like to obtain a picture like this one where I can name the arrows and most importantly change their size (or node distances individually ?).

I have come this far but as you can see I do not know how to make the arrow below that connects the input node to the third block and i do not know how to shorten the distance between the three blocks. Here's my picture:

... and my code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows, positioning, quotes}
\usetikzlibrary{arrows.meta, positioning, decorations.markings}
\usepackage{gensymb}
\usepackage{verbatim}

\begin{document}

\begin{figure}[htbp]
\centering

\begin{tikzpicture}
[block/.style={draw,minimum width=#1,minimum height=2em},
block/.default=10em,high/.style={minimum height=3em},auto]
%node distance=5em,auto]

% Nodes
\node (n0) {Input};
\node[block=3em,high,right=of n0] (n1) {DiM};
\node[block=3em,high,right=of n1] (n2) {Sensor};
\node[block=3em,high,right=of n2] (n3) {CANoe};
\node[right=of n3] (n4) {Measurement File};

% Connections
\draw[-stealth] (n0) edge[""] (n1);
\draw[-stealth] (n1) edge[""] (n2);
\draw[-stealth] (n2) edge[""] (n3);
\draw[-stealth] (n3) edge[""] (n4);

\end{tikzpicture}

\caption{CANoe Measurement Network}
\label{fig:measurement_network}
\end{figure}
\end{document}


I have loaded all important presets (babel, tikz, etc.)

I would be glad if someone could help me ! Thank you guys, i really appreciate the help !

• Could you please make your code compilable by adding the documentclass as well as the relevant packags? Dec 29 '19 at 13:29
• Where should the u-shaped arrow start from? From the word "Input" or from the arrow between "Input" and "DiM"? Dec 29 '19 at 13:42
• Edited it ;) Should compile now ! Best would be if the arrow starts in between Input and DiM :) Dec 29 '19 at 13:48

Use node distance for the spacing in of. To draw extra arrows, why not just draw "normal" arrows?

EDIT: To add text to that arrow, you need to modify a little bit.

EDIT 2: To change the starting point of the arrow, you just have to name the midpoint of the first arrow. Btw edge is not necessary, just -- is ok.

\documentclass[tikz,margin=10]{standalone}
\usetikzlibrary{positioning,arrows.meta,quotes}
\begin{document}
\begin{tikzpicture}
[block/.style={draw,minimum width=#1,minimum height=2em},
block/.default=10em,high/.style={minimum height=3em},auto,
node distance=5mm, % initially 1cm
>=Stealth]
%node distance=5em,auto]
% Nodes
\node (n0) {Input};
\node[block=3em,high,right=1cm of n0] (n1) {DiM};
\node[block=3em,high,right=of n1] (n2) {Sensor};
\node[block=3em,high,right=of n2] (n3) {CANoe};
\node[right=1cm of n3,align=center] (n4) {Measurement\\File};
% Connections
\draw[->] (n0) -- (n1) coordinate[midway] (start);
\draw[->] (n1) -- (n2);
\draw[->] (n2) -- (n3);
\draw[->] (n3) -- (n4);
\coordinate (x) at ([yshift=-1cm]n3.south);
\coordinate (y) at (start |- x);
\draw (start) -- (y) (x) edge[->] (n3.south) (x) edge["EXAMPLE"] (y);
\end{tikzpicture}
\end{document}


• Hi ! Thank you, this looks very good. I would like to additionally know how to individually set the node distances. For example, I would like to keep the node distance in your tikzpicture only between the blocks DiM-Sensor-CANoe, but the arrows should be longer from Input-DiM and CANoe-Measurement File ... :) Dec 29 '19 at 13:51
• @aladin Just use e.g. \node[block=3em,high,right=1cm of n0] (n1) {DiM}; Dec 29 '19 at 13:54
• thank you ! I have seen what you mean now. Can you just tell me how to place text over the horizontal long arrow from Input-CANoe ? My text just ends up directly at the root of the arrow. \draw[->] (n0) edge["EXAMPLE"] |- ([yshift=-1cm]n3.south) -- (n3.south); Dec 29 '19 at 14:18
• wow perfect. The other two thing that I need would be a) A way to introduce a line break in 'Measurement File'. I have not found any command to do so ... b) How to start the arrow Input-CANoe from the middle of the arrow Input-DiM ? Surely, I must create another node in between, right ? Thanks again Fractal! Dec 29 '19 at 14:39
• @aladin For the line break, you can use align e.g. \node[right=1cm of n3,align=left] (n4) {Measurement\\File};. For the arrow, wait me a little bit Dec 29 '19 at 14:41

You can also use \foreach to reduce code size. To change node distance locally just use right=<some length> of as also noted by @Fractal. Besides, the down-right-up arrow can be simplified as \draw[->] (n0) --++(0,-4em) -| (n3);.

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}

\begin{tikzpicture}
[block/.style={draw,minimum width=#1,minimum height=1em},
block/.default=10em,high/.style={minimum height=3em},
node distance=2em, > = Stealth]

% Nodes
\node (n0) {Input};
\node[block=3em,high,right=3em of n0] (n1) {DiM};
\node[block=3em,high,right=of n1] (n2) {Sensor};
\node[block=3em,high,right=of n2] (n3) {CANoe};
\node[right=3em of n3] (n4) {Measurement File};

% Connections
\foreach \i [count=\j from 1] in {0,...,3}
\draw[->] (n\i) -- (n\j);
\draw[->] (n0) --++(0,-4em) -| (n3);
\end{tikzpicture}

\end{document}


In case, that you not need labels on edges between nodes in chain, then code of your block scheme can be simple drawn by use of the chains library and for arrows between them use macro join. Label of the arrow ad only on arrow which link "input" with "CANoe" is ad with node accordingly positioned on arrow:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
chains,
positioning}
\begin{document}
\begin{tikzpicture}[auto,
node distance = 7mm and 9mm,
start chain = going right,
box/.style = {draw, minimum size=3ex, inner sep=2mm,
on chain, join=by arr},
arr/.style = {-Stealth}
]
% Nodes
\node (n0) [box,draw=none]  {Input};
\node (n1) [box] (n1) {DiM};
\node (n2) [box] (n2) {Sensor};
\node (n3) [box] (n3) {CANoe};
\node (n4) [box, draw=none] (n4) {Measurement File};
% Connections
\coordinate[below=of n3] (aux);
\draw[arr]   (n0) |- node[pos=0.75] {forefeed} (aux) -- (n3);
\end{tikzpicture}
\end{document}


In a case, that you like to have labeled all edged, than join can be replaced by arrows with labels. For them is handy to use quotes library:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
chains,
positioning,
quotes}
\begin{document}
\begin{tikzpicture}[auto,
node distance = 7mm and 11mm,
start chain = going right,
box/.style = {draw, minimum size=3ex, inner sep=2mm,
on chain},
every edge/.style = {draw, -Stealth}
]
% Nodes
\node (n0) [box,draw=none]  {Input};
\node (n1) [box] (n1) {DiM};
\node (n2) [box] (n2) {Sensor};
\node (n3) [box] (n3) {CANoe};
\node (n4) [box, draw=none] (n4) {Measurement File};
% Connections
\coordinate[below=of n3] (aux);
\draw   (n0)    edge["{$u[n]$}"]    (n1)
(n1)    edge["{$e[n]$}"]    (n2)
(n2)    edge["{$v[n]$}"]    (n3)
(n3)    edge["{$y[n]$}"]    (n4);
\draw   (n0) |-  node[pos=0.75] {forefeed} (aux)
(aux) edge (n3);
\end{tikzpicture}
\end{document}
`