我正在尝试用 LaTeX 创建这样的图表:
这是我目前使用来自 texample.net 的分配结构:
代码:
\begin{tikzpicture}[node distance=.8cm,start chain=going below]
\node[punktchain, join] (client) {$Client$};
\node[punktchain, join] (server) {$Job\ server$};
\node[punktchain, join] (worker1) {$Worker_1$};
\node[punktchain, join] (worker2) {$Worker_2$};
\node[punktchain, join] (worker3) {$Worker_3$};
\node[punktchain, join] (worker4) {$Worker_4$};
\end{tikzpicture}
但现在我陷入了困境。我不知道如何使用双面箭头,也无法将工人放在一起。
答案1
我认为链式结构不适合您的图表。不过您可以手动定位节点。该positioning
库提供了一些高级定位键。
也请不要滥用数学模式来获取斜体文本。\textit
为此使用。您可以仅将数学上标用作索引,或使用\textsubscript
(需要fixltx2e
包裹)。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[rounded corners=2pt,inner sep=5pt,node distance=.8cm]
\node [draw](client) {\textit{Client}};
\node [draw,below=of client] (server) {\textit{Job server}};
\node [inner sep=0pt,below=of server] (aux) {\strut};
\node [draw,left=.4cm of aux] (worker2) {\textit{Worker$_2$}};
\node [draw,right=.4cm of aux] (worker3) {\textit{Worker$_3$}};
\node [draw,left=of worker2] (worker1) {\textit{Worker$_1$}};
\node [draw,right=of worker3] (worker4) {\textit{Worker$_4$}};
\draw [<->] (client) -- (server);
\foreach \n in {1,...,4}
\draw [<->] (server) -- (worker\n.north);
\end{tikzpicture}
\end{document}