summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/loops/README
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-11-06 22:35:43 +0000
committerKarl Berry <karl@freefriends.org>2012-11-06 22:35:43 +0000
commit705b4d8f092a56d9ae900940d265fb6f55b3033d (patch)
tree8299b4712f70eff6211da7326d99ebd33ba035cc /Master/texmf-dist/doc/latex/loops/README
parent2f6000f28f9662342c1cfe6e59abfdf345bd3a23 (diff)
loops (6nov12)
git-svn-id: svn://tug.org/texlive/trunk@28196 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/loops/README')
-rw-r--r--Master/texmf-dist/doc/latex/loops/README83
1 files changed, 66 insertions, 17 deletions
diff --git a/Master/texmf-dist/doc/latex/loops/README b/Master/texmf-dist/doc/latex/loops/README
index ca4a68a07e6..955e90f4994 100644
--- a/Master/texmf-dist/doc/latex/loops/README
+++ b/Master/texmf-dist/doc/latex/loops/README
@@ -6,7 +6,7 @@ Ahmed Musa
VERSION
-Version 1.1, October 2012.
+Version 1.1, 2012/10/16.
LOCATION ON CTAN
@@ -124,8 +124,8 @@ The looping macros include:
\skvtfor:
- \skvtfor<holder.cmd>{<list>}\do{<callback>}
- \skvtfor*<holder.cmd>{<listcmd>}\do{<callback>}
+ \skvtfor<holder.cmd>:={<list>}\do{<callback>}
+ \skvtfor*<holder.cmd>:={<listcmd>}\do{<callback>}
A variant of LaTeX kernel's \@tfor that has a different
approach to breaking the loop prematurely.
@@ -307,18 +307,19 @@ The looping macros include:
restore the values of holder macros and some other internal
parameters/quantities.
- There is a long list of options/keys in <options>, available for
- \newforeach and \foxloop. For example, key 'reverse list' allows users
- to automatically reverse their lists prior to processing.
-
- Also, there are many internal macros that can be accessed by the user.
+ There is a long list of options/keys in <options>, available for
+ \newforeach and \foxloop or \foreachfox. For example, key 'reverse list'
+ allows users to automatically reverse their lists prior to processing.
+
+ Also, there are many internal macros that can be accessed by the user.
A few of them are
-
+
\interruptforeach, \foreachcurrentitem, \foreachnextitem,
\foreachitemcount, \foreachprevitem, \prependtobeginforeach,
\appendtobeginforeach, \prependtoendforeach, \appendtoendforeach,
- \ifforeachlastitem, \foreachnestdepth, \foreachlistremainder.
-
+ \ifforeachlastitem, \foreachnestdepth, \foreachlistremainder,
+ \skvforeachonlyinitially.
+
\foreachitemcount counts the items as the loop progresses.
It is depth dependent, ie, it can be called to access the
number of items processed on each depth of nesting of
@@ -334,6 +335,11 @@ The looping macros include:
to terminate the list prematurely. \listpauser will pause
the processing for user action.
+ \newforeach found a bug in PGF's \foreach, as reported at
+ <http://tex.stackexchange.com/questions/72707/an-unexpected-
+ outcome-from-pgfs-foreach>. However, \newforeach itself
+ can't be said to be bug free.
+
Maybe you fancy the following syntactic sugar, which PGF's
\foreach can't presently process:
@@ -344,7 +350,8 @@ The looping macros include:
\parindent-20pt
\begin{tikzpicture}
\draw[step=.5cm,blue!65,very thin] (0,0) grid (13,6);
- \newforeach* \x [
+ \newforeach \x [
+ expand list once,
count in=\xc all \x satisfying \ifnum\x>5\fi
] in \alist {
\newforeach [
@@ -411,13 +418,55 @@ The looping macros include:
\end{document}
- \newforeach found a bug in PGF's \foreach, as reported at
- <http://tex.stackexchange.com/questions/72707/an-unexpected-
- outcome-from-pgfs-foreach>. However, \newforeach itself
- can't be said to be bug free.
+ \begin{document}
+ \begin{tikzpicture}[scale=2]
+ \let\pgftrun\pgfmathtruncatemacro
+ \newforeach [count=\ic] \x/\y in {1/.5,1/1,0/1,0/0,1/0,1/-1,0/-1,0/-.5,0/0}
+ \coordinate (p\ic) at (\x,\y);
+ \draw[line width=1pt,blue] (p1) \newforeach \p in {2,...,8} {-- (p\p)};
+ \newforeach \q in {1,...,7} {%
+ \pgftrun{\qa}{\q+1}\pgftrun{\qb}{\q+2}\pgftrun{\ind}{2*\q-1}%
+ \pgftrun{\next}{2*\q}%
+ \coordinate (n\ind) at (barycentric cs:p\q=0.5,p\qa=0.5);
+ \coordinate (n\next) at (barycentric cs:p\q=0.125,p\qa=0.75,p\qb=0.125);
+ }
+ \draw[line width=2pt,red] (n1)\newforeach \q in {2,...,13}{--(n\q)};
+ \end{tikzpicture}
+ \end{document}
+
+
+ % A complete graph
+ % Example credit:
+ % Quintin Jean-Noël
+ % <http://moais.imag.fr/membres/jean-noel.quintin/>
+ \usepackage[active,tightpage]{preview}
+ \PreviewEnvironment{tikzpicture}
+ \setlength\PreviewBorder{5pt}%
+ \usetikzlibrary[topaths]
+ \newcount\mycount
+ \begin{document}
+ \begin{tikzpicture}[transform shape]
+ \newforeach \nr in {1,...,8}{
+ \mycount=\numexpr(\nr-1)*45\relax
+ \node[draw,circle,inner sep=0.25cm] (N-\nr) at
+ (\the\mycount:5.4cm) {};
+ }
+ \newforeach \nr in {9,...,16}{
+ \mycount=\numexpr(\nr-1)*45+22\relax
+ \node[draw,circle,inner sep=0.25cm] (N-\nr) at
+ (\the\mycount:5.4cm) {};
+ }
+ \newforeach \nr in {1,...,15}{
+ \mycount=\numexpr\nr+1\relax
+ \newforeach \nra in {\the\mycount,...,16}{
+ \path (N-\nr) edge[->,bend right=3] (N-\nra)
+ edge[<-,bend left=3](N-\nra);
+ }
+ }
+ \end{tikzpicture}
-\foxloop:
+\foxloop or \foreachfox:
\foxloop[<options>]{<list>}{<parametered.callback>}
\foxloop*[<options>]{<listcmd>}{<parametered.callback>}