

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer

In Mathematica, C# linq, or other languages, we can use auxiliary functions to produce list of certain pattern.

For example:

  1. In Mathematica, we can use Table[] or Range[] to produce a list of numbers in the specified pattern.
  2. In C#, we can also use Range to produce a list of consecutive integers.

I need this kind of function also in PGF/Tikz to be consumed by \foreach.

Are there list building macros in PGF/Tikz?

share|improve this question
up vote 5 down vote accepted

TikZ's \foreach accepts a lot of abbreviated lists. Examples include

  • \foreach \x in {1,2,...,6} {\x, } yields 1, 2, 3, 4, 5, 6,
  • \foreach \x in {1,3,...,11} {\x, } yields 1, 3, 5, 7, 9, 11,
  • \foreach \x in {Z,X,...,M} {\x, } yields Z, X, V, T, R, P, N,
  • \foreach \x in {0\pi,0.5\pi,...\pi,3\pi} {$\x$, } yields 0π, 0.5π, 1π, 1.5π, 2π, 2.5π, 3π,

For more details see “Repeating Things: The Foreach Statement“ in the TikZ manual (its Chapter 56 in the v2.10 manual).

share|improve this answer
thanks for answering. {1/a/Z,2/b/Y,...,26/z/A} is also possible ? – xport Jan 1 '11 at 18:31
I think not. At least the manual doesn't say anything about it and it doesn't work in any obvious way. – Caramdir Jan 1 '11 at 18:41

Your Answer


