0% found this document useful (0 votes)
38 views

For Loop

The document describes the \forloop and \forLoop commands. \forloop is the preferred command and defines a for loop that iterates through a range of numbers, performing code on each iteration. It takes 5 arguments - the step, counter name, initial value, condition, and code. \forLoop is deprecated and defines a similar for loop but takes the start, stop, counter name, and code as arguments.

Uploaded by

DrAndrei
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

For Loop

The document describes the \forloop and \forLoop commands. \forloop is the preferred command and defines a for loop that iterates through a range of numbers, performing code on each iteration. It takes 5 arguments - the step, counter name, initial value, condition, and code. \forLoop is deprecated and defines a similar for loop but takes the start, stop, counter name, and code as arguments.

Uploaded by

DrAndrei
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

The forloop package

nsetzer September 19, 2006


The forloop package denes two commands \forloop (preferred usage) and \forLoop (deprecated).

1
\forloop

Implementation

\forloop[ step ]{ counter }{ initial value }{ condition }{ code } \newcounter{ct} \forloop{ct}{1}{\value{ct} < 10}{\arabic{ct} } 123456789
\newcommand{\forloop}[5][1]% {% 3 \setcounter{#2}{#3}% 4 \ifthenelse{#4}% 5 {% 6 #5% 7 \addtocounter{#2}{#1}% 8 \forloop[#1]{#2}{\value{#2}}{#4}{#5}% 9 }%
1 2

Else
10 11 12

{% }% }%

\forLoop

\forLoop[ step ]{ start }{ stop }{ counter name }{ code }


13 14 15 16 17 18 19 20 21 22 23

\newcommand{\forLoop}[5][1] {% \setcounter{#4}{#2}% \ifthenelse{ \value{#4}<#3 }% {% #5% \addtocounter{#4}{#1}% \forLoop[#1]{\value{#4}}{#3}{#4}{#5}% }% % Else {%


This

document corresponds to forloop v3.0, dated 2006/09/18.

24 25 26 27 28 29 30 31

\ifthenelse{\value{#4}=#3}% {% #5% }% % Else {}% }% }

Change History
v1.0 General: Initial Release . . . . . . . . 1 v2.0 General: Re-wrote forloop command after discovering that whiledo took too many resources . . . . . . . . . . . . . . . . . . 1 v3.0 General: total restructure of forloop command to make nested loops work . . . . . . . . . . . . . . . . . . . 1

Index
Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the denition; numbers in roman refer to the code lines where the entry is used.
F \forLoop . . . . . . . . . . . . . . . . . . . . \forloop . . . . . . . . . . . . . . . . . . . . . 1 13

You might also like