-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdcsalg.sty
More file actions
131 lines (113 loc) · 3.92 KB
/
dcsalg.sty
File metadata and controls
131 lines (113 loc) · 3.92 KB
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
%
% $Id: dcsalg.sty 3115 2012-11-22 09:10:07Z sobaniec $
%
% Algorithm environment of DCS group
% by Cezary Sobaniec <cezary.sobaniec@cs.put.poznan.pl>
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dcsalg}[2010/01/14 v1.0 DCS Group algorithms package]
\RequirePackage{algpseudocode}
\RequirePackage{keyval}
\RequirePackage{ifthen}
\RequirePackage{caption}[2009/10/09]
\RequirePackage{translator}
\RequirePackage{xcolor}
\RequirePackage{float}
\usedictionary{translator-float-dictionary}
\definecolor{commentcolor}{rgb}{0.3,0.3,0.3}
\renewcommand{\algorithmiccomment}[1]{\hspace{1em}\textcolor{commentcolor}{::~\textit{#1}}}
\renewcommand{\algorithmicforall}{\textbf{foreach}}
% procedures
\algrenewcommand{\textproc}{\texttt}
% additional commands
\newcommand{\AND}{\ \textbf{and}\ }
\newcommand{\OR}{\ \textbf{or}\ }
\newcommand{\NOT}{\textbf{not}\ }
\newcommand{\algorithmicprocname}{\textbf{Procedure:}}
\newcommand{\ProcName}{\item[\algorithmicprocname]}
\newcommand{\algorithmicparameters}{\textbf{Parameters:}}
\newcommand{\Parameters}{\item[\algorithmicparameters]}
\newcommand{\Statey}[1]{\item[#1]}
\newcommand{\Stateybf}[1]{\item[\textbf{#1}]}
\newcommand{\Stateysf}[1]{\item[\textsf{#1}]}
\newcommand{\Stateytt}[1]{\item[\texttt{#1}]}
\newcommand{\Send}{\textbf{send}\ }
\newcommand{\Broadcast}{\textbf{broadcast}\ }
\newcommand{\Await}{\textbf{await}\ }
\newcommand{\Notify}{\textbf{notify}\ }
\newcommand{\NotifyAll}{\textbf{notify all}\ }
\newcommand{\Var}[1]{\ensuremath{\mathit{#1}}}
\newcommand{\Val}[1]{\ensuremath{\mathrm{#1}}}
\newcommand{\True}{\Val{true}}
\newcommand{\TRUE}{\True}
\newcommand{\False}{\Val{false}}
\newcommand{\FALSE}{\False}
\newcommand{\MSG}[1]{\ensuremath{\left\langle #1 \right\rangle}}
\newcommand{\Msg}[2]{\ensuremath{\mathsf{#1}%
\ifthenelse{\equal{#2}{}}{}{\left\langle#2\right\rangle}}}
\newcommand{\MSGN}[2]{\Msg{#1}{#2}}
%
% dcsalg environment
%
% width parameter
\newlength{\@dcsalgwidth}
\setlength{\@dcsalgwidth}{\textwidth}
\addtolength{\@dcsalgwidth}{-1.18em}
\define@key{dcsalg}{width}{\setlength{\@dcsalgwidth}{#1}}
% font parameter
\newcommand{\@dcsalgfont}{\small}
\define@key{dcsalg}{font}{\renewcommand{\@dcsalgfont}{#1}}
% number parameter
\newboolean{@dcsalgnumber}
\setboolean{@dcsalgnumber}{true}
\define@key{dcsalg}{number}[]{\setboolean{@dcsalgnumber}{true}}
\define@key{dcsalg}{nonumber}[]{\setboolean{@dcsalgnumber}{false}}
% plain|boxed|ruled parameters
\newboolean{@dcsalgruled}
\setboolean{@dcsalgruled}{false}
\newboolean{@dcsalgboxed}
\setboolean{@dcsalgboxed}{true}
\define@key{dcsalg}{plain}[]{\setboolean{@dcsalgruled}{false}
\setboolean{@dcsalgboxed}{false}}
\define@key{dcsalg}{ruled}[]{\setboolean{@dcsalgruled}{true}
\setboolean{@dcsalgboxed}{true}}
\define@key{dcsalg}{boxed}[]{\setboolean{@dcsalgruled}{false}
\setboolean{@dcsalgboxed}{true}}
\newenvironment{dcsalg}[1][]%
{\setkeys{dcsalg}{#1}%
\if@dcsalgboxed
\if@dcsalgruled
\begin{tabular}{c}%
\else
\begin{tabular}{|c|}%
\fi
\hline%
\fi
\begin{minipage}{\@dcsalgwidth}\smallskip%
\if@dcsalgnumber
\begin{algorithmic}[1]%
\else
\begin{algorithmic}%
\fi
\@dcsalgfont}%
{\end{algorithmic}%
\smallskip%
\end{minipage}%
\if@dcsalgboxed
\tabularnewline%
\hline%
\end{tabular}
\fi}
\newcommand{\dcsalgset}[1]{\setkeys{dcsalg}{#1}}
% algorithm float using "float" package
\ifthenelse{\isundefined{\chaptermark}}
{\newfloat{algorithm}{tbhp}{loa}}
{\newfloat{algorithm}{tbhp}{loa}[chapter]}
\floatname{algorithm}{\translate{Algorithm}}
%% algorithm float using newfloat package
%\DeclareFloatingEnvironment[fileext=loa,placement=tbhp,within=none,name=Alg.]{algorithm}
%\ifthenelse{\isundefined{\chaptermark}}
% {}
% {\SetupFloatingEnvironment{algorithm}{within=chapter}}
\captionsetup[algorithm]{position=bottom,skip=\bigskipamount}
\ProcessOptions\relax