1

I have drawn this:

enter image description here

And my code is:

\documentclass{article}
\usepackage{tikz}
\begin{tikzpicture}
    %1st rectangle
\draw (0,0) -- (0,5);
\draw (0,5) -- (6,5);
\draw (6,5) -- (6,0);
\draw (6,0) -- (0,0);
    %rectangle in 1st rectangle
\draw (1,3) -- (5,3);
\draw (5,3) -- (5,4);
\draw (5,4) -- (1,4);
\draw (1,4) -- (1,3);   
    %little square
\draw (2,3) -- (2,4);
\draw (3,3) -- (3,4);
\draw (4,3) -- (4,4);   
    %second rectangle
\draw (7,0) -- (7,5);
\draw (7,5) -- (13,5);
\draw (13,5) -- (13,0);
\draw (13,0) -- (7,0);
    %rectangle in 2nd rectangle
\draw (8,3) -- (12,3);
\draw (12,3) -- (12,4);
\draw (12,4) -- (8,4);
\draw (8,4) -- (8,3);   
    %little square
\draw (9,3) -- (9,4);
\draw (10,3) -- (10,4);
\draw (11,3) -- (11,4); 

\draw[thick,->](5,5) -- (8,5);
\end{tikzpicture}
\end{document}

I have numerous questions which are:

  1. Is there any better way to achieve the drawing of a "rectangle" than drawing it manually line by line?
  2. My final aim is to build a scheme with 4 of this rectangle where each are connected with arrows. Isn't there any way to define a rectangle as a shape and us it for a node of a graph? So i could easily link each of the rectangle.
  3. If not: how could I draw all these arrows? With a correct bending (not as this one) and not a disguting style when all the arrows will be up.
  • You should to ask one question per post. For drawing rectangle use something like \draw (0,0) rectangle (1,1); – sergiokapone Oct 5 '18 at 21:22
2

This is only a partial answer as I am not sure I understand your 3rd point.

  1. You can draw rectangles with the rectangle path construction.
  2. If you want to draw the same thing multiple times, you can use pics for that.

Code:

\documentclass{article}
\usepackage{tikz}
\tikzset{pics/.cd,
Kokodelo/.style={code={\begin{scope}[local bounding box=#1]
\draw (0,0) rectangle (6,5);
\draw (1,3) rectangle (5,4) foreach \X in {2,3,4} {(\X,3) -- (\X,4)};
\end{scope}
}}}
\begin{document}
\begin{tikzpicture}
\pic at (0,0) {Kokodelo=1};
\pic at (8,0) {Kokodelo=2};
\pic at (0,-8) {Kokodelo=3};
\pic at (8,-8) {Kokodelo=4};
\draw[thick,-latex] (1) to[bend left] (2);
\draw[thick,-latex] (3) to[bend right] (4);
\end{tikzpicture}
\end{document}

enter image description here

As mentioned above, I am not sure how to interpret your statements on the curved arrows, so I just added some.

  • Just what I wanted. For the 3rd point, i'm using anchors and it's working as expected. Thanks! – Kokodelo Oct 6 '18 at 7:50

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.