1

I'm trying to set 3 picture side by side and eventually set some caption on them, but for some reason the pictures are out of scale, specially the middle one. I don't know how to fix this:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{shapes} 


\begin{document}

\begin{figure}
\begin{minipage}{.3\textwidth}
\centering
\resizebox{\textwidth}{!}{
\begin{tikzpicture}[node distance=2cm,on grid]
\node[draw,rounded rectangle ,minimum height=20pt ,minimum width=100pt] (Red) {Red};
\node[draw, circle] (ISP1) [below =of Red,] {ISP};
\node[draw,circle] (ISP2) [left =of ISP1] {ISP};
\node[draw,circle] (ISP3) [right =of ISP1] {ISP};
\node[draw, rounded rectangle ,minimum height=30pt ,minimum width=100pt] (Consumer) [below=of ISP1] {Usuarios};
\draw (Red)--(ISP1);
\draw (Red)--(ISP2);
\draw (Red)--(ISP3);
\draw (ISP1)--(Consumer);
\draw (ISP2)--(Consumer);
\draw (ISP3)--(Consumer);
\end{tikzpicture}
}
\end{minipage}
\begin{minipage}{.3\textwidth}
\resizebox{\textwidth}{!}{
\begin{tikzpicture}[node distance=2cm,on grid]
\node[draw,rounded rectangle ,minimum height=20pt ,minimum width=100pt] (Red) {Red/ISP};
\node[draw, circle] (ISP1) [below =of Red] {ISP};
\node[draw, circle] (ISP3) [right =of ISP1] {ISP};
\node[draw,rounded rectangle ,minimum height=30pt ,minimum width=100pt] (Consumer) [below=of ISP1] {Usuarios};
\draw (Red)--(ISP1);
\draw (Red)--(ISP3);
\draw (ISP1)--(Consumer);
\draw (ISP3)--(Consumer);
\draw[transform canvas={xshift=-30pt}] (Red)--(Consumer);
\end{tikzpicture}
}
\end{minipage}
\begin{minipage}{.3\textwidth}
\resizebox{\textwidth}{!}{
\begin{tikzpicture}[node distance=2cm,on grid]
\node[draw,rounded rectangle ,minimum height=20pt ,minimum width=100pt,rotate=90] (Red) {\rotatebox{270}{Red}};
\node[draw, circle] (ISP1) [right =of Red] {ISP};
\node[draw, circle] (ISP2) [above =of ISP1] {ISP};
\node[draw, circle] (ISP3) [below =of ISP1] {ISP};
\node[draw, circle] (Consumer) [left=70pt of Red] {Usuarios};
\draw (ISP1)--(Red);
\draw (ISP2)--(Red);
\draw (ISP3)--(Red);
\draw (Red)--(Consumer);
\end{tikzpicture}
}
\end{minipage}
\end{figure}
\end{document}

enter image description here

  • 1
    Hi, welcome! What do you mean by "out of scale"? You've specifically resized them so that all have the same width with \resizebox. If they didn't all have the same width before resizing, then naturally the font sizes are different. – Torbjørn T. Nov 30 '16 at 15:38
  • Thanks Torbjon, then its a font size issue?, even tho I haven't specified anything different in the 3 pictures?. – R. Nihil Nov 30 '16 at 15:41
  • No, the problem is that you scale the three different pictures by different amounts, because they don't have the same width initially, but you scale all to the same width. – Torbjørn T. Nov 30 '16 at 15:47
  • Oh..., I get it now what is happening, thanks. – R. Nihil Nov 30 '16 at 15:47
2

You don't need to use three separate tikzpictures here. You can shift the second and third part right using a scope environment with xshift (and yshift) in the options. Some adjustment of the node distance and other things are needed to make it fit in the textblock of a standard article.

Your problem occurs because the three diagrams have different widths initially, but then you scale them all to the same width. Hence, the scaling factors are different in each case.

enter image description here

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{shapes}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[
  node distance=1.2cm,
  on grid,
  every node/.append style={font=\scriptsize}
]
\node[draw,rounded rectangle ,minimum height=20pt ,minimum width=100pt] (Red) {Red};
\node[draw, circle] (ISP1) [below =of Red,] {ISP};
\node[draw,circle] (ISP2) [left =of ISP1] {ISP};
\node[draw,circle] (ISP3) [right =of ISP1] {ISP};
\node[draw, rounded rectangle ,minimum height=30pt ,minimum width=100pt] (Consumer) [below=of ISP1] {Usuarios};
\draw (Red)--(ISP1);
\draw (Red)--(ISP2);
\draw (Red)--(ISP3);
\draw (ISP1)--(Consumer);
\draw (ISP2)--(Consumer);
\draw (ISP3)--(Consumer);


\begin{scope}[xshift=4cm]
\node[draw,rounded rectangle ,minimum height=20pt ,minimum width=100pt] (Red) {Red/ISP};
\node[draw, circle] (ISP1) [below =of Red] {ISP};
\node[draw, circle] (ISP3) [right =of ISP1] {ISP};
\node[draw,rounded rectangle ,minimum height=30pt ,minimum width=100pt] (Consumer) [below=of ISP1] {Usuarios};
\draw (Red)--(ISP1);
\draw (Red)--(ISP3);
\draw (ISP1)--(Consumer);
\draw (ISP3)--(Consumer);
\draw[transform canvas={xshift=-30pt}] (Red)--(Consumer);
\end{scope}


\begin{scope}[xshift=8.7cm,yshift=-1.2cm]
\node[draw,rounded rectangle ,minimum height=20pt ,minimum width=100pt,rotate=90] (Red) {\rotatebox{270}{Red}};
\node[draw, circle] (ISP1) [right =of Red] {ISP};
\node[draw, circle] (ISP2) [above =of ISP1] {ISP};
\node[draw, circle] (ISP3) [below =of ISP1] {ISP};
\node[draw, circle] (Consumer) [left=50pt of Red] {Usuarios};
\draw (ISP1)--(Red);
\draw (ISP2)--(Red);
\draw (ISP3)--(Red);
\draw (Red)--(Consumer);
\end{scope}
\end{tikzpicture}

\end{figure}
\end{document}

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.