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.

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

1 Answer 1

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
2  
thanks for answering. {1/a/Z,2/b/Y,...,26/z/A} is also possible ? –  xport Jan 1 '11 at 18:31
2  
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

 
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.