0

I am trying to make a diagram with multiple nodes, and I think it is going to be much cleaner to read if I use rounded square arrows between the nodes. I have drawn an example with most types of curving arrows I will need to use in the figure below:

example of diagram

I tried this using ".. controls (x,y) and (z,w).." but it becomes too rounded. It's actually ok this way, but I think it will be much better if it had rounded square arrows instead.

Can someone tell me how to do these, using the tikzpicture environment, of course.

Thanks in advance!

2
  • 2
    Look for ˋ [rounded corners]ˋ in the pgf manual.
    – MS-SPO
    Jun 8 at 22:50
  • 1
    I looked for "curving '[somethings]'" and I didn't find what I was looking for. Now I know why! Thank you very much! Jun 9 at 2:12

2 Answers 2

2

Try this code;

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=3pt,rounded corners=3pt]
 \draw (1,2) rectangle (4,4);
 \draw (1,6) rectangle (4,8);
 \draw (1,10) rectangle (4,12);
 \draw (7,15) rectangle (10,17);
 \draw (12,6) rectangle (15,8);
 \draw[-latex] (2.5,12)--(2.5,16)--(7,16);
 \draw[-latex] (4,7.5)--(8.5,7.5)--(8.5,15);
 \draw[-latex] (4,6.5)--(12,6.5);
 \draw[-latex] (4,3.5)--(13.5,3.5)--(13.5,6);
 \draw[-latex] (4,2.5)--(16,2.5)--(16,16)--(10,16);
\end{tikzpicture}
\end{document}

The output is:

enter image description here

EDIT (for Fractal Admirer): To better view where to put lines add ths lines of code inside the tikzpicture code:

\draw[gray!15,line width=.2pt] (0,0) grid (17,17.5);
 \foreach \x in {0,...,17}{%
    \node at (\x,0) () {\tiny \bfseries \x};
    \node at (0,\x) () {\tiny \bfseries \x};
    };

so you have this:

enter image description here

When finish you can delete or comment the same lines.

1
  • So I just need to specify where the line should begin, pass through and end? Thank you very much! Jun 9 at 2:11
1

Although Raffaele Santoro answer is great and reproduce the original scheme. I suggest to use nodes and positioning librariry to easily produces graphics like this one.

What's the difference? A rectangle is just a line while a node is an entity with a name which can be referenced later on. This way you don't need to know exact coordinates for link lines, but just nodes anchors.

Postioning library define a mechanism to place nodes relative to other nodes. Again, we don't need to specify exact coordinates but a distance from another node.

What follows is an alternative code to draw the original scheme without specifying coordinates at all. Hope it helps.

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{tikzpicture}[
    >={latex},
    line width=3pt, rounded corners=3pt,
    box/.style={draw, minimum width=3cm, minimum height=2cm}]
 \node[box] (1) {1};
 \node[box, above= 2cm of 1] (2) {2};
 \node[box, above= 2cm of 2] (3) {3};
 \node[box, above right=3cm and 3cm of 3] (4) {4};
 \node[box, right=8cm of 2] (5) {5};

 \draw[->] (3)|-(4);
 \draw[->] ([yshift=-5mm]2.north east)-|(4);
 \draw[->] ([yshift=5mm]2.south east) coordinate(aux)-- (aux-|5.west);
 \draw[->] ([yshift=-5mm]1.north east)-|(5);
 \draw[->] ([yshift=5mm]1.south east)-|([xshift=5mm]5.east)|-(4.east);
\end{tikzpicture}

\end{document}

enter image description here

2
  • Thank you very much for your answer. Where can I learn more about the "north east" and "|-" commands? Jun 9 at 23:14
  • @FractalAdmirer I suggest to read "Tutorials and guidelines" section in TiKZ documentation
    – Ignasi
    Jun 10 at 7:15

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.