LATEX Forloop PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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