我想使用下面的代码在行中添加单词,现在的图片是:
我想在“a”和“b”之间的行中添加单词“p1”,如下所示:
我尝试修改代码 \path [line] (a) -- (b){p1};
但是出现错误。
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{wrapfig}
\usepackage{graphicx}
\resizebox{.4\textwidth}{!}{\begin{tikzpicture}[
block/.style = {circle, draw,align=center,text width = 0.1cm, inner sep = 0.1cm},
line/.style = {draw,thick, -latex'},
node distance=0.9cm and 0.4cm
]
% Place nodes
\node [block] (a) {a};
\node [block, below left of=a,xshift=-1.0cm, yshift=-0.3cm] (b) {b};
\node [block, below right of=a,xshift=1.0cm, yshift=-0.3cm] (c) {c};
% Draw edges
\path [line] (a) -- (b);
\path [line] (a) -- (c);
\end{tikzpicture}}
答案1
\path [line] (a) -- node [sloped] {p1} (b)
有用