TikZ 改变两个节点之间的距离?

TikZ 改变两个节点之间的距离?

我希望得到有关如何更改 TikZ 图片中两个给定节点之间的距离的建议。这是我的工作示例:

\documentclass[oneside,a4paper,12pt]{report}
\usepackage{polyglossia}
\usepackage{microtype} 
\setmainlanguage{english} 
\usepackage{vmargin}
\setmarginsrb{3cm}{3cm}{3cm}{3cm}{0pt}{0mm}{0pt}{13mm}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes.geometric, shapes.misc}
\tikzstyle{arrow} = [very thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=1cm,
stage/.style={
% The shape:
rounded rectangle,
minimum width=3cm,
minimum height=1cm,
text centered,
text width=6cm,
% The rest
very thick,draw=black!50,
top color=white,bottom color=black!20,
font=\bfseries}]

\node (node1) [stage] { Some text in Node1};
\node (node2) [stage, below=of node1] {More text in Node 2!};
\draw [arrow] (node1) -- (node2);
\node (node3) [stage, right=of node2] {Text for node 3.};
\draw [arrow] (node2) -- (node3)
node [above,align=center,midway]
{replacement text here
};
\end{tikzpicture}

\end{document}

我想让节点 1 和节点 2 之间的距离保持 1 厘米,但是我想增加节点 2 和节点 3 之间的距离以容纳文本,我想将文本放置在箭头上方。谢谢!

答案1

在此处输入图片描述

\documentclass[oneside,a4paper,12pt]{report}
\usepackage{polyglossia}
\usepackage{microtype} 
\setmainlanguage{english} 
\usepackage{vmargin}
\setmarginsrb{3cm}{3cm}{3cm}{3cm}{0pt}{0mm}{0pt}{13mm}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes.geometric, shapes.misc}
\tikzstyle{arrow} = [very thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=1cm,
stage/.style={
% The shape:
rounded rectangle,
minimum width=3cm,
minimum height=1cm,
text centered,
text width=6cm,
% The rest
very thick,draw=black!50,
top color=white,bottom color=black!20,
font=\bfseries}]

\node (node1) [stage] { Some text in Node1};
\node (node2) [stage, below=of node1] {More text in Node 2!};
\draw [arrow] (node1) -- (node2);
\node (node3) [stage, right=4cm of node2] {Text for node 3.};
\draw [arrow] (node2) -- (node3)
node [above,align=center,midway]
{replacement text here
};
\end{tikzpicture}

\end{document}

答案2

替代 ...

\documentclass[oneside,a4paper,12pt]{report}
\usepackage{polyglossia}
\usepackage{microtype}
\setmainlanguage{english}
\usepackage{vmargin}
\setmarginsrb{3cm}{3cm}{3cm}{3cm}{0pt}{0mm}{0pt}{13mm}
\usepackage{tikz}
\usetikzlibrary{positioning, quotes, shapes.misc}

\begin{document}
    \begin{tikzpicture}[
node distance = 1cm and 3cm,
 stage/.style = {
% The shape:
rounded rectangle, align=center,
minimum height=1cm, text width=5.4cm,
% The rest
very thick, draw=black!50,
top color=white, bottom color=black!20,
font=\bfseries},
arr/.style = {very thick,-stealth},
every  edge quotes/.append style = {font=\small, align=center},
                    ]
\node (node1) [stage] {Some text in Node1};
\node (node2) [stage, below=of node1] {More text in Node 2!};
    \draw [arr] (node1) -- (node2);
\node (node3) [stage, right=of node2] {Text for node 3.};
    \draw [arr] (node2) to["replacement\\ text here"] (node3);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容