我正在努力生成 Tikz 图像...到目前为止我已经取得了以下进展:
然而,我想生成类似这样的内容:
我无法将箭头从 B 拉直至 A,也无法修复 C 和大脑图像之间的空间.....下面是我的代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,
decorations.pathreplacing,decorations.pathmorphing,shapes,
matrix,shapes.symbols}
\begin{document}
\tikzset{
>=stealth',
punktchain/.style={
rectangle,
rounded corners,
draw=black, very thick,
text width=22em,
minimum height=3em,
text centered,
on chain},
small punktchain/.style={
rectangle,
rounded corners,
draw=black, very thick,
text width=10em,
minimum height=3em,
text centered,
on chain},
line/.style={draw, thick, <-},
element/.style={
tape,
top color=white,
bottom color=blue!50!black!60!,
minimum width=8em,
draw=blue!40!black!90, very thick,
text width=10em,
minimum height=3em,
text centered,
on chain},
every join/.style={->, thick,shorten >=1pt},
decoration={brace},
tuborg/.style={decorate},
tubnode/.style={midway, right=2pt},
}
\begin{tikzpicture}
[node distance=2.8cm,
start chain=1 going below, start chain=2 going below]
\node[punktchain] (a) {\textbf{A}}
child[<-,thick]{node[small punktchain,anchor=east] (b) {\textbf{B}
}
child{node[on chain, right = 1cm of b] (brain) {\includegraphics[width=.25\textwidth]{brain.png}}
child{node[small punktchain, join,node distance=0.8em] (c) {\textbf{C}}}}}
;
\path [->] (brain.south) to node [near start, right, text width=3em] {\textit{solves}} (c);
\path [->] (a.south) to node [near start, right,text width=2cm] {\textit{Previous Knowledge}} (brain);
\path [] (b.north) to node [near start, right] {\textit{advises}} (a);
\end{tikzpicture}
\end{document}
答案1
我认为您正试图同时使用两种工具:positioning
,, ......这样做违背了使用它们中的任何一个的主要目的chains
,trees
即简化、构造和组织代码,使其更灵活、更直接。
我建议使用简单的positioning
,或许还有on grid
,或者chains
。这似乎不太适合成为一棵树。
例如,这里有一种方法可以做到这一点chains
。(您定义了 2 个链,但只使用其中 1 个。)必要时,我使用positioning
放置一个节点,然后\chainin
将其添加到链中join
。
example-image-a
是这次行动的策划者:
\documentclass[border=10pt,tikz,multi]{standalone}
\usetikzlibrary{positioning,arrows,chains}
\begin{document}
\tikzset{%
>=stealth',
punktchain/.style={
rectangle,
rounded corners,
draw=black, very thick,
text width=22em,
minimum height=3em,
text centered,
font=\bfseries,
on chain},
small punktchain/.style={
rectangle,
rounded corners,
draw=black, very thick,
text width=10em,
minimum height=3em,
text centered,
font=\bfseries,
on chain,
},
line/.style={draw, thick, <-},
element/.style={
tape,
top color=white,
bottom color=blue!50!black!60!,
minimum width=8em,
draw=blue!40!black!90, very thick,
text width=10em,
minimum height=3em,
text centered,
on chain},
every join/.style={->, thick, shorten >=1pt, shorten <=1pt},
}
\begin{tikzpicture}
[node distance=2.8cm, start chain=1 going below, every label/.style={font=\itshape}, label distance=0pt]
\node [punktchain] (a) {A};
\node [small punktchain, on chain, anchor=east, join={with a.south -| b by <-}, label={[anchor=south east]north east:advises}] (b) {B};
\node [anchor=west, right=10mm of b, inner sep=0pt] (brain) {\includegraphics[width=.25\textwidth]{example-image-a}};
\chainin (brain) [join={with a.south -| brain}];
\node [small punktchain, join, yshift=15mm, label={[anchor=south east]north east:solves}] (c) {C};
\draw [every join] (brain.east) [bend right=75] to (a.east);
\node [every label, anchor=north east, align=right] at (a.south -| brain) {previous\\knowledge};
\end{tikzpicture}
\end{document}