我有一个关于 Tikz 环境中图形的问题,在下图中我想将传入和传出箭头分开,并将每对传入和传出箭头设为水平线。请指导我如何做到这一点?
\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}
答案1
一个简单的解决方案,线条不太平行
\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}