summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/algorithmicx/algcompatible.sty
blob: 075f8512e27e72a7f4b43797138d7492af17dd95 (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
% ALGORITHMIC STYLE -- Released 27 APR 2005
%    for LaTeX version 2e
%
% Copyright Szasz Janos
% E-mail szaszjanos@users.sourceforge.net
% Based on Peter Williams's algorithmic.sty
%
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{algcompatible}%
\RequirePackage{ifthen}%
\RequirePackage{algorithmicx}%
\typeout{Document Style - algorithmic compatible environments for the `algorithmicx' style}%
%
\def\ALG@noend{f}%
%
\DeclareOption{noend}{\def\ALG@noend{t}}%
\DeclareOption{end}{\def\ALG@noend{f}}%
\ProcessOptions%
%
%      ***      DECLARATIONS      ***
%
\algnewlanguage{algorithmic}%
\alglanguage{algorithmic}%
%
%      ***      KEYWORDS      ***
%
\algnewcommand\algorithmicend{\textbf{end}}
\algnewcommand\algorithmicdo{\textbf{do}}
\algnewcommand\algorithmicwhile{\textbf{while}}
\algnewcommand\algorithmicfor{\textbf{for}}
\algnewcommand\algorithmicforall{\textbf{for all}}
\algnewcommand\algorithmicloop{\textbf{loop}}
\algnewcommand\algorithmicrepeat{\textbf{repeat}}
\algnewcommand\algorithmicuntil{\textbf{until}}
\algnewcommand\algorithmicif{\textbf{if}}
\algnewcommand\algorithmicthen{\textbf{then}}
\algnewcommand\algorithmicelse{\textbf{else}}
\algnewcommand\algorithmicrequire{\textbf{Require:}}
\algnewcommand\algorithmicensure{\textbf{Ensure:}}
%
%      ***      DECLARED LOOPS      ***
%
% lines...
\let\ALG@loopmark\ALG@x@nomark%
% default line and marks
\def\ALG@startmark{nomark}%
\def\ALG@blockline{noline}%
\def\ALG@continuemark{nomark}%
\def\ALG@endmark{nomark}%
%
\newcommand\ALG@compatcomm[1]{\ifthenelse{\equal{#1}{default}}{}{\ \algorithmiccomment{#1}}}%
\algrenewcomment[1]{\{#1\}}%
\algdef{SE}[WHILE]{WHILE}{ENDWHILE}%
   [2][default]{\algorithmicwhile\ #2\ \algorithmicdo\ALG@compatcomm{#1}}%
   {\algorithmicend\ \algorithmicwhile}%
\algdef{SE}[FOR]{FOR}{ENDFOR}%
   [2][default]{\algorithmicfor\ #2\ \algorithmicdo\ALG@compatcomm{#1}}%
   {\algorithmicend\ \algorithmicfor}%
\algdef{S}[FOR]{FORALL}%
   [2][default]{\algorithmicforall\ #2\ \algorithmicdo\ALG@compatcomm{#1}}%
\algdef{SE}[LOOP]{LOOP}{ENDLOOP}%
   [1][default]{\algorithmicloop\ALG@compatcomm{#1}}%
   {\algorithmicend\ \algorithmicloop}%
\algdef{SE}[REPEAT]{REPEAT}{UNTIL}%
   [1][default]{\algorithmicrepeat\ALG@compatcomm{#1}}%
   [1]{\algorithmicuntil\ #1}%
\algdef{SE}[IF]{IF}{ENDIF}%
   [2][default]{\algorithmicif\ #2\ \algorithmicthen\ALG@compatcomm{#1}}%
   {\algorithmicend\ \algorithmicif}%
\algdef{C}[IF]{IF}{ELSIF}%
   [2][default]{\algorithmicelse\ \algorithmicif\ #2\ \algorithmicthen\ALG@compatcomm{#1}}%
\algdef{Ce}[ELSE]{IF}{ELSE}{ENDIF}%
   [1][default]{\algorithmicelse\ALG@compatcomm{#1}}%
\algnewcommand\REQUIRE{\item[\algorithmicrequire]}%
\algnewcommand\ENSURE{\item[\algorithmicensure]}%
\algnewcommand\STATE{\State}%
\algnewcommand\STATEx{\Statex}%
\algnewcommand\COMMENT{\Comment}%
%
\ifthenelse{\equal{\ALG@noend}{t}}%
   {%
   \algtext*{ENDWHILE}%
   \algtext*{ENDFOR}%
   \algtext*{ENDLOOP}%
   \algtext*{ENDIF}%
   }{}%
%
\algrenewcommand\algorithmicindent{1em}%
%