Debian Codegraph @

texmf-dist/doc/latex/loops/loops-pokayoke1.tex

raw
1 %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
2 % This is file 'loops-pokayoke1.tex', version 1.3, 2013/05/15. %
3 % %
4 % This package and accompanying files may be distributed and/or %
5 % modified under the conditions of the LaTeX Project Public License, %
6 % either version 1.3 of this license or any later version. The latest %
7 % version of this license is in http://www.latex-project.org/lppl.txt %
8 % and version 1.3 or later is part of all distributions of LaTeX %
9 % version 2005/12/01 or later. %
10 % %
11 % The LPPL maintenance status of this software is 'author-maintained'. %
12 % %
13 % This software is provided 'as it is', without warranty of any kind, %
14 % either expressed or implied, including, but not limited to, the %
15 % implied warranties of merchantability and fitness for a particular %
16 % purpose. %
17 % %
18 % The following files constitute the loops bundle and must be %
19 % distributed as a whole: %
20 % %
21 % README, loops.sty, loops-pokayoke1. %
22 % %
23 % Copyright (c) 2010-2013 Ahmed Musa ([email protected]). %
24 %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
25
26 \documentclass{article}
27 \usepackage{tikz}
28 \usepackage{loops}
29
30 % See the README file for more examples.
31
32 %++++++++++++++++++++++++++ Examples +++++++++++++++++++++++++%
33
34 % There are two types of sequences in the following list, i.e.,
35 % {\pi0,\pi0.5,\pi...,\pi3} and {0\pi,0.5\pi,...\pi,3\pi}
36 %
37 \newforeach\x in {\pi0,\pi0.5,\pi...,\pi3,0\pi,0.5\pi,...\pi,3\pi}{%
38 \edef\y{\skvexpandonce\x}%
39 }
40
41
42 \begin{document}
43 \begin{tikzpicture}[every node/.style=draw]
44 \node (A) at (0,0) {A};
45 \node (B) at (2,0) {B};
46 \node (C) at (4,0) {C};
47 \node (D) at (6,0) {D};
48 \newforeach \n [remember=\n as \lastn initially A] in {B,C,D}
49 \draw [->] (\lastn) -- (\n);
50 \end{tikzpicture}
51
52 \par\bigskip
53
54 \foreachfox [remember=#1 as \x initially A] {B,C,D,E,F,G,H} {%
55 $\overrightarrow{\x#1}$\iflastfox.\else,\space\fi
56 }
57
58 \foreachfox [remember=#1 as \x initially A] {B,...,H} {%
59 $\overrightarrow{\x#1}$\iflastfox.\else,\space\fi
60 }
61
62 % (C1) and [F1] will be picked as single elements:
63 \foreachfox [list type=tsv,remember=#1 as \x initially A] {B(C1)DE[F1]GH} {%
64 $\overrightarrow{\x#1}$\iflastfox.\else,\space\fi
65 }
66
67 \end{document}
68
69
70 %++++++++++++++++++++++++++ Examples +++++++++++++++++++++++++%
71
72 \documentclass{article}
73 \usepackage{tikz,loops}
74 \usetikzlibrary{arrows,shapes,backgrounds,fit}
75 \usepackage{tkz-graph}
76
77 \begin{document}
78 \begin{tikzpicture}
79 \SetVertexNormal[Shape=rectangle,FillColor=lightgray,LineWidth=2pt]
80 \SetUpEdge[lw=1.5pt,color=black]
81 \foreach \y in {1,2,3,4} {
82 \foreach \x / \a in {1/a,2/b,3/c,4/d} {
83 \Vertex[L=\y \a,x=2*\x,y=2*\y]{\x\y}
84 }
85 }
86 \newforeach \x/\y/\z/\s in {
87 11/23/32/,14/33/22/,41/33/22/,44/44/23/,21/33/42/13,
88 24/12/32/43,31/12/23/43,34/13/22/42,12/33//,22/43//,
89 32/13//,42/23//
90 }{
91 \Edge(\x)(\y)
92 \ifx\z\empty\else\Edge(\x)(\z)\fi
93 \ifx\s\empty\else\Edge(\x)(\s)\fi
94 }
95 \end{tikzpicture}
96 \end{document}
97
98 \def\alist{}
99 \newforeach\x in {%
100 2pt_A,4pt_A,...pt_A,10pt_A
101 }{%
102 \xdef\alist{\alist\ifx\alist\@empty\else,\fi\x}%
103 }
104 \show\alist
105
106 \let\alist\@gobble
107 \newforeach\x in {%
108 A_2pt,A_4pt,A_...pt,A_10pt, A_20pt,A_24pt,A_...pt,A_40pt
109 }{%
110 \xdef\alist{\alist,\x}%
111 }
112 \show\alist
113
114 \let\alist\@gobble
115 \foreachfox {%
116 A_2pt,A_4pt,A_...pt,A_10pt, A_20pt,A_24pt,A_...pt,A_40pt%
117 }{%
118 \xdef\alist{\alist,#1}%
119 }
120 \show\alist
121
122 \let\alist\@gobble
123 % The key 'hide parameters' makes it possible to use parameter
124 % characters in the callback without doubling them.
125 \newforeach[hide parameters] \x in {1,...,10} do {%
126 \edef\cmda#1{\x*#1}%
127 \newforeach[hide parameters] \y in {A,...,M} do {%
128 \xdef\alist{\alist,\x(\y)}%
129 \edef\cmdb#1{\x*\y*#1}%
130 }%
131 }
132 \show\alist
133