I have the following code:
\foreach \x in {0,1,2,3,4}
Is there a possibility to accomplish the same thing with something like the following pseudo-code:
\foreach \x in {x1 to x2}
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI have the following code:
\foreach \x in {0,1,2,3,4}
Is there a possibility to accomplish the same thing with something like the following pseudo-code:
\foreach \x in {x1 to x2}
As @percusse says in the comment, various options for this are covered in the pgf
and tikz
manual. Here are a few examples:
For the integers from 0 to 10:
\foreach \x in {0,...,10}
For the even integers from 0 to 10:
\foreach \x in {0,2,...,10}
(The stepping is determined by the difference between the first two numbers provided.)
You can change the pattern midway. Thus, to get 0,1,2,3,4,6,8,10,12
write:
\foreach \x in {0,...,4,6,8,...,12}
\foreach \x in {x1,...,x2}
. You can find more options in the manual.