![如何将文本放置在相对于 TikZ 圆形路径的不同点?](https://linux22.com/image/319413/%E5%A6%82%E4%BD%95%E5%B0%86%E6%96%87%E6%9C%AC%E6%94%BE%E7%BD%AE%E5%9C%A8%E7%9B%B8%E5%AF%B9%E4%BA%8E%20TikZ%20%E5%9C%86%E5%BD%A2%E8%B7%AF%E5%BE%84%E7%9A%84%E4%B8%8D%E5%90%8C%E7%82%B9%EF%BC%9F.png)
我有以下代码,它使用 TikZ 生成一个小圆圈,其中包含圆形图像。如何将文本放置在相对于此圆圈的不同点?具体来说,
- 如何将一些文字放置在圆圈的中心?
- 如何在每个圆形图像下方添加标题?
\documentclass{article}
\usepackage{tikz}
\tikzset{%
image 1/.initial=test.png,
image 2/.initial=test.png,
image 3/.initial=test.png,
image 4/.initial=test.png,
image 5/.initial=test.png,
image 6/.initial=test.png,
path image/.style={path picture={%
\edef\imagename{\pgfkeysvalueof{/tikz/image #1}}%
\node at (path picture bounding box.center){
\includegraphics[height=1cm]{\imagename}
};
}}
}
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,...,6}
\draw [path image=\i] (\i * 60 + 30:2) circle [radius=0.5cm];
\end{tikzpicture}
\end{document}
\begin{document}
答案1
你必须找到你自己的图像...
\documentclass[tikz,border=5]{standalone}
\renewcommand\familydefault\sfdefault
\tikzset{%
team/.cd,
image/.store in=\imagefile, name/.store in=\imagenamed,
member 1/.style={image=pugh1, name=Pugh},
member 2/.style={image=pugh2, name=Pugh},
member 3/.style={image=barney, name=Barney McGrew},
member 4/.style={image=cuthbert, name=Cuthbert},
member 5/.style={image=dibble, name=Dibble},
member 6/.style={image=grub, name=Grub},
/tikz/pics/team member/.style={code={
\tikzset{team/.cd, member #1/.try}%
\draw [path picture={%
\node at (path picture bounding box.center)
{\includegraphics[width=1cm]{\imagefile}};}]
circle [radius=0.5];
\node [below, font=\small, text width=4em, align=center]
at (0,-.5) {\imagenamed};
}}
}
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,...,6}
\pic at (\i*60+30:2) {team member=\i};
\node [align=center] {Trumpton\\fire brigade};
\end{tikzpicture}
\end{document}