I want to write a single code for many polygons using foreach. How can I plot each one with the same code by using n variables and writing n values? I am repeating a few steps in the same way as below. But I want to write a single code for each polygon, usually foreach loop is used, but I would like to learn different loops. I'm working on one detail, tikz.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usepackage{caption}
\tikzset{
buffer/.style={
draw,
regular polygon,
regular polygon sides=4,
minimum size=20em
},
}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[buffer, fill=pink]{};
\end{tikzpicture}
\caption{One square}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}
\node[buffer, fill=pink] (A) {};
\foreach \mycorner in {1,2,3,4}
{\node[buffer, fill=green,scale=.33, transform shape] (A\mycorner) at (A.corner \mycorner) {};}
\end{tikzpicture}
\caption{One square with squares}
\end{figure}
\end{document}

\foreachis able to do way more than the standard user needs, what exactly are you missing from it? – Skillmon Dec 10 '21 at 11:25