0% found this document useful (0 votes)
141 views2 pages

LATEX Forloop PDF

The forloop package defines two commands, \forloop and \forLoop, to execute code in a loop. \forloop is the preferred command and takes four parameters - a counter, initial value, condition, and code. \forLoop is deprecated and takes five parameters - a start value, stop value, counter name, and code. The package was restructured in version 3.0 to allow for nested loops.

Uploaded by

jagadeeswara71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views2 pages

LATEX Forloop PDF

The forloop package defines two commands, \forloop and \forLoop, to execute code in a loop. \forloop is the preferred command and takes four parameters - a counter, initial value, condition, and code. \forLoop is deprecated and takes five parameters - a start value, stop value, counter name, and code. The package was restructured in version 3.0 to allow for nested loops.

Uploaded by

jagadeeswara71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
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 defines two commands \forloop (preferred usage) and
\forLoop (deprecated).

1 Implementation
\forloop \forloop[hstepi]{hcounter i}{hinitial valuei}{hconditioni}{hcodei}
\newcounter{ct} \forloop{ct}{1}{\value{ct} < 10}{\arabic{ct} }
123456789
1 \newcommand{\forloop}[5][1]%
2 {%
3 \setcounter{#2}{#3}%
4 \ifthenelse{#4}%
5 {%
6 #5%
7 \addtocounter{#2}{#1}%
8 \forloop[#1]{#2}{\value{#2}}{#4}{#5}%
9 }%

Else
10 {%
11 }%
12 }%

\forLoop \forLoop[hstepi]{hstarti}{hstopi}{hcounter namei}{hcodei}


13 \newcommand{\forLoop}[5][1]
14 {%
15 \setcounter{#4}{#2}%
16 \ifthenelse{ \value{#4}<#3 }%
17 {%
18 #5%
19 \addtocounter{#4}{#1}%
20 \forLoop[#1]{\value{#4}}{#3}{#4}{#5}%
21 }%
22 % Else
23 {%
This document corresponds to forloop v3.0, dated 2006/09/18.

1
24 \ifthenelse{\value{#4}=#3}%
25 {%
26 #5%
27 }%
28 % Else
29 {}%
30 }%
31 }

Change History

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

Index
Numbers written in italic refer to the page where the corresponding entry is de-
scribed; numbers underlined refer to the code line of the definition; numbers in
roman refer to the code lines where the entry is used.

F \forloop . . . . . . . . . . . . . . . . . . . . . 1
\forLoop . . . . . . . . . . . . . . . . . . . . 13

You might also like