2

I'm trying to translate a graphic in a book, and I need to connect some rectangles to do so. Here's what I have so far:

enter image description here

As you can see, the position of the arrow is not pleasant looking because the arrows don't connect to the edges of the rectangles. The code that generated this graphic:

\begin{tikzpicture}
\draw [rounded corners, fill=lightgray] (3,0) rectangle (6,-1) node (1) [pos=.5] {\textit{Output} gráfico} ;

\draw [rounded corners, fill=lightgray] (3,-2.5) rectangle (6,-3.5) node (2) [pos=.5] {\textit{Game Manager}};

\draw [rounded corners, fill=lightgray] (3,-5) rectangle (6,-6) node (3) [pos=.5] {Jogador};

\draw (-0.5,-1) rectangle (2,-2.5) node (4) [pos=.5, align=center] {Descrições de \\ jogos};

\draw (-0.5,-3) rectangle (2,-4.5) node (5) [pos=.5, align=center] {Registro de \\ partidas};

\draw (7,-2.5) rectangle (9,-3.5) node (6) [pos=.5, align=center] {Registro de \\ partidas};

 \draw[black, thick, ->]  (2) --  (1.south);

\end{tikzpicture}

I think it would be better to do this with nodes, since nodes connect to the borders, but I can't get nodes to look like the rectangles in the picture above. They're small and have no borders. Here's an example:

enter image description here

And the code that generated the graphic above:

\begin{tikzpicture}

\node [ rounded corners, fill=lightgray] at (4.5,0) (1) {\textit{Output} gráfico};

\end{tikzpicture}

So my questions are: How can I connect two rectangles with arrows that start and end at edges? If that's not possible, how can I generate larger nodes with visible borders (but the font size remaning the same)?

2
  • text width=<dimension>, text height=<dimension>, text depth=<dimension>, minimum height=<dimension, minimum width=<dimension> ?? Or inner sep=<dimension>, inner xsep=, inner ysep ...
    – cfr
    Commented Jun 7, 2016 at 3:32
  • Please edit your question to make your code compilable.
    – cfr
    Commented Jun 7, 2016 at 3:33

2 Answers 2

4

I don't have time right now to redo the entire MWE, but the first rectangle can be replaced by:

\node (1) [rounded corners, draw, fill=lightgray,minimum width=3cm,minimum height=1cm]
   at (4.5,-.5) {\textit{Output} gr\'afico} ;
4

Use the keys minimum height and minimum width for the size of the nodes, and use the library positioning to place them. Then use styles for every type of node.

enter image description here

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}


\begin{document}

\begin{tikzpicture}[node distance=15 mm and 15 mm,
                    every node/.style={draw},
                    central/.style={fill=lightgray,rounded corners,minimum           
                                    width=3cm,minimum height=1cm},
                    other/.style={text width=2.2 cm,text centered,minimum 
                                  width=2.5cm,,minimum height=1.5cm}]  
\node[central] (output){\textit{Output} gr\'afico};
\node[central] (manager) [below=of output] {\textit{Game Manager}};
\node[central] (jogador) [below=of manager] {Jogador};
\node[text width= 2cm,text centered] [right=of manager] {Registro de \\ partidas};
\node[other,yshift=-1cm] [left=of manager]{Registro de \\ partidas};
\node[other,yshift=1.2cm] [left=of manager]{Descri\c c\=oes de \\ jogos};
\draw[->] (manager)--(output);
\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .