summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/alg/alg.sty
blob: 929b0beaf1d7050ed2b0b2dd39e3ea4dad833a2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
%%
%% This is file `alg.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% alg.dtx  (with options: `package')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from alg.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file alg.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
\def\filedate{13 March 2001}
%% alg.dtx
%% Copyright (c) 1995, 1999, 2001 Staffan Ulfberg
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesPackage{alg}
         [2001/02/12]
\RequirePackage{float, ifthen}
\newlength{\algleftmarginwidth}\setlength{\algleftmarginwidth}{.5in}
\newlength{\algrightmarginwidth}\setlength{\algrightmarginwidth}{.5in}
\newlength{\alglinenowidth}\setlength{\alglinenowidth}{1.2cm}
\newlength{\algtabwidth}\setlength{\algtabwidth}{.5cm}
\newlength{\alg@fromleft}
\newlength{\alg@tmplen}
\newsavebox{\alg@tmpbox}
\newcounter{alg@inmargin}\setcounter{alg@inmargin}{0}
\newcounter{algline}
\newboolean{alg@linenums}
\newboolean{alg@nonumber}
\def\alg@language{english}
\@ifpackageloaded{babel}{
\iflanguage{english}{\def\alg@language{english}}{}
\iflanguage{american}{\def\alg@language{american}}{}
\iflanguage{swedish}{\def\alg@language{swedish}}{}
\iflanguage{french}{\def\alg@language{french}}{}
\iflanguage{german}{\def\alg@language{german}}{}}{}
\DeclareOption{english}{\def\alg@language{english}}
\DeclareOption{american}{\def\alg@language{american}}
\DeclareOption{swedish}{\def\alg@language{swedish}}
\DeclareOption{french}{\def\alg@language{french}}
\DeclareOption{german}{\def\alg@language{german}}
\ProcessOptions
\ifthenelse{\equal{\alg@language}{english}}{
\def\alg@floatname{Algorithm}
\def\alg@listname{List of Algorithms}
\def\alg@descname{Description}
\def\alg@inputname{Input}
\def\alg@outputname{Output}}{}
\ifthenelse{\equal{\alg@language}{american}}{
\def\alg@floatname{Algorithm}
\def\alg@listname{List of Algorithms}
\def\alg@descname{Description}
\def\alg@inputname{Input}
\def\alg@outputname{Output}}{}
\ifthenelse{\equal{\alg@language}{swedish}}{
\def\alg@floatname{Algoritm}
\def\alg@listname{Algoritmer}
\def\alg@descname{Beskrivning}
\def\alg@inputname{Input}
\def\alg@outputname{Output}}{}
\ifthenelse{\equal{\alg@language}{french}}{
\def\alg@floatname{Algorithme}
\def\alg@listname{Liste des algorithmes}
\def\alg@descname{Description}
\def\alg@inputname{Entr\'{e}e}
\def\alg@outputname{Sortie}}{}
\ifthenelse{\equal{\alg@language}{german}}{
\def\alg@floatname{Algorithmus}
\def\alg@listname{Algorithmenverzeichnis}
\def\alg@descname{Beschreibung}
\def\alg@inputname{Eingabe}
\def\alg@outputname{Ausgabe}}{}
\newcommand\floatc@alg[2]{{\bfseries\rmfamily
   \hspace{\algleftmarginwidth}#1:} #2\par}
\newcommand\fs@alg{
   \let\@fs@capt\floatc@alg
   \def\@fs@pre{}\def\@fs@post{}\def\@fs@mid{\vspace{3pt}}
   \let\@fs@iftopcapt\iftrue}
\floatstyle{alg}
\newfloat{algorithmfloat}{h}{loa}
\floatname{algorithmfloat}{\alg@floatname}
\newcommand{\listofalgorithms}{\listof{algorithmfloat}{\alg@listname}}
\newcommand{\alg@margin} {
   \ifthenelse{\value{alg@inmargin}=0} {
       \advance\leftskip\algleftmarginwidth
       \advance\rightskip\algrightmarginwidth
       \alg@fromleft=\leftskip
   } {}
   \stepcounter{alg@inmargin}
   \parskip=0cm\parindent=0cm
}
\newcommand{\alg@unmargin} {
   \addtocounter{alg@inmargin}{-1}%
   \advance\leftskip-\algleftmarginwidth%
   \advance\rightskip-\algrightmarginwidth%
}
\newenvironment{algorithm}[1][H] {
   \begin{algorithmfloat}[#1]\alg@margin
} {
   \alg@unmargin\end{algorithmfloat}
}
\newenvironment{alg@tab}[1] {
   \setboolean{alg@nonumber}{false}%
   \ifthenelse{\value{alg@inmargin}=0} {\vskip\baselineskip}{}
   \alg@margin
   \let\\=\alg@cr
   \catcode`\^^M=10
   \setcounter{algline}{0}\refstepcounter{algline}
   \advance\leftskip#1
   \alg@putlineno\ignorespaces
} {
   \setbox\alg@tmpbox=\lastbox
   \ifhbox\alg@tmpbox{\vskip-\baselineskip}\else\par\fi
   \alg@unmargin
   \ifthenelse{\value{alg@inmargin}=0}{\vskip\baselineskip}{}
}
\newenvironment{algtab}[1][\alglinenowidth] {
   \setboolean{alg@linenums}{true}\begin{alg@tab}{#1}
} {\end{alg@tab}}
\newenvironment{algtab*}[1][0cm] {
   \setboolean{alg@linenums}{false}\begin{alg@tab}{#1}
} {\end{alg@tab}}
\newcommand{\alg@kill}{\setbox\alg@tmpbox=\lastbox%
   \ifvoid\alg@tmpbox\PackageError{alg}{Attempt to remove label
      in middle of line}\fi}
\newcommand{\algbegin}[1][\algtabwidth]{\advance\leftskip#1%
   \alg@kill\alg@putlineno\ignorespaces}
\newcommand{\algend}[1][\algtabwidth]{\advance\leftskip-1#1%
   \alg@kill\alg@putlineno\ignorespaces}
\newcommand{\algnonumber}{\alg@kill\alg@putlabel{}%
   \setboolean{alg@nonumber}{true}\ignorespaces}
\newcommand{\alg@cr}{\par\refstepcounter{algline}%
   \setboolean{alg@nonumber}{false}\alg@putlineno\ignorespaces}
\newcommand{\alg@putlineno} {%
   \ifthenelse{\boolean{alg@linenums}} {%
      \ifthenelse{\boolean{alg@nonumber}}{\alg@putlabel{}} {%
         \alg@putlabel{(\arabic{algline})}}}%
      {\alg@putlabel{}}}
\newcommand{\alg@putlabel}[1]{{%
      \alg@tmplen=\leftskip \advance\alg@tmplen-\alg@fromleft%
      \makebox[0cm][r]{\makebox[\alg@tmplen][l]{#1}}}}
\newcommand{\algdescript}[1]{\alg@margin\textbf{\alg@descname: }#1\par}
\newcommand{\alginout}[2]{\alg@margin\textbf{\alg@inputname: }#1\par
   \textbf{\alg@outputname: }#2\par}
\newcommand{\algname}[2]{\alg@margin\textsc{#1}(#2)\par}
\newcommand{\alglabel}[1]{%
   \ifthenelse{\boolean{alg@linenums}}{%
      \label{#1}}{\alg@kill\alg@putlabel{#1}}\ignorespaces}
\newcommand{\algref}[1]{\ifthenelse{\boolean{alg@linenums}}%
   {\ref{#1}}{#1}}
\newcommand{\algand}{\mbox{\textbf{and }}}
\newcommand{\algbreak}{\textbf{break}}
\newcommand{\algcall}[2]{\textsc{#1}(#2)}
\newcommand{\algcase}[1]{\algend\textbf{case} #1\\\algbegin}
\newcommand{\algcontinue}{\textbf{continue}}
\newcommand{\algdefault}{\algend\textbf{default}\\\algbegin}
\newcommand{\algelse}{\algend\textbf{else}\\\algbegin}
\newcommand{\algelseif}[1]{\algelsif{#1}}
\newcommand{\algelsif}[1]{\algend\textbf{else if} #1\\\algbegin}
\newcommand{\algerror}{\textbf{error }}
\newcommand{\algfalse}{\mbox{\textbf{false }}}
\newcommand{\algforto}[2]{\textbf{for} #1 \textbf{to} #2\\\algbegin}
\newcommand{\algforeach}[1]{\textbf{foreach} #1\\\algbegin}
\newcommand{\alggoto}{\textbf{goto~}}
\newcommand{\algif}[1]{\textbf{if} #1\\\algbegin}
\newcommand{\algifthen}[2]{\textbf{if} #1 \textbf{then} #2\\}
\newcommand{\algifthenelse}[3]{\setbox\alg@tmpbox=
   \hbox{\textbf{if} #1 }\copy\alg@tmpbox\textbf{then} #2\\
   \settowidth{\alg@tmplen}{\box\alg@tmpbox}%
   \algbegin[\alg@tmplen]\textbf{else} #3\\ \algend[\alg@tmplen]}
\newcommand{\algnot}{\mbox{\textbf{not }}}
\newcommand{\algor}{\mbox{\textbf{or }}}
\newcommand{\algpardo}{\mbox{\textbf{pardo}}}
\newcommand{\algprint}{\textbf{print }}
\newcommand{\algrepeat}{\textbf{repeat}\\\algbegin}
\newcommand{\algreturn}{\textbf{return~}}
\newcommand{\algswitch}[1]{\textbf{switch} #1\\\algbegin}
\newcommand{\algtrue}{\mbox{\textbf{true }}}
\newcommand{\alguntil}[1]{\algend\textbf{until} #1\ \\}
\newcommand{\algwhile}[1]{\textbf{while} #1\\\algbegin}
\endinput
%%
%% End of file `alg.sty'.