My goal is to draw an array of shapes in the following fashion: square, square, triangle, square, square, triangle ...
I use a \foreach loop in which I use modular arithmetic to determine when to draw a triangle. Here is my MWE:
\documentclass{article}
\usepackage{pgfplots,tikz,tikz-3dplot}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture} [scale=0.35,
triangle/.style = {regular polygon, regular polygon sides=3, scale=2.5},
square/.style = {regular polygon, regular polygon sides=4, scale=2}]
\foreach \i in {1,...,9}
{
\ifthenelse{mod(\i,3) = 0}
{
\node[triangle] (\i) at (\i,0) {};
}
{
\node[square] (\i) at (\i,0) {};
}
}
\end{tikzpicture}
\end{figure}
\end{document}
I get the errors:
! Missing number, treated as zero.
! Missing = inserted for \ifnum.
The most related question about these error is this but it considers decimal numbers, which is not my case. What am I missing?