diff options
author | Norbert Preining <preining@logic.at> | 2013-05-27 01:42:10 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2013-05-27 01:42:10 +0000 |
commit | b2941aa318c54c9d2acb00a560f456d35d90f888 (patch) | |
tree | 15c80400114565771ffedec91c5709bf8798e81d /Master | |
parent | eadd78d6ef924f2410ccc83392717f1d87ee9d67 (diff) |
loops update 5/27
git-svn-id: svn://tug.org/texlive/trunk@30704 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/loops/README | 31 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/loops/loops-pokayoke1.tex | 133 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/loops/loops.sty | 71 |
3 files changed, 196 insertions, 39 deletions
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 <list> or <listcmd> to terminate the list prematurely. @@ -237,9 +244,9 @@ The looping macros include: \skvparselist*{<parser>}{<listcmd>}<holdercmd>{<callback>} 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 <list> or <listcmd> - to terminate the list prematurely. \listpauser isn't recognized by - \cicadaloop. + You can insert \foreachlistbreaker as an item in <list> or <listcmd> + 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 <list> or <listcmd> - to terminate the list prematurely. \listpauser will pause + You can insert \foreachlistbreaker as an item in <list> or <listcmd> + 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: <http://tex.stackexchange.com/questions/79586/foreach-has-a-% problem-with-initially-argument-in-remember-part/79644#79644> -% 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
+
diff --git a/Master/texmf-dist/tex/latex/loops/loops.sty b/Master/texmf-dist/tex/latex/loops/loops.sty index bd11a44a18f..3a356feb0bb 100644 --- a/Master/texmf-dist/tex/latex/loops/loops.sty +++ b/Master/texmf-dist/tex/latex/loops/loops.sty @@ -1,5 +1,5 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -% This is file 'loops.sty', version 1.2, 2013/02/10. % +% This is file 'loops.sty', 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, % @@ -15,6 +15,11 @@ % 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) 2012-2013 Ahmed Musa (amusa22@gmail.com). % %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% @@ -53,7 +58,7 @@ \do 032=10,033=12,036=03,038=04,040=12,041=12,042=12,043=12,% 059=12,045=12,047=12,058=12,063=12,091=12,093=12,126=13,\do=,% -\ProvidesPackage{loops}[2013/02/10 v1.2 Loops and list processors (AM)] +\ProvidesPackage{loops}[2013/05/15 v1.3 Loops and list processors (AM)] \NeedsTeXFormat{LaTeX2e}[2011/06/27] % This is the way to load 'skeyval-for-core' here, otherwise we @@ -446,7 +451,6 @@ % 7. The following are available here, as in \newforeach: % % \foreachcurrentitem, \foreachnextitem, \foreachitemcount, -% \foreachcurrentitem, \foreachnextitem, \foreachitemcount, % \foreachprevitem, \prependtobeginforeach, \appendtobeginforeach % (=\atbeginforeach), \prependtoendforeach, \appendtoendforeach % (=\atendforeach), \ifforeachlastitem, \foreachnestdepth, @@ -462,7 +466,7 @@ % Define \foreachfox keys. Name all the macros with 'foreach' prefix so % that we can avoid new command names and use the list auto-completion % scheme of \newforeach. -\quickkeys.define{loops/foreachfox}{% +\skvquickkeys.define{loops/foreachfox}{% parser/{,}/ \def\skv@foreach@parser{#1} \skvstripouterbraces{2}\skv@foreach@parser @@ -472,8 +476,8 @@ \edef\skv@foreach@paramlist{\unexpanded{#1}} \skvstripouterbraces{1}\skv@foreach@paramlist ; - list breaker/\skvlistbreaker/\def\skv@listbreakertoks{#1}; - list pauser/\skvlistpauser/\def\skv@listpausertoks{#1}; + list breaker/\foreachlistbreaker/\def\skv@listbreakertoks{#1}; + list pauser/\foreachlistpauser/\def\skv@listpausertoks{#1}; normalize list/true/ \edef\skv@foreach@normalizelist{0\skvifstrcmpTF{#1}{true}01} /true,false @@ -511,7 +515,7 @@ \skvstripouterbraces{2}\skv@foreach@processupto \fi ; - % This default value of 'link' is required by \skv@foreach@filllist: + % This default value of 'link' is required by \skvautocompletelist: .exec/\def\skv@foreach@link{\@nil}; link/\@nil/ \edef\skv@prova{\unexpanded{#1}} @@ -554,7 +558,7 @@ /true,false ; expand before fill,expand list before fill/true/ - \edef\skv@foreach@expandlistbeforefill{0\skvifstrcmpTF{true}{#1}01}% + \edef\skv@foreach@expandbeforefill{0\skvifstrcmpTF{true}{#1}01}% /true,false ; expand list once,*,list is a macro,macro list/true/ @@ -597,9 +601,9 @@ /true,false ; } -\quickkeys.preset{loops/foreachfox}{% +\skvquickkeys.preset{loops/foreachfox}{% parser={,},list type=csv,arg=#1,loop stopper, - list breaker=\skvlistbreaker,list pauser=\skvlistpauser, + list breaker=\foreachlistbreaker,list pauser=\foreachlistpauser, normalize list=true,use empty=false,keep decimals=true, keep high decimals=false,expand before fill=false, reverse list=false,expand list once=false,expand list twice=false, @@ -919,10 +923,11 @@ }% } \skvrobustdef*\skv@foreachfox@setkeys#1{% - \def\reserved@a{\quickkeys.set{loops/foreachfox}}% + \def\reserved@a{\skvquickkeys.set{loops/foreachfox}}% \expandafter\reserved@a\expandafter{\skv@foreachfox@kvlist,#1}% } \skvrobustdef*\foreachfox{% + \skv@inforeachtrue \skvifnextchar i{% \skv@foreachfox@prescan@a }{% @@ -952,7 +957,7 @@ }% } \skvrobustdef*\skv@foreachfox@a[#1]#2#3{% - \edef\skv@foreach@seenstar{0\ifskv@tempst0\else1\fi}% + \edef\skv@foreach@starform{0\ifskv@tempst0\else1\fi}% \skv@foreach@pushstate \skv@foreach@latehookerr \def\foreachitemcount{0}% @@ -962,7 +967,7 @@ \do\skv@foreach@precallback\do\skv@foreach@afterprecallback \do\skv@foreach@postcallback\do\skv@foreach@onlyinitially \skv@foreachfox@setkeys{#1}% - \if\skv@foreach@seenstar + \if\skv@foreach@starform \def\skv@foreach@expandlistonce{00}% \fi \ifcase0% @@ -1048,12 +1053,12 @@ }% \def\skv@foreach@lookahead@b{% \skvifxTF\skv@foreach@next[{% - \skv@foreach@parenthtrue\skv@foreach@lookahead@c + \skv@foreach@parenthesistrue\skv@foreach@lookahead@c }{% \skvifxTF\skv@foreach@next({% - \skv@foreach@parenthtrue\skv@foreach@lookahead@d + \skv@foreach@parenthesistrue\skv@foreach@lookahead@d }{% - \skv@foreach@parenthfalse\skv@foreach@picknext + \skv@foreach@parenthesisfalse\skv@foreach@picknext }% }% }% @@ -1072,9 +1077,20 @@ \skv@foreachfox@b{##1}{####2}{csv}% }% \skvifemptyTF\skv@foreach@userlist{}{% - \expandafter\skv@foreach@filllist\expandafter - {\skv@foreach@parser}\skv@foreach@userlist - \if\skv@foreach@reverselist\skvafterfi + \def\do####1{\if####1true\else false\fi}% + \skvexpandsecond{\skvautocompletelist*}{[% + % Note: the value of 'expand list once', etc., can't be + % transferred automatically to \skvautocompletelist since they + % have been used above. + parser={\skv@foreach@parser}, + link={\skvexpandonce\skv@foreach@link}, + grow left=\do\skv@foreach@growleft, + grow right=\do\skv@foreach@growright, + keep decimals=\do\skv@foreach@keepdecimals, + keep high decimals=\do\skv@foreach@keephighdecimals, + expand before fill=\do\skv@foreach@expandbeforefill + ]}\skv@foreach@userlist\skv@foreach@userlist + \if\skv@foreach@reverselist \expandafter\skv@foreach@doreverselist\expandafter {\skv@foreach@parser}\skv@foreach@userlist \fi @@ -1095,7 +1111,7 @@ }% \def\skv@foreach@do@b####1####2\skv@foreach@stop{% \let\bgroup\skv@orig@bgroup - \ifskv@foreach@parenth + \ifskv@foreach@parenthesis \edef\foreachcurrentitem{\unexpanded{####1}}% \else \skvifxTF\skv@foreach@next\bgroup{% @@ -1113,6 +1129,7 @@ \expandafter\reserved@a\expandafter{\skv@foreach@parser}% \skvcsuse{skv@foreach@atendhook@\romannumeral\foreachnestdepth}% \skv@foreach@popstate + \skv@inforeachfalse } % \skv@setupgetnextfox<parser> \skvrobustdef*\skv@setupgetnextfox#1{% @@ -1128,7 +1145,7 @@ }% \def\skv@foreach@g@tnext##1##2\skv@foreach@stop{% \let\bgroup\skv@orig@bgroup - \ifskv@foreach@parenth + \ifskv@foreach@parenthesis \edef\foreachnextitem{\unexpanded{##1}}% \else \skvifxTF\skv@foreach@next\bgroup{% @@ -1180,8 +1197,8 @@ \skv@foreach@callback\foreacheov \fi }{% - % Test for \skvlistpauser, in case the user decides to continue - % after \skvlistpauser has been picked: + % Test for \foreachlistpauser, in case the user decides to continue + % after \foreachlistpauser has been picked: \skvifxTF\foreachcurrentitem\skv@listpausertoks{}{% \skvifxTF\skv@foreach@paramlist\skv@simplearg{% \skvexpbracenext\skv@foreach@callback\foreachcurrentitem\foreacheov @@ -1226,7 +1243,7 @@ % 3. \ifskvbreakloop may be used as the conditional in <\if...>. % 5. The boolean \iflastcicada is available for accessing the last item % of the list. There are also the macros \currentcicada, \lastcicada, -% \cicadacount, and the counter \cicadaloopdepth. +% \cicadacount, and the counter \cicadanestdepth. % 6. \cicadaloop can be nested. % % Example: @@ -1248,7 +1265,7 @@ % }% % \ifnum\@tempcntb>\@ne % \@tempswatrue -% \skvcsedef{cmd@\romn\cicadaloopdepth}{\lastcicada,\cicadacount}% +% \skvcsedef{cmd@\romn\cicadanestdepth}{\lastcicada,\cicadacount}% % \fi % }% % } @@ -1269,7 +1286,7 @@ \skvrobustdef*\cicadaloop{\skv@teststopt\skv@cicadaloop,} \skvrobustdef*\skv@cicadaloop[#1]#2#3\fi#4{% \let\if@cicada@st\ifskv@tempst - \skvpushstate\skv@cicada@state\cicadaloopdepth + \skvpushstate\skv@cicada@state\cicadanestdepth \let\ifskv@tempst\if@cicada@st \skv@usetempst{#2}\skv@cicada@userlist \skv@foreach@normalize[#1]\skv@cicada@userlist @@ -1334,7 +1351,7 @@ \skvexpandnext{\skv@cicada@lookahead@a\skv@cicada@do}% \skv@cicada@userlist#1\skv@cicada@nil#1\skv@cicada@stop }% - \skvpopstate\skv@cicada@state\cicadaloopdepth + \skvpopstate\skv@cicada@state\cicadanestdepth } % \cicadiloop[<parser>]{<list>}<\if...>\fi{<ini-code>}{<1.parameter.code>} |