summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/tex/latex/pseudocode/pseudocode.sty201
1 files changed, 201 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/pseudocode/pseudocode.sty b/Master/texmf-dist/tex/latex/pseudocode/pseudocode.sty
new file mode 100644
index 00000000000..3046352df52
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/pseudocode/pseudocode.sty
@@ -0,0 +1,201 @@
+%%
+%% January 14, 2004
+%%
+%% pseudocode.sty
+%%
+%% S O F T W A R E L I C E N S E
+%% =================================
+%%
+%% The file pseudocode.sty
+%% is referred to as `the pseudocode package'
+%% or simply `the package'.
+%%
+%% The pseudocode package is copyright 1999 D.L. Kreher and D.R. Stinson.
+%%
+%% The pseudocode package and its drivers may be distributed and/or modified
+%% under the conditions of the LaTeX Project Public License, either version
+%% 1.3 of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% The package has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer is Donald L. Kreher.
+%%
+%% end of software license
+%%
+%% E-MAIL: kreher@mtu.edu dstinson@uwaterloo.ca
+%%
+%% DESCRIPTION:
+%% pseudocode.sty is a LaTeX style option, consisting of:
+%% the environment pseudocode
+%%
+%% INSTALLATION:
+%% Put this file where your TeX looks for inputs.
+%%
+%% DOCUMENTATION:
+%% See pseudocode.tex.
+%%
+%% \RETURN altered Oct 22, 1999
+%% Allowed for two column formating Dec 2, 2002
+%% \BREAK for breaking out of loops added Oct 10, 2003
+%% \FORALL added Oct 10, 2003
+%%
+%% CODE:
+\typeout{** }
+\typeout{** Document Style `pseudocode' - environment }
+\typeout{** by D.L. Kreher and D.R. Stinson }
+\typeout{** }
+\typeout{** The pseudocode environment was originally developed for the book}
+\typeout{** Combinatorial Algorithms: Enumeration, Generation, and Search}
+\typeout{** CRC Press, 1999. }
+
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{pseudocode}
+%
+\if@twocolumn
+\newlength{\pcode@width}
+\setlength{\pcode@width}{\columnwidth}
+\addtolength{\pcode@width}{-40pt}
+\else
+\newlength{\pcode@width}
+\setlength{\pcode@width}{\textwidth}
+\addtolength{\pcode@width}{-40pt}
+\fi
+%
+\RequirePackage{fancybox}
+\RequirePackage{ifthen}
+%
+\newcommand{\pcode@AF}[1]{\mbox{\textsc{#1}}} % Algorithm font
+\newcounter{pseudocode}[section]
+\newcounter{pseudonum}
+\renewcommand{\thepseudonum}{\arabic{pseudonum}}
+\newcommand{\pcode@tab}[1]{\hspace*{#1ex}}
+\renewcommand{\thepseudocode}{\thesection.\arabic{pseudocode}}
+%
+\newboolean{pcode@plain}
+\newboolean{pcode@ruled}
+\newboolean{pcode@disp}
+\newboolean{pcode@shad}
+\newboolean{pcode@dbox}
+\newboolean{pcode@obox}
+\newboolean{pcode@Obox}
+\newboolean{pcode@fbox}
+%
+\newenvironment{pseudocode}[3][plain]
+{%
+ \refstepcounter{pseudocode}%
+ \ifthenelse{\equal{#1}{plain}}{\setboolean{pcode@plain}{true}}{\setboolean{pcode@plain}{false}}%
+ \ifthenelse{\equal{#1}{ruled}}{\setboolean{pcode@ruled}{true}}{\setboolean{pcode@ruled}{false}}%
+ \ifthenelse{\equal{#1}{display}}{\setboolean{pcode@disp}{true}}{\setboolean{pcode@disp}{false}}%
+ \ifthenelse{\equal{#1}{shadowbox}}{\setboolean{pcode@shad}{true}}{\setboolean{pcode@shad}{false}}%
+ \ifthenelse{\equal{#1}{doublebox}}{\setboolean{pcode@dbox}{true}}{\setboolean{pcode@dbox}{false}}%
+ \ifthenelse{\equal{#1}{ovalbox}}{\setboolean{pcode@obox}{true}}{\setboolean{pcode@obox}{false}}%
+ \ifthenelse{\equal{#1}{Ovalbox}}{\setboolean{pcode@Obox}{true}}{\setboolean{pcode@Obox}{false}}%
+ \ifthenelse{\equal{#1}{framebox}}{\setboolean{pcode@fbox}{true}}{\setboolean{pcode@fbox}{false}}%
+ \setcounter{pseudonum}{0}%
+ \ifthenelse{\boolean{pcode@disp}}%
+ {%
+ \noindent\begin{math}%
+ }%
+ {%
+ \begin{Sbox}%
+ \begin{minipage}{\pcode@width}%
+ \ifthenelse{\boolean{pcode@ruled}}
+ {
+ \noindent\rule{\pcode@width}{1pt}\hfill\\
+ {\bfseries Algorithm \thepseudocode:\pcode@tab{1}}\pcode@AF{#2}($#3$)\\
+ \noindent\rule{\pcode@width}{1pt}\hfill\\[1ex]
+ }
+ {
+ {\bfseries Algorithm \thepseudocode:\pcode@tab{1}}\pcode@AF{#2}($#3$)\\[2ex]
+ }
+ \noindent\begin{math}\begin{array}{@{\pcode@tab{1}}lr@{}}%
+ }{}%
+}%
+{%
+ \ifthenelse{\boolean{pcode@disp}}%
+ {%
+ \end{math}
+ }%
+ {%
+ \ifthenelse{\boolean{pcode@ruled}}
+ {
+ \end{array}\end{math}\\[1ex]
+ \noindent\rule{\pcode@width}{1pt}\hfill
+ \end{minipage}\end{Sbox}\bigskip\noindent%
+ }
+ {\end{array}\end{math}\end{minipage}\end{Sbox}\bigskip\noindent}%
+ \ifthenelse{\boolean{pcode@plain}}{\TheSbox}{}%
+ \ifthenelse{\boolean{pcode@ruled}}{\TheSbox}{}%
+ \ifthenelse{\boolean{pcode@shad}}{\shadowbox{\TheSbox}}{}%
+ \ifthenelse{\boolean{pcode@dbox}}{\doublebox{\TheSbox}}{}%
+ \ifthenelse{\boolean{pcode@obox}}{\cornersize*{4ex}\ovalbox{\TheSbox}}{}%
+ \ifthenelse{\boolean{pcode@Obox}}{\cornersize*{4ex}\Ovalbox{\TheSbox}}{}%
+ \ifthenelse{\boolean{pcode@fbox}}{\fbox{\TheSbox}}{}%
+ \bigskip%
+ }%
+}%
+%
+\newcommand{\STMTNUM}[2]{&\refstepcounter{pseudonum}\hspace*{#1}%
+\mbox{(\thepseudonum)\label{#2}}}
+\newcommand{\LOCAL}[1]{\mbox{\bfseries local}\pcode@tab{1}#1}
+\newcommand{\GLOBAL}[1]{\mbox{\bfseries global}\pcode@tab{1}#1}
+\newcommand{\EXTERNAL}[1]{\mbox{\bfseries external}\pcode@tab{1}#1}
+\newcommand{\COMMENT}[1]%
+{%
+ \vspace*{1ex}%
+ \mbox{\bfseries comment:}\pcode@tab{.5} \mbox{#1}
+}
+\newcommand{\BEGIN}{\left\{\begin{array}{@{}lr@{}}}
+\newcommand{\END}{\end{array}\right.}
+\newcommand{\PROCEDURE}[2]%
+{%
+ \mbox{\bfseries procedure }\pcode@AF{#1}(\ensuremath{#2})\\%
+ \begin{array}{@{\pcode@tab{1}}l@{}}%
+}
+\newcommand{\ENDPROCEDURE}{\vspace*{2ex}\end{array}\\ }
+\newcommand{\CALL}[2]{\pcode@AF{#1}(#2)} %
+\newcommand{\MAIN}{\mbox{\bfseries main}\\\begin{array}{@{\pcode@tab{1}}lr@{}}}
+\newcommand{\ENDMAIN}{\end{array}}
+\newcommand{\RETURN}[1]{\ifthenelse{\equal{#1}{} }%
+{\mbox{\bfseries return }}%
+{\mbox{\bfseries return }(#1)}}
+\newcommand{\OUTPUT}[1]{\mbox{\bfseries output }(#1)}
+\newcommand{\EXIT}{\mbox{\bfseries exit }}
+\newcommand{\BREAK}{\mbox{\bfseries break }}
+\newcommand{\IF}{\mbox{\bfseries if }}
+\newcommand{\LET}{\mbox{\bfseries let }}
+\newcommand{\CTHEN}{\pcode@tab{1}\mbox{ \bfseries then }}
+\newcommand{\CELSE}{\pcode@tab{1}\mbox{ \bfseries else }}
+\newcommand{\THEN}{\\\pcode@tab{1}\mbox{ \bfseries then }}
+\newcommand{\ELSE}{\\\pcode@tab{1}\mbox{ \bfseries else }}
+\newcommand{\ELSEIF}{\\\pcode@tab{1}\mbox{ \bfseries else if }}
+\newcommand{\FOREACH}{\mbox{\bfseries for each }}
+\newcommand{\FORALL}{\mbox{\bfseries for all }}
+\newcommand{\FOR}{\mbox{\bfseries for }}
+\newcommand{\TO}{\mbox{ \bfseries to }}
+\newcommand{\DOWNTO}{\mbox{ \bfseries downto }}
+\newcommand{\CASE}{\mbox{\bfseries case }}
+\newcommand{\OF}{\\\pcode@tab{1}\mbox{ \bfseries of }\BEGIN}
+\newcommand{\ENDCASE}{\END}
+\newcommand{\AND}{\mbox{ \bfseries and }}
+\newcommand{\OR}{\mbox{ \bfseries or }}
+\newcommand{\NOT}{\mbox{ \bfseries not }}
+\newcommand{\SUCCESS}{\mbox{ \bfseries success }}
+\newcommand{\FAIL}{\mbox{ \bfseries fail }}
+\newcommand{\TRUE}{\mbox{ \bfseries true }}
+\newcommand{\FALSE}{\mbox{ \bfseries false }}
+\newcommand{\GOTO}{\mbox{\bfseries go to }}
+\newcommand{\DO}{\\\pcode@tab{1}\mbox{ \bfseries do }}
+\newcommand{\ADO}{\mbox{ \bfseries do }}
+\newcommand{\WHILE}{\mbox{\bfseries while }}
+\newcommand{\REPEAT}{\mbox{\bfseries repeat }\\\begin{array}{@{\pcode@tab{1}}lr@{}}}
+\newcommand{\UNTIL}{\end{array}\\\mbox{\bfseries until }}
+\newcommand{\GETS}{\leftarrow}
+\endinput
+%% END pseudodcode.sty
+