13

I'm trying to draw some repeated with PGF/Tikz, and I'm using a foreach. Problem: each line has, on the right, a description, which is a string of text - which may be somewhat long and contain commas or math expressions.

How can I create a list of strings, iterating over it and use each string as node text?

Peter Grill
  • 223,288
AkiRoss
  • 804
  • 1
    Welcome to TeX.SE.

    It is always best to compose a MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This will also help to clarify the question.

    – Peter Grill Nov 16 '11 at 18:15
  • 3
    Without a MWE, all I suggest is enclosing the strings within a curly braces: {} – Peter Grill Nov 16 '11 at 18:16
  • Thanks for the reply... Actually the curly braces was exactly what I was looking for! - Sorry, but using LyX I'm pretty untrained about LaTeX. – AkiRoss Nov 16 '11 at 18:17

1 Answers1

15

To solve this problem was sufficient to use curly braces around the strings, as Peter Grill suggested:

\begin{tikzpicture}
    \foreach \c [count=\x from 0] in {{a,f},{b,o},{c,o},{d,b},{e,a},{f,r}} 
        \node at (0,\x) {\c};
\end{tikzpicture}

Thanks Peter!

AkiRoss
  • 804