TikZ 图片箭头重叠

TikZ 图片箭头重叠

我想要这样的东西:

在此处输入图片描述

但是箭头在 TikZ 中重叠了!

我已经尝试了下面的代码,但是有没有比这更好的方法?

\documentclass{article}
\usepackage{color}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}


\begin{document}
\begin{tikzpicture}
    \path (0,0) node(a) [rectangle,draw, fill=blue, text=white] {\LARGE EP};
    \path (2,3) node(b) [rectangle,draw, fill=Cyan] {\LARGE GK};
    \path (7,3) node(c) [rectangle,draw, fill=Cyan] {\LARGE GK};
    \path (9,0) node(d) [rectangle,draw, fill=blue, text=white] {\LARGE EP};

    \draw[thick,<-] (a.north) -- (b.west) node[midway, below right=0.3cm]{\parbox{2cm}{1. Request permission to place call}};
    \draw[thick,->] (a.east) -- (b.south) node[midway, above left=0.3cm]{\parbox{2cm}{4. Grant permission to place call}};    
\end{tikzpicture}
\end{document}

答案1

我的回答(根据问题中的图片)是:

在此处输入图片描述

以下是代码:

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}

\tikzset{block/.style={rectangle,draw,minimum height=1cm,minimum width=1cm}}

\begin{document}
\begin{tikzpicture}
    \path (0,0) node(a) [block, fill=blue, text=white] {\LARGE EP};
    \path (2.5,3) node(b) [block, fill=Cyan] {\LARGE GK};
    \path (6.5,3) node(c) [block, fill=Cyan] {\LARGE GK};
    \path (9,0) node(d) [block, fill=blue, text=white] {\LARGE EP};

    \draw[thick,stealth-] (a.120) -- (b.150) node[midway, below right=0.4cm,text width=1.75cm ]{1. Request permission to place call};
    \draw[thick,-stealth] (a.70) -- (b.210) node[pos= 0.3, above left,text width=1.75cm]{4. Grant permission to place call};    
\end{tikzpicture}
\end{document}

我创建了一个名为的样式,block其中还定义了minimum widthminimum height。此外,为了设置箭头的起点和终点,我使用了方框的角度,而不是采用parboxes,我更喜欢设置text width选项。

答案2

我删除color,因为xcolor加载color

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \node [draw, fill=blue, text=white,minimum size=24pt,outer sep=2pt] (a) at (0,0) {\LARGE EP};
    \node [draw, fill=Cyan,minimum size=24pt,outer sep=2pt]             (b) at (3,2) {\LARGE GK};

    \draw[thick,->] ([xshift=-6pt]a.north) -- ([yshift=+4pt]b.west) 
                   node[midway, below right=5pt,align=left,font=\small]
                   {1. Request \\permission  \\to place call};
    \draw[thick,<-] ([xshift=+6pt]a.north)  -- ([yshift=-4pt]b.west) 
                   node[midway, above left=5pt,align=left,font=\small]
                   {4. Grant \\ permission\\ to place call};    
\end{tikzpicture}
\end{document} 

在此处输入图片描述

相关内容