Page MenuHomec4science

algo.sty
No OneTemporary

File Metadata

Created
Sat, Mar 15, 05:24

algo.sty

This document is not UTF8. It was detected as Shift JIS and converted to UTF8 for display.
% D馭initions des macros algorithmiques
% Il faudrait ins駻er des parbox du style : ``\parbox[t]{5cm}{le texte un peu lon pour une seule ligne.}''. Ceci pour les lignes un peu longues.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{algo}[2000/11/10 Macro for design of algorithms]
% A rendre local quand j'aurai le temps
\newlength{\indenta}
\newlength{\tmp}
\newlength{\tmpa}
\newcounter{linenumber}
% Ins鑽e la num駻otation et l'espacement.
\newcommand{\numbering}{\raggedright\refstepcounter{linenumber}\settowidth{\tmpa}{\arabic{linenumber}:}\setlength{\tmp}{1cm}\addtolength{\tmp}{-\tmpa}\arabic{linenumber}:\hspace{\tmp}\hspace{\indenta}}
\newcommand{\spacing}{\raggedright\hspace{1cm}\hspace{\indenta}}
\newcommand{\addspace}{\addtolength{\indenta}{0.5cm}}
\newcommand{\subspace}{\addtolength{\indenta}{-0.5cm}}
\newenvironment{ALGO}
{\parindent=0cm\setlength{\indenta}{0cm}\setcounter{linenumber}{0}\sf}
{}
\newenvironment{BEGIN}
{\numbering \textbf{begin}\addspace\par}
{\subspace\numbering\textbf{end}\par}
\newenvironment{VAR}
{\numbering \textbf{var}\addspace\par}
{\subspace}
\newcommand{\INSTR}[1]{\numbering\mbox{#1}\par}
\newcommand{\ASSIGN}[2]{\numbering#1 $\longleftarrow$ \mbox{#2} \par}
\newcommand{\NONUMBERING}[1]{\spacing\mbox{#1}\par}
\newcommand{\COMMENT}[1]{\spacing\mbox{// \emph{#1}}\par}
\newcommand{\WHILE}[2]{\numbering\textbf{while} \textit{#1} \textbf{do} \linebreak \addspace#2 \subspace\numbering\textbf{endwhile}\par}
\newcommand{\FORALL}[2]{\numbering\textbf{forall} \textit{#1} \textbf{do} \linebreak \addspace#2 \subspace\numbering\textbf{endforall}\par}
\newcommand{\REPEAT}[2]{\numbering\textbf{repeat} \linebreak \addspace#1 \subspace\numbering\textbf{until} \textit{#2}\par}
\newenvironment{FUNCTION}[3]
{\numbering\textbf{function} #1 (\textit{#2}) \textbf{return} \textit{#3} \addspace\par}
{\subspace\numbering\textbf{endfunc}\par}
\newcommand{\RETURN}[1]{\numbering\textbf{return} \textit{#1}\par}
\newenvironment{PROCEDURE}[2]
{\numbering\textbf{procedure} #1 (\textit{#2}) \addspace\par}
{\subspace\numbering\textbf{endproc}\par}
\newcommand{\IFTHENELSE}[3]{\numbering\textbf{if} \textit{#1} \textbf{then} \linebreak \addspace#2 \subspace\numbering\textbf{else}\linebreak\addspace#3 \subspace\numbering\textbf{endif}\par}
\newcommand{\IFTHEN}[2]{\numbering\textbf{if} \textit{#1} \textbf{then} \linebreak \addspace#2 \subspace\numbering\textbf{endif}\par}
\newcommand{\ELSEIF}[1]{\subspace\numbering\textbf{elseif} #1 \textbf{then}\addspace\par}
\newcommand{\ELSE}{\subspace\numbering\textbf{else}\addspace\par}

Event Timeline