Is there a way to use the TikZ \foreach
command to do operations with parameters?
E.g. I would like to be able to write (just a silly example):
\newcommand{\foo}[9]{
\foreach \x in{1,2,...,9}{
\draw(0,#\x)--++(1,1);
}
}
where #\x
would mean the x th parameter of the command I'm defining with \newcommand
.
This should come in handy since I'm writing macros that depend on global values that can be set arbitrarily. E.g. \def\N{9}
would go in preamble and I'd write newcommand{\bar}[\N]{...}
, but since I don't know beforehand how much parameters there will be, I can't define anything unless I write \foreach \x in{1,2,...,\N}
and the above draw command.
What I actually like to do:
I'd like to have a command that plots some coordinates which are given.
So I'd like \foo{#1}{#2}{#3}
to expand to something like;
\draw plot coordinates {(360/\N*1:#1) (360/\N*2:#2) (360/\N*3:#3) ... (360/\N*\N:#N};
but I don't know if this is possible.
Best Answer
I do not reall understand what exactly do you want to draw, but maybe this helps: