各位同仁、各位朋友,大家好!
由于这张图片有版权,我找到了类似的免费版权图标。你能帮我把节点和箭头弄成原图那样吗?我真的很不擅长做这些
孩子们:
水果:
梅威瑟:
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt] (boy) at (0,0)
{\includegraphics[width=.25\textwidth]{boy.jpg}};
\node[inner sep=0pt] (girl1) at (0,5)
{\includegraphics[width=.25\textwidth]{girl.jpg}};
\node[inner sep=0pt] (girl) at (0,10)
{\includegraphics[width=.25\textwidth]{girl.jpg}};
%\draw[<->,thick] (boy) -- (girl1);
%
\node[inner sep=0pt] (pera) at (10,0)
{\includegraphics[width=.25\textwidth]{pera.png}};
\node[inner sep=0pt] (grapes) at (10,5)
{\includegraphics[width=.25\textwidth]{grapes.png}};
%%\draw[<->,thick] (pera) -- (grapes)
;
\node[inner sep=0pt] (strawberry) at (10,10)
{\includegraphics[width=.25\textwidth]{strawberry.png}};
\node[inner sep=0pt] (tangerine) at (10,15)
{\includegraphics[width=.25\textwidth]{tangerine.png}};
\draw[-latex,thick] (girl1) -- (grapes);
\draw[-latex,thick] (girl1) -- (strawberry);
\draw[-latex,thick] (girl1) -- (pera);
\end{tikzpicture}
\end{document}
新版本:
答案1
由于我没有您的图像,我使用选项demo
,而不是您的图像产生黑色矩形。我将节点组织成两个链(使用库chains
),节点之间的距离由控制node distance
。节点以链确定的名称命名(从A-1
到A-7
)。使用这些名称可以设置简单的循环以在节点之间绘制箭头。
对于所有节点都定义了通用节点样式,对于箭头也做了相同的定义(除了第一个,它的两侧都有箭头)。
为了缩短代码,使用包Gin
中的宏graphicx
,通过它定义节点的大小:
\documentclass{article}
\usepackage[demo]{graphicx} % in real document remove option "demo"
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 4mm and 44mm,
start chain = A going below,
every node/.style = {inner sep=0pt, outer sep=2mm, rounded corners,
text width=0.15\linewidth,
on chain=A},
arr/.style = {color=#1, ultra thick, -{Straight Barb[angle=60:2pt 3]}}
]
\setkeys{Gin}{width=\linewidth}
\node {\includegraphics{boy.jpg}}; % A-1
\node {\includegraphics{girl.jpg}};
\node {\includegraphics{girl.jpg}}; % A-3
%
\node[above right=of A-1.east]
{\includegraphics{pera.png}}; % A-4
\node {\includegraphics{grapes.png}};
\node {\includegraphics{strawberry.png}};
\node {\includegraphics{tangerine.png}}; % A-7
%
\draw[red, ultra thick,
{Straight Barb[angle=60:2pt 3]}-{Straight Barb[angle=60:2pt 3]}
] (A-1.west) to [bend right=45] (A-3.west);
\foreach \i in {4,...,7}
\draw[arr=black] (A-1.east) -- (A-\i);
\draw[arr=blue!50!gray] (A-2.east) -- (A-5);
\foreach \i in {5,6}
\draw[arr=purple!50!gray] (A-3.east) -- (A-\i);
%
\draw[arr=brown,densely dashed] (A-4) -- (A-3);
\draw[arr=brown,densely dashed] (A-7) -- (A-3);
\end{tikzpicture}
\end{document}