summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-pgffor.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-pgffor.tex')
-rw-r--r--Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-pgffor.tex31
1 files changed, 23 insertions, 8 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-pgffor.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-pgffor.tex
index fbd4820310d..fb89643018c 100644
--- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-pgffor.tex
+++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-pgffor.tex
@@ -20,7 +20,7 @@ automatically by \tikzname, but not by \pgfname:
two new commands: |\foreach| and |\breakforeach|.
\end{package}
-\begin{command}{\foreach| |\meta{variables}| in |\marg{list}
+\begin{command}{\foreach| |\meta{variables}| in |\meta{list}
\meta{commands}}
The syntax of this command is a bit complicated, so let us go
through it step-by-step.
@@ -30,9 +30,10 @@ automatically by \tikzname, but not by \pgfname:
active characters. If you do not know what active characters are,
you are blessed.)
- Still in the easiest case, \meta{list} is a comma-separated list of
- values. Anything can be used as a value, but numbers are most
- likely.
+ Still in the easiest case, \meta{list} is either a comma-separated
+ list of values surrounded by curly braces or it is the name of a
+ macro that contain such a list of values. Anything can be used as a
+ value, but numbers are most likely.
Finally, in the easiest case, \meta{commands} is some \TeX-text in
curly braces.
@@ -40,12 +41,27 @@ automatically by \tikzname, but not by \pgfname:
With all these assumptions, the |\foreach| statement will execute
the \meta{commands} repeatedly, once for every element of the
\meta{list}. Each time the \meta{commands} are executed, the
- \meta{variable} will be set to the current value of the list item.
+ \meta{variable} will be set to the current value of the list
+ item.
\begin{codeexample}[]
\foreach \x in {1,2,3,0} {[\x]}
\end{codeexample}
+\begin{codeexample}[]
+\def\mylist{1,2,3,0}
+\foreach \x in \mylist {[\x]}
+\end{codeexample}
+
+ Note that in each execution of \meta{commands} the
+ \meta{commands} are put in a \TeX\ group. This means that
+ \emph{local changes to counters inside \meta{commands} do not
+ persist till the next iteration}. For instance, if you add 1 to a
+ counter inside \meta{commands} locally, then in the next iteration
+ the counter will have the same value it had at the beginning of the
+ first iteration. You have to add |\global| if you wish changes to
+ persist from iteration to iteration.
+
\medskip
\textbf{Syntax for the commands.}
Let us move on to a more complicated setting. The first
@@ -200,8 +216,7 @@ automatically by \tikzname, but not by \pgfname:
\begin{codeexample}[]
\begin{tikzpicture}
% Define some coordinates:
- \tikzstyle{every node}=[draw,fill]
- \path[shape=circle,fill=examplefill]
+ \path[nodes={circle,fill=examplefill,draw}]
(0,0) node(a) {a}
(2,0.55) node(b) {b}
(1,1.5) node(c) {c}
@@ -226,7 +241,7 @@ automatically by \tikzname, but not by \pgfname:
\end{codeexample}
\begin{codeexample}[]
-\begin{tikzpicture}[cap=round,line width=3pt]
+\begin{tikzpicture}[line cap=round,line width=3pt]
\filldraw [fill=examplefill] (0,0) circle (2cm);
\foreach \angle / \label in