From b2941aa318c54c9d2acb00a560f456d35d90f888 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 27 May 2013 01:42:10 +0000 Subject: loops update 5/27 git-svn-id: svn://tug.org/texlive/trunk@30704 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/loops/README | 31 +++-- .../texmf-dist/doc/latex/loops/loops-pokayoke1.tex | 133 +++++++++++++++++++++ 2 files changed, 152 insertions(+), 12 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/loops/loops-pokayoke1.tex (limited to 'Master/texmf-dist/doc/latex/loops') diff --git a/Master/texmf-dist/doc/latex/loops/README b/Master/texmf-dist/doc/latex/loops/README index 61eb1c82929..8882c716bb5 100644 --- a/Master/texmf-dist/doc/latex/loops/README +++ b/Master/texmf-dist/doc/latex/loops/README @@ -6,12 +6,19 @@ Ahmed Musa VERSION -Version 1.2, 2013/02/10. +Version 1.3, 2013/05/15. LOCATION ON CTAN macros/latex/contrib/loops/ + +The package provides efficient looping macros for processing both +csv (separated-values) and nsv/tsv (non-separated values) lists. +Csv lists that have associated arbitrary list-separators may be +processed with the tools of the package. + + LICENSE Copyright (c) 2012-2013 Ahmed Musa @@ -167,7 +174,7 @@ The looping macros include: \sifakaloop is as \ayeloop but will first normalize the list using \skvtsvnormalize before parsing. Unlike all the other nsv/tsv loops, it preserves outer braces in the - arguments. Hence, it is costlier. You can insert \listbreaker + arguments. Hence, it is costlier. You can insert \foreachlistbreaker as a token in or to terminate the list prematurely. @@ -237,9 +244,9 @@ The looping macros include: \skvparselist*{}{}{} These can process lists with arbitrary parsers/list - separators.The only difference between \skvdolist and - \skvparselist is that \skvparselist will first normalize - the list before parsing. + separators, including non-separated lists. The only difference + between \skvdolist and \skvparselist is that \skvparselist will + first normalize the list before parsing. \cicadaloop: @@ -256,9 +263,9 @@ The looping macros include: \currentcicada, \nextcicada, \lastcicada, \cicadacount. \cicadacount is depth-dependent. - You can insert \listbreaker as an item in or - to terminate the list prematurely. \listpauser isn't recognized by - \cicadaloop. + You can insert \foreachlistbreaker as an item in or + to terminate the list prematurely. Note: Unlike \newforeach and \foreachfox, + \foreachlistpauser isn't recognized by \cicadaloop. \let\romn\romannumeral \@tempcnta\z@ @@ -278,7 +285,7 @@ The looping macros include: }% \ifnum\@tempcntb>\@ne \@tempswatrue - \skvcsedef{cmd@\romn\cicadaloopdepth}{\lastcicada,\cicadacount}% + \skvcsedef{cmd@\romn\cicadanestdepth}{\lastcicada,\cicadacount}% \fi }% } @@ -333,8 +340,8 @@ The looping macros include: \ifnum\foreachitemcount>10\relax\breaknewforeach\fi - You can insert \listbreaker as an item in or - to terminate the list prematurely. \listpauser will pause + You can insert \foreachlistbreaker as an item in or + to terminate the list prematurely. \foreachlistpauser will pause the processing for user action. \newforeach found a bug in PGF's \foreach, as reported at @@ -653,4 +660,4 @@ The looping macros include: -% End of readme file of loops package +% End of readme file of loops.sty diff --git a/Master/texmf-dist/doc/latex/loops/loops-pokayoke1.tex b/Master/texmf-dist/doc/latex/loops/loops-pokayoke1.tex new file mode 100644 index 00000000000..26f9145ee62 --- /dev/null +++ b/Master/texmf-dist/doc/latex/loops/loops-pokayoke1.tex @@ -0,0 +1,133 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% This is file 'loops-pokayoke1.tex', version 1.3, 2013/05/15. % +% % +% This package and accompanying files may be distributed and/or % +% modified under the conditions of the LaTeX Project Public License, % +% either version 1.3 of this license or any later version. The latest % +% version of this license is in http://www.latex-project.org/lppl.txt % +% and version 1.3 or later is part of all distributions of LaTeX % +% version 2005/12/01 or later. % +% % +% The LPPL maintenance status of this software is 'author-maintained'. % +% % +% This software is provided 'as it is', without warranty of any kind, % +% either expressed or implied, including, but not limited to, the % +% implied warranties of merchantability and fitness for a particular % +% purpose. % +% % +% The following files constitute the loops bundle and must be % +% distributed as a whole: % +% % +% README, loops.sty, loops-pokayoke1. % +% % +% Copyright (c) 2010-2013 Ahmed Musa (amusa22@gmail.com). % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\documentclass{article} +\usepackage{tikz} +\usepackage{loops} + +% See the README file for more examples. + +%++++++++++++++++++++++++++ Examples +++++++++++++++++++++++++% + +% There are two types of sequences in the following list, i.e., +% {\pi0,\pi0.5,\pi...,\pi3} and {0\pi,0.5\pi,...\pi,3\pi} +% +\newforeach\x in {\pi0,\pi0.5,\pi...,\pi3,0\pi,0.5\pi,...\pi,3\pi}{% + \edef\y{\skvexpandonce\x}% +} + + +\begin{document} +\begin{tikzpicture}[every node/.style=draw] +\node (A) at (0,0) {A}; +\node (B) at (2,0) {B}; +\node (C) at (4,0) {C}; +\node (D) at (6,0) {D}; +\newforeach \n [remember=\n as \lastn initially A] in {B,C,D} + \draw [->] (\lastn) -- (\n); +\end{tikzpicture} + +\par\bigskip + +\foreachfox [remember=#1 as \x initially A] {B,C,D,E,F,G,H} {% + $\overrightarrow{\x#1}$\iflastfox.\else,\space\fi +} + +\foreachfox [remember=#1 as \x initially A] {B,...,H} {% + $\overrightarrow{\x#1}$\iflastfox.\else,\space\fi +} + +% (C1) and [F1] will be picked as single elements: +\foreachfox [list type=tsv,remember=#1 as \x initially A] {B(C1)DE[F1]GH} {% + $\overrightarrow{\x#1}$\iflastfox.\else,\space\fi +} + +\end{document} + + +%++++++++++++++++++++++++++ Examples +++++++++++++++++++++++++% + +\documentclass{article} +\usepackage{tikz,loops} +\usetikzlibrary{arrows,shapes,backgrounds,fit} +\usepackage{tkz-graph} + +\begin{document} +\begin{tikzpicture} +\SetVertexNormal[Shape=rectangle,FillColor=lightgray,LineWidth=2pt] +\SetUpEdge[lw=1.5pt,color=black] +\foreach \y in {1,2,3,4} { + \foreach \x / \a in {1/a,2/b,3/c,4/d} { + \Vertex[L=\y \a,x=2*\x,y=2*\y]{\x\y} + } +} +\newforeach \x/\y/\z/\s in { + 11/23/32/,14/33/22/,41/33/22/,44/44/23/,21/33/42/13, + 24/12/32/43,31/12/23/43,34/13/22/42,12/33//,22/43//, + 32/13//,42/23// +}{ + \Edge(\x)(\y) + \ifx\z\empty\else\Edge(\x)(\z)\fi + \ifx\s\empty\else\Edge(\x)(\s)\fi +} +\end{tikzpicture} +\end{document} + +\def\alist{} +\newforeach\x in {% + 2pt_A,4pt_A,...pt_A,10pt_A +}{% + \xdef\alist{\alist\ifx\alist\@empty\else,\fi\x}% +} +\show\alist + +\let\alist\@gobble +\newforeach\x in {% + A_2pt,A_4pt,A_...pt,A_10pt, A_20pt,A_24pt,A_...pt,A_40pt +}{% + \xdef\alist{\alist,\x}% +} +\show\alist + +\let\alist\@gobble +\foreachfox {% + A_2pt,A_4pt,A_...pt,A_10pt, A_20pt,A_24pt,A_...pt,A_40pt% +}{% + \xdef\alist{\alist,#1}% +} +\show\alist + +\let\alist\@gobble +% The key 'hide parameters' makes it possible to use parameter +% characters in the callback without doubling them. +\newforeach[hide parameters] \x in {1,...,10} do {% + \edef\cmda#1{\x*#1}% + \newforeach[hide parameters] \y in {A,...,M} do {% + \xdef\alist{\alist,\x(\y)}% + \edef\cmdb#1{\x*\y*#1}% + }% +} +\show\alist + -- cgit v1.2.3