答案1
有几种不同的方法可以实现这一点,这里是一种方法。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\tikzset{
hex/.style={
regular polygon,
regular polygon sides=6,
minimum size=2cm,
fill=green!30
},
pent/.style={
hex,
regular polygon sides=5
}
}
\begin{document}
\begin{tikzpicture}
\node [hex] (inner) {};
\foreach \i in {1,...,6}
\path (inner.center) ++({360/6*(\i-0.5)}:2cm) node[hex,fill=blue!10]{};
\node [pent] (inner) at (6,0) {};
\foreach \i in {1,...,5}
\path (inner.center) ++({90+360/5*(\i-0.5)}:2cm)
node[pent,fill=blue!10, rotate={360/5*(\i-0.5)}]{};
\end{tikzpicture}
\end{document}
作为对 Sigur 评论的后续,有一个小的变化,即在两种情况下,从中心多边形到周围多边形的距离是相同的。
\begin{tikzpicture}
\node [hex] (inner) {};
\foreach [evaluate={\j=360/6*(\i-0.5)}] \i in {1,...,6}
\path (inner.\j) ++(\j:2mm) node[hex,fill=blue!10,rotate=\j-90,anchor=270]{};
\node [pent] (inner2) at (6,0) {};
\foreach [evaluate={\j=90+360/5*(\i-0.5)}] \i in {1,...,5}
\path (inner2.\j) ++(\j:2mm)
node [pent,fill=blue!10,rotate=\j-90,anchor=270] {};
\end{tikzpicture}