5

I want something like this:

enter image description here

but the arrows get overlapped in TikZ!

I have tried the following code, but is there a better way than this?

\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}
4

My answer (following the picture in the question) leads to:

enter image description here

Here is the code:

\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}

I created a style called block where there are also the minimum width and minimum height defined. Moreover to set the starting and arrival point of arrows I used angles of the boxes and instead of adopting parboxes I preferred to set the text width option.

  • If you want to use angles, you need to use a square, so you can use minimum size instead of minimum width and minimum height – Alain Matthes Jun 29 '12 at 17:05
  • You are right! I discovered now from the manual that minimum size sets both minimum width and minimum height at the same time. Thanks ;) – Claudio Fiandrino Jun 29 '12 at 17:12
4

I remove color because xcolor loads 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} 

enter image description here

  • The arrows are misplaced ! Do you want exactly what I see in your example ? – Alain Matthes Jun 29 '12 at 16:37
  • ooh..ya...sry...they are interchanged.. it was the first draft...will change them.. – Vineet Menon Jun 29 '12 at 16:54
  • @VineetMenon \node at (a,b) is the natural syntax instead of \path (a,b) node. – Alain Matthes Jun 29 '12 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.