使用 [midway] 标记中心的弯曲路径

使用 [midway] 标记中心的弯曲路径

我正在尝试使用该node[midway]选项标记连接两个节点的两条曲线路径,并在其中心放置标签。这应该非常简单,但我无法想出可行的方法。以下是我的 MWE,其中的问题为两条评论:

\documentclass[crop,border=0]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[>=latex]
    \node [draw,rectangle] (Start) {Start};
    \node [draw,rectangle] (Finish) [right=2cm] {Finish};
    \draw [->,out=90,in=90,looseness=0.75] (Start.north) to (Finish.north);
    % I want to label this path using [midway,below] as {forward}
    \draw [->,out=-90,in=-90,looseness=0.75] (Finish.south) to (Start.south);
    % I want to label this path using [midway,above] as {reverse}
\end{tikzpicture}
\end{document}

有人可以给我指明正确的方向吗?

我也很欣赏能够改善代码优雅度或简洁性的评论。

谢谢。

答案1

你必须把node直接放在to

\documentclass[crop,border=0]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture} [>=latex]
    \node [draw,rectangle] (Start) {Start};
    \node [draw,rectangle] (Finish) [right=2cm] {Finish};
    \draw [->,out=90,in=90,looseness=0.75] (Start.north) to node[above]{above}  (Finish.north);
    \draw [->,out=-90,in=-90,looseness=0.75] (Finish.south) to node[below]{below} (Start.south)
      ;
\end{tikzpicture}
\end{document

enter image description here

相关内容