标记多“节点”路径

标记多“节点”路径

我想用以下命令请求绘制的路径

\draw [->] (4) to [out=225,in=0] (11) to [out=180,in=-90] (12) to [out=90] (2);

我如何在路径上添加倾斜标签。此外,如果我想让标签出现在 (12) 和 (2) 之间的部分,我该怎么做?

谢谢!在此处输入图片描述


已编辑

抱歉。代码和生成的输出如下。

\begin{tikzpicture}[->,>=stealth',node distance=5cm,font=\small\setstretch{1.0}]

    \node [state] (1) [] {A};
    \node [state] (2) [below=15cm of 1] {B};
    \node [state] (3) [left of=2] {C};
    \node [state] (4) [above of=3] {D};
    \node []      (5) [below=1cm of 3] {};
    \node []      (6) [left  of=4]  {};

    \draw [->,smooth] (2) to [out=225,in=0] (5) to [out=180,in=-90] (6) to [out=90] (1);

\end{tikzpicture}

在此处输入图片描述

答案1

您可以将带有选项的节点 [pos=0.8,above,sloped]放在适当的位置

\draw [->,smooth] (2) to [out=225,in=0] (5) to [out=180,in=-90] (6) to [out=90]node[pos=0.8,above,sloped]{here} (1);

此外,使用positioning库应该= of不是of =,使用 ese 你的代码变成

\documentclass[12pt,tikz,border=5]{standalone}
\usetikzlibrary{automata,arrows,positioning}

\begin{document}
  \begin{tikzpicture}[->,>=stealth',node distance=5cm,font=\small]

    \node [state] (1)  {A};
    \node [state,below=15cm of 1] (2)  {B};
    \node [state] (3) [left = of 2] {C};
    \node [state] (4) [above = of 3] {D};
    \node []      (5) [below=1cm of 3] {};
    \node []      (6) [left  = of 4]  {};

    \draw [->,smooth] (2) to [out=225,in=0] (5) to [out=180,in=-90] (6) to [out=90]node[pos=0.8,above,sloped]{here} (1);

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容