249 lines
9.6 KiB
TeX
249 lines
9.6 KiB
TeX
%%
|
|
%% 11 juin 2010
|
|
%%
|
|
%% algorithmique.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".
|
|
%%
|
|
%% Francisé par Alain Busser, Lycée Roland-Garros, Le Tampon
|
|
%%
|
|
%% end of software license
|
|
%%
|
|
%%
|
|
%% DESCRIPTION:
|
|
%% algorithmique.sty est un fichier de style LaTeX, comprenant:
|
|
%% l'environment pseudocode traduit en Français
|
|
%%
|
|
%% INSTALLATION:
|
|
%% À placer là où LaTeX cherche des fichiers.
|
|
%%
|
|
%% DOCUMENTATION:
|
|
%% Voir pseudocode.tex.
|
|
%%
|
|
%% COPYING:
|
|
%% Copying of part or all of this file is allowed under the following
|
|
%% conditions only:
|
|
%% (1) You may freely distribute unchanged copies of the file. Please
|
|
%% include the documentation when you do so.
|
|
%% (2) You may modify a renamed copy of the file, but only for personal
|
|
%% use or use within an organization.
|
|
%% (3) You may copy fragments from the file, for personal use or for
|
|
%% distribution, as long as credit is given where credit is due.
|
|
%%
|
|
%% You are NOT ALLOWED to take money for the distribution or use of
|
|
%% this file or modified versions or fragments thereof, except for
|
|
%% a nominal charge for copying etc.
|
|
%%
|
|
%%
|
|
%% CODE:
|
|
\typeout{** }
|
|
\typeout{** Document Style `algorithmique' }
|
|
\typeout{** by D.L. Kreher and D.R. Stinson }
|
|
\typeout{** Alain Busser }
|
|
|
|
%
|
|
\NeedsTeXFormat{LaTeX2e}
|
|
\ProvidesPackage{algorithmique}
|
|
%
|
|
\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}}} % choix de la police
|
|
\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 Algorithme \thepseudocode:\pcode@tab{1}}\pcode@AF{#2}($#3$)\\
|
|
\noindent\rule{\pcode@width}{1pt}\hfill\\[1ex]
|
|
}
|
|
{
|
|
{\bfseries Algorithme \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{\BOOL}[1]{\mbox{\bfseries variables booléennes }\pcode@tab{1}#1}
|
|
\newcommand{\INT}[1]{\mbox{\bfseries variables entières }\pcode@tab{1}#1}
|
|
\newcommand{\ENT}[1]{\mbox{\bfseries variables entières }\pcode@tab{1}#1}
|
|
\newcommand{\FLOAT}[1]{\mbox{\bfseries variables réelles }\pcode@tab{1}#1}
|
|
\newcommand{\REAL}[1]{\mbox{\bfseries variables réelles }\pcode@tab{1}#1}
|
|
\newcommand{\REEL}[1]{\mbox{\bfseries variables réelles }\pcode@tab{1}#1}
|
|
\newcommand{\STRING}[1]{\mbox{\bfseries chaînes de caractères }\pcode@tab{1}#1}
|
|
\newcommand{\CHAINE}[1]{\mbox{\bfseries chaînes de caractères }\pcode@tab{1}#1}
|
|
\newcommand{\ARRAY}[1]{\mbox{\bfseries tableaux }\pcode@tab{1}#1}
|
|
\newcommand{\TABLEAU}[1]{\mbox{\bfseries tableaux }\pcode@tab{1}#1}
|
|
\newcommand{\LOCAL}[1]{\mbox{\bfseries variables locales }\pcode@tab{1}#1}
|
|
\newcommand{\GLOBAL}[1]{\mbox{\bfseries variables globales }\pcode@tab{1}#1}
|
|
\newcommand{\EXTERNAL}[1]{\mbox{\bfseries variables externes }\pcode@tab{1}#1}
|
|
\newcommand{\EXTERNE}[1]{\mbox{\bfseries variables externes }\pcode@tab{1}#1}
|
|
\newcommand{\COMMENT}[1]%
|
|
{%
|
|
\vspace*{1ex}%
|
|
\mbox{\bfseries Commentaire: }\pcode@tab{.5} \mbox{#1}
|
|
}
|
|
\newcommand{\BEGIN}{\left\{\begin{array}{@{}lr@{}}}
|
|
\newcommand{\DEBUT}{\left\{\begin{array}{@{}lr@{}}}
|
|
\newcommand{\END}{\end{array}\right.}
|
|
\newcommand{\FIN}{\end{array}\right.}
|
|
\newcommand{\PROCEDURE}[2]%
|
|
{%
|
|
\mbox{\bfseries procédure }\pcode@AF{#1}(\ensuremath{#2})\\%
|
|
\begin{array}{@{\pcode@tab{1}}l@{}}%
|
|
}
|
|
\newcommand{\ENDPROCEDURE}{\vspace*{2ex}\end{array}\\ }
|
|
\newcommand{\FINPROCEDURE}{\vspace*{2ex}\end{array}\\ }
|
|
\newcommand{\CALL}[2]{\pcode@AF{#1}(#2)} %
|
|
\newcommand{\APPEL}[2]{\pcode@AF{#1}(#2)} %
|
|
\newcommand{\MAIN}{\mbox{\bfseries principal }\\\begin{array}{@{\pcode@tab{1}}lr@{}}}
|
|
\newcommand{\ENDMAIN}{\end{array}}
|
|
\newcommand{\RETURN}[1]{\ifthenelse{\equal{#1}{} }%
|
|
{\mbox{\bfseries fini }}%
|
|
{\mbox{\bfseries retourne }(#1)}}
|
|
\newcommand{\RETOURNE}[1]{\ifthenelse{\equal{#1}{} }%
|
|
{\mbox{\bfseries fini }}%
|
|
{\mbox{\bfseries retourne }(#1)}}
|
|
\newcommand{\INPUT}[1]{\mbox{\bfseries Entrer }(#1)}
|
|
\newcommand{\ENTRER}[1]{\mbox{\bfseries Entrer }(#1)}
|
|
\newcommand{\OUTPUT}[1]{\mbox{\bfseries Afficher }(#1)}
|
|
\newcommand{\AFF}[1]{\mbox{\bfseries Afficher }(#1)}
|
|
\newcommand{\EXIT}{\mbox{\bfseries quitte }}
|
|
\newcommand{\BREAK}{\mbox{\bfseries rompt }}
|
|
\newcommand{\IF}{\mbox{\bfseries si }}
|
|
\newcommand{\SI}{\mbox{\bfseries si }}
|
|
\newcommand{\LET}{\mbox{\bfseries soit }}
|
|
\newcommand{\SOIT}{\mbox{\bfseries soit }}
|
|
\newcommand{\THEN}{\\\pcode@tab{1}\mbox{ \bfseries alors }}
|
|
\newcommand{\ALORS}{\\\pcode@tab{1}\mbox{ \bfseries alors }}
|
|
\newcommand{\ELSE}{\\\pcode@tab{1}\mbox{ \bfseries sinon }}
|
|
\newcommand{\SINON}{\\\pcode@tab{1}\mbox{ \bfseries sinon }}
|
|
\newcommand{\ELSEIF}{\\\pcode@tab{1}\mbox{ \bfseries sinon, si }}
|
|
\newcommand{\SINONSI}{\\\pcode@tab{1}\mbox{ \bfseries sinon, si }}
|
|
\newcommand{\FOREACH}{\mbox{\bfseries pour chaque }}
|
|
\newcommand{\POURTOUT}{\mbox{\bfseries pour tout }}
|
|
\newcommand{\FORALL}{\mbox{\bfseries pour tout }}
|
|
\newcommand{\FOR}{\mbox{\bfseries pour }}
|
|
\newcommand{\POUR}{\mbox{\bfseries pour }}
|
|
\newcommand{\TO}{\mbox{ \bfseries jusqu'à }}
|
|
\newcommand{\JUSQUE}{\mbox{ \bfseries jusqu'à }}
|
|
\newcommand{\DOWNTO}{\mbox{ \bfseries descendant jusqu'à }}
|
|
\newcommand{\CASE}{\mbox{\bfseries selon }}
|
|
\newcommand{\SELON}{\mbox{\bfseries selon }}
|
|
\newcommand{\OF}{\\\pcode@tab{1}\mbox{ \bfseries parmi }\BEGIN}
|
|
\newcommand{\PARMI}{\\\pcode@tab{1}\mbox{ \bfseries parmi }\BEGIN}
|
|
\newcommand{\ENDCASE}{\END}
|
|
\newcommand{\FINSELON}{\END}
|
|
\newcommand{\AND}{\mbox{ \bfseries et }}
|
|
\newcommand{\ET}{\mbox{ \bfseries et }}
|
|
\newcommand{\OR}{\mbox{ \bfseries ou }}
|
|
\newcommand{\OU}{\mbox{ \bfseries ou }}
|
|
\newcommand{\NOT}{\mbox{ \bfseries non }}
|
|
\newcommand{\NON}{\mbox{ \bfseries non }}
|
|
\newcommand{\SUCCESS}{\mbox{ \bfseries succès }}
|
|
\newcommand{\SUCCES}{\mbox{ \bfseries succès }}
|
|
\newcommand{\FAIL}{\mbox{ \bfseries échec }}
|
|
\newcommand{\ECHEC}{\mbox{ \bfseries échec }}
|
|
\newcommand{\TRUE}{\mbox{ \bfseries vrai }}
|
|
\newcommand{\VRAI}{\mbox{ \bfseries vrai }}
|
|
\newcommand{\FALSE}{\mbox{ \bfseries faux }}
|
|
\newcommand{\FAUX}{\mbox{ \bfseries faux }}
|
|
\newcommand{\GOTO}{\mbox{\bfseries aller à }}
|
|
\newcommand{\DO}{\\\pcode@tab{1}\mbox{ \bfseries faire }}
|
|
\newcommand{\FAIRE}{\\\pcode@tab{1}\mbox{ \bfseries faire }}
|
|
\newcommand{\WHILE}{\mbox{\bfseries tant que }}
|
|
\newcommand{\TANTQUE}{\mbox{\bfseries tant que }}
|
|
\newcommand{\REPEAT}{\mbox{\bfseries répéter }\\\begin{array}{@{\pcode@tab{1}}lr@{}}}
|
|
\newcommand{\REPETE}{\mbox{\bfseries répéter }\\\begin{array}{@{\pcode@tab{1}}lr@{}}}
|
|
\newcommand{\UNTIL}{\end{array}\\\mbox{\bfseries jusqu'à }}
|
|
\newcommand{\JUSQUA}{\end{array}\\\mbox{\bfseries jusqu'à }}
|
|
\newcommand{\GETS}{\leftarrow}
|
|
\newcommand{\PREND}{\leftarrow}
|
|
\endinput
|
|
%% END pseudodcode.sty
|
|
|