Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
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
add comment

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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