tikz:如何在弯曲路径下方添加文本

tikz:如何在弯曲路径下方添加文本

梅威瑟:

\documentclass[12pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T2A]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning, decorations.pathreplacing, calc}
\begin{document}
\begin{tikzpicture}
  \tikzset{
    node/.style={draw, rectangle, rounded corners},
  }
  \node [node] (1) {hotels\_options};

  \node [node, right = 4cm of 1] (2) {hotels\_groups};

  \draw (2.south) to[out=200,in=-20] (1.south);

\end{tikzpicture}
\end{document}

输出:

在此处输入图片描述

如何在曲率中心下方添加文字?

在此处输入图片描述

答案1

在此处输入图片描述

\documentclass[12pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T2A]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning, decorations.pathreplacing, calc}
\begin{document}
\begin{tikzpicture}
  \tikzset{
    node/.style={draw, rectangle, rounded corners},
  }
  \node [node] (1) {hotels\_options};

  \node [node, right = 4cm of 1] (2) {hotels\_groups};

  \draw (2.south) to[out=200,in=-20] node[midway,below,sloped](a){relation description}(1.south);

\end{tikzpicture}
\end{document}

答案2

你可能喜欢:

\documentclass[tikz, 12pt, margin=3mm]{standalone}
\usetikzlibrary{decorations.text,
                positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 0mm and 40mm,
box/.style = {draw, rectangle, rounded corners},
                        ]
\node (n1) [box]                {hotels\_options};
\node (n2) [box, right=of n1]   {hotels\_groups};
\draw [postaction={decorate},
       decoration={text along path, raise=-2ex,
       text align={center}, 
       text={relation description}}
       ]
       (n1.south) to[bend right=30] (n2.south);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容