全部,
我想将文本放置在 tikz 图片中,使其不干扰所绘制的线条。我是 tikz 新手,所以请耐心等待我的编码。
这是我的代码
\begin{tikzpicture} % STYLES \tikzset{
ellips/.style={ellipse, minimum width=100pt,
align=center,node distance=3cm,fill=black!10,inner sep=5pt,text width=2.5cm,minimum
height=2.0cm,>=stealth'} }
\node [ellips](Choices) {Strategic Choices};
\node [above=2cm of Choices](dummy) {};
\node [ellips, force, left=1.5cm of dummy] (Institutions) {Institutions};
\node [ellips, force, right=1.5cm of dummy] (Organisations) {Organisations};
% Draw the links between
\path[<->,thick]
(Choices) edge node[anchor=center, text width=3.5cm, left, midway] {Industry conditions and firm-specific resources} (Institutions)
(Choices) edge node[anchor=center, text width=3.5cm, right, midway] {Formal and informal constraints} (Organisations)
(Institutions) edge node [midway, below] {interaction} node[midway, above] {Dynamic} (Organisations);
\end{tikzpicture}
结果如下
答案1
放置auto
尝试猜测路径中节点的最佳定位,以便节点的文本不会与路径重叠。
通常,auto
到 会将文本放在路径遍历方向的左侧。因此,对于从(Institutions)
到 的路径(Organization)
,auto
将把文本放在上方。对于从(Choices)
到 的路径(Institutions)
,它将使用,而对于从到 的below left
路径,它将使用。(Choices)
(Organizations)
above left
由于最后一个不是我们想要的,我们可以从(Organizations)
到绘制最后一条路径(Choices)
,以将文本放在所需的位置:
%In the preamble
\usetikzlibrary{shapes.geometric,arrows,positioning}
\begin{tikzpicture}[force/.style={},
ellips/.style={ellipse, minimum width=100pt,
align=center,node distance=3cm,fill=black!10,inner sep=5pt,text width=2.5cm,minimum
height=2.0cm,>=stealth'}
]
\node [ellips](Choices) {Strategic Choices};
\node [above=2cm of Choices](dummy) {};
\node [ellips, force, left=1.5cm of dummy] (Institutions) {Institutions};
\node [ellips, force, right=1.5cm of dummy] (Organisations) {Organisations};
% Draw the links between
\path[<->,thick]
(Choices) edge node[anchor=center, text width=3.5cm, auto, midway] {Industry conditions and firm-specific resources} (Institutions)
(Organisations) edge node[anchor=center, text width=3.5cm, auto, midway] {Formal and informal constraints} (Choices)
(Institutions) edge node [midway, below] {interaction} node[above, midway] {Dynamic} (Organisations);
\end{tikzpicture}
答案2
您可以使用below left
和below right
。但请确保您的 MWE 是可编译的。它缺少许多必需的项目。
%In the preamble
% \usetikzlibrary{shapes.geometric,arrows,positioning}
\begin{tikzpicture}[force/.style={},
ellips/.style={ellipse, minimum width=100pt,
align=center,node distance=3cm,fill=black!10,inner sep=5pt,text width=2.5cm,minimum
height=2.0cm,>=stealth'}
]
\node [ellips](Choices) {Strategic Choices};
\node [above=2cm of Choices](dummy) {};
\node [ellips, force, left=1.5cm of dummy] (Institutions) {Institutions};
\node [ellips, force, right=1.5cm of dummy] (Organisations) {Organisations};
% Draw the links between
\path[<->,thick]
(Choices) edge node[anchor=center, text width=3.5cm, below left, midway] {Industry conditions and firm-specific resources} (Institutions)
(Choices) edge node[anchor=center, text width=3.5cm, below right, midway] {Formal and informal constraints} (Organisations)
(Institutions) edge node [midway, below] {interaction} node[midway, above] {Dynamic} (Organisations);
\end{tikzpicture}