绘制折断箭头/节点间有角的箭头

绘制折断箭头/节点间有角的箭头

我有三个节点,想用一个像我的绘画中那样弯曲的箭头连接两个节点。我还需要在箭头上方添加一些文本。

在此处输入图片描述

这是我用于生成节点的精简代码:

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node[draw=none,fill=none, text height=1em] (1) {test1};
\node[draw=none,fill=none, text height=1em] (2) [right=.6cm of 1 ]{test2};
\node[draw=none,fill=none, text height=1em] (3) [right=.6cm of 2]{test3};
\end{tikzpicture}
\end{document}

过去,我用曲线连接节点,如下所示:

\path[every node/.style={font=\sffamily\small}]
    (3)edge [bend angle=90] node[above left] {foo} (1);

不幸的是,我无法使该代码看起来如上图所示。

我想我可以插入“隐形”节点来伪造箭头的角,但 TikZ 可能有一个简单的选项来实现我想要的输出,但我找不到?

答案1

+(0,1)这是一个可能的解决方案,可以根据需要改变垂直高度。

在此处输入图片描述

代码

\documentclass[border=10pt]{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}
\node[draw=none,fill=none, text height=1em] (1) {test1};
\node[draw=none,fill=none, text height=1em] (2) [right=.6cm of 1 ]{test2};
\node[draw=none,fill=none, text height=1em] (3) [right=.6cm of 2]{test3};
\draw (3.north) -- +(0,1)-| node[above right]{Text starts from there} (1);
\end{tikzpicture}
\end{document}

答案2

\usetikzlibrary{arrows,calc}
\usetikzlibrary{positioning}
\begin{tikzpicture}
\node[draw=none,fill=none, text height=1em] (1) {test1};
\node[draw=none,fill=none, text height=1em] (2) [right=.6cm of 1 ]{test2};
\node[draw=none,fill=none, text height=1em] (3) [right=.6cm of 2]{test3};
\draw[->, every node/.style={font=\sffamily\small}] 
   (3) -- ($(3)+(0,.5)$) -- ($(1)+(0,.5)$) node[above, pos=0.8] {some text} -- (1) ; 
\end{tikzpicture}

结果

答案3

为了好玩,这里有一个非tikz版本。

\documentclass{article}
\usepackage{stackengine}
\usepackage{xcolor}
\newcommand\leftbentarrow[4][]{\setstackgap{L}{.3\baselineskip}%
  \setbox0=\hbox{#2}%
  \def\stackalignment{r}\stackon{#2}{\def\stackalignment{l}%
    \stackon[-.2pt]{\makebox[0pt]{$\downarrow$}}%
    {\trlap{\textcolor{cyan}{\sffamily#1}}\rule{.5\wd0}{.4pt}}}%
  \setbox0=\hbox{#3}%
  \setbox1=\hbox{$\downarrow$}%
  \def\stackalignment{c}\stackon[\Sstackgap+\dp1+\ht1-.2pt]{#3}{\rule{\wd0}{.4pt}}%
  \setbox0=\hbox{#4}%
  \def\stackalignment{l}\stackon{#4}{\def\stackalignment{r}%
    \stackon[-.2pt]{\makebox[0pt]{\rule{.4pt}{\ht1+\dp1}}}{\rule{.5\wd0}{.4pt}}}%
}
\usepackage{lipsum}
\parskip 1em
\begin{document}
\leftbentarrow[some text]{test1}{ test2 test2a }{test3}

\leftbentarrow[some text]{test1}{\makebox[1in]{test2}}{test3}
\end{document}

在此处输入图片描述

相关内容