I am having an issue I have never had before where code I wrote and works fine on my PC using Texmaker (MiKTeX) throws errors when copy-pasted into Overleaf.
This is the code:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\def\chair#1#2#3#4{
\begin{scope}[shift={#1},rotate={#2-90},scale={0.5*#3}]
\draw (-1.1,1) to[out=30,in=150] (1.1,1);
\draw (-1,0.75) to[out=30,in=150] (1,0.75) -- (1,-0.75) to[out=-150,in=-30] (-1,-0.75) to cycle;
\draw (0,0) node {#4};
\end{scope}
}
\pagenumbering{gobble}
\centering
\begin{tikzpicture}[line width=0.5mm,scale=1.1]
\def\a{12}
\def\s{2}
\foreach \i in {0,...,\a-1}
\chair{({\i*180/(\a-1)}:{1.5+\s})}{\i*180/(\a-1)}{0.75}{}; % (this is line 20)
\end{tikzpicture}
\end{document}
In Texmaker it renders exactly as I would like:
But when that exact code is copy-pasted into Overleaf the \foreach statement does not iterate properly as shown below.
(Note that the messed up anti-aliasing indicates that the 12 figures were stacked on top of each other.)
And I am given the following two error messages:
Based on this post I suspect this has something to do with the version used by Overleaf, but I am unsure how to change this. If it is not possible, how can I amend my code to render properly in the version Overleaf uses?




\foreachcommand inside curly braces ({}). It is just one command but sometime later you could possibly try to add more commands and this could create problems. Even if not it is more readable inside of them. – koleygr Mar 25 '19 at 00:18