Debian Codegraph @

texmf-dist/source/latex/forloop/forloop.dtx

raw
1 % \iffalse
2 %
3 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
4 %<package>\ProvidesPackage{forloop}
5 %<package> [2023/05/03 v3.0 For Loops for LaTeX]
6 %<package>\RequirePackage{ifthen}
7 %
8 % Update on 2023/05/03 purely to clarify the license; no code changes.
9 % This package is released under the GNU LGPL.
10 %
11 %<*driver>
12 \documentclass{ltxdoc}
13 \usepackage{forloop}
14 \EnableCrossrefs
15 \CodelineIndex
16 \RecordChanges
17 \begin{document}
18 \DocInput{forloop.dtx}
19 \end{document}
20 %</driver>
21 % \fi
22 %
23 % \iffalse meta-comment
24 % remove this comment to get a checksum
25 % \CheckSum{0}
26 % \fi
27 %
28 %% \CharacterTable
29 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
30 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
31 %% Digits \0\1\2\3\4\5\6\7\8\9
32 %% Exclamation \! Double quote \" Hash (number) \#
33 %% Dollar \$ Percent \% Ampersand \&
34 %% Acute accent \' Left paren \( Right paren \)
35 %% Asterisk \* Plus \+ Comma \,
36 %% Minus \- Point \. Solidus \/
37 %% Colon \: Semicolon \; Less than \<
38 %% Equals \= Greater than \> Question mark \?
39 %% Commercial at \@ Left bracket \[ Backslash \\
40 %% Right bracket \] Circumflex \^ Underscore \_
41 %% Grave accent \` Left brace \{ Vertical bar \|
42 %% Right brace \} Tilde \~}
43 %
44 % \changes{v1.0}{2006/09/17}{Initial Release}
45 % \changes{v2.0}{2006/09/18}{Re-wrote forloop command after discovering that whiledo took too many resources}
46 % \changes{v3.0}{2006/09/18}{total restructure of forloop command to make nested loops work}
47 %
48 % \GetFileInfo{forloop.sty}
49 %
50 % \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\!,\(,\),\,}
51 % \DoNotIndex{\@ne,\expandafter}
52 % \DoNotIndex{\advance,\begingroup,\catcode,\closein}
53 % \DoNotIndex{\newcommand,\renewcommand,\providecommand}
54 % \DoNotIndex{\closeout,\day,\def,\edef,\gdef,\let,\empty,\endgroup}
55 % \DoNotIndex{\newcounter,\providecounter,\addtocounter,\setcounter,\stepcounter,\value,\arabic}
56 % \DoNotIndex{\if,\fi,\ifthenelse,\else,\setboolean,\boolean,\newboolean,\provideboolean,\equal,\AND,\OR,\NOT,\whiledo}
57 % \DoNotIndex{\ifcase,\ifcat,\or,\else}
58 % \DoNotIndex{\par,\parbox,\mbox,\hbox,\begin,\end,\nabla,\partial}
59 % \DoNotIndex{\overline,\bar,\small,\tiny,\mathchoice,\scriptsize,\textrm,\texttt}
60 % \DoNotIndex{\alpha,\beta,\gamma,\epsilon,\varepsilon,\delta,\zeta,\eta,\theta,\vartheta,\iota,\kappa,\lambda,\mu,\nu}
61 % \DoNotIndex{\xi,\omicron,\pi,\varpi,\rho,\varrho,\sigma,\tau,\upsilon,\phi,\varphi,\chi,\psi,\omega}
62 % \DoNotIndex{\Delta,\Gamma,\Theta,\Lambda,\Xi,\Pi,\Sigma,\Phi,\Psi,\Omega}
63 % \DoNotIndex{\digamma,\lceil,\rceil,\lfloor,\rfloor,\left,\right,\inp,\inb,\inbr,\inap,\nop}
64 % \DoNotIndex{\sum,\prod,\int,\log,\ln,\exp,\sin,\cos,\tan,\csc,\sec,\cot,\arcsin,\arccos,\arctan,\det}
65 % \DoNotIndex{\sinh,\cosh,\tanh,\csch,\sech,\coth,\arcsinh,\arccosh,\arctanh}
66 % \DoNotIndex{\mod,\max,\min,\gcd,\lcm,\wp,\arg,\dots,\infty,}
67 % \DoNotIndex{\frac,\binom,\braket,\@@atop}
68 % \DoNotIndex{\cdot,\ldots,\tilde,\times,\dagger,\relax}
69 % \DoNotIndex{\mathbb,\roman,\bf,\mathord,\cal,\DeclareMathOperator,\PackageError,\PackageWarning}
70 % \DoNotIndex{\csname,\endcsname,\ifx,\ifnum}
71 % \DoNotIndex{\mod,\bmod,\pmod,\pod,\operatorname}
72 %
73 % \title{The \textsf{forloop} package\thanks{This document
74 % corresponds to \textsf{forloop}~\fileversion,
75 % dated~\filedate.}}
76 % \author{nsetzer}
77 %
78 % \maketitle
79 %
80 % \setcounter{IndexColumns}{2}
81 % \StopEventually{\PrintChanges\PrintIndex}
82 %
83 % The \textsf{forloop} package defines two commands |\forloop| (preferred usage) and |\forLoop| (deprecated).
84 %
85 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87 %\section{Implementation}
88 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 %
91 % \begin{macro}{\forloop}
92 % |\forloop|\oarg{step}\marg{counter}\marg{initial value}\marg{condition}\marg{code}
93 %
94 % |\newcounter{ct} \forloop{ct}{1}{\value{ct} < 10}{\arabic{ct} }|
95 %
96 % \newcounter{ct} \forloop{ct}{1}{\value{ct} < 10}{\arabic{ct} }
97 % \begin{macrocode}
98 \newcommand{\forloop}[5][1]%
99 {%
100 \setcounter{#2}{#3}%
101 \ifthenelse{#4}%
102 {%
103 #5%
104 \addtocounter{#2}{#1}%
105 \forloop[#1]{#2}{\value{#2}}{#4}{#5}%
106 }%
107 % \end{macrocode}
108 % Else
109 % \begin{macrocode}
110 {%
111 }%
112 }%
113 % \end{macrocode}
114 % \end{macro}
115 %
116 %
117 % \begin{macro}{\forLoop}
118 % |\forLoop|\oarg{step}\marg{start}\marg{stop}\marg{counter name}\marg{code}
119 % \begin{macrocode}
120 \newcommand{\forLoop}[5][1]
121 {%
122 \setcounter{#4}{#2}%
123 \ifthenelse{ \value{#4}<#3 }%
124 {%
125 #5%
126 \addtocounter{#4}{#1}%
127 \forLoop[#1]{\value{#4}}{#3}{#4}{#5}%
128 }%
129 % Else
130 {%
131 \ifthenelse{\value{#4}=#3}%
132 {%
133 #5%
134 }%
135 % Else
136 {}%
137 }%
138 }
139 % \end{macrocode}
140 % \end{macro}
141 %
142 %
143 %
144 %
145 % \Finale
146 \endinput