在箭头(不在下方/上方)与边节点之间插入标签,tikz

时间:2017-05-30 13:25:51

标签: latex labels arrows tikz

我正在尝试用箭头绘制图形,我希望箭头的标签位于线条之间(不在上方或下方),如下所示: 输出应该如何: enter image description here

我使用tikz库和边缘节点在两个节点之间绘制箭头。 这是箭头上方标签的最小例子:

\documentclass[12pt]{article}
\usepackage[letterpaper, margin=1in, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage{xcolor}
\definecolor{corn}{rgb}{0.98, 0.93, 0.36}
\definecolor{emerald}{rgb}{0.31, 0.78, 0.47}

\usepackage{array}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{float}
\usepackage{subcaption,caption}
\captionsetup{labelsep=period}
\usetikzlibrary{positioning,patterns,arrows,decorations.markings,decorations.pathreplacing,shapes,shapes.misc}
\tikzset{
    %Define standard arrow tip
    >=stealth',
        % Define arrow style
    pil/.style={
           ->,
           thick,
           shorten <=3pt,
           shorten >=3pt,}
}

\title{ }
\begin{document}
\maketitle

\begin{figure}[h!] 
\centering
\caption{}
\label{paths}
\begin{subfigure}{0.9\textwidth}
\resizebox{.9\textwidth}{!}{
\begin{tikzpicture}[shorten >=2pt,on grid,auto]
\node (A) [draw=black,fill=emerald,double=white,double distance=2pt,shape=rounded rectangle,minimum width=4cm ]{A}; 
\node[right=9cm of A] (B) [draw,fill=corn,shape=rounded rectangle,minimum width=4cm ]{B};
\path[->]
    (A) edge[line width=0.742mm] node[ anchor=center, above, pos=0.5,font=\bfseries] {\Huge +} (B);
    \end{tikzpicture}
}
\caption{}
\label{M1w}
\end{subfigure}
\end{figure}

\end{document}%\grid

我在线搜索过,找不到边缘节点的任何示例。我真的很感激任何帮助!

1 个答案:

答案 0 :(得分:7)

如下更改\ path似乎可以解决问题:

\path[->] (A) edge[line width=0.742mm] node[ fill=white, anchor=center, pos=0.5,font=\bfseries] {\Huge +} (B);