2

I use TikZ/PGF 2.00. In the CVS PGF manual pag. 563 we have

\def\myarray{{1,"two",2+1,"IV","cinq","sechs",sin(\i*5)*14}}
\foreach \i in {0,...,6}{\pgfmathparse{\myarray[\i]}\pgfmathresult, }

My question is: How can do the same but in TikZ/PGF 2.00?

0

2 Answers 2

2

I think you can use them directly:

\foreach \i/\foo in {0/1, 1/two, 2/{2+1}, 3/IV, 4/cinq, 5/sechs, 6/{sin(6*5)*14}}

or use arrayjobx package insdead.

1
  • in all cases error. i use pgf/tikz 2.0. and arrayjobx Dec 29, 2010 at 18:03
2

With PGF 2.0 you could define the array differently and process it outside of \pgfmathparse.

For example:

\def\myarray{{1},{"two"},{2+1},{"IV"},{"cinq"},{"sechs"},{sin(6*5)*14}}
\foreach \i in \myarray {\pgfmathparse{\i}\pgfmathresult,}

Or with a loop index:

\def\myarray{0/{1},1/{"two"},2/{2+1},3/{"IV"},4/{"cinq"},5/{"sechs"},6/{sin(\i*5)*14}}
\foreach \i\element in \myarray {\pgfmathparse{\element}\pgfmathresult,}

I tested both and got

1,two,3.0,IV,cinq,sechs,7.0,

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .