TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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
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
up vote 6 down vote accepted

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

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

Thanks Peter!

share|improve this answer

Your Answer


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.