I had been trying to make a block diagram with TikZ.
The diagram that I am aiming at looks like
+-----------------+
I ---->----| H = f(a, b) |---------> o
| |
+->--| a = a + b + c |--->--+
| +-----------------+ |
| |
^ v
| +-----------------+ |
+-<--| | |
| z = z + y |---<--+
B ---->----| |
+-----------------+
I wanted 'rectangular' arrows with the blocks and nodes (along with their labels) aligned all right.
Based on multiple posts found online, I made
\begin{document}
\begin{tikzpicture}[
base/.style={
rectangle,% draw,
align=center
},
arrow/.style={-Stealth}
]
\node[draw,minimum height=1cm,align=center] (comb) [base] {$H = f(a, b)$ \\ $a = a + b + c$};
\node[draw,minimum height=1cm] (seq) [base,below=of comb] {$z = z + y$};
\node (D) [base,above left=of comb.south west] {$I$};
\node (clk) [base,left=of seq.south west] {$B$};
\node (q) [base,right=of comb] {$o$};
\draw[arrow] (comb.east) -- ++(1cm,0) |- (seq.east);
\draw[arrow] (clk) -- (seq.south west);
\draw[arrow] (D) -- (comb.150);
\draw[arrow] (seq.west) -- ++(-1cm,0) |- (comb.west);
\end{tikzpicture}
\end{document}
But this has the nodes (like I
and B
) ill-aligned. Like:
How can this be fixed?
I just started trying TikZ.
Best Answer
Like this?
or you prefer, that arrows heads are in the middle of arrows?
Addendum: Regarding your request in comment, a possible solution is to define four additional coordinates for loops' arrows: