Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 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,

share|improve this answer

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.

share|improve this answer
    
in all cases error. i use pgf/tikz 2.0. and arrayjobx –  Regis da Silva Dec 29 '10 at 18:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.