PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/pkg/vignettes/algpseudocode.sty

https://code.google.com/
TeX | 92 lines | 66 code | 0 blank | 26 comment | 1 complexity | 8dfffa296b2349618eda3a914290b6aa MD5 | raw file
 1% PSEUDOCODE ALGORITHMIC STYLE -- Released 27 APR 2005
 2%    for LaTeX version 2e
 3%
 4% Copyright Szasz Janos
 5% E-mail szaszjanos@users.sourceforge.net
 6% Based on Peter Williams's algorithmic.sty
 7%
 8\NeedsTeXFormat{LaTeX2e}%
 9\ProvidesPackage{algpseudocode}%
10\RequirePackage{ifthen}%
11\RequirePackage{algorithmicx}%
12\typeout{Document Style - pseudocode environments for use with the `algorithmicx' style}%
13%
14\def\ALG@noend{f}%
15\newboolean{ALG@compatible}%
16\setboolean{ALG@compatible}{false}%
17%
18\DeclareOption{noend}{\def\ALG@noend{t}}%
19\DeclareOption{end}{\def\ALG@noend{f}}%
20\DeclareOption{compatible}{\typeout{For compatibility mode use algcompatible.sty!!!}\setboolean{ALG@compatible}{true}}%
21\DeclareOption{noncompatible}{\setboolean{ALG@noncompatible}{false}}%
22\ProcessOptions%
23%
24%      ***      DECLARATIONS      ***
25%
26\algnewlanguage{pseudocode}%
27\alglanguage{pseudocode}%
28%
29%      ***      KEYWORDS      ***
30%
31\algnewcommand\algorithmicend{\textbf{end}}
32\algnewcommand\algorithmicdo{\textbf{do}}
33\algnewcommand\algorithmicwhile{\textbf{while}}
34\algnewcommand\algorithmicfor{\textbf{for}}
35\algnewcommand\algorithmicforall{\textbf{for all}}
36\algnewcommand\algorithmicloop{\textbf{loop}}
37\algnewcommand\algorithmicrepeat{\textbf{repeat}}
38\algnewcommand\algorithmicuntil{\textbf{until}}
39\algnewcommand\algorithmicprocedure{\textbf{procedure}}
40\algnewcommand\algorithmicfunction{\textbf{function}}
41\algnewcommand\algorithmicif{\textbf{if}}
42\algnewcommand\algorithmicthen{\textbf{then}}
43\algnewcommand\algorithmicelse{\textbf{else}}
44\algnewcommand\algorithmicrequire{\textbf{Require:}}
45\algnewcommand\algorithmicensure{\textbf{Ensure:}}
46\algnewcommand\algorithmicreturn{\textbf{return}}
47\algnewcommand\textproc{\textsc}
48%
49%      ***      DECLARED LOOPS      ***
50%
51\algdef{SE}[WHILE]{While}{EndWhile}[1]{\algorithmicwhile\ #1\ \algorithmicdo}{\algorithmicend\ \algorithmicwhile}%
52\algdef{SE}[FOR]{For}{EndFor}[1]{\algorithmicfor\ #1\ \algorithmicdo}{\algorithmicend\ \algorithmicfor}%
53\algdef{S}[FOR]{ForAll}[1]{\algorithmicforall\ #1\ \algorithmicdo}%
54\algdef{SE}[LOOP]{Loop}{EndLoop}{\algorithmicloop}{\algorithmicend\ \algorithmicloop}%
55\algdef{SE}[REPEAT]{Repeat}{Until}{\algorithmicrepeat}[1]{\algorithmicuntil\ #1}%
56\algdef{SE}[IF]{If}{EndIf}[1]{\algorithmicif\ #1\ \algorithmicthen}{\algorithmicend\ \algorithmicif}%
57\algdef{C}[IF]{IF}{ElsIf}[1]{\algorithmicelse\ \algorithmicif\ #1\ \algorithmicthen}%
58\algdef{Ce}[ELSE]{IF}{Else}{EndIf}{\algorithmicelse}%
59\algdef{SE}[PROCEDURE]{Procedure}{EndProcedure}%
60   [2]{\algorithmicprocedure\ \textproc{#1}\ifthenelse{\equal{#2}{}}{}{(#2)}}%
61   {\algorithmicend\ \algorithmicprocedure}%
62\algdef{SE}[FUNCTION]{Function}{EndFunction}%
63   [2]{\algorithmicfunction\ \textproc{#1}\ifthenelse{\equal{#2}{}}{}{(#2)}}%
64   {\algorithmicend\ \algorithmicfunction}%
65%
66\ifthenelse{\equal{\ALG@noend}{t}}%
67   {%
68   \algtext*{EndWhile}%
69   \algtext*{EndFor}%
70   \algtext*{EndLoop}%
71   \algtext*{EndIf}%
72   \algtext*{EndProcedure}%
73   \algtext*{EndFunction}%
74   }{}%
75%
76%      ***      OTHER DECLARATIONS      ***
77%
78\algnewcommand\Require{\item[\algorithmicrequire]}%
79\algnewcommand\Ensure{\item[\algorithmicensure]}%
80\algnewcommand\Return{\algorithmicreturn{} }%
81\algnewcommand\Call[2]{\textproc{#1}\ifthenelse{\equal{#2}{}}{}{(#2)}}%
82%
83%
84%
85\ifthenelse{\boolean{ALG@compatible}}%
86   {%
87   \ifthenelse{\equal{\ALG@noend}{t}}%
88      {\RequirePackage[noend]{algcompatible}}%
89      {\RequirePackage{algcompatible}}%
90   }%
91   {}%
92%