我尝试将 3 张图片并排放置,并最终为它们添加一些标题,但由于某种原因,这些图片不按比例显示,特别是中间那张。我不知道如何解决这个问题:
\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}
答案1
您无需在此处使用三个分隔符。您可以使用选项中带有(和)的环境tikzpictures
将第二部分和第三部分向右移动。需要对 和其他内容进行一些调整,以使其适合标准的文本块。scope
xshift
yshift
node distance
article
出现此问题的原因是,这三个图最初宽度不同,但随后您将它们缩放到相同宽度。因此,每种情况下的缩放因子都不同。
\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}