2

I have a question regarding figures in Tikz environment, in the following figure I want to make the incoming and outgoing arrow to be separated and each pair of incoming and outgoing arrows to be horizontal lines. Please guide me how to do that?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,arrows,positioning}

\tikzset{
line/.style={draw,-stealth,thick},
block/.style={draw,rectangle, text width=10em, text centered, minimum height=15mm, node distance=10em}
}

%fill=yellow!50
\begin{document}

\begin{tikzpicture}
\node [block] (browser) {BROWSER};
\node [block, below of= browser] (mediaplayer) {MEDIA PLAYER};  
\node [block, right of= browser,node distance= 30em, yshift=-50pt, minimum height=20em] (webserver) {WEB SERVER};  

%arrows
\path [line] (browser) -- (webserver);
\path [line] (webserver) -- (browser);

\path [line] (browser) -- (mediaplayer);

\path [line] (mediaplayer) -- (webserver);
\path [line] (webserver) -- (mediaplayer);

\end{tikzpicture}

\end{document}

enter image description here

3

A simple solution, the lines are not quite parallel

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,arrows,positioning}

\tikzset{
line/.style={draw,-stealth,thick},
block/.style={draw,rectangle, text width=10em, text centered, minimum height=15mm, node distance=10em}
}

%fill=yellow!50
\begin{document}

\begin{tikzpicture}
\node [block] (browser) {BROWSER};
\node [block, below of= browser] (mediaplayer) {MEDIA PLAYER};  
\node [block, right of= browser,node distance= 30em, yshift=-50pt, minimum height=20em] (webserver) {WEB SERVER};  

%arrows
\path [line] (browser.-3) -- (browser.-3-|webserver.west);
\path [line,red] (webserver.west|-browser.3) |- (browser.3);

\path [line] (browser) -- (mediaplayer);

\path [line] (mediaplayer.-3) -- (mediaplayer.-3-|webserver.west);
\path [line,green] (webserver.west|-mediaplayer.3) -- (mediaplayer.3);

\end{tikzpicture}

\end{document}

enter image description here

  • how can each pair of lines be horizontal ? – Umar Mar 13 '15 at 18:17
  • I have modified the solution – rpapa Mar 13 '15 at 18:22

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.