1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
|