summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/algorithmicx/algmatlab.sty
blob: e274a7dfa996a1f3cc89f037d61c4df4b2d46ed7 (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
% Matlab ALGORITHMIC STYLE -- Released 27 APR 2005
%    for LaTeX version 2e
%
% Copyright Szasz Janos
% E-mail szaszjanos@users.sourceforge.net
%
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{algmatlab}%
\RequirePackage{ifthen}%
\RequirePackage{algorithmicx}%
\typeout{Document Style - matlab environments for use with the `algorithmicx' style}%
%
\ProcessOptions%
%
%      ***      DECLARATIONS      ***
%
\algnewlanguage{matlab}%
\alglanguage{matlab}%
%
%      ***      KEYWORDS      ***
%
\newcommand\textkeyword{\textbf}
\newcommand\textfunc{\texttt}
%
%      ***      DECLARED LOOPS      ***
%
\algdef{SE}[WHILE]{While}{End}[1]{\textkeyword{while}\ #1}{\textkeyword{end}}%
\algdef{Se}[FOR]{For}{End}[1]{\textkeyword{for}\ #1}%
\algdef{Se}[IF]{If}{End}[1]{\textkeyword{if}\ #1}%
\algdef{C}[IF]{IF}{ElseIf}[1]{\textkeyword{else}\textkeyword{if}\ #1}%
\algdef{Ce}[ELSE]{IF}{Else}{End}{\textkeyword{else}}%
\algdef{LSxnE}[FUNCTION]{Function}{End}{65535}%
   [2]{\textkeyword{function}\ \textfunc{#1}\ifthenelse{\equal{#2}{}}{}{(#2)}}%
%
\algdef{SxE}[SWITCH]{Switch}{End}[1]{\let\Case\ALG@thecase\textkeyword{switch}\ #1}%
   {\textkeyword{end}}%
\algdef{LS}[CASE]{Case}{65535}[1]{\let\Case\Case@continue\textkeyword{case}\ #1:}%
\let\ALG@thecase\Case%
\algdef{LxC}[CASE]{CASE}{Case@continue}{65535}[1]{\let\Case\Case@continue\textkeyword{case}\ #1:}%
\algdef{LC}[OTHERWISE]{CASE}{Otherwise}{65535}{\textkeyword{otherwise}:}%
%
\renewcommand\algorithmiccomment[1]{\hskip 1.5em\textit{\% #1}}%
%
\newcommand\algnewfunction[2]%
   {%
   \expandafter\newcommand\csname #1\endcsname[1]{\textfunc{#2}\((\)##1\()\)}%
   }%
%
\algnewfunction{Line}{line}%
\algnewfunction{Scatter}{scatter}%
\algnewfunction{Plot}{plot}%
\algnewfunction{Zeros}{zeros}%
\algnewfunction{Ones}{ones}%
\algnewfunction{Load}{load}%
\algnewfunction{Size}{size}%
\algnewfunction{Disp}{disp}%
\algnewfunction{Min}{min}%
\algnewfunction{Max}{max}%
%
\def\Break{\textkeyword{break}}%
\def\Return{\textkeyword{return}}%
\def\Global{\textkeyword{global}}%
\def\Hold#1{\textkeyword{hold} #1}%
%
%      ***      OTHER DECLARATIONS      ***
%
\algrenewcommand\ALG@beginalgorithmic{\let\leftbr[\let\rightbr]\def\[{\textbf{\leftbr}}\def\]{\textbf{\rightbr}}}%
%