我正在学习使用 tikz 创建图表,并希望重新创建以下内容(但文本已B*
旋转):
到目前为止我有以下内容:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\tikzset{
big/.style={
rectangle,
rounded corners,
draw=black, very thick,
text width=10em,
minimum height=3em,
text centered,
on chain,
join
},
small/.style={
rectangle,
rounded corners,
draw=black, very thick,
text width=4em,
minimum height=2em,
text centered,
on chain,
rotate=-90,
join
},
line/.style={draw, thick, <-},
every join/.style={->, thick, shorten >=1pt},
}
\begin{document}
\begin{tikzpicture}[node distance=1.8cm, start chain=going below]
\node[big] (A) {A};
\node[small] (B1) {B1};
\node[small, on chain=going right] (B2) {B2};
\end{tikzpicture}
\end{document}
但正如所见,我被困在了B
s 上。我认为链条被重定向到了正确的位置,但我不知道如何将它们置于中心位置,A
同时用独特的箭头将它们连接起来。
我该如何继续?
答案1
像这样吗?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,calc,shapes.geometric}
\tikzset{
big/.style={
rectangle,
rounded corners,
draw=black, very thick,
text width=10em,
minimum height=3em,
text centered,
%on chain,
%join
},
small/.style={
rectangle,
rounded corners,
draw=black, very thick,
text width=2em,
minimum height=4em,
text centered,
on chain,
anchor=center
},
line/.style={draw, thick, <-},
every join/.style={->, thick, shorten >=1pt},
}
\begin{document}
\begin{tikzpicture}[node distance=1.8cm,>=stealth]
\begin{scope}[start chain=going right,local bounding box=B]
\foreach \X in {1,...,4} {\node[small] (B\X) {B\X};}
\end{scope}
\path let \p1=($(B.east)-(B.west)$) in
node[big,above=of B,minimum width=\x1](A) {A};
\begin{scope}[start chain=going below,nodes={on chain,big,join}]
\node[below=of B,ellipse,minimum height=5em] (C){C};
\node (D){D};
\end{scope}
\foreach \X in {1,...,4} {
\draw[line] (B\X.north) -- (B\X.north|-A.south);
\draw[line] (C.200-44*\X) -- (B\X.south);}
\end{tikzpicture}
\end{document}