I have a collection of points and I want use tikz package to connect them by using the \foreach command to scan all the data. But I failed :( Here is a mwe

  \foreach \mx/\my/\mz in {(1,1)/(2,2)/(3,3)}{
    \draw \my--\my--\mz;

I wonder why I failed and how to solve it. Thanks.


You have to hide the commas from the TikZ parser otherwise it thinks that the array is (1,1)/(2,2)/(3,3). Also you are missing the closing brace of the body of the loop.

\foreach \mx/\my/\mz in {{(1,1)}/{(2,2)}/{(3,3)}}{\draw \my--\my--\mz;}

should work. Note that your loop is spinning only once.

  • It works. Thanks for your answer and notes :) – Ice0cean Oct 10 '16 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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