From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/algorithm2e/README | 18 + .../latex/contrib/algorithm2e/doc/algorithm2e.pdf | Bin 0 -> 533935 bytes .../latex/contrib/algorithm2e/doc/algorithm2e.tex | 2514 +++++++++++++++ .../contrib/algorithm2e/doc/algorithm2e_ex01.tex | 8 + .../contrib/algorithm2e/doc/algorithm2e_ex02.tex | 5 + .../contrib/algorithm2e/doc/algorithm2e_ex03.tex | 5 + .../contrib/algorithm2e/doc/algorithm2e_ex04.tex | 2 + .../contrib/algorithm2e/doc/algorithm2e_ex05.tex | 10 + .../contrib/algorithm2e/doc/algorithm2e_ex06.tex | 13 + .../contrib/algorithm2e/doc/algorithm2e_ex07.tex | 35 + .../doc/algorithm2e_exAlgoDisjdecomp.tex | 30 + .../contrib/algorithm2e/doc/algorithm2e_exIR.tex | 40 + .../contrib/algorithm2e/doc/algorithm2e_exProg.tex | 6 + .../contrib/algorithm2e/doc/algorithm2e_exfor.tex | 10 + .../algorithm2e/doc/algorithm2e_exgeneric.tex | 36 + .../algorithm2e/doc/algorithm2e_exgeneric2.tex | 20 + .../algorithm2e/doc/algorithm2e_exnlsty.tex | 12 + .../algorithm2e/doc/algorithm2e_exrepeat.tex | 6 + .../algorithm2e/doc/algorithm2e_exswitch.tex | 15 + .../latex/contrib/algorithm2e/tex/algorithm2e.sty | 3288 ++++++++++++++++++++ 20 files changed, 6073 insertions(+) create mode 100644 macros/latex/contrib/algorithm2e/README create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e.pdf create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_ex01.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_ex02.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_ex03.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_ex04.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_ex05.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_ex06.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_ex07.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exAlgoDisjdecomp.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exIR.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exProg.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exfor.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exgeneric.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exgeneric2.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exnlsty.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exrepeat.tex create mode 100644 macros/latex/contrib/algorithm2e/doc/algorithm2e_exswitch.tex create mode 100644 macros/latex/contrib/algorithm2e/tex/algorithm2e.sty (limited to 'macros/latex/contrib/algorithm2e') diff --git a/macros/latex/contrib/algorithm2e/README b/macros/latex/contrib/algorithm2e/README new file mode 100644 index 0000000000..5eff12e035 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/README @@ -0,0 +1,18 @@ +Algorithm2e is an environment for writing algorithms in LaTeX2e. +An algorithm is defined as a floating object like figures. +It provides macros that allow you to create different sorts of key +words, thus a set of predefined key words is given. You can also +change the typography of the keywords. + + +You can subscribe to algorithm2e-announce mailing list to receive +announcements about revisions of the package and to +algorithm2e-discussion to discuss, send comments, ask questions about +the package. +In order to subscribe to the mailing lists you have to send an email to +sympa@lirmm.fr with: +subscribe algorithm2e-announce Firstname Name +subscribe algorithm2e-discussion Firstname Name +in the body of the message. + +see the documentation for explanation and examples. diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e.pdf b/macros/latex/contrib/algorithm2e/doc/algorithm2e.pdf new file mode 100644 index 0000000000..746a80c363 Binary files /dev/null and b/macros/latex/contrib/algorithm2e/doc/algorithm2e.pdf differ diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e.tex new file mode 100644 index 0000000000..4ff13e11a1 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e.tex @@ -0,0 +1,2514 @@ +% algorithm2e.tex --- doc of the package file for algorithms +% +% (c) 1995-1997 Christophe Fiorio, Tu-Berlin, Germany +% (c) 1998-2017 Christophe Fiorio, Montpellier University, France +% +% Report bugs and comments to: +% christophe.fiorio@umontpellier.fr +% +% $Id: algorithm2e.tex,v 5.2 2017/07/18 15:34:38 fioriochristophe Exp $ +% +\documentclass[a4paper]{article} + +\usepackage{a4wide} +\usepackage[ + colorlinks% + ,linktocpage%This puts the link on page number. +% ,plainpages=false%This forces a unique identification of pages. +% ,hypertexnames=true%This is necessary to have exact link on Index page. +% ,pdfpagelabels% + ,hyperindex +]{hyperref} + +\renewcommand{\subsectionautorefname}{section} +\renewcommand{\subsubsectionautorefname}{section} +\usepackage{makeidx} +\usepackage{moreverb} +\usepackage[boxed,commentsnumbered]{algorithm2e} + + +\def\no{n$^\circ$} +\def\No{N$^\circ$} + +%% macros for the macros !! +\newcommand\macind[1]{\index{#1@\texttt{$\protect\backslash$#1}|textit}} + +\newcommand\almac[1]{$\backslash$\texttt{#1}\index{#1@\texttt{$\protect\backslash$#1}|textit}} +\newcommand\almacp[2]{$\backslash$\texttt{#1\{#2\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} +\newcommand\almacpp[3]{$\backslash$\texttt{#1\{#2\}\{#3\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} +\newcommand\almacppp[4]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} +\newcommand\almacpppp[5]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} +\newcommand\almacpsix[7]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}\{#6\}\{#7\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} +\newcommand\almacphuit[9]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}\{#6\}\{#7\}\{#8\}\{#9\}}\index{#1@\texttt{$\protect\backslash$#1}|textit}} +\newcommand\Alenv[1]{\texttt{#1}\index{#1@\texttt{#1}|textbf}} +\newcommand\Almac[1]{$\backslash$\texttt{#1}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} +\newcommand\Almacp[2]{$\backslash$\texttt{#1\{#2\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} +\newcommand\Almacpp[3]{$\backslash$\texttt{#1\{#2\}\{#3\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} +\newcommand\Almacppp[4]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} +\newcommand\Almacpppp[5]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} +\newcommand\Almacpsix[7]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}\{#6\}\{#7\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} +\newcommand\Almacpseven[8]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}\{#6\}\{#7\}\{#8\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} +\newcommand\Almacphuit[9]{$\backslash$\texttt{#1\{#2\}\{#3\}\{#4\}\{#5\}\{#6\}\{#7\}\{#8\}\{#9\}}\index{#1@\texttt{$\protect\backslash$#1}|textbf}} + +%% macro for the options !! +% 2.40 +\newcommand{\optalgopart}{\textsf{algopart}\index{french@\textsf{algopart}|textit}\xspace} +\newcommand{\optalgochapter}{\textsf{algochapter}\index{french@\textsf{algochapter}|textit}\xspace} +\newcommand{\optalgosection}{\textsf{algosection}\index{french@\textsf{algosection}|textit}\xspace} +% +\newcommand{\optslide}{\textsf{slide}\index{french@\textsf{slide}|textit}\xspace} +\newcommand{\optalgoe}{\textsf{algo2e}\index{french@\textsf{algo2e}|textit}\xspace} +\newcommand{\optenglish}{\textsf{english}\index{english@\textsf{english}|textit}\xspace} +\newcommand{\optenglishkw}{\textsf{englishkw}\index{englishkw@\textsf{englishkw}|textit}\xspace} +\newcommand{\optfrench}{\textsf{french}\index{french@\textsf{french}|textit}\xspace} +\newcommand{\optfrenchkw}{\textsf{frenchkw}\index{frenchkw@\textsf{frenchkw}|textit}\xspace} +\newcommand{\optgerman}{\textsf{german}\index{german@\textsf{german}|textit}\xspace} +\newcommand{\optgermankw}{\textsf{germankw}\index{germankw@\textsf{germankw}|textit}\xspace} +\newcommand{\optngerman}{\textsf{ngerman}\index{ngerman@\textsf{ngerman}|textit}\xspace} +\newcommand{\optngermankw}{\textsf{ngermankw}\index{ngermankw@\textsf{ngermankw}|textit}\xspace} +\newcommand{\optspanish}{\textsf{spanish}\index{spanish@\textsf{spanish}|textit}\xspace} +\newcommand{\optspanishkw}{\textsf{spanishkw}\index{spanishkw@\textsf{spanishkw}|textit}\xspace} +\newcommand{\optitaliano}{\textsf{italiano}\index{italiano@\textsf{italiano}|textit}\xspace} +\newcommand{\optitalianokw}{\textsf{italianokw}\index{italianokw@\textsf{italianokw}|textit}\xspace} +\newcommand{\optcroatian}{\textsf{croatian}\index{croatian@\textsf{croatian}|textit}\xspace} +\newcommand{\optcroatiankw}{\textsf{croatiankw}\index{croatiankw@\textsf{croatiankw}|textit}\xspace} +\newcommand{\optportuguese}{\textsf{portuguese}\index{portuguese@\textsf{portuguese}|textit}\xspace} +\newcommand{\optportuguesekw}{\textsf{portuguesekw}\index{portuguesekw@\textsf{portuguesekw}|textit}\xspace} +\newcommand{\optczech}{\textsf{czech}\index{czech@\textsf{czech}|textit}\xspace} +\newcommand{\optczechkw}{\textsf{czechkw}\index{czechkw@\textsf{czechkw}|textit}\xspace} +\newcommand{\optslovak}{\textsf{slovak}\index{slovak@\textsf{slovak}|textit}\xspace} +\newcommand{\optslovakkw}{\textsf{slovakkw}\index{slovakkw@\textsf{slovakkw}|textit}\xspace} +\newcommand{\optturkish}{\textsf{turkish}\index{turkish@\textsf{turkish}|textit}\xspace} +\newcommand{\optturkishkw}{\textsf{turkishkw}\index{turkishkw@\textsf{turkishkw}|textit}\xspace} +\newcommand{\optboxed}{\textsf{boxed}\index{boxed@\textsf{boxed}|textit}\xspace} +\newcommand{\optboxruled}{\textsf{boxruled}\index{boxruled@\textsf{boxruled}|textit}\xspace} +\newcommand{\optruled}{\textsf{ruled}\index{ruled@\textsf{ruled}|textit}\xspace} +\newcommand{\opttworuled}{\textsf{tworuled}\index{tworuled@\textsf{tworuled}|textit}\xspace} +\newcommand{\optalgoruled}{\textsf{algoruled}\index{algoruled@\textsf{algoruled}|textit}\xspace} +\newcommand{\optplain}{\textsf{plain}\index{plain@\textsf{plain}|textit}\xspace} +\newcommand{\optlined}{\textsf{lined}\index{lined@\textsf{lined}|textit}\xspace} +\newcommand{\optvlined}{\textsf{vlined}\index{vlined@\textsf{vlined}|textit}\xspace} +\newcommand{\optnoline}{\textsf{noline}\index{noline@\textsf{noline}|textit}\xspace} +\newcommand{\optlinesnumbered}{\textsf{linesnumbered}\index{linesnumbered@\textsf{linesnumbered}|textit}\xspace} +\newcommand{\optlinesnumberedhidden}{\textsf{linesnumberedhidden}\index{linesnumberedhidden@\textsf{linesnumberedhidden}|textit}\xspace} +\newcommand{\optcommentsnumbered}{\textsf{commentsnumbered}\index{commentsnumbered@\textsf{commentsnumbered}|textit}\xspace} +\newcommand{\optinoutnumbered}{\textsf{inoutnumbered}\index{inoutnumbered@\textsf{inoutnumbered}|textit}\xspace} +\newcommand{\opttitlenumbered}{\textsf{titlenumbered}\index{titlenumbered@\textsf{titlenumbered}|textit}\xspace} +\newcommand{\opttitlenotnumbered}{\textsf{titlenotnumbered}\index{titlenotnumbered@\textsf{titlenotnumbered}|textit}\xspace} +\newcommand{\optresetcount}{\textsf{resetcount}\index{resetcount@\textsf{resetcount}|textit}\xspace} +\newcommand{\optnoresetcount}{\textsf{noresetcount}\index{noresetcount@\textsf{noresetcount}|textit}\xspace} +\newcommand{\optalgonl}{\textsf{algonl}\index{algonl@\textsf{algonl}|textit}\xspace} +\newcommand{\optlongend}{\textsf{longend}\index{longend@\textsf{longend}|textit}\xspace} +\newcommand{\optshortend}{\textsf{shortend}\index{shortend@\textsf{shortend}|textit}\xspace} +\newcommand{\optnoend}{\textsf{noend}\index{noend@\textsf{noend}|textit}\xspace} +\newcommand{\optfigure}{\textsf{figure}\index{figure@\textsf{figure}|textit}\xspace} +\newcommand{\optscright}{\textsf{scright}\index{scright@\textsf{scright}|textit}\xspace} +\newcommand{\optscleft}{\textsf{scleft}\index{scleft@\textsf{scleft}|textit}\xspace} +\newcommand{\optfillcomment}{\textsf{fillcomment}\index{fillcomment@\textsf{fillcomment}|textit}\xspace} +\newcommand{\optnofillcomment}{\textsf{nofillcomment}\index{nofillcomment@\textsf{nofillcomment}|textit}\xspace} +\newcommand{\optdotocloa}{\textsf{dotocloa}\index{dotocloa@\textsf{dotocloa}|textit}\xspace} +\newcommand{\optendfloat}{\textsf{endfloat}\index{endfloat@\textsf{endfloat}|textit}\xspace} +\newcommand{\optnorelsize}{\textsf{norelsize}\index{norelsize@\textsf{norelsize}|textit}\xspace} +\newcommand{\optonelanguage}{\textsf{onelanguage}\index{onelanguage@\textsf{onelanguage}|textit}\xspace} +\newcommand{\optrightnl}{\textsf{rightnl}\index{rightnl@\textsf{rightnl}|textit}\xspace} +\newcommand{\optprocnumbered}{\textsf{procnumbered}\index{procnumbered@\textsf{procnumbered}|textit}\xspace} +\newcommand{\optoldcommands}{\textsf{oldcommands}\index{oldcommands@\textsf{oldcommands}|textit}\xspace} +\newcommand{\optnokwfunc}{\textsf{nokwfunc}\index{nokwfunc@\textsf{nokwfunc}|textit}\xspace} +\newcommand{\optblockmarkers}{\textsf{displayblockmarkers}\index{displayblockmarkers@\textsf{displayblockmarkers}|textit}\xspace} +% +\newcommand{\optgroupmarkers}{\textsf{displaygroupmarkers}\index{displaygroupmarkers@\textsf{displaygroupmarkers}|textit}\xspace} +\newcommand{\optnoalgohanging}{\textsf{noalgohanging}\index{noalgohanging@\textsf{noalgohanging}|textit}\xspace} +\newcommand{\opthangingcomment}{\textsf{hangingcomment}\index{hangingcomment@\textsf{hangingcomment}|textit}\xspace} +\newcommand{\opthanginginout}{\textsf{opthanginginout}\index{opthanginginout@\textsf{opthanginginout}|textit}\xspace} +% +\newcommand{\Optfrench}{\textsf{french}\index{french@\textsf{french}|textbf}\xspace} +\newcommand{\Optfrenchkw}{\textsf{frenchkw}\index{frenchkw@\textsf{frenchkw}|textbf}\xspace} +\newcommand{\Optenglish}{\textsf{english}\index{english@\textsf{english}|textbf}\xspace} +\newcommand{\Optenglishkw}{\textsf{englishkw}\index{englishkw@\textsf{englishkw}|textbf}\xspace} +\newcommand{\Optgerman}{\textsf{german}\index{german@\textsf{german}|textbf}\xspace} +\newcommand{\Optgermankw}{\textsf{germankw}\index{germankw@\textsf{germankw}|textbf}\xspace} +\newcommand{\Optngerman}{\textsf{ngerman}\index{ngerman@\textsf{ngerman}|textbf}\xspace} +\newcommand{\Optngermankw}{\textsf{ngermankw}\index{ngermankw@\textsf{ngermankw}|textbf}\xspace} +\newcommand{\Optspanish}{\textsf{spanish}\index{spanish@\textsf{spanish}|textbf}\xspace} +\newcommand{\Optspanishkw}{\textsf{spanishkw}\index{spanishkw@\textsf{spanishkw}|textbf}\xspace} +\newcommand{\Optcroatian}{\textsf{croatian}\index{croatian@\textsf{croatian}|textbf}\xspace} +\newcommand{\Optcroatiankw}{\textsf{croatiankw}\index{croatiankw@\textsf{croatiankw}|textbf}\xspace} +\newcommand{\Optportugues}{\textsf{portuguese}\index{portuguese@\textsf{portuguese}|textbf}\xspace} +\newcommand{\Optportugueskw}{\textsf{portuguesekw}\index{portuguesekw@\textsf{portuguesekw}|textbf}\xspace} +\newcommand{\Optczech}{\textsf{czech}\index{czech@\textsf{czech}|textbf}\xspace} +\newcommand{\Optczechkw}{\textsf{czechkw}\index{czechkw@\textsf{czechkw}|textbf}\xspace} +\newcommand{\Optitaliano}{\textsf{italiano}\index{italiano@\textsf{italiano}|textbf}\xspace} +\newcommand{\Optitalianokw}{\textsf{italianokw}\index{italianokw@\textsf{italianokw}|textbf}\xspace} +\newcommand{\Optslovak}{\textsf{slovak}\index{slovak@\textsf{slovak}|textbf}\xspace} +\newcommand{\Optslovakkw}{\textsf{slovakkw}\index{slovakkw@\textsf{slovakkw}|textbf}\xspace} +\newcommand{\Optturkish}{\textsf{turkish}\index{turkish@\textsf{turkish}|textbf}\xspace} +\newcommand{\Optturkishkw}{\textsf{turkishkw}\index{turkishkw@\textsf{turkishkw}|textbf}\xspace} +\newcommand{\Optboxed}{\textsf{boxed}\index{boxed@\textsf{boxed}|textbf}\xspace} +\newcommand{\Optboxruled}{\textsf{boxruled}\index{boxruled@\textsf{boxruled}|textbf}\xspace} +\newcommand{\Optruled}{\textsf{ruled}\index{ruled@\textsf{ruled}|textbf}\xspace} +\newcommand{\Opttworuled}{\textsf{tworuled}\index{tworuled@\textsf{tworuled}|textbf}\xspace} +\newcommand{\Optalgoruled}{\textsf{algoruled}\index{algoruled@\textsf{algoruled}|textbf}\xspace} +\newcommand{\Optplain}{\textsf{plain}\index{plain@\textsf{plain}|textbf}\xspace} +\newcommand{\Optlined}{\textsf{lined}\index{lined@\textsf{lined}|textbf}\xspace} +\newcommand{\Optvlined}{\textsf{vlined}\index{vlined@\textsf{vlined}|textbf}\xspace} +\newcommand{\Optnoline}{\textsf{noline}\index{noline@\textsf{noline}|textbf}\xspace} +\newcommand{\Optlinesnumbered}{\textsf{linesnumbered}\index{linesnumbered@\textsf{linesnumbered}|textbf}\xspace} +\newcommand{\Optlinesnumberedhidden}{\textsf{linesnumberedhidden}\index{linesnumberedhidden@\textsf{linesnumberedhidden}|textbf}\xspace} +\newcommand{\Optcommentsnumbered}{\textsf{commentsnumbered}\index{commentsnumbered@\textsf{commentsnumbered}|textbf}\xspace} +\newcommand{\Optinoutnumbered}{\textsf{inoutnumbered}\index{inoutnumbered@\textsf{inoutnumbered}|textbf}\xspace} +\newcommand{\Opttitlenumbered}{\textsf{titlenumbered}\index{titlenumbered@\textsf{titlenumbered}|textbf}\xspace} +\newcommand{\Opttitlenotnumbered}{\textsf{titlenotnumbered}\index{titlenotnumbered@\textsf{titlenotnumbered}|textbf}\xspace} +\newcommand{\Optresetcount}{\textsf{resetcount}\index{resetcount@\textsf{resetcount}|textbf}\xspace} +\newcommand{\Optnoresetcount}{\textsf{noresetcount}\index{noresetcount@\textsf{noresetcount}|textbf}\xspace} +\newcommand{\Optalgonl}{\textsf{algonl}\index{algonl@\textsf{algonl}|textbf}\xspace} +\newcommand{\Optlongend}{\textsf{longend}\index{longend@\textsf{longend}|textbf}\xspace} +\newcommand{\Optshortend}{\textsf{shortend}\index{shortend@\textsf{shortend}|textbf}\xspace} +\newcommand{\Optnoend}{\textsf{noend}\index{noend@\textsf{noend}|textbf}\xspace} +\newcommand{\Optfigure}{\textsf{figure}\index{figure@\textsf{figure}|textbf}\xspace} +\newcommand{\Optscright}{\textsf{scright}\index{scright@\textsf{scright}|textbf}\xspace} +\newcommand{\Optscleft}{\textsf{scleft}\index{scleft@\textsf{scleft}|textbf}\xspace} +\newcommand{\Optfillcomment}{\textsf{fillcomment}\index{fillcomment@\textsf{fillcomment}|textbf}\xspace} +\newcommand{\Optnofillcomment}{\textsf{nofillcomment}\index{nofillcomment@\textsf{nofillcomment}|textbf}\xspace} +\newcommand{\Optdotocloa}{\textsf{dotocloa}\index{dotocloa@\textsf{dotocloa}|textbf}\xspace} +\newcommand{\Optendfloat}{\textsf{endfloat}\index{endfloat@\textsf{endfloat}|textbf}\xspace} +\newcommand{\Optnorelsize}{\textsf{norelsize}\index{norelsize@\textsf{norelsize}|textbf}\xspace} +\newcommand{\Optonelanguage}{\textsf{onelanguage}\index{onelanguage@\textsf{onelanguage}|textbf}\xspace} +\newcommand{\Optrightnl}{\textsf{rightnl}\index{rightnl@\textsf{rightnl}|textbf}\xspace} +\newcommand{\Optprocnumbered}{\textsf{procnumbered}\index{procnumbered@\textsf{procnumbered}|textbf}\xspace} +\newcommand{\Optoldcommands}{\textsf{oldcommands}\index{oldcommands@\textsf{oldcommands}|textbf}\xspace} +\newcommand{\Optnokwfunc}{\textsf{nokwfunc}\index{nokwfunc@\textsf{nokwfunc}|textbf}\xspace} +\newcommand{\Optblockmarkers}{\textsf{displayblockmarkers}\index{displayblockmarkers@\textsf{displayblockmarkers}|textbf}\xspace} +\newcommand{\Optgroupmarkers}{\textsf{displaygroupmarkers}\index{displaygroupmarkers@\textsf{displaygroupmarkers}|textbf}\xspace} +\newcommand{\Optnoalgohanging}{\textsf{noalgohanging}\index{noalgohanging@\textsf{noalgohanging}|textbf}\xspace} +\newcommand{\Opthangingcomment}{\textsf{hangingcomment}\index{hangingcomment@\textsf{hangingcomment}|textbf}\xspace} +\newcommand{\Opthanginginout}{\textsf{opthanginginout}\index{opthanginginout@\textsf{opthanginginout}|textbf}\xspace} +% +%%% +\newcommand{\ExampleOfAlgo}[1]{% + \begin{minipage}{.4\textwidth}% + \verbatiminput{#1}% + \end{minipage}\hfill$\Longrightarrow$\hfill% + \begin{minipage}{.45\textwidth}% + \begin{algorithm}[H]% + \input{#1}% + \end{algorithm}% + \end{minipage}% +} +%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\algocfversion}{release 5.2} +\title{algorithm2e.sty --- package for algorithms\\ {\large\algocfversion}} +\author{(c) 1995-1997 Christophe Fiorio, Tu-Berlin, Germany\\ +(c) 1998-2017 Christophe Fiorio, LIRMM, Montpellier University, France\\ + Report bugs and comments to christophe.fiorio@umontpellier.fr\\ + algorithm2esty-annonce@lirmm.fr mailing list for announcements\\ + algorithm2esty-discussion@lirmm.fr mailing list for discussion\thanks{The author is very grateful + to David Carlisle, one of the authors of the LaTeX Companion book, for his advices} \thanks{Martin Blais for his + suggestions} \thanks{David A. Bader for his new option + \texttt{noend}} \thanks{Gilles Geeraerts for his new + command \texttt{SetKwIfElseIf}} \thanks{Ricardo Fukasawa for the portuguese keywords} \thanks{Christian Icking + for the german translation of keywords} + \thanks{Arnaud Giersch for his suggestions and corrections on SetKwComments} +\thanks{and the many users as Jean-Baptiste Rouquier + for their remarks} } \date{July 18 2017} + +\makeindex + +\begin{document} +\maketitle +\vspace{-0.5cm} + +\tableofcontents +\clearpage + +\section{Introduction} + +Algorithm2e is an environment for writing algorithms in \LaTeX2e{}. An algorithm is defined as a floating object +like figures. It provides macros that allow you to create different sorts of key words, thus a set of predefined +key words is given. You can also change the typography of the keywords. See \autoref{longexample} for two long +examples of algorithms written with this package. + + +You can subscribe to \texttt{algorithm2e-announce} mailing list to receive +announcements about revisions of the package and to +\texttt{algorithm2e-discussion} to discuss, send comments, +ask questions about the package. +\makeatletter +In order to subscribe to the mailing lists you have to send an email to +\texttt{sympa@lirmm.fr} with \texttt{subscribe algorithm2e-announce Firstname + Name} or\\\texttt{subscribe algorithm2e-discussion Firstname + Name} in the body of the message.\makeatother + +Changes from one release to the next are indicated in release notes at the beginning of the packages. For this +release (5.0), changes are indicated at the end of this document. + +\section{How to use it: abstract} + +You must set +\texttt{$\backslash$usepackage[\emph{options}]\{algorithm2e\}} before +\texttt{$\backslash$begin\{document\}} command. The available options +are described in \autoref{sec_options}. + + +The optional arguments [Hhtbp] works like those of figure environment. The +\textbf{H} argument forces the algorithm to stay in place. If used, an algorithm +is no more a floating object. Caution: algorithms cannot be cut, so if there is +not enough place to put an algorithm with H option at a given spot, \LaTeX\ will +place a blank and put the algorithm on the following page. + + +Here is a quick example\footnote{For longer and more complexe examples + see \protect\autoref{longexample}}: + +\begin{verbatim} +\begin{algorithm}[H] + \SetAlgoLined + \KwData{this text} + \KwResult{how to write algorithm with \LaTeX2e } + + initialization\; + \While{not at end of this document}{ + read current\; + \eIf{understand}{ + go to next section\; + current section becomes this one\; + }{ + go back to the beginning of current section\; + } + } + \caption{How to write algorithms} +\end{algorithm} +\end{verbatim} + +which gives + +\begin{algorithm}[H] + \SetAlgoLined + \KwData{this text} + \KwResult{how to write algorithm with \LaTeX2e } + + initialization\; + \While{not at end of this document}{ + read current section\; + \eIf{understand}{ + go to next section\; + current section becomes this one\; + }{ + go back to the beginning of current section\; + } + } + \caption{How to write algorithms} +\end{algorithm} + +\textsc{Very Important} : each line \textbf{MUST} end with \almac{;} +only those with a macro beginning a block should not end with \almac{;}. +Note then that you can always use the \almac{;} command in math mode +to set a small space. + +The caption works as in a figure environment, except that it should be located at the end of the algorithm. It is +used by \almac{listofalgorithms} as a reference name for the list of algorithms. You can also use the title macro +given with the package, but this macro doesn't insert an entry in the list of algorithms. +%%%%%%%%%%%%% +\section{Two more detailed examples}\label{longexample} + + +The \autoref{algo_disjdecomp} and \autoref{IR} are written with this package. + +\subsection{Algorithm disjoint decomposition} + +Here we suppose that we have done: +\begin{verbatim} +\usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e} +\end{verbatim}\index{lined|textit,algonl|textit,boxed|textit} + +\noindent The \autoref{algo_disjdecomp} was written in \LaTeX2e code as presented next page. You can label lines, +and for example \autoref{forins} denotes the second \texttt{For} (see \almac{label} command in the example). Notice +also some ways of doing comments at lines~\ref{lt}, \ref{ut}, \ref{cmt} and \ref{lelse}. Star comment commands are +for comment on lines of code, else comment is a line by itself as at \autoref{cmt}. The different option in star +comments defines if it is left (\texttt{l} and \texttt{h}) or right justified (\texttt{r} and \texttt{f}). The +first ones (\texttt{l} and \texttt{r}) add $;$ at the end of line code, the second ones (\texttt{f} and \texttt{h}) +doesn't. These last are useful when used in side comment (introduced by \texttt{()}) of alternatives of loops keyword +commands. +\RestyleAlgo{boxed}\LinesNumbered\input{algorithm2e_exAlgoDisjdecomp.tex}\par +\vspace{-10ex}\noindent\fbox{% + \begin{minipage}[c]{\textwidth}% + \verbatiminput{algorithm2e_exAlgoDisjdecomp.tex}% + \end{minipage}\label{code:algodisjdecom}% +}% + +\clearpage +\subsection{Algorithm: IntervalRestriction} +\def\theAlgoLine{\arabic{AlgoLine}} + +Here we suppose we that have done: +\begin{verbatim} +\usepackage[ruled,vlined]{algorithm2e} +\end{verbatim} +\index{ruled|textit,vlined|textit} + +The \LaTeX2e code on next page gives \autoref{IR}. Here lines are not autonumbered but you can number them +individually with \almac{nl} command as for \autoref{InRes1} or \autoref{InRes2}. You even can set your own +reference with \almac{nlset} command and get back this reference by simply using classical \almac{ref}. For +example \texttt{$\backslash$ref\{InResR\}} gives \ref{InResR}.\par +{% +\RestyleAlgo{algoruled}\SetAlgoVlined\LinesNotNumbered\input{algorithm2e_exIR.tex} +\noindent\fbox{% + \begin{minipage}[c]{\textwidth}% + \verbatiminput{algorithm2e_exIR.tex}% + \end{minipage}\label{code:algoIR}% +}}% +\par +\clearpage + +%%%%%%%%%%%%% +\section{Genericity and example of languages} + +In this section, we will try to show you main macros and how you can use this package to +suit your need. Based on one example using most popular algorithms expressions, we will +show you how it can be configured to be display in pseudo-code, in python or in C. + +The following code shows how is typeset the generic example we'll use in this section:\par +{% +\noindent\fbox{% + \begin{minipage}[c]{\textwidth}% + \verbatiminput{algorithm2e_exgeneric}% + \end{minipage}\label{code:exgeneric}% +}}% +\par\medskip +To handle \texttt{if} condition, use a macro to be abble to change it according to +language syntax, in particular we will change it for python-style and c-style. We also +define a function to write algorithm as a recursive function. These macros are defined as:\vspace{-1.5ex} +\begin{verbatim} +\newcommand{\forcond}{$i=0$ \KwTo $n$} +\SetKwFunction{FRecurs}{FnRecursive}% +\end{verbatim} + +The \autoref{algo:pseudocode} shows how algorithm is displayed in pseudo-code with default +behaviour and options \texttt{boxed}, \texttt{commentsnumbered} and \texttt{longend} +set. Note that by default, lines are used to show block of code. Note also that +\texttt{longend} option makes package use special \emph{end} keyword for each +command\footnote{Default behaviour uses \emph{short end} keywords, it means typeseting only + \emph{end}.}. +\SetKwProg{Fn}{Function}{}{end}\SetKwFunction{FRecurs}{FnRecursive}% +\newcommand{\forcond}{$i=0$ \KwTo $n$} +\begin{algorithm}\SetAlgoLongEnd + \caption{Generic example with most classical expressions derived in pseudo-code}% + \label{algo:pseudocode} + \input{algorithm2e_exgeneric} +\end{algorithm} + +The \autoref{algo:pseudocodeblock} shows how you can have each block tagged with begin-end +keywords. This is done by using automatic block +display (new feature since release 5.0). To achieve this display, we only add following +macros at start of the algorithm:\vspace{-1.5ex} +\begin{verbatim} +\AlgoDisplayBlockMarkers\SetAlgoBlockMarkers{begin}{end}% +\SetAlgoNoEnd +\end{verbatim} +\vspace{-1.5ex}First one tells package to display blocks with keyword markers. Note that +the definition of block markers are the one by default. Last macro remove end keywords of +commands to avoid a double end (the one of block marker and the one of command). +\begin{algorithm}\AlgoDisplayBlockMarkers\SetAlgoNoEnd\SetAlgoBlockMarkers{begin}{end} + \caption{Generic example in pseudo-code with begin-end block set}\label{algo:pseudocodeblock} + \input{algorithm2e_exgeneric} +\end{algorithm} + +Not that since release 5.1, you can also have block tagged for one line display. The +\autoref{algo:pseudocodegroup} is based on \autoref{algo:pseudocodeblock} but uses ``l macros'' as e.g. \texttt{$\backslash$lIf} to display command on one line ; \texttt{$\backslash$AlgoDisplayGroupMarkers} is added to have also block tagged with markers defined by \texttt{$\backslash$SetAlgoBlockMarkers}. To achieve this display, we replace preamble of \autoref{algo:pseudocodeblock} by:\vspace{-1.5ex} +\begin{verbatim} + \AlgoDisplayBlockMarkers\AlgoDisplayGroupMarkers\SetAlgoBlockMarkers{ \{}{ \}\ }% + \SetAlgoNoEnd\SetAlgoNoLine +\end{verbatim} +\begin{algorithm} + \AlgoDisplayBlockMarkers\AlgoDisplayGroupMarkers\SetAlgoBlockMarkers{ \{}{ \}\ }% + \SetAlgoNoEnd\SetAlgoNoLine + \caption{\autoref{algo:pseudocodeblock} with \{\} block set even for one line command.}\label{algo:pseudocodegroup} + \input{algorithm2e_exgeneric2} +\end{algorithm} +\medskip + +The \autoref{algo:pythoncodeblock} shows how algorithm looks like with a python-style +syntax. To achieve this display, we need to make following changes before the algorithm:\vspace{-1.5ex} +\begin{verbatim} +\SetStartEndCondition{ }{}{}% +\SetKwProg{Fn}{def}{\string:}{} +\SetKwFunction{Range}{range}%% +\SetKw{KwTo}{in}\SetKwFor{For}{for}{\string:}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{:}{elif}{else:}{}% +\SetKwFor{While}{while}{:}{fintq}% +\renewcommand{\forcond}{$i$ \KwTo\Range{$n$}} +\AlgoDontDisplayBlockMarkers\SetAlgoNoEnd\SetAlgoNoLine% +\end{verbatim} +\vspace{-1.5ex}\texttt{SetStartEndCondition} is used to display alternatives and loops +conditions according to python syntax: it means a space before condition, and no space +after since ':' marks end of condition. Functions are defined with \emph{def} in python, +so we redefine \texttt{$\backslash$Fn} macro. \texttt{Range} is a new macro for +\emph{range} python function. Next are redefined \emph{For}, \emph{If} and \emph{While} +commands accordingly to python syntax. Note that we do nothing for \emph{repeat-until} +command since it doesn't exist in python. For condition is redefined to match python +behaviour. At last we tell package to not display block, to +not display end keyword and to not print line according to python syntax.% +\renewcommand{\forcond}{$i$ \KwTo\Range{$n$}} +\begin{algorithm} \AlgoDontDisplayBlockMarkers\SetAlgoNoEnd\SetAlgoNoLine% +\SetStartEndCondition{ }{}{}% +\SetKwProg{Fn}{def}{\string:}{}% +\SetKw{KwTo}{in}\SetKwFunction{Range}{range}% +\SetKwFor{For}{for}{\string:}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{:}{elif}{else:}{}% +\SetKwFor{While}{while}{:}{fintq}% + \caption{Generic example in python-style like syntax}\label{algo:pythoncodeblock} + \input{algorithm2e_exgeneric} +\end{algorithm} + + The \autoref{algo:ccodeblock} shows how algorithm looks like with a c-style +syntax. To achieve this display, we need to make following changes before the algorithm:\vspace{-1.5ex} +\begin{verbatim} +\SetStartEndCondition{ (}{)}{)}\SetAlgoBlockMarkers{\{}{\}}% +\SetKwProg{Fn}{}{}{}\SetKwFunction{FRecurs}{void FnRecursive}% +\SetKwFor{For}{for}{}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{}{elif}{else}{}% +\SetKwFor{While}{while}{}{}% +\SetKwRepeat{Repeat}{repeat}{until}% +\AlgoDisplayBlockMarkers\SetAlgoNoLine% +\end{verbatim} +\vspace{-1.5ex} \texttt{SetStartEndCondition} set braces around conditions like in C. We +want that each block is marked with \{ at start and \} at end, so we set it thanks to +\texttt{$\backslash$SetAlgoBlockMarkers} macro. \texttt{$\backslash$Fn} is redefined with +no keyword since in C, name of function defines it. Then we redefin \texttt{FnRecursive} +with its type. Next, \emph{For}, \emph{If}, \emph{While} and \emph{Repeat} are redefined +accordingly to C syntax. At last, we tell the package to display block markers. +\SetKwFunction{FRecurs}{void FnRecursive}% +\begin{algorithm}\AlgoDisplayBlockMarkers\SetAlgoNoLine% +\SetStartEndCondition{ (}{)}{)}\SetAlgoBlockMarkers{\{}{\}}% +\SetKwProg{Fn}{}{}{}% +\SetKwFor{For}{for}{}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{}{elif}{else}{}% +\SetKwFor{While}{while}{}{}% +\SetKwRepeat{Repeat}{repeat}{until}% + \caption{Generic example in c-style like syntax}\label{algo:ccodeblock} + \input{algorithm2e_exgeneric} +\end{algorithm} + +The \autoref{algo:ccodeblockcf} shows how algorithm looks like with a c-style +syntax and a more compact way to mark blocks. To achieve this display, we need to make following changes before the algorithm:\vspace{-1.5ex} +\begin{verbatim} +\SetStartEndCondition{ (}{)}{)}\SetAlgoBlockMarkers{}{\}}% +\SetKwProg{Fn}{}{\{}{}\SetKwFunction{FRecurs}{void FnRecursive}% +\SetKwFor{For}{for}{\{}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{\{}{elif}{else\{}{}% +\SetKwFor{While}{while}{\{}{}% +\SetKwRepeat{Repeat}{repeat\{}{until}% +\AlgoDisplayBlockMarkers\SetAlgoNoLine% +\end{verbatim} +\vspace{-1.5ex} If you look at \autoref{algo:pseudocode}, you can see that some command +doesn't put a end. For example, it is a case for a \emph{if} followed by an \emph{else}, +same thing for a \emph{else if}. In C, there is always an end marker. So, to achieve our +goal we need to use end marker of blocks. But we don't want displaying begin marker as in +\autoref{algo:pseudocodeblock} or \autoref{algo:ccodeblock}. If begin block marker is set to +empty, then nothing is written (especially not a blank line). So we tell package to use +block markers with an empty marker for begin and a \} for end. Now we have to tell package +to write a \{ on the same line as commands. This is achieve by redefining \emph{If}, +\emph{For}, \emph{While} and \emph{Repeat} command. +\begin{algorithm}\AlgoDisplayBlockMarkers\SetAlgoLongEnd\SetAlgoNoLine% +\SetStartEndCondition{ (}{)}{)}\SetAlgoBlockMarkers{}{\}}% +\SetKwProg{Fn}{}{\{}{}% +\SetKwFor{For}{for}{\{}{}% +\SetKwIF{If}{ElseIf}{Else}{if}{\{}{elif}{else\{}{}% +\SetKwFor{While}{while}{\{}{}% +\SetKwRepeat{Repeat}{repeat\{}{until}% + \caption{Generic example in c-style like syntax with compact block}\label{algo:ccodeblockcf} + \input{algorithm2e_exgeneric} +\end{algorithm} + + +%%%%%%%%%%%%% +\section{Compatibility issues} + +Compatibily with other packages improven by changing name of internal macros. Algorithm2e can now be used with +almost all package, as \texttt{elsart}\index{elsart}, \texttt{hermes}\index{hermes}, +\texttt{arabtex}\index{arabtex} for example, if this last is loaded after algorithm2e package. So, at this time, +\algocfversion has few known compatibility problem with other packages. The packages or classes that are known to +be not compatible with \texttt{algorithm2e} package is: +\begin{itemize} +\item \texttt{ascelike}\index{ascelike} +\item \texttt{pstcol}\index{pstcol} +\end{itemize} +Nevertheless, when use with some packages, some of their options cannot be used, or you need to specify some +particular options (as \optalgoe to change name of environment if \texttt{algorithm} is already defined by the +class), either from \texttt{algorithm2e} package or from the other packages. +\begin{description} +\item[hyperref\index{hyperref}] if you want to compile in Pdf\LaTeX, you must not use \texttt{naturalnames} option. + \textbf{Beware} this has changed from release 3 where you should use it! +\item[article-hermes\index{article-hermes}] is not compatible with relsize used by \texttt{algorithm2e} package, so + you have to use \optnorelsize option to get algorithm works with \texttt{article-hermes} class. +\end{description} +Note also that, if you use packages changing the way references are printed, you must define labels of algorithm +\textbf{after} the caption to ensure a correct printing. You cannot use \almac{label} inside a caption without +errors. + +\medskip +From release $4.0$, some commands have been renamed to have consistent naming (CamlCase syntax) and old commands +are no more available. If you doesn't want to change your mind or use old latex files, you have to use +\Optoldcommands option to enable old commands back. Here are these commands: +\begin{itemize} +\item \almac{SetNoLine} becomes \almac{SetAlgoNoLine} +\item \almac{SetVline} becomes \almac{SetAlgoVlined} +\item \almac{Setvlineskip} becomes \almac{SetVlineSkip} +\item \almac{SetLine} becomes \almac{SetAlgoLined} +\item \almac{dontprintsemicolon} becomes \almac{DontPrintSemicolon} +\item \almac{printsemicolon} becomes \almac{PrintSemicolon} +\item \almac{incmargin} becomes \almac{IncMargin} +\item \almac{decmargin} becomes \almac{DecMargin} +\item \almac{setnlskip} becomes \almac{SetNlSkip} +\item \almac{Setnlskip} becomes \almac{SetNlSkip} +\item \almac{setalcapskip} becomes \almac{SetAlCapSkip} +\item \almac{setalcaphskip} becomes \almac{SetAlCapHSkip} +\item \almac{nlSty} becomes \almac{NlSty} +\item \almac{Setnlsty} becomes \almac{SetNlSty} +\item \almac{linesnumbered} becomes \almac{LinesNumbered} +\item \almac{linesnotnumbered} becomes \almac{LinesNotNumbered} +\item \almac{linesnumberedhidden} becomes \almac{LinesNumberedHidden} +\item \almac{showln} becomes \almac{ShowLn} +\item \almac{showlnlabel} becomes \almac{ShowLnLabel} +\item \almac{nocaptionofalgo} becomes \almac{NoCaptionOfAlgo} +\item \almac{restorecaptionofalgo} becomes \almac{RestoreCaptionOfAlgo} +\item \almac{restylealgo} becomes \almac{RestyleAlgo} +\item \almac{gIf} macros and so on do no more exist +\end{itemize} + +%%%%%%%%%%%%% +\section{Environments defined in the package\label{sec_envi}} + +This package provides 4 environments : +\begin{description} +\item[algorithm:] the main environment, the one you will used most of the + time. +\item[algorithm*:] same as the precedent, but used in a two columns text, puts + the algorithm across the two columns. +\item[procedure:] This environment works like algorithm environment but: + \begin{itemize} + \item the \texttt{ruled} (or \texttt{algoruled}) style is recommended. + \item the caption now writes \textbf{Procedure name...} + \item the syntax of the $\backslash$\texttt{caption} command is restricted as + follow: you MUST put a name followed by 2 braces like this + ``\emph{Name()}''. You can put arguments inside the braces and text after. + If no argument is given, the braces will be removed in the title. + \item label now puts the name (the text before the braces in the caption) of + the procedure or function as reference (not the number like a classic + algorithm environment). + \item name of the procedure or function set in caption is automatically defined as a KwFunction and so can be + used as a macro. For example, if inside a procedure environment you set \almacp{caption}{myproc()}, you can use + $\backslash$\texttt{myproc} macro in you main text. Beware that the macro is only defined after the + \almac{caption}! + \item \optnokwfunc unable the feature described above in function and procedure environment. Useful if you use + name of procedure or function that cannot be a command name as a math display for example. + \end{itemize} +\item[procedure*:] same as the precedent, but used in a two columns text outs the + procedure across the two columns. +\item[function:] as the precedent but with \textbf{Function} instead of + procedure in the title. +\item[function*:] same as the precedent, but used in a two columns text outs the + function across the two columns. +\end{description} + +If you don't like algorithm or look for something else, you can change the name of algorithm by using command +below: +\begin{description} +\item[\almacppp{SetAlgorithmName}{algorithmname}{algorithmautorefname}{list of algorithms name}] which redefines + name of the algorithms and the sentence list of algorithms. Example:\\\noindent\almacpp{SetAlgorithmName}{Protocol}{List of + protocols} if you prefer protocol than algorithm. Second argument is the name that \almac{autoref}, from + \texttt{hyperref}\index{hyperref} package, will use. +\end{description} +The same exists for procedure and function environment, the difference is that list of algorithms is not change and +keep its original name: +\begin{description} +\item[\Almacpp{SetAlgoProcName}{aname}{anautorefname}] sets the name of Procedure printed by procedure environment + (the environment prints Procedure by default). Second argument is the name that \almac{autoref}, from + \texttt{hyperref}\index{hyperref} package, will use. +\item[\Almacpp{SetAlgoFuncName}{aname}{anautorefname}] sets the name of Function printed by procedure environment + (the environment prints Function by default). Second argument is the name that \almac{autoref}, from + \texttt{hyperref}\index{hyperref} package, will use. +\end{description} + +%%%%%%%%%%%%% + +\section{The options of the package\label{sec_options}} + + +%-------------------------------------------------------------------------- +\subsection{language option} +\label{sec:option:language} + +There are predefined keywords in different languages already defined (see +section~\ref{sec_lang} or in the .sty file) that you can activate by using appropriate option. You +can also activate these localized keywords by using same option followed by \emph{kw}. In +this case, you keep all localized keywords already defined and add the new ones. Note that +this option is not robust, and there are macros in differents language that are the +same. In this case, last defined is the one staying. But this allow you to have +predefined keywords in multiple languages. + +\begin{description} +\item[\Optenglish:] the default. +\item[\Optfrench:] to have French keywords, for example \textsl{algorithme\ :} instead of \textsl{algorithm:}. +\item[\Optfrenchkw:] to add French keywords definition. +\item[\Optgerman:] to have German keywords, for example \textsl{Prozedur\ :} instead of \textsl{procedure:}. \medskip +\item[\Optgermankw:] to add German keywords definition. +\item[\Optngerman:] German option as babel +\item[\Optspanish:] to have Spanish keywords, for example \textsl{Algoritmo:} instead of \textsl{algorithm:}. \medskip +\item[\Optspanishkw:] to add Spanish keywords definition. +\item[\Optitaliano:] to have Italian keywords, for example \textsl{Algoritmo:} instead of \textsl{algorithm:}. \medskip +\item[\Optitalianokw:] to add Italian keywords definition. +\item[\Optportugues:] to have Portuguese keywords, for example \textsl{Algoritmo:} instead of \textsl{algorithm:}. \medskip +\item[\Optportugueskw:] to add Portuguese keywords definition. +\item[\Optcroatian:] to have Croatian keywords, for example \textsl{Algoritam:} instead of \textsl{algorithm:}. \medskip +\item[\Optcroatiankw:] to add Croatian keywords definition. +\item[\Optczech:] to have Czech keywords, for example \textsl{Algoritmus:} instead of \textsl{algorithm:}. +\item[\Optczechkw:] to add Czech keywords definition. +\item[\Optturkish:] to have Turkish keywords, for example \textsl{Algoritma:} instead of \textsl{algorithm:}. +\item[\Optturkishkw:] to add Turkish keywords definition. +\item[\Optczech:] to have for example \textsl{Algoritmus:} instead of \textsl{algorithm:}. +\item[\Optczechkw:] to add Czech keywords definition. +\item[\Optonelanguage:] allows, if using standard keywords listed below, to switch from one language to another + without changing keywords by using appropriate language option: + \begin{itemize} + \item \texttt{KwIn, KwOut, KwData, KwResult} + \item \texttt{KwTo KwFrom} + \item \texttt{KwRet, Return} + \item \texttt{Begin} + \item \texttt{Repeat} + \item \texttt{If, ElseIf, Else} + \item \texttt{Switch, Case, Other} + \item \texttt{For, ForPar, ForEach, ForAll, While} + \end{itemize} +\end{description} + +%-------------------------------------------------------------------------- +\subsection{compatibility issue} +\label{sec:option:compatibility} + +\begin{description} +\item[\optalgoe:] changes the name of environment algorithm into algorithm2e + and so allows to use the package with some journal style which already define + an algorithm environment. Changes also the command name for the list of + algorithms, it becomes \Almac{listofalgorithmes} +\item[\Optendfloat:] endfloat packages doesn't allow float environment inside other environment. So using it with + figure option of algorithm2e makes error. This option enables a new environment algoendfloat to be used instead + of algorithm environment that put algorithm at the end. algoendfloat environment make algorithm acting as + endfloat figures. This option load endfloat package, so it is required to have it. +\item[\Optnorelsize:] starting from this release (v4.00), algorithm2e package uses relsize package in order to get + relative size for lines numbers; but it seems that some rare classes (such as inform1.cls) are not compatible + with relsize; to have algorithm2e working, this option makes algorithm2e not to load relsize package and go back + to previous definition by using $\backslash$\texttt{scriptsize} font for lines numbers. +\item[\optslide:] require package color. To be used with slide class in order to have correct margins. +\item[\Optnokwfunc] disable the setting in \almac{KwFunction} of procedure's or function's name (see \autoref{sec_envi}) + of function and procedure environment. Useful if you use name of procedure or function that cannot be a command + name as a math display for example. +\end{description} + +%-------------------------------------------------------------------------- +\subsection{environment display and use} +\label{sec:option:envdisplay} + +%--------------------------------- +\subsubsection{boxed, ruled, plain environment} +\label{sec:option:envdisplay:box} + +\begin{description} +\item[\Optboxed :] to have algorithms enclosed in a box. +\item[\Optboxruled :] surround algorithm by a box, puts caption above and add a line after caption. +\item[\Optruled :] to have algorithms with a line at the top and the bottom. Note that the caption is not centered + under the algorithm anymore but is set at the beginning of the algorithm. +\item[\Optalgoruled :] as above but with extra spaces after the rules. +\item[\Opttworuled:] tworuled acts like ruled but doesn't put a line after the title. +\item[\Optplain :] the default, with no feature.\par +\end{description} + +%--------------------------------- +\subsubsection{algorithm numbering} +\label{sec:option:envdisplay:numbers} + +\begin{description} +\item[\optalgochapter :] algorithms are numbered within chapter numbers. +\item[\optalgosection :] (default) algorithms are numbered within section numbers. +\item[\optalgopart :] algorithms are numbered within part numbers.\par\medskip +\item[\Optprocnumbered:] makes the procedure and function to be numbered as algorithm. +\end{description} + +%--------------------------------- +\subsubsection{figure and toc} +\label{sec:option:envdisplay:figuretoc} + +\begin{description} +\item[\Optfigure :] algorithms are put in classical figures and so are numbered as + figures and putted in the $\backslash$\texttt{listoffigures}.\par +\item[\Optdotocloa] adds an entry in the toc for the list of algorithms. This option loads package + \texttt{tocbibind} if not already done and so list of figures and list of tables are also added in + the toc. If you want to control which ones of the lists will be added in the toc, please load + package \texttt{tocbibind} before package algorithm and give it the options you want. +\end{description} + +%-------------------------------------------------------------------------- +\subsection{code typesetting} +\label{sec:option:algodisplay} + +\subsubsection{indentation of long statements} +\label{sec:option:algohanging} + +\begin{description} +\item[\Optnoalgohanging] By default, long statement are indented on subsequent lines (see + to know how to control length of indentation); with this option you get old behavior and + lines are no more indented. +\item[\Opthangingcomment] Comment that are alone on a line (not side comment) are not + driven by algorithm hanging: subsequent lines of long comments are indented according to + width of start comment marker. With this option, comment are indented like normal + statement. +\item[\Opthanginginout] As for comment, by default, in/out keywords and input keywords + (defined by \texttt{$\backslash$SetKwInOut} or \texttt{$\backslash$SetKwInput}) are not + indented by algorithm hangindent. They are indented according to width of input + keyword. If you want that these keywords acts like other statements, use this option. +\end{description} + + +%--------------------------------- +\subsubsection{blocks display} +\label{sec:option:algodisplay:blocks} + +\paragraph{lines} +\label{sec:option:algodisplay:blocks:lines} + +\begin{description} +\item[\Optlined:] \almac{SetAlgoLined} becomes the default, see + \autoref{sec_styleoptions} for explanations about the + \almac{SetAlgoLined} macros. +\item[\Optvlined:] \almac{SetAlgoVlined} becomes the default, see + \autoref{sec_styleoptions} for explanations about the + \almac{SetAlgoVlined} macros. +\item[\Optnoline:] \almac{SetNoline} becomes the default, see + \autoref{sec_styleoptions} for explanations about the + \almac{SetNoline} macros. +\end{description} + +\paragraph{block markers} +\label{sec:option:algodisplay:blocks:markers} + +\begin{description} +\item[\Optblockmarkers] \almac{AlgoDisplayBlockMarkers} becomes the default, see \autoref{sec_styleoptions} + for explanations about the \almac{AlgoDisplayBlockMarkers} macro. +\item[\Optgroupmarkers] \almac{AlgoDisplayGroupMarkers} becomes the default, see \autoref{sec_styleoptions} + for explanations about the \almac{AlgoDisplayGroupMarkers} macro. +\end{description} + +%--------------------------------- +\subsubsection{end keywords} +\label{sec:option:algodisplay:endkeywords} + +\begin{description} +\item[\Optlongend] the end keyword are longer and different for + each macro. For example \emph{endif} for a if-then-else macro. +\item[\Optshortend] the ``end keyword'' of the macros is just + \emph{end} (default). +\item[\Optnoend] the ``end keyword'' of the macros is not printed. +\end{description} + +%--------------------------------- +\subsubsection{comments} +\label{sec:option:algodisplay:comments} + +\begin{description} +\item[\Optscright (default)] right justified side comments (side comments are flushed to the right) +\item[\Optscleft] left justified side comments (side comments are put right after the code line) +\item[\Optfillcomment (default)] end mark of comment is flushed to the right so comments fill all + the width of text +\item[\Optnofillcomment] end mark of comment is put right after the comment +\end{description} + +%--------------------------------- +\subsubsection{lines numbers} +\label{sec:optin:algodisplay:linenumber} + +\begin{description} +\item[\Optlinesnumbered:] lines of the algorithms are numbered except for + comments and input/output (KwInput and KwInOut). You must use \almacp{nllabel}{label} + to label thoses lines. +\item[\Optlinesnumberedhidden:] lines of the algorithms are numbered as \optlinesnumbered but + numbers are not shown. \almac{ShowLn} and \almacp{ShowLnLabel}{label} show the number on line they are + put. +\item[\Optcommentsnumbered:] makes comments be numbered if numbering is active. +\item[\Optinoutnumbered:] makes data input/output be numbered if numbering is active. +\item[\Optrightnl:] put lines numbers to the right of the algorithm instead of + left.\par\medskip +\item[\Optresetcount] the line numbers are reset to 0 at the beginning of + each algorithm (by default). +\item[\Optnoresetcount] the contreverse of the precedent. To reset + the line counter to 0 do:\\ + \texttt{$\backslash$setcounter\{AlgoLine\}\{0\}} +\item[\Optalgonl] the line numbers will be prefixed with the number of the + current algorithm. \textbf{Take care} to set the caption of the + algorithm at the beginning of the environnement, else you will have + the precedent algorithm number as the current one. +\end{description} + +%--------------------------------- +\subsubsection{title of algorithms} +\label{sec:option:algodisplay:title} + +\begin{description} +\item[\Opttitlenumbered :] \almacp{TitleOfAlgo}{title} + prints \textsl{Algorithm n: thetitle} where \emph{n} is the counter + of the algo.\\ + \textbf{Beware}: \almac{TitleOfAlgo} don't insert an entry in the + list of algorithms. So do not use \almac{TitleOfAlgo} with a caption. + Both increment the counter of the algorithms. +\item[\Opttitlenotnumbered (default)] the macro + \texttt{$\backslash$TitleOfAlgo\{title\}} doesn't number the algorithm. +\end{description} + + +%%%%%%%%%%%%% + +\section{Typesetting} + +There are eight text types in an algorithm environment: +\begin{enumerate} +\item The keywords (\textbf{Kw}): Macros which usually indicate words of the language. Some are predefined and + given with \emph{the algorithm package}. + + The user can define his own language keywords by using the different macros presented in + \autoref{sec_deflanguage} (see below for a short, non exhaustive list). He can also define simple keywords with + the \almacpp{SetKw}{Kw}{thetext} macro. +\item The Functions: (\textbf{Func}) Macros defined by the user which denote local functions or other algorithms + defined in the text. (See also function environment at~\autoref{sec_envi}, which defines not only function + keyword but algorithm of the function. + + They are defined using \almacpp{SetKwFunction}{KwFn}{Fn} where $\backslash$KwFn will be the macro and + \FuncSty{Fn} the text printed. +\item The Arguments (\textbf{Arg}): The arguments of the \emph{Kw} or + \emph{Func} macros. +\item The procedure and function name environment style (\almac{ProcNameSty} and \almac{ProcNameFnt}): The type + style of the caption of \emph{procedure} and \emph{function} environment. +\item The arguments of procedure and function environments style (\almac{ProcArgSty} and \almac{ProcArgFnt}): the + type style of the argument of \emph{procedure} and \emph{function} environments. +\item Data (\textbf{Data}): A type of text different from the default. You can use it as you want, and can be + useful for example to emphasize a Data structure or denotes some important variables. + + They are defined with the help of the \almacpp{SetKwData}{KwDat}{data} macro, where $\backslash$KwDat will be the + macro and \DataSty{data} the text printed. +\item Block markers : \textbf{BlockMarkersSty} is style of keywords that are print at begin + and end of block when \optblockmarkers and/or \optgroupmarkers option are set, or \almac{AlgoDisplayBlockMarkers} and/or \almac{AlgoDisplaygroupMarkers} macro are used. By default, \almac{BlockMarkersSty} is set to \almac{KwSty}. +\item The text (the default): All the remaining text of the algorithm. +\end{enumerate} + + +%%%%%%%%%%%%% + +\section{Commands provided with the package} + +Note that if you define macros outside the algorithm environment they are available in all the document and, in +particular, you can use them inside all algorithms without redefining them. Be careful you can't use macros +beginning a block outside an algorithm environment. + +%---------- +\subsection{global code typesetting commands}\label{sec:basiccommands} + +\begin{description} +\item[\Almac{;}] marks the end of a line. \textbf{Don't forget it !}. By + default, it prints a `;'. You can change this with \almac{DontPrintSemicolon}. +\item[\Almac{DontPrintSemicolon}] the `;' are no more printed at the + end of each line. +\item[\Almac{PrintSemicolon}] prints a `; ' at the end of each + line (by default) +\item[\Almac{BlankLine}] prints a blank line. In fact puts a + vertical space of one \texttt{ex}. +\item[\Almac{Indp}] indents plus $\rightarrow$ the text is shifted to the right. +\item[\Almac{Indm}] indents minus $\rightarrow$ the text is shifted to the left. +\item[\Almacppp{SetStartEndCondition}{typo1}{typo2}{typo3}] which sets typo around + condition in \texttt{For}, \texttt{If}, \texttt{Switch}, \texttt{Case} and + \texttt{Repeat} macros. First two are used around \texttt{For}, \texttt{If}, + \texttt{Switch}, \texttt{Case} conditions, First and third are used for \texttt{Repeat} + condition. Default definition is:\\ \verb+\SetStartEndCondition{ }{ }{}+.\\ + A common alternative is \verb+\SetStartEndCondition{ (}{) }{)}+.\\ + It can also be used to remove space around condition, for example if you want python style + commands: \verb+\SetStartEndCondition{ }{}{}+ and \verb+\SetKwFor{For}{for}{:}{}+ +\item[\Almac{AlgoDisplayBlockMarkers}] that prints begin and end markers at the start and end + of all block. These begin and end keywords could be specified by using + \almacpp{SetAlgoBlockMarkers{begin keywords}{end keywords}} command. By default, these + keywords are not printed but \emph{begin} and \emph{end} are default keywords used if + \verb+\AlgoDisplayBlockMarkers+ is called. +\item[\Almac{AlgoDisplayGroupMarkers}] is related to \almac{AlgoDisplayBlockMarkers} and do the same but for command that are displayed on a single line. +\end{description} + +%---------- +\subsection{algorithm environment, caption, list of algorithms, ...}\label{sec:titlemacros} + +\subsubsection{caption, title and changind reference of algorithms} +\label{sec:captionmacros} + +Algorithm environment are float environment. So you can use classical \almac{caption}, \almacp{listofalgorithms}, +\Almac{label}. If you want a title but not a caption (for example to not add an enter in the list of algorithm) +you have \almacp{TitleOfAlgo}. And if you want to name your algorithm and not number it, you can change the +reference of it by using \almacp{SetAlgoRefName}{ref}: + +\begin{description} +\item[\Almacp{caption}{thetitle}] works as classical caption of figures. It inserts an entry in the list of + algorithms. Should be the standard way to put title of algorithms. +\item[\Almacp{TitleOfAlgo}{thetitle}] prints: ``Algorithm \no: thetitle'' in the typography and size defined by + \almac{SetTitleSty}. Puts a vertical space below.\\ + Beware: \almac{TitleOfAlgo} doesn't insert an entry in the list of algorithms. So don't use \almac{TitleOfAlgo} + with \almac{caption}. Both increment the counter of the algorithms.\\ + {\small note:\emph{with the \optfrench option prints \emph{Algorithme \no :}}} +\item[\Almac{listofalgorithms}] inserts the list of all algorithms + having a \emph{caption}. +\item[\Almacp{SetAlgoRefName}{ref}] which changes the default ref (number of the algorithm) by the name given in + parameter. For example \almacp{SetAlgoRefName}{QXY} sets reference of the algorithm to \texttt{QXY}. If you label + your algorithm and reference it, you will get \texttt{QXY}. On the same manner, entry in the list of algorithm + will name it \texttt{QXY}. +\item[\Almacp{SetAlgoRefRelativeSize}{relative integer}] which sets the output size of reference in list of + algorithms for references set by \almac{SetAlgoRefName}. The default is \almacp{SetAlgoRefRelativeSize}{-2}. +\end{description} + +\subsubsection{setting style and layout of algorithm, caption and title} +\label{sec:captionstyle} + +The following commands help you to define the style and the layout of the caption: +\begin{description} +\item[\almacp{SetAlgoCaptionSeparator}{sep}] which sets the separator between title of algorithms (\textbf{Algorithm + 1}) and the name of the algorithm. By default it's ':' and caption looks like "\textbf{Algorithm 2: name}" but now you + can change it by using for example \SetAlgoCaptionSeparator{.} which will give + "\textbf{Algorithm 3. name}". +\item[\Almacp{SetCustomAlgoRuledWidth}{length}] set a custom ruled width of ruled and + algoruled options ; note that by the moment you use this macro, rules will have this + fixed length: this can cause strange behavior in multicolumn mode or other layout that + change the line width. +\item[\Almac{AlCapSkip}] is the dimension of the distance between algorithm body and caption in + \emph{plain} and \emph{boxed} mode. You can change by hands or by using \almacp{SetAlCapSkip}{0ex}. +\item[\Almacp{SetAlCapSkip}{length}] sets the lenght of \almac{AlCapSkip}) dimension between + algorithm body and caption. +\item[\Almacp{SetAlCapHSkip}{length}] sets the horizontal skip before Algorithm: in caption when used in ruled algorithm. +\item[\Almacpp{SetTitleSty}{type style}{type size}] sets the + typography and size of the titles defined with the macro + \almacp{TitleOfAlgo}{} (not with $\backslash$caption). +\item[\Almac{NoCaptionOfAlgo}] doesn't print Algorithm and its number + in the caption. This macros is \textbf{ONLY} active for + \emph{``\optalgoruled''} or \emph{``\optruled''} algorithms and for + the next algorithm. For example, it is useful when the algorithm + just describes a function and you only want to display the name of + the function in the caption. +\item[\Almac{RestoreCaptionOfAlgo}] restores correct captions that was + corrupted by a \almac{NoCaptionOfAlgo} macro. +\item[\Almacp{SetAlgoCaptionLayout}{style}] sets global style of the caption; style must be the name of a macro taking one + argument (the text of the caption). Examples below show how to use it: + \begin{itemize} + \item \almacp{SetAlgoCaptionLayout}{centerline} to have centered caption; + \item \almacp{SetAlgoCaptionLayout}{textbf} to have bold caption. + \end{itemize} + If you want to apply two styles in the same time, such as centered bold, you have to define you own macro and + then use \almac{SetAlgoCaptionLayout} with its name. \almac{AlCapFnt} and \almac{AlCapNameFnt} can change the + font used in caption, beware of interactions between this three commands. +\end{description} + +Note that two length control the layout of ruled, algoruled, boxruled algorithms +caption. \Almac{interspacetitleruled} and \Almac{interspacetitleboxruled} are described \autoref{sec_styleoptions}. + +%---------- +\subsection{line numbering}\label{sec:linenumbering} + +\subsubsection{labelling and numbering lines} +\label{sec:refline} + +\texttt{AlgoLine} is the counter used to number the lines. It's a standard counter, so \LaTeX commands works with +it. + +\optlinesnumbered, \optlinesnumberedhidden and \optcommentsnumbered (see above \autoref{sec_options}) are the +options controlling auto-numbering of lines. You can also control this feature manually and precisely with the +following commands: +\begin{description} +\item[\Almac{LinesNumbered}] makes lines of the following algorithms be auto-numbered. This command corresponds to + \optlinesnumbered option. +\item[\Almac{LinesNumberedHidden}] makes lines of the following algorithms be auto-numbered, but numbers stay + hidden. You have to use \almac{ShowLn} and \almac{ShowLnLabel} to see them. This command corresponds to + \optlinesnumberedhidden option. +\item[\Almac{LinesNotNumbered}] makes lines of the following algorithms no be auto-numbered. +\item[\Almacp{nllabel}{label}] macro for labelling lines when auto-numbering is active. +\item[\Almac{nl}] numbers the line: must \textsc{begin} the line. You can use \almac{label} to label the line and + reference it further. +\item[\Almacp{lnl}{label}] numbers and labels the line : must \textsc{begin} the line. Do a + \textbf{Beware} this has changed from release 3\almac{nl}\almacp{label}{label} in one time. Prefer to use a + classical \almac{label} as it is more readable. +\item[\Almacp{nlset}{text}] works as \almac{nl} except that the additional argument is the text to put at the + beginning of the line. This text becomes the reference if you label it and \almac{ref} will print it instead of + classical number. +\item[\almacpp{lnlset}{text}{label}] works for \almac{nlset} as \almac{lnl} for \almac{nl}. Prefer to use a + classical \almac{label} as it is more readable. +\item[\Almac{ShowLn}] shows number of the line when \optlinesnumberedhidden is activated. +\item[\Almacp{ShowLn}{label}] same as precedent but with a label. Prefer to use \almac{ShowLn} with a classical + \almac{label}. +\end{description} + +\subsubsection{setting style of lines numbers} +\label{sec:linestyle} + +The following command allows you to change the way line numbers are printed: +\begin{description} +\item[\Almacppp{SetNlSty}{$<$font$>$}{$<$txt before$>$}{$<$txt after$>$}] defines how to print line numbers:\\ + will print \{$<$font$>$ $<$txt bef$>$ thelinenumber $<$txt aft$>$\}. \\ + By default \almacppp{SetNlSty}{textbf}{}{}. +\item[\Almacp{SetNlSkip}{length}] sets the value of the space between the line numbers and the text, by default + 1em. +\item[\Almacp{SetAlgoNLRelativeSize}{number}] sets the relative size of line numbers. By default, line numbers are + two size smaller than algorithm text. Use this macro to change this behavior. For example, + \almacp{SetAlgoNlRelativeSize}{$0$} sets it to the same size, \almacp{SetAlgoNlRelativeSize}{$-1$} to one size + smaller and \almacp{SetAlgoNlRelativeSize}{$1$} to one size bigger. +\end{description} +Example below shows use of these macros:\par\smallskip\noindent% +{\RestyleAlgo{tworuled}\ExampleOfAlgo{algorithm2e_exnlsty.tex}} + +%---------- + +\subsection{math display} +\label{sec:mathdisplay} + +If you need to use math display to handle complex mathematics as matrix, using standard +$\backslash$[ $\backslash$] or \$\$ will not allow correct numbering and end line +management. If you don't need line numbers, there is no problem. If you want line numbers, +please use \Alenv{algomathdisplay} environment instead of $\backslash$[ $\backslash$] or +\$\$. It will work as standard math display but line spacing, line numbers, end line will +be managed correcly + +%---------- + +\subsection{standard styles}\label{sec:styles} + +\subsubsection{standard font shapes and styles} +\label{sec:fntsty} + +Almost every text in algorithm has his own style that can be customized. The following commands correspond to the +different styles used by the package. They can be customized by using corresponding ``\texttt{$\backslash$Set} +commands'' (see \autoref{sec:setfntsty}) +\begin{description} +\item[\Almac{AlFnt}] is used at the beginning of the body of algorithm in order to define the fonts + used for typesetting algorithms. You can use it elsewhere you want to typeset text as algorithm\\ + For example you can do \SetAlFnt{$\backslash$small$\backslash$sf} to have algorithms typeset in small sf font. + Default is nothing so algorithm is typeset as the text of the document. +\medskip + +\item[\Almacp{KwSty}{$<$text$>$}] sets $<$text$>$ in keyword type style. +\item[\Almacp{FuncSty}{$<$text$>$}] sets $<$text$>$ in function type style. +\item[\Almacp{FuncArgSty}{$<$text$>$}] sets $<$text$>$ in function argument type style. +\item[\Almacp{ProgSty}{$<$text$>$}] sets $<$text$>$ in programm (KwProg) type style. +\item[\Almacp{ArgSty}{$<$text$>$}] sets $<$text$>$ in argument type + style. +\item[\Almacp{DataSty}{$<$text$>$}] sets $<$text$>$ in data typography. +\item[\Almacp{CommentSty}{$<$text$>$}] sets $<$text$>$ in comment typography. +\item[\Almacp{NlSty}{$<$text$>$}] sets $<$text$>$ in number line typography. +\medskip + +\item[\Almacp{ProcNameSty}{$<$text$>$}] sets $<$text$>$ in procedure style of procedure and function environment (by + default the same as \almacp{AlCapSty}). (see \autoref{sec:captionsty} for more explanations and details) +\item[\Almacp{ProcFnt}{$<$text$>$}] sets $<$text$>$ in procedure typography of procedure and function environment (by + default the same as \almacp{AlCapFnt}). (see \autoref{sec:captionsty} for more explanations and details) +\item[\Almacp{ProcArgSty}{$<$text$>$}] sets $<$text$>$ in argument style of procedure and function environment + (by default the same as \almacp{AlCapNameSty}). (see \autoref{sec:captionsty} for more explanations and details) +\item[\Almacp{ProcArgFnt}{$<$text$>$}] sets $<$text$>$ in argument typography of procedure and function environment + (by default the same as \almacp{AlCapNameFnt}). (see \autoref{sec:captionsty} for more explanations and details) +\item[\Almacp{BlockMarkersSty}{$<$text$>$}] sets $<$text$>$ in block markers typography + (by default the same as \almacp{KwSty}) (see \autoref{sec_styleoptions} for more + explanations and details on block markers). +\end{description} + +\subsubsection{caption and title font style} +\label{sec:captionsty} + +\almac{AlCapSty}, \almac{AlCapNameSty}, \almac{AlCapFnt}, \almac{AlCapNameFnt}, \almac{ProcSty}, \almac{ProcFnt}, +\almac{ProcNameSty}, \almac{ProcNameFnt}, \almac{ProgArgSty}, \almac{ProgArgFnt} and corresponding +``\texttt{$\backslash$Set} commands'' (see \autoref{sec:setcaptionfntsty}) \almac{SetAlCapSty}, +\almac{SetAlCapNameSty}, \almac{SetAlCapFnt}, \almac{SetAlCapNameFnt}, \almac{SetProcSty}, \almac{SetProcFnt}, +\almac{SetProcNameSty}, \almac{SetProcNameFnt}, \almac{SetProgArgSty}, \almac{SetProgArgFnt} control the way +caption of algorithm and procedure/function environment are printed. + +\almac{AlCapSty} and \almac{AlCapFnt} are used to define style and font shape of ``\texttt{Algorithm \#:}'' in +caption. \almac{AlCapNameSty} and \almac{AlCapNameFnt} are used to define style and +font shape of the caption text. In fact a caption \almacp{caption}{my algorithm} is printed as follow :\medskip + +\noindent\almacp{AlCapSty}{\almac{AlCapFnt} Algorithm \#:}\almacp{AlCapNameSty}{\almac{AlCapNameFnt} my algorithm}. +\medskip + +By default, \almac{AlCapSty} is \texttt{textbf} and \almac{AlCapFnt} is nothing. \almac{AlCapNameSty} keeps text as +it is, and \almac{AlCapNameFnt} do nothing. + +\almac{ProcSty} and \almac{ProcFnt} are used to define style and font shape of ``\texttt{Procedure}'' in caption of +procedure and function environment. \almac{ProcNameSty} and \almac{ProcNameFnt} are used to define style and font +shape of the procedure or function name. \almac{ProcArgSty} and \almac{ProgArgFnt} are used to define style and +font shape of arguments in procedure/function environment. In fact a caption \almacp{caption}{Proc(int i)} of +procedure/function environment is printed as follow :\medskip + +\noindent\almacp{ProcSty}{\almac{ProcFnt} Procedure}\almacp{ProcNameSty}{\almac{ProcNameFnt} Proc(}\%\\% +\almacp{ProgArgSty}{\almac{ProgArgFnt} int i}\almacp{ProcNameSty}{\almac{ProcNameFnt} )}.\medskip + +By default, \almac{ProcSty} is \almac{AlCapSty} and \almac{ProcFnt} is \almac{AlCapFnt}. \almac{ProcNameSty} keeps text as +it is, and \almac{ProcNameFnt} do nothing. + +\begin{description} +\item[\Almacp{AlCapSty}{$<$text$>$}] sets $<$text$>$ in caption title typography, that is the same used, together + with \almac{AlCapFnt}, to print \texttt{Algorithm \#:}, more precisely it is printed as follow:\\ + \almacp{AlCapSty}{\almac{AlCapFnt} Algorithm \#:}\\ + which gives actually ``\AlCapSty{\AlCapFnt Algorithm \#:}''. By default \almac{AlCapSty} is \texttt{textbf}. +\item[\Almacp{AlCapNameSty}{$<$text$>$}] sets $<$text$>$ in caption name typography, that is the same used, + together with \almac{AlCapNameFnt} to print the name of caption you set by calling \almacp{caption}{name}. More + precisely it is printed as follow:\\ + \almacp{AlCapNameSty}{\almac{AlCapNameFnt} name}\\ + which gives ``\AlCapNameSty{\AlCapNameFnt name}''. By default \almac{AlCapNameSty} is \texttt{textnormal} which + means print in standard text. +\item[\Almacp{AlCapFnt}{$<$text$>$}] sets $<$text$>$ in font shape of caption title, that is the same used, + together with \almac{AlCapSty}, to print \texttt{Algorithm \#:}, more precisely it is printed as follow:\\ + \almacp{AlCapSty}{\almac{AlCapFnt} Algorithm \#:}\\ + which gives actually ``\AlCapSty{\AlCapFnt Algorithm \#:}''. By default \almac{AlCapFnt} is \almac{relax} which + means keep text as it is. +\item[\Almacp{AlCapNameFnt}{$<$text$>$}] sets $<$text$>$ in caption name typography, that is the same used, + together with \almac{AlCapNameSty} to print the name of caption you set by calling \almacp{caption}{name}. More + precisely it is printed as follow:\\ + \almacp{AlCapNameSty}{\almac{AlCapNameFnt} name}\\ + which gives ``\AlCapNameSty{\AlCapNameFnt name}''. By default \almac{AlCapNameFnt} is \almac{relax} which means + keep text as it is. +\medskip + +\item[\Almacp{ProcSty}{$<$text$>$}] sets $<$text$>$ in procedure/function caption title typography, that is the + same used, together with \almac{ProcFnt}, to print \texttt{Procedure}, more precisely it is printed as follow:\\ + \almacp{ProcSty}{\almac{ProcFnt} Procedure}\\ + which gives actually ``\ProcSty{\ProcFnt Procedure}''. By default \almac{ProcSty} is \almac{AlCapSty}. +\item[\Almacp{ProcNameSty}{$<$text$>$}] sets $<$text$>$ in procedure name typography, that is the same used, + together with \almac{ProcNameFnt} to print the name of caption you set by calling \almacp{caption}{Proc(int + i)}. More precisely it is printed as follow:\\ + \almacp{ProcNameSty}{\almac{ProcNameFnt} Proc(}\\ + which gives ``\ProcNameSty{\ProcNameFnt Proc(}''. By default \almac{ProcNameSty} is \almac{AlCapNameSty} which + means print in standard text. +\item[\Almacp{ProcArgSty}{$<$text$>$}] sets $<$text$>$ in argument of procedure/function typography, that is the + same used, together with \almac{ProcArgFnt}, to print \texttt{int i} if \almacp{caption}{Proc(int i)} was + called. More precisely it is printed as follow:\\ + \almacp{ProcArgSty}{\almac{ProcArgFnt} int i}\\ + which gives actually ``\ProcArgSty{\ProcArgFnt int i}''. By default \almac{ProcArgSty} is \almac{AlCapNameSty}; +\item[\Almacp{ProcFnt}{$<$text$>$}] sets $<$text$>$ in font shape of caption title, that is the same used, + together with \almac{ProcSty}, to print \texttt{Procedure}, more precisely it is printed as follow:\\ + \almacp{ProcSty}{\almac{ProcFnt} Procedure}\\ + which gives actually ``\ProcSty{\ProcFnt Procedure}''. By default \almac{ProcFnt} is \almac{relax} which + means keep text as it is. +\item[\Almacp{ProcNameFnt}{$<$text$>$}] sets $<$text$>$ in procedure/function name typography, that is the same + used, together with \almac{ProcNameSty} to print the name of caption you set by calling \almacp{caption}{Proc(int + i)}. More precisely it is printed as follow:\\ + \almacp{ProcNameSty}{\almac{ProcNameFnt} Proc(}\\ + which gives ``\ProcNameSty{\ProcNameFnt Proc(}''. By default \almac{ProcNameFnt} is \almac{relax} which means + keep text as it is. +\item[\Almacp{ProcArgFnt}{$<$text$>$}] sets $<$text$>$ in font shape of argument of procedure/environment caption, + that is the same used, together with \almac{ProcArgSty}, to print \texttt{int i} if \almacp{caption}{int i} was + called. More precisely it is printed as follow:\\ + \almacp{ProcArgSty}{\almac{ProcFnt} int i}\\ + which gives actually ``\ProcArgSty{\ProcArgFnt int i}''. By default \almac{ProcArgFnt} do nothing. + +\medskip +\item[\Almacp{AlTitleSty}{$<$text$>$}] is used to typeset ``\texttt{Algorithm \#:}'' in title, together with + \almac{AlTitleFnt}. You can use it to have text as your titles. Precisely, titles are typeset as follow:\\ + \almacp{AlTitleSty}{\almacp{AlTitleFnt}{Algorithm \#:}}. +\item[\Almacp{AlTitleFnt}{$<$text$>$}] is used to typeset ``\texttt{Algorithm \#:}'' in title, together with + \almac{AlTitleSty}. You can use it to have text as your titles. Precisely, titles are typeset as follow:\\ + \almacp{AlTitleSty}{\almacp{AlTitleFnt}{Algorithm \#:}}. +\end{description} + +\subsubsection{setting font standard font shapes and styles} +\label{sec:setfntsty} + +With the following commands you can customize the style and have the look you want for your algorithms: +\begin{description} +\item[\Almacp{SetAlFnt}{$<$font$>$}] define the fonts used for typesetting algorithms. +\end{description} +You have to give commands to set the font in argument. You can use it elsewhere you want to typeset text as +algorithm. For example you can do \almacp{SetAlFnt}{$\backslash$\texttt{small}$\backslash$\texttt{sf}} to have +algorithms typeset in small sf font. + +The next ones require to give in parameter name of a macro (whithout $\backslash$) which takes one argument. For +example, \almacp{SetAlCapFnt}{textbf} (see \autoref{sec:captionstyle}) defines the default behaviour of +\almac{AlCapFnt}. If you want to do more complicated thing, you should define your own macro and give it to +\almac{SetAlCapFnt} or \almac{SetAlCapNameFnt}. Here are two examples: +\begin{itemize} +\item $\backslash$\texttt{newcommand\{}$\backslash$\texttt{mycapfn\}[1]\{}$\backslash$\texttt{tiny \#1\}}\almacp{SetAlCapNameFnt}{mycapfnt} +\item $\backslash$\texttt{newcommand\{}$\backslash$\texttt{mycapfn\}[1]\{}$\backslash$\texttt{textsl\{}$\backslash$\texttt{small \#1\}\}}\almacp{SetAlCapNameFnt}{mycapfnt} +\end{itemize} +Here is the complete list of these macros: +\begin{description} +\item[\Almacp{SetKwSty}{$<$font$>$}] sets the Kw typography to $<$font$>$ (by + default: \textbf{textbf}). +\item[\Almacp{SetFuncSty}{$<$font$>$}] sets the function typography +(by default: \textbf{texttt}). +\item[\Almacp{SetFuncArgSty}{$<$font$>$}] sets the typography of function argument +(by default: \textbf{emph}). +\item[\Almacp{SetProgSty}{$<$font$>$}] sets the KwProg typography to $<$font$>$ (by + default: \textbf{emph}). +\item[\Almacp{SetArgSty}{$<$font$>$}] sets the argument typography (by + default: \textbf{emph}). +\item[\Almacp{SetDataSty}{$<$font$>$}] sets the data typography (by + default: \textbf{textsf}). +\item[\Almacp{SetCommentSty}{$<$font$>$}] sets the comment text typography (by + default: \textbf{texttt}). +\item[\Almacp{SetNlSty}{$<$font$>$}] sets the number line typography (by default: + \textbf{$\backslash$relsize\{-2\}}) +\medskip + +\item[\Almacp{SetProcNameSty}{$<$font$>$}] sets caption typography of procedure and function environment (by + default the same as \almacp{AlCapSty}). +\item[\Almacp{SetProcArgSty}{$<$font$>$}] sets argument typography of procedure and function environment (by + default the same as \almacp{AlCapNameSty}). +\item[\Almacp{SetBlockMarkersSty}{$<$font$>$}] sets block markers typography (by default + the same as \almacp{KwSty}). +\end{description} + +\subsubsection{setting caption and title font style} +\label{sec:setcaptionfntsty} + +The following commands allow to redefine \texttt{Fnt} macros. This ones requires to give directly commands that +define the font shape you want. They works as \almacp{SetAlFnt} described above. For example you can do +\almacp{SetAlCapFnt}{$\backslash$\texttt{large}$\backslash$\texttt{color\{red\}}} to have \texttt{Algorithm \#:} in +caption printed in large red font. +\begin{description} +\item[\Almacp{SetAlCapFnt}{$<$font$>$}] sets the font used for \{algorithm: \} + in caption of algorithm (default is set to \almac{relax}). +\item[\Almacp{SetAlCapNameFnt}{$<$font$>$}] sets the font used by caption text. Default is \almac{relax} and text is + kept as it is. +\item[\Almacp{SetAlTitleFnt}{$<$font$>$}] sets the font used in \almac{TitleOfAlgo} command (default is + set to \texttt{$\backslash$relax}, so text is kept as it is). +\end{description} + +The next commands allow to redefine \texttt{Sty} macros for caption or title. As ``\texttt{$\backslash$Set} +commands'' of basic font style (see \autoref{sec:setfntsty}), they require a name of a command in argument, +this command have to take one argument, the text to be typeset. They should be combined +with previous commands to redefine display of caption or title. Examples of use: +\begin{itemize} +\item + $\backslash$\texttt{newcommand\{}$\backslash$\texttt{mycapsty\}[1]\{}$\backslash$\texttt{textbf\{}$\backslash$\texttt{emph\{\#1\}\}\}}\almacp{SetAlCapNameSty}{mycapsty}\\ + caption will be print emphased and in bold face. +\item \almacp{SetAlCapNameFnt}{$\backslash$tiny} set font to tiny size. +\item if you combine $\backslash$SetAlCapNameSty\{mycapsty\} and + $\backslash$SetAlCapNameFnt\{$\backslash$tiny\} will give tiny bold empased caption. +\end{itemize} + +Now the commands: +\begin{description} +\item[\Almacp{SetAlCapSty}{$<$commandname$>$}:] sets the command that will be used by \almac{AlCapSty} to define + style of \texttt{Algorithm \#:} in caption. The argument is a name of a command (without $\backslash$). This + command have to take one argument, the text to be formatted. Default is set to: \almacp{SetAlCapSty}{textbf}. +\item[\Almacp{SetAlCapNameSty}{$<$commandname$>$}:] sets the command that will be used by \almac{AlCapNameSty} to + define style of caption text. The argument is a name of a command (without $\backslash$). This command have to + take one argument, the text to be formatted. Default is set to: \almacp{SetAlCapSty}{textnormal}. +\item[\Almacp{SetAlTitleSty}{$<$commandname$>$}] sets the command that will be used by \almac{AlTitleSty} to define + style of algorithm title given by \almac{TitleOfAlgo} (default is set to \almacp{SetAlTitleSty}{textbf}). + + +% You can redefine \AlCapFnt and \AlCapNameFnt by giving macro to \Set commands. For +% example, you can do \SetAlCapFnt{\large} to see Algorithm printed in \large font. +% You can redefine \AlCapSty, \AlCapFnt, \AlCapNameSty and \AlCapNameFnt with the +% corresponding \Set command. For the Sty commands, you have to give in parameter +% name of a macro (whithout \) which takes one argument. For example, +% \SetAlCapFnt{textbf} defines the default behaviour. If you want to do more +% complicated thing, you should define your own macro and give it to \SetAlCapFnt or +% \SetAlCapNameFnt. Here are two examples: +% - \newcommand{\mycapsty}[1]{\tiny #1}\SetAlCapNameSty{mycapsty} +% - \newcommand{\mycapsty}[1]{\textsl{\small #1}}\SetAlCapNameSty{mycapsty} +% Or you can combine the two, for the last example you can also do: +% \SetAlCapNameSty{textsl}\SetAlCapNameFnt{\small} +% Thanks to Jan Stilhammer who gives me the idea of \AlCapNameFnt. + +% * ADD: - \AlTitleSty and \SetAlTitleSty commands to set a style for title. These commands +% are defined from a macro taking the text in argument, as \textbf for example. +% To set the TitleSty you have to give name of the macro (without the '\') +% to \SetAlTitleSty. For example \SetAlTitleSty{textbf} to set \textbf style. +\end{description} + +Note that by combining \texttt{Fnt} and \texttt{Sty} macros you can define almost all styles easily. For example, +the last example above can be define in a simplier way that previously presented by doing: +\begin{itemize} +\item \almacp{SetAlCapNameSty}{textsl}\almacp{SetAlCapNameFnt}{$\backslash$small} +\end{itemize} + +%---------- +\subsection{controlling the layout of algorithms\label{sec_styleoptions}} + +\begin{description} +\item[\Almacp{RestyleAlgo}{style}] change the layout of the algorithms as do + options \emph{boxed}, \emph{boxruled}, \emph{ruled} and \emph{algoruled}. +\item[\Almacp{RestyleAlgo}{style}] sets the style of the following algorithms + to that given by this macro (\optplain, \optboxed, \optruled, \optalgoruled) + unlike those indicated in the options of the package (see options of + the package). +\item[\Almac{SetAlgoVlined}] prints a vertical line followed by a little + horizontal line between the start and the end of each block. Looks + like that : \rule{0.4pt}{3mm}\rule{0.5mm}{0.4pt} +\item[\Almac{SetNoline}] Doesn't print vertical lines (by default). + The block is marked with keywords such as \emph{begin}, \emph{end}. +\item[\Almac{SetAlgoLined}] prints vertical lines between bloc start-end + keywords as \emph{begin}, \emph{end}. +\item[\Almac{SetAlgoLongEnd}] acts like \optlongend option. +\item[\Almac{SetAlgoShortEnd}] acts like \optshortend option. +\item[\Almac{SetAlgoNoEnd}] acts like \optnoend option. +\item[\Almacpp{SetInd}{before rule space}{after rule space}] sets the size of the space before the vertical rule + and after. In \almac{NoLine} mode the indentation space is the sum of these two values, by default 0.5em and 1em +\item[\Almacp{SetAlgoHangIndent}{length}] sets the value of indent length used by + hangindent to indent subsequent lines after the first on a long statement. +\item[\Almacp{Setvlineskip}{length}] sets the value of the vertical space after the little horizontal line which + closes a block in \optvlined mode. +\item[\Almacp{SetAlgoSkip}{skip command}] Algorithms puts extra vertical space + before and after to avoid having text bumping lines of boxed or ruled + algorithms. By default, this is a \smallskip. You can change this value with + this macro. The four possibilities are: + \begin{itemize} + \item $\backslash$SetAlgoSkip\{\}] for no extra vertical skip + \item $\backslash$SetAlgoSkip\{smallskip\}] to act as the default behaviour + \item $\backslash$SetAlgoSkip\{medskip\}] to have a bigger skip + \item $\backslash$SetAlgoSkip\{bigskip\}] to have the bigger skip + \end{itemize} + Note that you can apply the skip you want by defining a macro doing it and + passing its name (without $\backslash$) to $\backslash$SetAlgoSkip +\item[\Almacp{SetAlgoInsideSkip}{skip command}] Algorithms puts no extra vertical space + before and after the core of the algorithm. So text is put right after the lines in boxed or ruled style. To put an + extra space, use \Almacp{SetAlgoInsideSkip}{skip command}, for example \Almacp{SetAlgoInsideSkip}{smallskip}, like for + \Almacp{SetAlgoSkip}{skip command}. +\item[\Almac{algomargin}] this is the value of the margin of all algorithms. You can change it by setting: + $\backslash$\texttt{setlength\{}\almac{algomargin}\texttt{\}\{2em\}} for example. The default value is the sum of + the two dimensions \almac{leftskip} and \almac{parindent} when the algorithm2e package is loaded. Note that if + you change this value, it will take effect with the next algorithm environment. So even if you change it + \emph{inside} an algorithm environment, it will not affect the current algorithm. +\item[\Almacp{IncMargin}{length}] increases the size of the \almac{algomargin} by the length given in argument. +\item[\Almacp{DecMargin}{length}] decreases the size of the \almac{algomargin} by the length given in argument. +\item[\Almacp{DecMargin}{length}] decreases the size of the \almac{algomargin} by the length given in argument. +\item[\almacp{SetAlgoNlRelativeSize}{number}] sets the relative size of line number (see + \autoref{sec:linenumbering}) for more details on this command. +\item[\almacp{SetAlgoCaptionLayout}{style}] sets the global style of caption (see \autoref{sec:titlemacros} for + more details). +\item[\Almac{DisplayBlockMarkers}] acts like \optblockmarkers option: each block will be + started by a \emph{begin} keyword and be ended by an \emph{end} keywords. This is tricky + to use but allows to customize syntax to match almost every language (see + \autoref{code:exgeneric} for examples showing how to use + it). \Almacpp{SetAlgoBlockMarkers}{begin keyword}{end keyword} defines \emph{begin} and + \emph{end} keywords that will be used by \verb+\DisplayBlockMarkers+. Default keywords + are \textbf{begin} and \textbf{end}. but for example you can set + \verb+\DisplayBlockMarkers{\{}{\}}+ to match c-style syntax. +\item[\Almac{DisplayGroupMarkers}] acts like \optgroupmarkers option: each block of single line command will be started by a \emph{begin} keyword and be ended by an \emph{end} keywords. \Almacpp{SetAlgoBlockMarkers}{begin keyword}{end keyword} defines \emph{begin} and \emph{end} keywords that will be used by \verb+\DisplayGroupMarkers+. Note that begin-end group markers are necessarly the same as \verb+\DisplayBlockMarkers+. +\end{description} + +Some length are used to set the layout of ruled, algoruled and boxruled algorithms caption. These length have no +particular macro to set them but can be changed by classical \almac{setlength} commmand: +\begin{description} +\item[interspacetitleruled] (2pt by defaut) which controls the vertical space between rules and title in ruled and + algoruled algorithms. +\item[interspacetitleboxruled] (2\almac{lineskip} by default) which controls the vertical space between rules and title in + boxruled algorithms. +\end{description} + +%---------- +\subsection{comments} +\label{sec:comments} + +There are two ways to do comments in algorithm : +\begin{enumerate} +\item by using a comment macro defined by \almacppp{SetKwComment}{command}{right mark}{left mark} (see below) like + \almac{tcc}; +\item by using side comment, it means comment put in between (\ ) after control command like if-then-else, for, + ... macros. +\end{enumerate} + +At \autoref{sec:commentsmacros}, you can see how \almac{tcc} is defined and at +\autoref{sec:ifthenelsemacros} you can look at some examples how to use it with \texttt{if then else} like +commands and finally you can look at \autoref{sec:defcommentsmacros} how to define comments and explanations on +the different macros and ways of printing comments. Note also that comments are not numbered by default when using +\optlinesnumbered option. You have to set \optcommentsnumbered to number them also. + +The following macro control how comment are typeseted. +\begin{description} +\item[\Almac{SetSideCommentLeft}] right justified side comments (side comments are flushed to the right), + equivalent to \optscleft option. +\item[\Almac{SetSideCommentRight}] left justified side comments (side comments are put right after the code line) , + equivalent to \optscright option. +\item[\Almac{SetFillComment}] end mark of comment is flushed to the right so comments fill all the width of text, + equivalent to \optfillcomment option. +\item[\Almac{SetNoFillComment}] end mark of comment is put right after the comment, equivalent to \optnofillcomment + option. +\end{description} + + + +%******************************************************************* + +\section{The predefined language keywords}\label{predefkeywords} + +Here are the English keywords predefined in the package. There are other +language predefined macros provided, such as French keywords, see +\autoref{sec_lang} for a list of other language keywords. All these keywords +are defined using macros provided by the package and described in +\autoref{sec_deflanguage}. + +%\subsection{english keywords} +\RestyleAlgo{boxed} + +%---------- +\subsection{Input, output macros...}\label{sec:inputmacros} + +\begin{itemize} +\item $\backslash$KwIn\{input\}\macind{KwIn} +\item $\backslash$KwOut\{output\}\macind{KwOut} +\item $\backslash$KwData\{input\}\macind{KwData} +\item $\backslash$KwResult\{output\}\macind{KwResult} +\end{itemize} + +%---------- +\subsection{basic keywords and blocks} +\label{sec:basickeywords} + +\begin{enumerate} +\item One simple common keyword: + \begin{itemize} + \item $\backslash$KwTo\macind{KwTo} + \end{itemize} +\item One keyword requiring an argument: + \begin{itemize} + \item $\backslash$KwRet\{[value]\}\macind{KwRet} + \item $\backslash$Return\{[value]\}\macind{Return} + \end{itemize} +\item A block: + \begin{itemize} + \item $\backslash$Begin\{block inside\}\macind{Begin} + \item $\backslash$Begin(\textit{begin comment})\{block inside\}\macind{Begin} + \end{itemize} +\end{enumerate} + +%---------- +\subsection{comments} +\label{sec:commentsmacros} + +\begin{itemize} +\item $\backslash$tcc\{line(s) of comment\}\macind{tcc}: comment ``à la'' C +\item $\backslash$tcc*\{right justified side comment\}\macind{tcc*}: comment ``à la'' C +\item $\backslash$tcc*[r]\{right justified side comment, ends the line (default)\}\macind{tcc*[r]}: comment ``à la'' C +\item $\backslash$tcc*[l]\{left justified side comment, ends the line\}\macind{tcc*[l]}: comment ``à la'' C +\item $\backslash$tcc*[h]\{left justified comment, without end line; useful with "if-then-else" macros for + example\}\macind{tcc*[h]}: comment ``à la'' C +\item $\backslash$tcc*[f]\{right justified comment, without end line; useful with "if-then-else" macros for + example\}\macind{tcc*[f]}: comment ``à la'' C +\item $\backslash$tcp\{line(s) of comment\}\macind{tcp}: comment ``à la'' C++ +\item $\backslash$tcp*\{right justified side comment\}\macind{tcp*}: comment ``à la'' C++ +\item $\backslash$tcp*[r]\{right justified side comment, ends the line (default)\}\macind{tcp*[r]}: comment ``à la'' C++ +\item $\backslash$tcp*[l]\{left justified side comment, ends the line\}\macind{tcp*[l]}: comment ``à la'' C++ +\item $\backslash$tcp*[h]\{left justified comment, without end line; useful with "if-then-else" macros for + example\}\macind{tcp*[h]}: comment ``à la'' C++ +\item $\backslash$tcp*[f]\{right justified comment, without end line; useful with "if-then-else" macros for + example\}\macind{tcp*[f]}: comment ``à la'' C++ +\end{itemize} + +You can see some examples of this macros with \texttt{if then else} at the end of \autoref{sec:defifthenelsemacros} + +%---------- +\subsection{if-then-else macros} +\label{sec:ifthenelsemacros} + +\begin{itemize} +\item $\backslash$If\{condition\}\{then block\}\macind{If} +\item $\backslash$If(\textit{then comment})\{condition\}\{then block\}\macind{If} +\item $\backslash$uIf\{condition\}\{then block without end\}\macind{uIf} +\item $\backslash$uIf(\textit{then comment})\{condition\}\{then block without end\}\macind{uIf} +\item $\backslash$lIf\{condition\}\{then's line text\}\macind{lIf} +\item $\backslash$lIf(\textit{if comment})\{condition\}\{then's line text\}\macind{lIf} +\item $\backslash$ElseIf\{elseif block\}\macind{ElseIf} +\item $\backslash$ElseIf(\textit{elseif comment})\{elseif block\}\macind{ElseIf} +\item $\backslash$uElseIf\{elseif block without end\}\macind{uElseIf} +\item $\backslash$uElseIf(\textit{elseif comment})\{elseif block without end\}\macind{uElseIf} +\item $\backslash$lElseIf\{elseif's line text\}\macind{lElseIf} +\item $\backslash$lElseIf(\textit{elseif comment})\{elseif's line text\}\macind{lElseIf} +\item $\backslash$Else\{else block\}\macind{Else} +\item $\backslash$Else(\textit{else comment})\{else block\}\macind{Else} +\item $\backslash$uElse\{else block without end\}\macind{uElse} +\item $\backslash$uElse(\textit{else comment})\{else block without end\}\macind{uElse} +\item $\backslash$lElse\{else's line text\}\macind{lElse} +\item $\backslash$lElse(\textit{else comment})\{else's line text\}\macind{lElse} +\item $\backslash$eIf\{condition\}\{then block\}\{else block\}\macind{eIf} +\item $\backslash$eIf(\textit{then comment})\{condition\}\{then block\}(\textit{else comment})\{else block\}\macind{eIf} +\item $\backslash$eIf(\textit{then comment})\{condition\}\{then block\}\{else block\}\macind{eIf} +\item $\backslash$eIf\{condition\}\{then block\}(\textit{else comment})\{else block\}\macind{eIf} +\item $\backslash$leIf\{condition\}\{then block\}\{else block\}\macind{eIf} +\item $\backslash$leIf(\textit{comment})\{condition\}\{then block\}\{else block\}\macind{eIf} +\end{itemize} + +%---------- +\subsection{multiple condition selection:} +\label{sec:switchmacros} + +\begin{itemize} +\item $\backslash$Switch(\textit{switch comment})\{condition\}\{Switch block\}\macind{Switch} +\item $\backslash$Switch\{condition\}\{Switch block\}\macind{Switch} +\item $\backslash$Case\{a case\}\{case block\}\macind{Case} +\item $\backslash$Case(\textit{case comment})\{a case\}\{case block\}\macind{Case} +\item $\backslash$uCase\{a case\}\{case block without end\}\macind{uCase} +\item $\backslash$uCase(\textit{case comment})\{a case\}\{case block without end\}\macind{uCase} +\item $\backslash$lCase\{a case\}\{case's line\}\macind{lCase} +\item $\backslash$lCase(\textit{case comment})\{a case\}\{case's line\}\macind{lCase} +\item $\backslash$Other\{otherwise block\}\macind{Other} +\item $\backslash$Other(\textit{other comment})\{otherwise block\}\macind{Other} +\item $\backslash$lOther\{otherwise's line\}\macind{lOther} +\item $\backslash$lOther(\textit{other comment})\{otherwise's line\}\macind{lOther} +\end{itemize} + +%---------- +\subsection{loops with "end condition" test at the beginning} +\label{sec:loopfor} + +\begin{itemize} +\item $\backslash$For\{condition\}\{text loop\}\macind{For} +\item $\backslash$For(\textit{for comment})\{condition\}\{text loop\}\macind{For} +\item $\backslash$lFor\{condition\}\{line text loop\}\macind{lFor} +\item $\backslash$lFor(\textit{for comment})\{condition\}\{line text loop\}\macind{lFor} +\end{itemize} +\begin{itemize} +\item $\backslash$While\{condition\}\{text loop\}\macind{While} +\item $\backslash$While(\textit{while comment})\{condition\}\{text loop\}\macind{While} +\item $\backslash$lWhile\{condition\}\{line text loop\}\macind{lWhile} +\item $\backslash$lWhile(\textit{while comment})\{condition\}\{line text loop\}\macind{lWhile} +\end{itemize} +\begin{itemize} +\item $\backslash$ForEach\{condition\}\{text loop\}\macind{ForEach} +\item $\backslash$ForEach(\textit{foreach comment})\{condition\}\{text loop\}\macind{ForEach} +\item $\backslash$lForEach\{condition\}\{line text loop\}\macind{lForEach} +\item $\backslash$lForEach(\textit{foreach comment})\{condition\}\{line text loop\}\macind{lForEach} +\end{itemize} +\begin{itemize} +\item $\backslash$ForAll\{condition\}\{text loop\}\macind{ForAll} +\item $\backslash$ForAll(\textit{forall comment})\{condition\}\{text loop\}\macind{ForAll} +\item $\backslash$lForAll\{condition\}\{line text loop\}\macind{lForAll} +\item $\backslash$lForAll(\textit{forall comment})\{condition\}\{line text loop\}\macind{lForAll} +\end{itemize} + +\subsection{loops with "end condition" test at the end} +\label{sec:loprepeat} + +\begin{itemize} +\item $\backslash$Repeat\{end condition\}\{text loop\}\macind{Repeat} +\item $\backslash$Repeat(\textit{repeat comment})\{end condition\}\{text loop\}(\textit{until comment})\macind{Repeat} +\item $\backslash$Repeat(\textit{repeat comment})\{end condition\}\{text loop\}\macind{Repeat} +\item $\backslash$Repeat\{end condition\}\{text loop\}(\textit{until comment})\macind{Repeat} +\item $\backslash$lRepeat\{end condition\}\{line text loop\}\macind{lRepeat} +\item $\backslash$lRepeat(\textit{repeat comment})\{end condition\}\{line text loop\}\macind{lRepeat} +\end{itemize} + +%---------- +\subsection{how default keywords are obtained} +\label{sec:defaultkeyworddefinition} + +\begin{enumerate} +\item \almacpp{SetKwInput}{KwData}{Data}\par + \almacpp{SetKwInput}{KwResult}{Result}\par + \almacpp{SetKwInput}{KwIn}{Input}\par + \almacpp{SetKwInput}{KwOut}{Output} +\item \almacpp{SetKw}{KwTo}{to} +\item \almacpp{SetKw}{KwRet}{return}\par + \almacpp{SetKw}{Return}{return} +\item \almacppp{SetKwBlock}{Begin}{begin}{end} +\item \almacppp{SetKwComment}{tcc}{/*}{*/}\par + \almacppp{SetKwComment}{tcp}{//}{} +\item \almacphuit{SetKwIF}{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif} +\item {\small\almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}\texttt{endsw}} +\item \almacpppp{SetKwFor}{For}{for}{do}{endfor}\par + \almacpppp{SetKwFor}{While}{while}{do}{endw}\par + \almacpppp{SetKwFor}{ForEach}{foreach}{do}{endfch}\par + \almacpppp{SetKwAll}{ForEach}{forall}{do}{endfall} +\item \almacppp{SetKwRepeat}{Repeat}{repeat}{until} +\end{enumerate} + +%******************************************************************* + +\section{To define your own language keywords}\label{sec_deflanguage} +Note that all these macros verify if the keywords are already defined and do a +renewcommand if they are. So you can overload the default definitions of this +package with your own. + +%---------- +\subsection{to define Input, output macros...}\label{sec:definputmacros} + +\begin{description} +\item[\Almacpp{SetKwInput}{Kw}{input}] defines the macro + \almacp{Kw}{arg} which prints \emph{input} followed by `:' in key + word typography, and behind the argument \emph{arg}. Typically used + to define macros such as \almacp{Input}{data} or + \almacp{Output}{result}. Note that \emph{arg} will be shifted so that + all the text is vertically aligned and to the right of the `:'. +\item[\Almacpp{SetKwInOut}{Kw}{input}] works as + \almacpp{SetKwInput}{Kw}{input}. But the position of the `:' is fixed + and set by the longest keyword defined by this macro.\par + \Almacp{ResetInOut}{input} resets the position of the `:' for all + macros defined previously by \almacpp{SetKwInOut}{Kw}{input}. The + new position is fixed depending on the size of the text \emph{input} + given in argument. +\end{description} + +%---------- +\subsection{to define basic keywords or blocks}\label{sec:defbasickeywords} + +\begin{description}\RestyleAlgo{plain} +\item[\Almacpp{SetKw}{Kw}{thetext}] defines the macro \almac{Kw} which + defines a keyword \emph{thetext} and prints it in keyword + typography. It can take one argument: $\backslash$Kw\{arg\}. If so, + \emph{arg} is printed in argument typography. For example \verb+\Kw{thetext}+ + could give: \KwSty{Kw} \ArgSty{thetext} +\item[\Almacpp{SetKwHangingKw}{Kw}{thetext}] defines a hanging keyword that should act + like a combination of \almac{SetKwInput} and \almac{SetKw}. In comparison with + $\backslash$SetKwInput, it doesn't print ':' at end of keyword and line is numbering if + \optlinesnumbered is set.\\ + For example \verb+\SetKwHangingKw{HData}{Data$\rightarrow$}+ could gives:\par\vspace{-.5ex} + \begin{algorithm}[H] + \KwHData{a list of data and a long description of this data to be sure that text requires several lines to be printed} + \end{algorithm}\vspace{-1ex} +\item[\Almacpp{SetKwData}{Kw}{thetext}] defines the macro \almacp{Kw} + which defines a data text. Prints \emph{thetext} in data typography. + Note that this macros can takes one argument as function macros. +\item[\Almacpp{SetKwArray}{Kw}{array}] which defines an array keywords \texttt{Kw} called \emph{array} and printed + in DataSty style when call with $\backslash$\texttt{Kw}. It can be used with one argument which denotes the + element index: $\backslash$\texttt{Kw}\{n\} prints \DataSty{array[}\ArgSty{n}\DataSty{]} with \emph{array} in + \Almac{DataSty} and \emph{n} in \Almac{ArgSty}. +\item[\Almacppp{SetKwBlock}{Begin}{begin}{end}] defines a macro + \almacp{Begin}{txt} which denotes a block. The text is surrounded by + the words \emph{begin} and \emph{end} in keyword typography and + shifted to the right (indented). In \almac{Vline}\emph{ or }% + \almac{Line}\emph{ mode} a straight vertical line is added.\\ + \verb+\Begin(side text){text}+ gives also text in a block surrounded by \emph{begin} and + \emph{end}, but \emph{side text} if put after the \emph{begin} keyword. Combined with + \Almac{tcc*[f]} macro, it allows you to put comments on the same line as + \emph{begin}.\par + You can also use alternativ \almacp{uBegin}{txt} which acts as \almacp{Begin}{txt} but + without \emph{end}. Useful for example as a part separator that doesn't necessary need + an \emph{end} keyword. +\item[\Almacpppp{SetKwProg}{Prog}{Title}{ is}{end}] Env is a block with 'Title' (in + \texttt{CapSty} style) at the beginning followed by args in \texttt{ProgSty} followed by + '\texttt{is}' then '\texttt{text}' inside a block ended by '\texttt{end}'. If no + '\texttt{end}' is specified, nothing is written (no blank line is inserted). Useful to + typeset function or prog. For example:\par + \noindent\ExampleOfAlgo{algorithm2e_exProg.tex}\par +\end{description} + +\subsection{to define keywords as function} +\label{sec:deffunction} + +If you want describe the function by an algorithm, use instead \emph{function} or \emph{procedure} environment. + +\begin{description} +\item[\Almacpp{SetKwFunction}{KwFn}{Fn}] defines a macro + \almacp{KwFn}{arg} which prints \emph{Fn} in \texttt{FuncSty} typography and + its argument \emph{arg} in \texttt{FuncArgSty} typography, surrounded by a pair + of parentheses. + + \almacpp{SetKwFunction}{Dothat}{Do that} defines the macro + \almacp{DoThat}{this}, which is equivalent to + \almacp{FuncSty}{Do that(}\almacp{ArgSty}{this}\almacp{FuncSty}{)} which + gives: \FuncSty{Do that(}\ArgSty{this}\FuncSty{)}. + + Note that you can also use it without + arguments, it will be printed without `()', example: + \almacpp{SetKwFunction}{Fn}{TheFunction} use as + \almac{Fn} gives \FuncSty{TheFunction}. + + Keywords (with or without arguments) and functions defined + previously in normal text (not in an algorithm environment) can be + used outside an algorithm environment. You can use it by typing + \almacp{DoThat}{toto} (for a function defined by + \almacpp{SetKwFunction}{Dothat}{Do that}), you will obtain + \FuncSty{Do That(\ArgSty{toto})}. +\end{description} + +%---------- +\subsection{to define comments} +\label{sec:defcommentsmacros} + +\begin{description} +\item[\Almacppp{SetKwComment}{Comment}{start}{end}] defines a macro + \almacp{Comment}{text comment} which writes \emph{text comment} between + \emph{start} and \emph{end}. Note that \emph{start} or \emph{end} can be + empty.\\ + It defines also \almacp{Comment*}{side comment text} macro which allows to put comment on the same + line as the code. This macro can take various option to control its behaviour:\\ + \verb+\Comment*[r]{side comment text}+ put the end of line mark (';' by default) and side comment + text just after and right justified, then end the line. It is the default.\\ + \verb+\Comment*[l]{side comment text}+ same thing but side comment text is left justified.\\ + \verb+\Comment*[h]{side comment text}+ put side comment right after the text. No end of line + mark is put, and line is not terminated (is up to you to put \verb+\;+ to end the line).\\ + \verb+\Comment*[f]{side comment text}+ same as the previous one but with side comment text right + justified. +\end{description} + +%---------- +\subsection{to define if-then-else macros} +\label{sec:defifthenelsemacros} + +\begin{description} +\item[\Almacphuit{SetKwIF}{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}] + defines several macros to give the opportunity to write all + if-then-else-elseif-endif possibilities: + \begin{itemize} + \item \almacpp{If}{cond}{Then's text}\\ + Then's text is writen in a block (below \texttt{then} and on several lines) + and terminating by the \texttt{endif} given in the last argument. + \item \almacpp{If(comment)}{cond}{Then's text}\\ + as previous but put \emph{comment} after \texttt{then} keyword. Usually use with + comment macro like \almac{tcc}*[f]\{comment\} or \almac{tcp}*[f]\{comment\} + \item \almacpp{If}{cond}{Then's text(comment)}\\ + as previous but put \emph{comment} after \texttt{end} keyword. Usually use with + comment macro like \almac{tcc}*[f]\{comment\} or \almac{tcp}*[f]\{comment\} + \item \almacpp{If(comment1)}{cond}{Then's text(comment2)}\\ + as previous but put \emph{comment1} after \texttt{then} keyword and \emph{comment2} + after \texttt{end}. Usually use with comment macro like \almac{tcc}*[f]\{comment\} or + \almac{tcp}*[f]\{comment\} + \item \almacp{ElseIf}{ElseIf's text}\\ + ElseIf's text is writen in a block and terminating by the \texttt{endif}. + \item \almacp{ElseIf(comment)}{ElseIf's text}\\ + the same with comment. + \item \almacp{ElseIf}{ElseIf's text(comment)}\\ + the same with comment. + \item \almacp{ElseIf(comment)}{ElseIf's text(comment)}\\ + the same with comment. + \item \almacp{Else}{Else's text}\\ + Else's text is writen in a block and terminating by the \texttt{endif}. + \item \almacp{Else(comment)}{Else's text}\\ + the same with comment. + \item \almacp{Else}(comment){Else's text(comment)}\\ + the same with comment. + \item \almacpp{lIf}{cond}{Then's text}\\ + Then's text is written on the same line as \texttt{then}. No \texttt{endif} + is printed. Do not put $\backslash$; after \emph{Then's text} neither after \almac{lIf}. + \item \almacpp{lIf(comment)}{cond}{Then's text}\\ + the same with comment. + \item \almacpp{lIf*}{cond}{Then's text}\\ + Then's text is written on the same line as \texttt{then}. No \texttt{endif} and no end + of line are printed. Do not put $\backslash$; after \emph{Then's text} neither after \almac{lIf}. + \item \almacp{lElseIf}{ElseIf's text}\\ + ElseIf's text is written on the same line as \texttt{else if}. No \texttt{endif} + is printed. + \item \almacp{lElseIf(comment)}{ElseIf's text}\\ + the same with comment. + \item \almacp{lElseIf*}{ElseIf's text}\\ + ElseIf's text is written on the same line as \texttt{else if}. No \texttt{endif} + and no end of line are printed. + \item \almacp{lElse}{Else's text}\\ + Else's text is written on the same line as \texttt{else}. No \texttt{endif} + is printed. + \item \almacp{lElse(comment)}{Else's text}\\ + the same with comment. + \item \almacp{lElse*}{Else's text}\\ + Else's text is written on the same line as \texttt{else}. No \texttt{endif} + is printed and no end of line are printed. + \item \almacpp{uIf}{cond}{Then's text} (for uncomplete if)\\ + defines a If block unterminated like in a \almac{eIf} block, + i.e. don't print the \texttt{endif} or don't put the little + horizontal line in \emph{Vline} mode (see examples below). +% \\\vskip\lineskip +% \begin{minipage}{.35\textwidth}\begin{verbatim} +% \uIF{condition}{ +% if's block\; +% } +% \lElse{else in one line}\;\end{verbatim} +% \end{minipage}$\Longrightarrow$% +% \begin{minipage}{.4\textwidth}% +% \begin{algorithm}[H] +% \SetAlgLined +% \uIf{condition}{ +% if's block\; +% } +% \lElse{else in one line}\; +% \end{algorithm} +% \end{minipage} + \item \almacpp{uIf(comment)}{cond}{Then's text}\\ + the same with comment. + \item \almacp{uElseIf}{ElseIf's text} (for uncomplete elseif)\\ + Same explanation as for \almac{uIf} but with \texttt{else if}. + \item \almacp{uElseIf(comment)}{ElseIf's text}\\ + the same with comment. + \item \almacp{uElse}{Else's text} (for uncomplete else)\\ + Same explanation as for \almac{uElseIf} but with \texttt{else}. + \item \almacp{uElse}{Else's text}\\ + the same with comment. + \item \almacppp{eIf}{cond}{Then's text}{Else's text}\\ + equivalent to the use of \almac{uIf} followed by \almac{Else}. + \end{itemize} +\end{description} + +The macros which begin with a `l' {\small (l as line)} denote that the text passed in argument will be printed on +the same line while with the others the text is printed in a block and shifted. You should put \almac{;} at the end +of ``l macros''. + +The macros which begin with a `u' {\small (u as uncomplete)} denote that the text passed in argument will be +printed in a block not terminated by endif. They are useful to chain different alternatives. + +The keywords \emph{then} and \emph{else} are automatically printed. \emph{cond} is always printed in argument +typography just behind the keyword if. + +All this macros can be combined with () and \almac{Comment*} macros to put comments after main keywords as If, Else +or ElseIf (see list of predefined keywords above and example below). + +Some examples with \verb+\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}+ the default definition given +in the package:\par\smallskip \ExampleOfAlgo{algorithm2e_ex01.tex}\par---\par +\ExampleOfAlgo{algorithm2e_ex02.tex}\par---\par +%\ExampleOfAlgo{algorithm2e_ex03.tex}\par---\par +\ExampleOfAlgo{algorithm2e_ex04.tex}\par---\par +\ExampleOfAlgo{algorithm2e_ex05.tex}\par---\par +\ExampleOfAlgo{algorithm2e_ex06.tex}\par---\par +\ExampleOfAlgo{algorithm2e_ex07.tex}\par +\RestyleAlgo{boxed} + + +%---------- +\subsection{to define multiple condition selection:} +\label{sec:defswitchmacros} + +\begin{description} +\item[\Almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}\texttt{endsw}] + defines several macros to give a complete Switch-do-case-otherwise + environment: + \begin{itemize} + \item \almacpp{Switch}{iden}{switch's block} + \item \almacpp{Switch(comment)}{iden}{switch's block} + \item \almacpp{Switch}{iden}{switch's block(comment)} + \item \almacpp{Switch(comment)}{iden}{switch's block(comment)} + \item \almacpp{Case}{cond}{Case's block} + \item \almacpp{Case(comment)}{cond}{Case's block} + \item \almacpp{Case}{cond}{Case's block(comment)} + \item \almacpp{Case(comment)}{cond}{Case's block(comment)} + \item \almacpp{uCase}{cond}{Case's block} + \item \almacpp{uCase(comment)}{cond}{Case's block} + \item \almacpp{lCase}{cond}{Case's text} + \item \almacpp{lCase*}{cond}{Case's text} + \item \almacpp{lCase(comment)}{cond}{Case's text} + \item \almacp{Other}{Otherwise's block} + \item \almacp{Other(comment)}{Otherwise's block} + \item \almacp{Other}{Otherwise's block(comment)} + \item \almacp{Other(comment)}{Otherwise's block(comment)} + \item \almacp{lOther}{Otherwise's text} + \item \almacp{lOther*}{Otherwise's text} + \item \almacp{lOther(comment)}{Otherwise's text} + \item \almacp{uOther}{Otherwise's text} + \item \almacp{uOther}(comment){Otherwise's text} + \end{itemize} +\end{description} + +The keywords \emph{do} and \emph{endsw} are automatically printed. \emph{iden} and \emph{cond} are always printed +in argument typography just behind the keywords Switch, Case and Otherwise. Here is an example with the default +keywords:\par\smallskip \ExampleOfAlgo{algorithm2e_exswitch.tex} + +As for If-then-elseif-else-endif macro, you can use () to put comments after main keywords. + +%---------- +\subsection{to define loops with "end condition" test at the beginning} +\label{sec:defloopfor} + +\begin{description} +\item[\Almacpppp{SetKwFor}{For}{for}{do}{endfor}] + defines a loop environment with stop-test done at the beginning of + the loop. + \begin{itemize} + \item \almacpp{For}{loop's condition}{For's text} + \item \almacpp{For(comment)}{loop's condition}{For's text} + \item \almacpp{For}{loop's condition}{For's text(comment)} + \item \almacpp{For(comment)}{loop's condition}{For's text(comment)} + \item \almacpp{lFor}{loop's condition}{For's text} + \item \almacpp{lFor(comment)}{loop's condition}{For's text} + \item \almacpp{lFor*}{loop's condition}{For's text} + \end{itemize} +\end{description} + +The keywords \emph{do} and \emph{endfor} are automatically printed. The loop condition is printed in argument +typography. For example:\par\smallskip \ExampleOfAlgo{algorithm2e_exfor.tex} + +As for If-then-elseif-else-endif macro, you can use () to put comments after main keywords. + +\subsection{to define loops with "end condition" test at the end} +\label{sec:defloprepeat} + +\begin{description} +\item[\Almacppp{SetKwRepeat}{Repeat}{repeat}{until}] + defines a repeat-until environment (loop with stop-test at the end + of the loop): + \begin{itemize} + \item \almacpp{Repeat}{end loop condition}{the loop} + \item \almacpp{Repeat(comment after repeat)}{end loop condition}{the loop} + \item \almacpp{Repeat}{end loop condition}{the loop(comment after until)} + \item \almacpp{Repeat(comment after repeat)}{end loop condition}{the loop(comment after until)} + \item \almacpp{lRepeat}{end loop condition}{only one line} + \item \almacpp{lRepeat*}{end loop condition}{only one line} + \item \almacpp{lRepeat(comment)}{end loop condition}{only one line} + \end{itemize} +\end{description} + +It prints the loop condition behind the \emph{until} after the text of the loop.For example:\par\smallskip +\ExampleOfAlgo{algorithm2e_exrepeat.tex} + +As for If-then-elseif-else-endif macro, you can use () to put comments after main keywords. + +%\clearpage +\section{Other language predefined keywords}\label{sec_lang} + +\subsection{French keywords} + +Hey, I am a frenchy , so I have defined the same as in +\autoref{predefkeywords} but in french. + +\begin{enumerate} +\item $\backslash$Donnees\{donn\'ees\}\macind{Donnees}\par + $\backslash$Res\{r\'esultats\}\macind{Res}\par + $\backslash$Entree\{entr\'ees\}\macind{Entree}\par + $\backslash$Sortie\{sorties\}\macind{Sortie}\par +\item $\backslash$KwA\macind{KwA}\par + $\backslash$Retour\{[valeur]\}\macind{Retour} +\item $\backslash$Deb\{int\'erieur du bloc\}\macind{Deb} +\item $\backslash$eSi\{condition\}\{bloc du alors\}\{bloc du sinon\}\macind{eSi}\par + $\backslash$Si\{condition\}\{bloc du alors\}\macind{Si}\par + $\backslash$uSi\{condition\}\{bloc du alors sans fin\}\macind{uSi}\par + $\backslash$lSi\{condition\}\{ligne du alors\}\macind{lSi}\par + $\backslash$SinonSi\{condition\}\{bloc du sinonsi\}\macind{uSinonSi}\par + $\backslash$uSinonSi\{condition\}\{bloc du sinonsi sans fin\}\macind{uSinonSi}\par + $\backslash$lSinonSi\{condition\}\{ligne du sinonsi sans fin\}\macind{lSinonSi}\par + $\backslash$Sinon\{bloc du sinon\}\macind{Sinon}\par + $\backslash$uSinon\{bloc du sinon sans fin\}\macind{uSinon}\par + $\backslash$lSinon\{ligne du sinon\}\macind{lSinon}\par +\item $\backslash$Suivant\{condition\}\{bloc du Suivant-cas-alors\}\macind{Suivant} + $\backslash$uCas\{cas o\`u\}\{bloc de ce cas sans fin\}\macind{uCas}\par + $\backslash$Cas\{cas o\`u\}\{bloc de ce cas\}\macind{Cas}\par + $\backslash$lCas\{cas o\`u\}\{ligne de ce cas\}\macind{lCas}\par + $\backslash$Autre\{bloc de l'alternative\}\macind{Autre}\par + $\backslash$lAutre\{ligne de l'alternative\}\macind{lAutre}\par +\item $\backslash$Pour\{condition\}\{bloc de la boucle\}\macind{Pour}\par + $\backslash$lPour\{condition\}\{ligne de la boucle\}\macind{lPour} +\item $\backslash$Tq\{condition\}\{bloc de la boucle\}\macind{Tq}\par + $\backslash$lTq\{condition\}\{ligne de la boucle\}\macind{lTq} +\item $\backslash$PourCh\{condition\}\{bloc de la boucle\}\macind{PourCh}\par + $\backslash$lPourCh\{condition\}\{ligne de la boucle\}\macind{lPourCh} +\item $\backslash$PourTous\{condition\}\{bloc de la boucle\}\macind{PourTous}\par + $\backslash$lPourTous\{condition\}\{ligne de la boucle\}\macind{lPourTous} +\item $\backslash$Repeter\{condition d'arr\^et\}\{bloc de la boucle\}\macind{Repeter}\par + $\backslash$lRepeter\{condition d'arr\^et\}\{ligne de la boucle\}\macind{lRepeter} +\end{enumerate} + +Here we describe how they are obtained: + +\begin{enumerate} +\item \almacpp{SetKwInput}{Donnes}{Donn\'ees}\par + \almacpp{SetKwInput}{Res}{R\'esultat}\par + \almacpp{SetKwInput}{Entree}{Entr\'ees}\par + \almacpp{SetKwInput}{Sortie}{Sorties}\par +\item \almacpp{SetKw}{KwA}{\`a}\par + \almacpp{SetKw}{Retour}{retourner} +\item \almacppp{SetKwBlock}{Deb}{d\'ebut}{fin} +\item \almacphuit{SetKwIF}{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{alors}{finsi} +\item {\footnotesize\almacphuit{SetKwSwitch}{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}\texttt{fin d'alternative}} +\item \almacpppp{SetKwFor}{Pour}{pour}{faire}{finpour}\par +\item \almacpppp{SetKwFor}{Tq}{tant que}{faire}{fintq}\par +\item \almacpppp{SetKwFor}{PourCh}{pour chaque}{faire}{finprch} +\item \almacpppp{SetKwFor}{PourTous}{pour tous}{faire}{finprts} +\item \almacppp{SetKwRepeat}{Repeter}{r\'ep\'eter}{jusqu'\`a} +\end{enumerate} + +\subsection{German keywords} + +\begin{itemize} +\item $\backslash$Ein\{Eingabe\}\macind{Ein}\par + $\backslash$Aus\{Ausgabe\}\macind{Aus}\par + $\backslash$Daten\{Daten\}\macind{Daten}\par + $\backslash$Ergebnis\{Ergebnis\}\macind{Ergebnis} +\item $\backslash$Bis\{bis\}\macind{Bis}\par + $\backslash$KwZurueck\{zur\"uck\}\macind{KwZurueck}\par + $\backslash$Zurueck\{zur\"uck\}\macind{Zurueck} +\item $\backslash$Beginn\{Beginn\}\macind{Beginn}%Begin +\item $\backslash$Wiederh\{stop condition\}\{loop\}\macind{Wiederh}\par + $\backslash$lWiederh\{stop condition\}\{line loop\}\macind{lWiederh}%Repeat +\item $\backslash$eWenn\{condition\}\{then text\}\{else text\}\macind{eWenn}\par + $\backslash$Wenn\{condition\}\{then text\}\macind{Wenn}\par + $\backslash$uWenn\{condition\}\{then text without end\}\macind{uWenn}\par + $\backslash$lWenn\{condition\}\{then line\}\macind{lWenn}\par + $\backslash$SonstWenn\{condition\}\{elseif text\}\macind{gSonstWenn}\par + $\backslash$uSonstWenn\{condition\}\{elseif text without end\}\macind{uSonstWenn}\par + $\backslash$lSonstWenn\{condition\}\{elseif line\}\macind{lSonstWenn}\par + $\backslash$Sonst\{else text\}\macind{Sonst}\par + $\backslash$uSonst\{else text without end\}\macind{uSonst}\par + $\backslash$lSonst\{else line\}\macind{lSonst}\par +\item $\backslash$Unterscheide\{conditions\}{switch-case-default text}\macind{Unterscheide}%Switch + $\backslash$Fall\{case of\}\{text\}\macind{Fall}\par + $\backslash$uFall\{case of\}\{text\}\macind{uFall}\par + $\backslash$lFall\{case of\}\{line text\}\macind{lFall}\par + $\backslash$Anderes\{default text\}\macind{Anderes}\par + $\backslash$lAnderes\{default line\}\macind{lAnderes}\par +\item $\backslash$Fuer\{condition\}\{loop\}\macind{Fuer}\par + $\backslash$lFuer\{condition\}\{line loop\}\macind{lFuer}%For +\item $\backslash$FuerPar\{condition\}\{loop\}\macind{FuerPar}\par%ForPar + $\backslash$lFuerPar\{condition\}\{line\}\macind{lFuerPar}\par%ForPar +\item $\backslash$FuerJedes\{condition\}\{loop\}\macind{FuerJedes}\par%ForEach + $\backslash$lFuerJedes\{condition\}\{line\}\macind{lFuerJedes}\par%ForEach +\item $\backslash$FuerAlle\{condition\}\{loop\}\macind{FuerAlle}\par%ForAll + $\backslash$lFuerAlle\{condition\}\{line\}{Ende}\macind{lFuerAlle}\par%ForAll +\item $\backslash$Solange\{condition\}\{loop\}{Ende}\macind{Solange}\par%While + $\backslash$lSolange\{condition\}\{line\}\macind{lSolange}\par%While +\end{itemize} + +Here we describe how they are obtained: + +\begin{itemize} +\item \almacpp{SetKwInput}{Ein}{Eingabe}\par%KwIn + \almacpp{SetKwInput}{Aus}{Ausgabe}\par%KwOut + \almacpp{SetKwInput}{Daten}{Daten}\par%KwData + \almacpp{SetKwInput}{Ergebnis}{Ergebnis}%KwResult +\item \almacpp{SetKw}{Bis}{bis}\par%KwTo + \almacpp{SetKw}{KwZurueck}{zur\"uck}\par%KwRet + \almacpp{SetKw}{Zurueck}{zur\"uck}%Return +\item \almacppp{SetKwBlock}{Beginn}{Beginn}{Ende}%Begin +\item \almacppp{SetKwRepeat}{Wiederh}{wiederhole}{bis}%Repeat +\item \almacphuit{SetKwIF}{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende}%IF +\item + \almacphuit{SetKwSwitch}{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}\texttt{Ende.}%Switch +\item \almacpppp{SetKwFor}{Fuer}{f\"ur}{tue}{Ende}%For +\item \almacpppp{SetKwFor}{FuerPar}{f\"ur}{tue gleichzeitig}{Ende}%ForPar +\item \almacpppp{SetKwFor}{FuerJedes}{f\"ur jedes}{tue}{Ende}%ForEach +\item \almacpppp{SetKwFor}{FuerAlle}{f\"ur alle}{tue}{Ende}%ForAll +\item \almacpppp{SetKwFor}{Solange}{solange}{tue}{Ende}%While +\end{itemize} + +\subsection{Spanish keywords} + +\begin{enumerate} +\item $\backslash$Datos\{Datos\}\macind{Datos}\par + $\backslash$Resultado\{Resultado\}\macind{Resultado}\par + $\backslash$Entrada\{Entrada\}\macind{Entrada}\par + $\backslash$Salida\{Salida\}\macind{Salida}\par +\item $\backslash$KwA\macind{KwA}\par + $\backslash$Devolver\{[value]\}\macind{Devolver} +\item $\backslash$Inicio\{inside block\}\macind{Inicio} +\item $\backslash$eSSi\{condition\}\{then block\}\{else block\}\macind{eSSi}\par + $\backslash$SSi\{condition\}\{then block\}\macind{SSi}\par + $\backslash$uSSi\{condition\}\{then block without end\}\macind{uSSi}\par + $\backslash$lSSi\{condition\}\{then line\}\macind{lSSi}\par + $\backslash$EnOtroCasoSi\{condition\}\{elseif block\}\macind{EnOtroCasoSi}\par + $\backslash$uEnOtroCasoSi\{condition\}\{elseif block\}\macind{uEnOtroCasoSi}\par + $\backslash$lEnOtroCasoSi\{condition\}\{elseif line without end\}\macind{lEnOtroCasoSi}\par + $\backslash$EnOtroCaso\{else block\}\macind{EnOtroCaso}\par + $\backslash$uEnOtroCaso\{else block without end\}\macind{uEnOtroCaso}\par + $\backslash$lEnOtroCaso\{else line\}\macind{lEnOtroCaso}\par +\item $\backslash$Seleccionar\{condition\}\{Seleccionar caso block\}\macind{Seleccionar} + $\backslash$uSeleccionar\{seleccionar\}\{caso block without end\}\macind{uSeleccionar}\par + $\backslash$Caso\{seleccionar\}\{caso block\}\macind{Caso}\par + $\backslash$lCaso\{seleccionar\}\{caso line\}\macind{lCaso}\par + $\backslash$Otro\{sin\'o block\}\macind{Otro}\par + $\backslash$lOtro\{sin\'o line\}\macind{lOtro}\par +\item $\backslash$Para\{condition\}\{loop block\}\macind{Para}\par + $\backslash$lPara\{condition\}\{loop line\}\macind{lPara} +\item $\backslash$ParaPara\{condition\}\{loop block\}\macind{ParaPara}\par + $\backslash$lParaPara\{condition\}\{loop line\}\macind{lParaPara} +\item $\backslash$Mientras\{condition\}\{loop block\}\macind{Mientras}\par + $\backslash$lMientras\{condition\}\{loop line\}\macind{lMientras} +\item $\backslash$ParaCada\{condition\}\{loop block\}\macind{ParaCada}\par + $\backslash$lParaCada\{condition\}\{loop line\}\macind{lPourCh} +\item $\backslash$ParaTodo\{condition\}\{loop block\}\macind{ParaTodo}\par + $\backslash$lParaTodo\{condition\}\{loop line\}\macind{lParaTodo} +\item $\backslash$Repetir\{stop condition\}\{loop block\}\macind{Repetir}\par + $\backslash$lRepetir\{stop condition\}\{line loop\}\macind{lRepetir} +\end{enumerate} + +Here we describe how they are obtained: + +\begin{enumerate} +\item \almacpp{SetKwInput}{Datos}{Datos}\par + \almacpp{SetKwInput}{Resultado}{Resultado}\par + \almacpp{SetKwInput}{Entrada}{Entrada}\par + \almacpp{SetKwInput}{Salida}{Salida}\par +\item \almacpp{SetKw}{KwA}{a}\par + \almacpp{SetKw}{Devolver}{devolver} +\item \almacppp{SetKwBlock}{Inicio}{inicio}{fin} +\item \almacphuit{SetKwIF}{SSi}{EnOtroCasoSi}{EnOtroCaso}{si}{entonces}{sin\'o, si}{sin\'o}{fin si} +\item {\footnotesize\almacphuit{SetKwSwitch}{Seleccionar}{Caso}{Otro}{seleccionar}{hacer}{caso}{sin\'o}{fin caso}\texttt{fin seleccionar}} +\item \almacpppp{SetKwFor}{Para}{para}{hacer}{fin para}\par +\item \almacpppp{SetKwFor}{ParaPara}{par}{hacer en paralelo}{fin para}\par +\item \almacpppp{SetKwFor}{Mientras}{mientras}{hacer}{fin mientras}\par +\item \almacpppp{SetKwFor}{ParaCada}{ParaCada}{hacer}{fin para cada} +\item \almacpppp{SetKwFor}{ParaTodo}{para todo}{hacer}{fin para todo} +\item \almacppp{SetKwRepeat}{Repetir}{repetir}{hasta que} +\end{enumerate} + +\subsection{Italian keywords} + +\begin{itemize} +\item $\backslash$KwIng\{Ingresso\}\macind{KwIng}\par + $\backslash$KwUsc\{Uscita\}\macind{KwUsc}\par + $\backslash$KwDati\{Dati\}\macind{KwDati}\par + $\backslash$KwRisult\{Risultato\}\macind{KwRisult} +\item $\backslash$KwA\macind{a}\par + $\backslash$KwRitorna\{ritorna\}\macind{KwRitorna}\par + $\backslash$Ritorna\{ritorna\}\macind{Ritorna} +\item $\backslash$Inizio\{inside block\}\macind{Inizio} +\item $\backslash$Ripeti\{stop condition\}\{text loop\}\macind{Ripeti}\par + $\backslash$lRipeti\{stop condition\}\{line of the loop\}\macind{lRipeti} +\item $\backslash$eSea\{condition\}\{then block\}\{else block\}\macind{eSea}\par + $\backslash$\{condition\}\{then block\}\macind{Sea}\par + $\backslash$uSea\{condition\}\{then block without end\}\macind{uSea}\par + $\backslash$lSea\{condition\}\{then's line text\}\macind{lSea}\par + $\backslash$AltSe\{else block\}\macind{AltSe}\par + $\backslash$uAltSe\{else block without else\}\macind{uAltSe}\par + $\backslash$lAltSe\{else's line text\}\macind{lAltSe}\par + $\backslash$Altrimenti\{condition\}\{elseif block\}\macind{Altrimenti}\par + $\backslash$uAltrimenti\{condition\}\{elseif block without end\}\macind{uAltrimenti}\par + $\backslash$lAltrimenti\{condition\}\{elseif's line text\}\macind{lAltrimenti} +\item $\backslash$Switch\{condition\}\{Switch block\}\macind{Switch}\par + $\backslash$Case\{a case\}\{case block\}\macind{Case}\par + $\backslash$uCase\{a case\}\{case block without end\}\macind{uCase}\par + $\backslash$lCase\{a case\}\{case's line\}\macind{lCase}\par + $\backslash$Other\{otherwise block\}\macind{Other}\par + $\backslash$lOther\{otherwise's line\}\macind{lOther} +\item $\backslash$Per\{condition\}\{text loop\}\macind{Per}\par + $\backslash$lPer\{condition\}\{line text loop\}\macind{lPer} +\item $\backslash$PerPar\{condition\}\{text loop\}\macind{PerPar}\par + $\backslash$lPerPar\{condition\}\{line text loop\}\macind{lPerPar} +\item $\backslash$PerCiascun\{condition\}\{text loop\}\macind{PerCiascun}\par + $\backslash$lPerCiascun\{condition\}\{line text loop\}\macind{lPerCiascun} +\item $\backslash$PerTutti\{condition\}\{text loop\}\macind{PerTutti}\par + $\backslash$lPerTutti\{condition\}\{line text loop\}\macind{lPerTutti} +\item $\backslash$Finche\{stop condition\}\{text loop\}\macind{Finche}\par + $\backslash$lFinche\{stop condition\}\{text loop\}\macind{lFinche} +\end{itemize} + +Here we describe how they are obtained: + +\begin{enumerate} +\item \almacpp{SetKwInput}{KwIng}{Ingresso} +\item \almacpp{SetKwInput}{KwUsc}{Uscita} +\item \almacpp{SetKwInput}{KwDati}{Dati} +\item \almacpp{SetKwInput}{KwRisult}{Risultato} +\item \almacpp{SetKw}{KwA}{a} +\item \almacpp{SetKw}{KwRitorna}{ritorna} +\item \almacpp{SetKw}{Ritorna}{ritorna} +\item \almacppp{SetKwBlock}{Inizio}{inizio}{fine} +\item \almacppp{SetKwRepeat}{Ripeti}{ripeti}{finché} +\item \almacphuit{SetKwIF}{Sea}{AltSe}{Altrimenti}{se}{allora}{altrimenti se}{allora}{fine se} +\item \almacphuit{SetKwSwitch}{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}\texttt{endsw} +\item \almacpppp{SetKwFor}{Per}{per}{fai}{fine per} +\item \almacpppp{SetKwFor}{PerPar}{per}{fai in parallelo}{fine per} +\item \almacpppp{SetKwFor}{PerCiascun}{per ciascun}{fai}{fine per ciascun} +\item \almacpppp{SetKwFor}{PerTutti}{per tutti i}{fai}{fine per tutti} +\item \almacpppp{SetKwFor}{Finche}{finché}{fai}{fine finché} +\end{enumerate} + +\subsection{Portuguese keywords} + +\begin{itemize} +\item $\backslash$Entrada\{Entrada\}\macind{KwEntrada}\par + $\backslash$Saida\{Sa\'{i}da\}\macind{KwSaida}\par + $\backslash$Dados\{Dados\}\macind{KwDados}\par + $\backslash$Resultado\{Resultado\}\macind{KwResultado} +\item $\backslash$Ate\macind{at\'{e}}\par + $\backslash$KwRetorna\{[val]\}\macind{KwRetorna}\par + $\backslash$Retorna\{[val]\}\macind{Retorna} +\item $\backslash$Iniciob\{inside block\}\macind{Iniciob} +\item $\backslash$eSe\{condition\}\{then block\}\{else block\}\macind{eSe}\par + $\backslash$Se\{condition\}\{then block\}\macind{Se}\par + $\backslash$uSe\{condition\}\{then block without end\}\macind{uSe}\par + $\backslash$lSe\{condition\}\{then's line text\}\macind{lSe}\par + $\backslash$Senao\{else block\}\macind{Senao}\par + $\backslash$uSenao\{else block without else\}\macind{uSenao}\par + $\backslash$lSenao\{else's line text\}\macind{lSenao}\par + $\backslash$SenaoSe\{condition\}\{elseif block\}\macind{uSenaoSe}\par + $\backslash$uSenaoSe\{condition\}\{elseif block without end\}\macind{uSenaoSe}\par + $\backslash$lSenaoSe\{condition\}\{elseif's line text\}\macind{lSenaoSe} +\item $\backslash$Selec\{condition\}\{Switch block\}\macind{Selec}\par + $\backslash$Caso\{a case\}\{case block\}\macind{Caso}\par + $\backslash$uCaso\{a case\}\{case block without end\}\macind{uCaso}\par + $\backslash$lCaso\{a case\}\{case's line\}\macind{lCaso}\par + $\backslash$Outro\{otherwise block\}\macind{Outro}\par + $\backslash$lOutro\{otherwise's line\}\macind{lOutro} +\item $\backslash$Para\{condition\}\{text loop\}\macind{Para}\par + $\backslash$lPara\{condition\}\{line text loop\}\macind{lPara} +\item $\backslash$ParaPar\{condition\}\{text loop\}\macind{ParaPar}\par + $\backslash$lParaPar\{condition\}\{line text loop\}\macind{lParaPar} +\item $\backslash$ParaCada\{condition\}\{text loop\}\macind{ParaCada}\par + $\backslash$lParaCada\{condition\}\{line text loop\}\macind{lParaCada} +\item $\backslash$ParaTodo\{condition\}\{text loop\}\macind{ParaTodo}\par + $\backslash$lParaTodo\{condition\}\{line text loop\}\macind{lParaTodo} +\item $\backslash$Enqto\{stop condition\}\{text loop\}\macind{Enqto}\par + $\backslash$lEnqto\{stop condition\}\{text loop\}\macind{lEnqto} +\item $\backslash$Repita\{stop condition\}\{text loop\}\macind{Repita}\par + $\backslash$lRepita\{stop condition\}\{line of the loop\}\macind{lRepita} +\end{itemize} + +Here we describe how they are obtained: + +\begin{enumerate} +\item \almacpp{SetKwInput}{Entrada}{Entrada}\par + \almacpp{SetKwInput}{Saida}{Sa\'{i}da}\par + \almacpp{SetKwInput}{Dados}{Dados}\par + \almacpp{SetKwInput}{Resultado}{Resultado}% +\item \almacpp{SetKw}{Ate}{at\'{e}} + \almacpp{SetKw}{KwRetorna}{retorna}\par + \almacpp{SetKw}{Retorna}{retorna}\par +\item \almacppp{SetKwBlock}{Inicio}{in\'{i}cio}{fim}% +\item \almacphuit{SetKwIF}{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% +\item \almacphuit{SetKwSwitch}{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}\texttt{fim selec}% +\item \almacpppp{SetKwFor}{Para}{para}{fa\c{c}a}{fim para}% +\item \almacpppp{SetKwFor}{ParaPar}{para}{fa\c{c}a em paralelo}{fim para} +\item \almacpppp{SetKwFor}{ParaCada}{para cada}{fa\c{c}a}{fim para cada}% +\item \almacpppp{SetKwFor}{ParaTodo}{para todo}{fa\c{c}a}{fim para todo}% +\item \almacpppp{SetKwFor}{Enqto}{enquanto}{fa\c{c}a}{fim enqto}% +\item \almacppp{SetKwRepeat}{Repita}{repita}{at\'{e}}% +\end{enumerate} + +\subsection{Some Czech keywords} + +Here are some czech keywords, please feel free to send me the others. + +\begin{itemize} +% \item $\backslash$AlgVst\macind{AlgVst} +% \item $\backslash$AlgVyst\macind{AlgVyst} +\item $\backslash$Vst\macind{Vst} +\item $\backslash$Vyst\macind{Vyst} +\item $\backslash$Vysl\macind{Vysl} +\end{itemize} + +How they are obtained: + +\begin{enumerate} +% \item \almacp{SetKwInOut}{AlgVst}{Vstup} +% \item \almacp{SetKwInOut}{AlgVyst}{V\'{y}stup} +\item \almacp{SetKwInput}{Vst}{Vstup}% +\item \almacp{SetKwInput}{Vyst}{V\'{y}stup}% +\item \almacp{SetKwInput}{Vysl}{V\'{y}sledek}% +\end{enumerate} + + +\section{Known bugs}\label{sec_bugs} + +\begin{itemize} +\item no more known bugs actually; if you find one, please send it to me. +\end{itemize} + +\clearpage +\appendix +\section*{Release notes}\label{sec:relnotes} + +\begin{verbatim} +% - July 18 2017 - revision 5.2 +% * FIX: There was an overfull box 0.8pt with boxruled algorithm. This +% is fixed. +% * FIX: problem when mixing caption package and figure option. This bug +% was partially corrected in 5.0 for one side document but with +% false indentation and not working for two side document. This +% is now fully fixed. +% * FIX: misaligned lines numbers with noline option +% * FIX: Fix croation keywords thanks to Ivan Kolan +% * FIX: there was an overfull hbox of 8.5pt when using [H] and ruled +% caption. This is fixed. +% * FIX: \SetCustomAlgoRuledWidth only changed midrule. This is fixed, +% it changes all the rules +% - October 19 2015 - revision 5.1 +% * CHANGE/ADD: l commands (the ones as \lIf) can now be used with a +% star. If done, no end of line are done, so you can enclose +% l command into another one. For example, you can write: +% \lForEach{$i$}{\lIf*{foo}{bar}}. +% Note that when you use a star, side comments are not allowed. +% * CHANGE/ADD: Now you can have a side comment at end of macros which +% have a block. For example you can do : +% \Begin(\tcc*[h]{side comment for begin}{ +% text}(\tcc*[h]{side comment after end}) +% Note: there are some side effects for some commands: +% \SetKwProg : macro defined thanks to \SetKwProg are allowed +% to have no end marker. In this case, +% beware to end side comment, this can +% do weird output (but no error) +% * CHANGE: \SetKwSwitch defines also an \uOther command which was not +% the case until this release. +% * CHANGE: \SetStartEndCondition{typo1}{typo2}{typo3} defined two end +% conditions (type2 and typo3) : typo3 is no more used for +% case condition as typo2 is used which is more consistent +% since there is a condition followed by a keyword as for +% if-then or other command that are defined using typo2. +% * CHANGE: keywords was not language dependant to allow to use multiple +% languages in the same document, but some keywords in +% different language were having the same keyword that lead +% last one declared to replace first one and so you could have some +% spanish keywords printed as you were in portuguese. So +% this behavior is changed from now: +% - localized keywords are defined if according language +% option is defined ; +% - if you want to keep old behaviour and use localized +% keywords without using language option (keep old +% behavior), you can use languagekw option +% (e.g. frenchkw, germankw, ...). Note that you can use +% multiple languagekw options at the same time, in +% contrary of language option. Note also that if you use +% multiple languagekw options, you can get back the same +% problem as previously when keywords was not language +% dependant. +% * ADD: new typo styles: +% - Arguments of functions have now their own style. By +% default, FuncArgSty is the same as ArgSty. +% - Name of KwProg have now their own sty (they used ArgSty +% previously). By default, ProgSty is still ArgSty. +% As usual, \SetFuncArgSty{}, FuncArgSty{} and +% \SetProgSty{}, ProgSty{} are macros to set and use these +% typo styles. +% * ADD: Options to manage algorithm hangindent +% Until this revision, long statement acts as classical text and +% continue on next line starting from the same point. This makes +% difficult to notice that the new lines of text is not a new +% statement. Now, hangindent is managed and when a long +% statement continue on next lines, lines, except the first, +% are indented. +% Option: noalgohanging +% By default, long statement are indented on subsequent +% lines; with this option you get old behavior and lines are +% no more indented +% Option: hangingcomment +% Comment that are alone on a line (not side comment) are +% not driven by algo hanging: subsequent lines of long +% comments are indented according to width of start comment +% marker. With this option, comment are indented like normal +% statement. +% Option: hanginginout +% As for comment, by default, in/out keywords and input +% keywords (defined by \SetKwInOut or \SetKwInput) are not +% indented by algorithm hangindent. They are indented +% according to width of input keyword. If you want that these +% keywords acts like normal statement, use this option. +% \SetAlgoHangIndent{length} +% This macro allows you to set your own indent length. By +% default, \SetAlgoHangIndent{0.5em} +% * ADD: Group markers. +% This option is related to block markers of release 5.0. Some +% have ask to put also block markers for single line +% command. This new feature has been implemented to do this. +% So, you can now ask package to put begin and end keywords +% automatically at start and end of single line command (see +% example in documentation). +% These new group markers macros are: +% - \AlgoDisplayGroupMarkers and \AlgoDontDisplayGroupMarkers +% Note that a new option has also been added: displaygroupmarkers +% * ADD: \SetCustomAlgoRuledWidth{length} +% set a custom ruled width of ruled and algoruled options ; +% note that by the moment you use this macro, rules will have +% this fixed length: this can cause strange behavior in +% multicolumn mode or other layout that change the line +% width. +% * ADD: turkish language option +% * FIX: a spurious whitespace which results in a spurious indent in the +% user's text right after the end of the algorithm environment +% was introduced in release 5.0. This is fixed now thanks to +% Alexander Malkis. +% * FIX: there was a problem with margins in caption when option figure +% was use with caption package. This is fixed. +% * FIX: when changing font size in caption with, interline skip stayed +% unchanged and so with a small font was to large. This is fixed. +% * FIX: in contrary of that is written in the documentation, ':' what +% not in KwSty typo for KwIn and KwOut command. This is fixed. +% * FIX: strange behaviour with label and lines numbered: @currentlabel +% was updated according to algo line number not in all +% situation. For e.g, with hyperref package, always updated ; +% with \nlset also updated, but with \nl or linesnumbered +% option, not updated. This "feature" causes different output +% with \label command according to options used which is not +% that one want. This is solved now, and @currentlabel is +% always updated so \label command works always is the same way. +% * FIX: some czech keywords +% * FIX: some spanish keywords +% * FIX: some croatian keywords +% * FIX: krantz class changes definition of chapter and get one more +% option that classical classes as book.cls or report.cls and +% broke fix for hyperref on chapter definition. This is now +% fixed and algorithm detects use of krantz class and use then +% a definition of chapter working with krantz class. +% * FIX: an issue with internal macro which causes ([Q]) use as argument +% of some environment to be misprinted (thanks to Martin Schröder). +% * FIX: mispelled name of hyperrefcounter inside internal macro. +% +% - January 6 2013 - revision 5.0 +% * CHANGE: SetKwSwith takes now 9 args: 9th arg is the same as +% previous 8th arg ('end of switch' keyword). New 8th arg is +% 'end of case' keyword. This is due to change of release +% 3.2 which introduce end after case block... as I never +% test with longend option, I never see that the 'end +% switch' used for case was not good. +% * CHANGE: when no end keyword is defined in a block macro, then +% algorithm2e does no more try to print it. So even with lined or noline +% option, no empty line is printed (before: a blank end was +% printed, so a blank line appeared) +% * Internal Change: add some internal function to improve readibility +% (thanks to Philip K. F. H\ölzenspies) +% * ADD: Block markers. +% You can now ask package to put begin and end keywords automatically at begin +% and end of blocks, it means each group of commands shifted and enclosed in +% braces. +% This is tricky to use but, combined with \SetStartEndCondition and +% redefinition of keywords, you should be abble to simulate any syntax. See +% examples in documentation where a generic example is derived in pseudo-code, +% python and C by keeping code and changing only style using block markers +% macros, \SetStartEndCondition and some redefinition of keywords. +% These new block markers macros are: +% - \AlgoDisplayBlockMarkers and \AlgoDontDisplayBlockMarkers +% - \SetAlgoBlockMarkers{begin marker}{end marker} +% - \BlockMarkersSty{text} and \SetBlockMarkersSty +% Note that a new option has also been added: displayblockmarkers +% * ADD: \leIf macro automatically defined by \SetKw: allow to define +% an if-then-else on a single line. +% * ADD: new macro \SetStartEndCondition{typo1}{typo2}{typo3} which +% sets typo around condition in For, If, Switch, Case and +% Repeat macros. First two are used around For, If, Swith +% conditions, First and third are used for Case and Repeat +% condition. Default definition is \SetStartEndCondition{ }{ }{}. +% A common alternative is \SetStartEndCondition{ (}{) }{)} +% Can also be used to remove space around condition, for +% example if you want python style commands: +% \SetStartEndCondition{ }{}{} and \SetKwFor{For}{for}{:}{} +% * ADD: new environment algomathdisplay which allow display math (like inside \[ \] or $$ $$) +% handling end line and line number +% * ADD: new command \SetKwProg{Env}{Title}{ is}{end} which defines a macro +% \Env{args}{text}. Env is a block with 'Title' (in \CapSty) at the beginning +% followed by args followed by 'is' then 'text' is put below inside a block ended +% by 'end'. If no 'end' is specified, nothing is written (no +% blank line is inserted). Useful to typeset function or prog for example: +% \SetKwProg{Fn}{Function}{ is}{end} makes \Fn{afunc(i: int) : int}{return 0\;} +% writes: +% Function afunc(i: int) : int is +% | return 0; +% end +% or \SetKwProg{Def}{def}{:}{} makes \Def{afunc(i: int)}{return 0\;} writes: +% def afunc(i: int): +% | return 0 +% Tip: combine it with \SetKwFunction to write recursive function algorithm. With +% example above, you could define \SetKwFunction{\Afunc}{afunc} and then write: +% Def{\Afunc{i:int}{\eIf{i>0}{\KwRet \Afunc{i-1}}{\KwRet 0\;}} that writes: +% def afunc(i: int): +% | if(i>0): +% | return afunc(i-1) +% | else: +% | return 0 +% with appropriate typo. +% * ADD: option croatian: croatian keywords (thanks to Ivan Gavran) +% * ADD: option ngerman: same as german option but so can be used with global option ngerman +% of babel +% * ADD: option spanish: Spanish support (thanks to Mario Abarca) +% * ADD: unterminated block: useful to add part separator that doesn't necessary need an end +% keyword. +% Designed on the pattern of unterminated if (see \uIf macro) allowing to +% add a block that is not terminated by a keyword. Such block are defined in the same +% time as a block is defined by adding a macro beginning with u. So, for example, +% predefined \SetKwBlock{Begin}{begin}{end} defines now two commands: +% - \Begin{} as previously which print a begin - end block +% - \uBegin{} that defines a begin only block +% * FIX: dotocloa option which was broken +% * FIX: uIf and uCase didn't have same behavior when used with +% noline, vlined or lined option. This is fixed. Side effect: no empty +% line after an uIf or uCase when used with options lined or vlined +% * FIX: a bug with Repeat Until command when use with side comment on Until +% * FIX: a bug with side text -- text put into () -- of command macro (SetKwIf and so on) +% which was always setting a ';' even after a \DontPrintSemicolon +% * FIX: a bug with hyperref and chapter definition (thanks to Hubert Meier) +% * FIX: bugs with l macro and side comment +% * FIX: revision number +% * FIX: fix non ascii character (utf8 not yet recognized by all latex engine) +% * FIX: fnum@algocf had an useless parameter which sometimes broke expansion and output an error +% * FIX: works now with multicol package +\end{verbatim} + +\clearpage +\listofalgorithms +\clearpage +\printindex +\end{document} + diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex01.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex01.tex new file mode 100644 index 0000000000..083de70a63 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex01.tex @@ -0,0 +1,8 @@ +\SetAlgoVlined +\eIf{cond1}{ + a line\; + a line\; +}{ + another line\; + another line\; +} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex02.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex02.tex new file mode 100644 index 0000000000..4162e95621 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex02.tex @@ -0,0 +1,5 @@ +\SetAlgoNoLine +\If{cond2}{ + second if\; + second if\; +} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex03.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex03.tex new file mode 100644 index 0000000000..7b106461f3 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex03.tex @@ -0,0 +1,5 @@ +\lIf{cond3}{ another example} +\Else{ + a block\; + a block\; +} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex04.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex04.tex new file mode 100644 index 0000000000..2d586a01c9 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex04.tex @@ -0,0 +1,2 @@ +\lIf{cond4}{ok} \lElse{wrong} +\leIf{cond4}{ok}{wrong} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex05.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex05.tex new file mode 100644 index 0000000000..7db5f9d249 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex05.tex @@ -0,0 +1,10 @@ +\SetAlgoVlined +\lIf{cond5}{cond5 true} +\uElseIf{cond51}{ + cond 5 false\; + but cond51 true\; +} +\ElseIf{}{ + all is wrong\; + \Return result52\; +} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex06.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex06.tex new file mode 100644 index 0000000000..b9837cbd40 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex06.tex @@ -0,0 +1,13 @@ +\SetAlgoLined +\uIf{cond6}{ + cond6 is ok\; + always ok\; +} +\uElseIf{cond62}{ + choose result62\; + \Return result62\; +} +\Else{ + all is wrong\; + do something else\; +} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex07.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex07.tex new file mode 100644 index 0000000000..7aecb14f2d --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_ex07.tex @@ -0,0 +1,35 @@ +Let's have a look at what we can do +with if-then-else and side comments\; +\eIf{if-then-else test}{ + no comment here\; + neither in then\; +}{ + nor in else\; +} +\eIf(\tcc*[f]{then comment}){test}{ + then with a comment\; +}(\tcc*[f]{comment in else}) +{ + here we are in else\; +} +\eIf(\tcc*[f]{then comment}){test}{ + again a comment in then\; +}{ + but not in else\; +} +\eIf{if-then-else test}{ + this time, no comment in then\; +}(\tcc*[f]{else comment}) +{ + but one comment in else\; +} +Let's try with other if possibilities\; +\lIf(\tcc*[h]{lif comment}){test}{text} +\uIf(\tcc*[f]{uif comment}){test}{ + then text\; +} +\uElseIf(\tcc*[f]{comment}){test}{ + elseif text\; +} +\lElseIf(\tcc*[h]{comment}){test}{text} +\lElse(\tcc*[f]{comment}){text} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_exAlgoDisjdecomp.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exAlgoDisjdecomp.tex new file mode 100644 index 0000000000..d62fbb685a --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exAlgoDisjdecomp.tex @@ -0,0 +1,30 @@ +\IncMargin{1em} +\begin{algorithm} + \SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up} + \SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress} + \SetKwInOut{Input}{input}\SetKwInOut{Output}{output} + + \Input{A bitmap $Im$ of size $w\times l$} + \Output{A partition of the bitmap} + \BlankLine + \emph{special treatment of the first line}\; + \For{$i\leftarrow 2$ \KwTo $l$}{ + \emph{special treatment of the first element of line $i$}\; + \For{$j\leftarrow 2$ \KwTo $w$}{\label{forins} + \Left$\leftarrow$ \FindCompress{$Im[i,j-1]$}\; + \Up$\leftarrow$ \FindCompress{$Im[i-1,]$}\; + \This$\leftarrow$ \FindCompress{$Im[i,j]$}\; + \If(\tcp*[h]{O(\Left,\This)==1}){\Left compatible with \This}{\label{lt} + \lIf{\Left $<$ \This}{\Union{\Left,\This}} + \lElse{\Union{\This,\Left}} + } + \If(\tcp*[f]{O(\Up,\This)==1}){\Up compatible with \This}{\label{ut} + \lIf{\Up $<$ \This}{\Union{\Up,\This}} + \tcp{\This is put under \Up to keep tree as flat as possible}\label{cmt} + \lElse{\Union{\This,\Up}}\tcp*[h]{\This linked to \Up}\label{lelse} + } + } + \lForEach{element $e$ of the line $i$}{\FindCompress{p}} + } + \caption{disjoint decomposition}\label{algo_disjdecomp} +\end{algorithm}\DecMargin{1em} \ No newline at end of file diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_exIR.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exIR.tex new file mode 100644 index 0000000000..1415f65e91 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exIR.tex @@ -0,0 +1,40 @@ +\begin{algorithm} +\DontPrintSemicolon +\KwData{$G=(X,U)$ such that $G^{tc}$ is an order.} +\KwResult{$G'=(X,V)$ with $V\subseteq U$ such that $G'^{tc}$ is an +interval order.} +\Begin{ + $V \longleftarrow U$\; + $S \longleftarrow \emptyset$\; + \For{$x\in X$}{ + $NbSuccInS(x) \longleftarrow 0$\; + $NbPredInMin(x) \longleftarrow 0$\; + $NbPredNotInMin(x) \longleftarrow |ImPred(x)|$\; + } + \For{$x \in X$}{ + \If{$NbPredInMin(x) = 0$ {\bf and} $NbPredNotInMin(x) = 0$}{ + $AppendToMin(x)$} + } + \nl\While{$S \neq \emptyset$}{\label{InRes1} + \nlset{REM} remove $x$ from the list of $T$ of maximal index\;\label{InResR} + \lnl{InRes2}\While{$|S \cap ImSucc(x)| \neq |S|$}{ + \For{$ y \in S-ImSucc(x)$}{ + \{ remove from $V$ all the arcs $zy$ : \}\; + \For{$z \in ImPred(y) \cap Min$}{ + remove the arc $zy$ from $V$\; + $NbSuccInS(z) \longleftarrow NbSuccInS(z) - 1$\; + move $z$ in $T$ to the list preceding its present list\; + \{i.e. If $z \in T[k]$, move $z$ from $T[k]$ to + $T[k-1]$\}\; + } + $NbPredInMin(y) \longleftarrow 0$\; + $NbPredNotInMin(y) \longleftarrow 0$\; + $S \longleftarrow S - \{y\}$\; + $AppendToMin(y)$\; + } + } + $RemoveFromMin(x)$\; + } + } +\caption{IntervalRestriction\label{IR}} +\end{algorithm} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_exProg.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exProg.tex new file mode 100644 index 0000000000..10428c0862 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exProg.tex @@ -0,0 +1,6 @@ +\SetAlgoLined +\SetKwProg{Fn}{Function}{ is}{end} +\Fn{afunc(i: int) : int}{return 0\;} + +\SetKwProg{Def}{def}{:}{} +\Def{afunc(i: int)}{return 0\;} \ No newline at end of file diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_exfor.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exfor.tex new file mode 100644 index 0000000000..d8667fc333 --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exfor.tex @@ -0,0 +1,10 @@ +\SetAlgoLined +\ForAll{elements of $S_1$}{ + remove an element e from $S_1$\; + put e in the set $S_2$\; + } +\lFor{i=1 \emph{\KwTo}max}{mark i}\; +\ForEach{$e$ in the set}{ + put $e$ in ${\cal E}$\; + mark $e$\; +} diff --git a/macros/latex/contrib/algorithm2e/doc/algorithm2e_exgeneric.tex b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exgeneric.tex new file mode 100644 index 0000000000..dc8c53d49b --- /dev/null +++ b/macros/latex/contrib/algorithm2e/doc/algorithm2e_exgeneric.tex @@ -0,0 +1,36 @@ +\Fn(\tcc*[h]{algorithm as a recursive function}){\FRecurs{some args}}{ + \KwData{Some input data\\these inputs can be displayed on several lines and one + input can be wider than line's width.} + \KwResult{Same for output data} + \tcc{this is a comment to tell you that we will now really start code} + \If(\tcc*[h]{a simple if but with a comment on the same line}){this is true}{ + we do that, else nothing\; + \tcc{we will include other if so you can see this is possible} + \eIf{we agree that}{ + we do that\; + }{ + else we will do a more complicated if using else if\; + \uIf{this first condition is true}{ + we do that\; + } + \uElseIf{this other condition is true}{ + this is done\tcc*[r]{else if} + } + \Else{ + in other case, we do this\tcc*[r]{else} + } + } + } + \tcc{now loops} + \For{\forcond}{ + a for loop\; + } + \While{$i '^^J% +% +% $Id: algorithm2e.sty,v 5.2 2017/07/18 15:26:26 fioriochristophe Exp $ +% +% PACKAGES REQUIRED: +% +% - float (in contrib/supported/float) +% - ifthen (in base) +% - xspace (in packages/tools) +% - relsize (in contrib/misc/relsize.sty) +% +%%%%%%%%%%%%%%% Release 5.2 +% +% Package options: +% --------------- +% - oldcommands : to use old command names +% - french, english, german, ngerman +% portuguese, czech, italiano, +% slovak, croatian, spanish : for the name of the algorithm and some keyword code +% - onelanguage : to simply switch keyword from one language to another without changing +% keyword commands +% - boxed, boxruled, ruled, tworuled, +% algoruled, plain : layout of the algorithm +% - algo2e : environment is algorithm2e instead of algorithms and \listofalgorithmes +% instead of \listofalgorithms +% - slide : to use when making slides +% - noline,lined,vlined : how block are designed. +% - shortend, longend, noend : short or long end keyword as endif for e.g. +% - linesnumbered : auto numbering of the algorithm's lines +% - linesnumberedhidden : to hide autonumbered lines (show number on a line with \ShowLn +% - commentsnumbered, inoutnumbered : to autonumber comments and inout keywords (by defaut not numbered) +% - rightnl : to have line number on the right instead of on the left as default +% - algonl : line numbers preceded by algo number +% - scright, scleft : right or left justified side comments +% - fillcomment, nofillcomment : end mark of comment is flushed to the right so comments fill the line +% - dotocloa : add an entry in the toc for list of algorithms (require tocbibind package) +% - endfloat : add algoendfloat environment pushing algorithm so written to the end of document +% - resetcount, noresetcount : start value of line numbers. +% - algopart,algochapter,algosection : algo numbering within part, chapter or section +% - titlenumbered,titlenotnumbered : numbering of title set by \Titleofalgo +% - figure : algorithms are figures, numbered as figures, and put in the list of figures. +% - procnumbered : procedure or function are numbered as algorithm +% - nokwfunc : procedure or function name doens't become a command +% - norelsize : don't use relsize package (useful if it breaks the compatibily) +% - displayblockmarkers : display begin, end keywords at start of each block +% +% defaults are; english,plain,resetcount,titlenotnumbered +% +%%%%%%%%%%%%%% +% +% Short summary +% ------------- +% +% algorithm is an environment for writing algorithm in LaTeX2e. +% Almost all is customizable. You can add keywords, change style, change the layout, ... +% It provide macros that allow you to create differents sorts of key words, therefore a set of predefined key +% word is gived. +% +% IT should be used as follows +% +% \begin{algorithm} +% ... +% ... +% \end{algorithm} +% +% +% IMPORTANT : each line MUST end with \; +% +% Note that if you define macros outside algorithm environment they +% are avaible in all the document and particulary you can use then +% inside all algorithms without re-define them. +% +% an example: +% +% \begin{algorithm} +% \SetAlgoLined +% \KwIn{this text} +% \KwOut{how to write algorithm with \LaTeX2e } +% +% initialization\; +% \While{not at end of this document}{ +% read current section\; +% \eIf{understand}{ +% go to next section\; +% current section becomes this one\; +% }{ +% go back to the beginning of current section\; +% } +% } +% \caption{How to write algorithm} +% \end{algorithm} +% +% +%%%%%%%%%%%%%% predefined keywords +% +% \KwIn{input} +% \KwOut{output} +% \KwData{input} +% \KwResult{output} +% \KwTo % a simple keyword +% \KwFrom % a simple keyword +% \KwRet{[value]} +% \Return{[value]} +% \Begin{block inside} +% \eIf{condition}{Then Block}{Else block} % in blocks +% \If{condition}{Then block} % in a block +% \uIf{condition}{Then block} % in a block unended +% \lIf{condition}{Else text} % on the same line +% \Else{inside Else} % in a block +% \lElse{Else text} % on the same line +% \uElse{Else text} % in a block unended +% \ElseIf{inside Elseif} % in a block +% \lElseIf{Elseif text} % on the same line +% \uElseIf{Elseif text} % in a block unended +% \Switch{Condition}{Switch block} +% \Case{a case}{case block} % in a block +% \lCase{a case}{case text} % on the same line +% \Other{otherwise block} % in a block +% \lOther{otherwise block} % on the same line +% \For{condition}{text loop} % in a block +% \lFor{condition}{text} % on the same line +% \ForEach{condition}{text loop} % in a block +% \lForEach{condition}{text} % on the same line +% \ForPar{condition}{text loop} % in a block +% \lForPar{condition}{text} % on the same line +% \While{condition}{text loop} % in a block +% \lWhile{condition}{text loop} % on the same line +% \Repeat{End condition}{text loop} % in a block +% \lRepeat{condition}{text} % on the same line +% +%%%%%%%%%%%%%% +% +% History: +% +% - July 18 2017 - revision 5.2 +% * FIX: There was an overfull box 0.8pt with boxruled algorithm. This is fixed. +% * FIX: problem when mixing caption package and figure option. This bug was partially corrected +% in 5.0 for one side document but with false indentation and not working for two side +% document. This is now fully fixed. +% * FIX: misaligned lines numbers with noline option +% * FIX: Fix croation keywords thanks to Ivan Kolan +% * FIX: there was an overfull hbox of 8.5pt when using [H] and ruled caption. This is fixed. +% * FIX: \SetCustomAlgoRuledWidth only changed midrule. This is fixed, it changes all the rules +% - October 19 2015 - revision 5.1 +% * CHANGE/ADD: l commands (the ones as \lIf) can now be used with a +% star. If done, no end of line are done, so you can enclose +% l command into another one. For example, you can write: +% \lForEach{$i$}{\lIf*{foo}{bar}}. +% Note that when you use a star, side comments are not allowed. +% * CHANGE/ADD: Now you can have a side comment at end of macros which +% have a block. For example you can do : +% \Begin(\tcc*[h]{side comment for begin}{text}(\tcc*[h]{side comment after end}) +% Note: there are some side effects for some commands: +% \SetKwProg : macro defined thanks to \SetKwProg are allowed +% to have no end marker. In this case, +% beware to end side comment, this can +% do weird output (but no error) +% * CHANGE: \SetKwSwitch defines also an \uOther command which was not +% the case until this release. +% * CHANGE: \SetStartEndCondition{typo1}{typo2}{typo3} defined two end +% conditions (type2 and typo3) : typo3 is no more used for +% case condition as typo2 is used which is more consistent +% since there is a condition followed by a keyword as for +% if-then or other command that are defined using typo2. +% * CHANGE: keywords was not language dependant to allow to use multiple +% languages in the same document, but some keywords in +% different language were having the same keyword that lead +% last one declared to replace first one and so you could have some +% spanish keywords printed as you were in portuguese. So +% this behavior is changed from now: +% - localized keywords are defined if according language +% option is defined ; +% - if you want to keep old behaviour and use localized +% keywords without using language option (keep old +% behavior), you can use languagekw option +% (e.g. frenchkw, germankw, ...). Note that you can use +% multiple languagekw options at the same time, in +% contrary of language option. Note also that if you use +% multiple languagekw options, you can get back the same +% problem as previously when keywords was not language +% dependant. +% * ADD: new typo styles: +% - Arguments of functions have now their own style. By +% default, FuncArgSty is the same as ArgSty. +% - Name of KwProg have now their own sty (they used ArgSty +% previously). By default, ProgSty is still ArgSty. +% As usual, \SetFuncArgSty{}, FuncArgSty{} and +% \SetProgSty{}, ProgSty{} are macros to set and use these +% typo styles. +% * ADD: Options to manage algorithm hangindent +% Until this revision, long statement acts as classical text and +% continue on next line starting from the same point. This makes +% difficult to notice that the new lines of text is not a new +% statement. Now, hangindent is managed and when a long +% statement continue on next lines, lines, except the first, +% are indented. +% Option: noalgohanging +% By default, long statement are indented on subsequent +% lines; with this option you get old behavior and lines are +% no more indented +% Option: hangingcomment +% Comment that are alone on a line (not side comment) are +% not driven by algo hanging: subsequent lines of long +% comments are indented according to width of start comment +% marker. With this option, comment are indented like normal +% statement. +% Option: hanginginout +% As for comment, by default, in/out keywords and input +% keywords (defined by \SetKwInOut or \SetKwInput) are not +% indented by algorithm hangindent. They are indented +% according to width of input keyword. If you want that these +% keywords acts like normal statement, use this option. +% \SetAlgoHangIndent{length} +% This macro allows you to set your own indent length. By +% default, \SetAlgoHangIndent{0.5em} +% * ADD: Group markers. +% This option is related to block markers of release 5.0. Some +% have ask to put also block markers for single line +% command. This new feature has been implemented to do this. +% So, you can now ask package to put begin and end keywords +% automatically at start and end of single line command (see +% example in documentation). +% These new group markers macros are: +% - \AlgoDisplayGroupMarkers and \AlgoDontDisplayGroupMarkers +% Note that a new option has also been added: displaygroupmarkers +% * ADD: \SetCustomAlgoRuledWidth{length} +% set a custom ruled width of ruled and algoruled options ; +% note that by the moment you use this macro, rules will have +% this fixed length: this can cause strange behavior in +% multicolumn mode or other layout that change the line +% width. +% * ADD: turkish language option +% * FIX: a spurious whitespace which results in a spurious indent in the +% user's text right after the end of the algorithm environment +% was introduced in release 5.0. This is fixed now thanks to +% Alexander Malkis. +% * FIX: there was a problem with margins in caption when option figure +% was use with caption package. This is fixed. +% * FIX: when changing font size in caption with, interline skip stayed +% unchanged and so with a small font was to large. This is fixed. +% * FIX: in contrary of that is written in the documentation, ':' what +% not in KwSty typo for KwIn and KwOut command. This is fixed. +% * FIX: strange behaviour with label and lines numbered: @currentlabel +% was updated according to algo line number not in all +% situation. For e.g, with hyperref package, always updated ; +% with \nlset also updated, but with \nl or linesnumbered +% option, not updated. This "feature" causes different output +% with \label command according to options used which is not +% that one want. This is solved now, and @currentlabel is +% always updated so \label command works always is the same way. +% * FIX: some czech keywords +% * FIX: some spanish keywords +% * FIX: some croatian keywords +% * FIX: krantz class changes definition of chapter and get one more +% option that classical classes as book.cls or report.cls and +% broke fix for hyperref on chapter definition. This is now +% fixed and algorithm detects use of krantz class and use then +% a definition of chapter working with krantz class. +% * FIX: an issue with internal macro which causes ([Q]) use as argument +% of some environment to be misprinted (thanks to Martin Schröder). +% * FIX: mispelled name of hyperrefcounter inside internal macro. +% +% - January 06 2013 - revision 5.0 +% * CHANGE: SetKwSwitch takes now 9 args: 9th arg is the same as +% previous 8th arg ('end of switch' keyword). New 8th arg is +% 'end of case' keyword. This is due to change of release +% 3.2 which introduce end after case block... as I never +% test with longend option, I never see that the 'end +% switch' used for case was not good. +% * CHANGE: when no end keyword is defined in a block macro, then +% algorithm2e does no more try to print it. So even with lined or noline +% option, no empty line is printed (before: a blank end was +% printed, so a blank line appeared) +% * Internal Change: add some internal function to improve readibility +% (thanks to Philip K. F. H\ölzenspies) +% * ADD: Block markers. +% You can now ask package to put begin and end keywords automatically at begin +% and end of blocks, it means each group of commands shifted and enclosed in +% braces. +% This is tricky to use but, combined with \SetStartEndCondition and +% redefinition of keywords, you should be abble to simulate any syntax. See +% examples in documentation where a generic example is derived in pseudo-code, +% python and C by keeping code and changing only style using block markers +% macros, \SetStartEndCondition and some redefinition of keywords. +% These new block markers macros are: +% - \AlgoDisplayBlockMarkers and \AlgoDontDisplayBlockMarkers +% - \SetAlgoBlockMarkers{begin marker}{end marker} +% - \BlockMarkersSty{text} and \SetBlockMarkersSty +% Note that a new option has also been added: displayblockmarkers +% * ADD: \leIf macro automatically defined by \SetKwIF: allow to define +% an if-then-else on a single line. +% * ADD: new macro \SetStartEndCondition{typo1}{typo2}{typo3} which +% sets typo around condition in For, If, Switch, Case and +% Repeat macros. First two are used around For, If, Swith +% conditions, First and third are used for Case and Repeat +% condition where condition ends the line. Default definition +% is \SetStartEndCondition{ }{ }{}. +% A common alternative is \SetStartEndCondition{ (}{) }{)} +% Can also be used to remove space around condition, for +% example if you want python style commands: +% \SetStartEndCondition{ }{}{} and \SetKwFor{For}{for}{:}{} +% * ADD: new environment algomathdisplay which allow display math (like inside \[ \] or $$ $$) +% handling end line and line number +% * ADD: new command \SetKwProg{Env}{Title}{is}{end} which defines a macro +% \Env{args}{text}. Env is a block with 'Title' (in \CapSty) at the beginning +% followed by args followed by 'is' then 'text' is put below inside a block ended +% by 'end'. If no 'end' is specified, nothing is written (no +% blank line is inserted). Useful to typeset function or prog for example: +% \SetKwProg{Fn}{Function}{ is}{end} makes \Fn{afunc(i: int) : int}{return 0\;} +% writes: +% Function afunc(i: int) : int is +% | return 0; +% end +% or \SetKwProg{Def}{def}{:}{} makes \Def{afunc(i: int)}{return 0\;} writes: +% def afunc(i: int): +% | return 0 +% Tip: combine it with \SetKwFunction to write recursive function algorithm. With +% example above, you could define \SetKwFunction{\Afunc}{afunc} and then write: +% \Def{\Afunc{i:int}{\eIf{i>0}{\KwRet \Afunc{i-1}}{\KwRet 0\;}} that writes: +% def afunc(i: int): +% | if(i>0): +% | return afunc(i-1) +% | else: +% | return 0 +% with appropriate typo. +% * ADD: option croatian: croatian keywords (thanks to Ivan Kohan and +% Yvan Gavran) +% * ADD: option ngerman: same as german option but so can be used with global option ngerman +% of babel +% * ADD: option spanish: Spanish support (thanks to Mario Abarca) +% * ADD: unterminated block: useful to add part separator that doesn't necessary need an end +% keyword. +% Designed on the pattern of unterminated if (see \uIf macro) allowing to +% add a block that is not terminated by a keyword. Such block are defined in the same +% time as a block is defined by adding a macro beginning with u. So, for example, +% predefined \SetKwBlock{Begin}{begin}{end} defines now two commands: +% - \Begin{} as previously which print a begin - end block +% - \uBegin{} that defines a begin only block +% * FIX: problem when numbering line inside until condition of +% \SetKwRepeat macro: line number was not correctly aligned. +% * FIX: dotocloa option which was broken +% * FIX: uIf and uCase didn't have same behavior when used with +% noline, vlined or lined option. This is fixed. Side effect: no empty +% line after an uIf or uCase when used with options lined or vlined +% * FIX: a bug with Repeat Until command when use with side comment on Until +% * FIX: a bug with side text -- text put into () -- of command macro (SetKwIf and so on) +% which was always setting a ';' even after a \DontPrintSemicolon +% * FIX: a bug with hyperref and chapter definition (thanks to Hubert Meier) +% * FIX: bugs with l macro and side comment +% * FIX: revision number +% * FIX: fix non ascii character (utf8 not yet recognized by all latex engine) +% * FIX: fnum@algocf had an useless parameter which sometimes broke expansion and output an error +% * FIX: works now with multicol package +% +% - december 14 2009 - revision 4.1 +% * ADD: new command \SetKwHangingKw{Name}{text} (hanging indent with keyword): This creates a +% hanging indent much like \texttt{SetKwInput}, except that it removes the trailing `:' +% and does not reset numbering (thanks to Nathan Tallent) +% +% - november 17 2009 - revision 4.00 - +% +% * CHANGE: IMPORTANT: some commands have been renamed to have consistent naming (CamlCase +% syntax) and old commands are no more available. If you doesn't want to change +% your mind or use old latex files, you can use oldcommands option to enable old +% commands back. +% text. Here are these commands: +% - \SetNoLine becomes \SetAlgoNoLine +% - \SetVline becomes \SetAlgoVlined +% - \Setvlineskip becomes \SetVlineSkip +% - \SetLine becomes \SetAlgoLined +% - \dontprintsemicolon becomes \DontPrintSemicolon +% - \printsemicolon becomes \PrintSemicolon +% - \incmargin becomes \IncMargin +% - \decmargin becomes \DecMargin +% - \setnlskip becomes \SetNlSkip +% - \Setnlskip becomes \SetNlSkip +% - \setalcapskip becomes \SetAlCapSkip +% - \setalcaphskip becomes \SetAlCapHSkip +% - \nlSty becomes \NlSty +% - \Setnlsty becomes \SetNlSty +% - \linesnumbered becomes \LinesNumbered +% - \linesnotnumbered becomes \LinesNotNumbered +% - \linesnumberedhidden becomes \LinesNumberedHidden +% - \showln becomes \ShowLn +% - \showlnlabel becomes \ShowLnLabel +% - \nocaptionofalgo becomes \NoCaptionOfAlgo +% - \restorecaptionofalgo becomes \RestoreCaptionOfAlgo +% - \restylealgo becomes \RestyleAlgo +% - gIf macros and so on do no more exist +% * NEW: - Compatibily with other packages improven by changing name of internal +% macros. Algorithm2e can now be used with arabtex for example, if this last is +% loaded after algorithm2e package. +% * ADD: - OPTION endfloat: endfloat packages doesn't allow float environment inside other +% environment. So using it with figure option of algorithm2e makes error. This +% option enables a new environment algoendfloat to be used instead of algorithm +% environment that put algorithm at the end. algoendfloat environment make +% algorithm acting as endfloat figures. This option requires endfloat packages. +% * ADD: - OPTION norelsize: starting from this release (v4.00), algorithm2e package uses +% relsize package in order to get relative size for lines numbers; but it seems +% that some rare classes (such as inform1.cls) are not compatible with relsize; to +% have algorithm2e working, this option makes algorithm2e not to load relsize +% package and go back to previous definition by using \scriptsize font for lines +% numbers. +% * ADD: - OPTION onelanguage: allow, if using standard keywords listed below, to switch +% from one language to another without changing keywords by using appropriate +% language option: +% . KwIn, KwOut, KwData, KwResult +% . KwTo KwFrom +% . KwRet, Return +% . Begin +% . Repeat +% . If, ElseIf, Else +% . Switch, Case, Other +% . For, ForPar, ForEach, ForAll, While +% . +% * ADD: - OPTION rightnl: put lines numbers to the right of the algorithm instead of left. +% * ADD: new commands \setRightLinesNumbers and \setLeftLinesNumbers which sets the lines +% numbers to the right or to the left of the algorithm. +% * ADD: - new kind of keywords: KwArray used to define arrays: +% \SetKwArray{Kw}{array} defines an array keywords Kw called array and printed in +% DataSty style when call with \Kw. It can be used with one argument which +% denotes the element index: \Kw{n} prints array[n] with array in DataSty and n in +% ArgSty. +% * ADD/FIX: rules of ruled, algoruled, tworuled styles used rules of different sizes! This +% is now fixed. Moreover size of the rules is now controlled by a length and so +% can be customized by the user. +% \algoheightrule is the height of the rules and can be changed via \setlength +% \algoheightruledefault is the default height of he rules (0.8pt) +% \algotitleheightrule is the height of the rule that comes just after the +% caption in ruled and algoruled style; it can be changed via \setlength +% \algotitleheightruledefault is the default height of this rules (0.8pt) +% Thanks to Philippe Dumas who reports the bug and make the suggestion. +% * ADD: - \SetAlgoCaptionSeparator which sets the separator between Algorithm 1 and the +% title. By default it's ':' and caption looks like "Algorithm 2: title" but now +% you can change it by using for example \SetAlgoCaptionSeparator{.} which will +% give "Algorithm 3. title" +% * ADD: - \SetAlgoLongEnd and \SetAlgoShortEnd and \SetAlgoNoEnd commands which act as +% corresponding package options +% * ADD: - OPTIONS italiano and slovak as new language (thanks to Roberto Posenato and +% Miroslav Binas) +% * CHANGE: - Fnt and Sty macro to have consistent use and naming (see below) +% * ADD: - \AlCapSty, \AlCapNameSty, \AlCapFnt, \AlCapNameFnt, \ProcSty, \ProcFnt, +% \ProcNameSty, \ProcNameFnt, \ProcArgSty, ProcArgFnt and corresponding "set macro" +% \SetAlCapSty, \SetAlCapNameSty, \SetAlCapFnt, \SetAlCapNameFnt, \SetProcSty, +% \SetProcFnt, \SetProcNameSty, \SetProcNameFnt, \SetProcArgSty, \SetProcArgFnt which +% control the way caption is printed. Sty macro use command taking one parameter as +% argument, Fnt macros use directly command. In Fact caption is printed as follow: +% \AlCapSty{\AlCapFnt Algorithm 1:}\AlCapNameSty{\AlCapNameFnt my algorithm} +% By default, \AlCapSty is textbf and \AlCapFnt is nothing. \AlCapNameSty keep text +% as it is, and \AlCapNameFnt do nothing also. +% You can redefine \AlCapFnt and \AlCapNameFnt by giving macro to \Set commands. For +% example, you can do \SetAlCapFnt{\large} to see Algorithm printed in \large font. +% You can redefine \AlCapSty, \AlCapFnt, \AlCapNameSty and \AlCapNameFnt with the +% corresponding \Set command. For the Sty commands, you have to give in parameter +% name of a macro (whithout \) which takes one argument. For example, +% \SetAlCapFnt{textbf} defines the default behaviour. If you want to do more +% complicated thing, you should define your own macro and give it to \SetAlCapFnt or +% \SetAlCapNameFnt. Here are two examples: +% - \newcommand{\mycapsty}[1]{\tiny #1}\SetAlCapNameSty{mycapsty} +% - \newcommand{\mycapsty}[1]{\textsl{\small #1}}\SetAlCapNameSty{mycapsty} +% Or you can combine the two, for the last example you can also do: +% \SetAlCapNameSty{textsl}\SetAlCapNameFnt{\small} +% Thanks to Jan Stilhammer who gives me the idea of \AlCapNameFnt. +% * CHANGE \AlTitleFnt to match definition of all other Fnt macros and add a \AlTitleSty +% macro (see below) . Now you set \AlTitleFnt by calling \SetAlTitleFnt with +% directly a macro without parameter in argument: +% Example: \SetAlTitleFnt{\small} to set title in small font. +% * ADD: - \AlTitleSty and \SetAlTitleSty commands to set a style for title. These commands +% are defined from a macro taking the text in argument, as \textbf for example. +% To set the TitleSty you have to give name of the macro (without the '\') +% to \SetAlTitleSty. For example \SetAlTitleSty{textbf} to set \textbf style. +% * ADD: - new command \SetAlgorithmName{algorithmname}{list of algorithms name} which +% redefines name of the algorithms and the sentence list of algorithms. Second +% argument is the name that \autoref, from hyperref package, will use. Example: +% \SetAlgorithmName{Protocol}{List of protocols} if you prefer protocol than +% algorithm. +% * ADD: - new \SetAlgoRefName{QXY} which change the default ref (number of the algorithm) by +% the name given in parameter (QXY in the example). +% * ADD: - new command \SetAlgoRefRelativeSize{-2} which sets the output size of refs, defined +% by \SetAlgoRefName, used in list of algorithms. +% * ADD: - two dimensions to control the layout of caption in ruled, algoruled and boxruled +% algorithms: +% - interspacetitleruled (2pt by defaut) which controls the vertical space between +% rules and title in ruled and algoruled algorithms. +% - interspaceboxruled (2\lineskip by default) which controls the vertical space +% between rules and title in boxruled algorithms. +% These two dimensions can be changed by using \setlength command. +% * ADD: - With the fix (see below) of procedure and function environments, a new feature has +% been added: the name of the procedure or function set in caption is automatically +% defined as a KwFunction and so can be used as a macro. For example, if inside a +% procedure environment you set \caption{myproc()}, you can use \myproc macro in you +% main text. Beware that the macro is only defined after the \caption! +% * ADD: - OPTION nokwfunc to unable the new feature described above in function and +% procedure environment. Useful if you use name of procedure or function that cannot +% be a command name as a math display for example. +% * ADD: - \SetAlgoNlRelativeSize{number} command which sets the relative size of line +% numbers. By default, line numbers are two size smaller than algorithm text. Use +% this macro to change this behavior. For example, \SetAlgoNlRelativeSize{0} sets it +% to the same size, \SetAlgoNlRelativeSize{-1} to one size smaller and +% \SetAlgoNlRelativeSize{1} to one size bigger +% * ADD: - \SetAlgoProcName{aname} command which sets the name of Procedure printed by +% procedure environment (the environment prints Procedure by default). Second +% argument is the name that \autoref, from hyperref package, will use. +% * ADD: - \SetAlgoFuncName{aname} command which sets the name of Function printed by +% procedure environment (the environment prints Function by default). Second +% argument is the name that \autoref, from hyperref package, will use. +% * ADD: - \SetAlgoCaptionLayout{style} command which sets style of the caption; style must +% be the name of a macro taking one argument (the text of the caption). Examples +% below show how to use it: +% . \SetAlgoCaptionLayout{centerline} to have centered caption +% . \SetAlgoCaptionLayout{textbf} to have bold caption +% If you want to apply two styles in the same time, such as centered bold, you have +% to define you own macro and then use \SetAlgoCaptionLayout with its name. +% * ADD: - OPTION procnumbered: which makes the procedure and function to be numbered as +% algorithm +% * ADD: - OPTIONS tworuled and boxruled +% these are two new layouts: tworuled acts like ruled but doesn't put a line after +% caption ; boxruled surround algorithm by a box, puts caption above and add a line +% after caption. +% * REMOVE: - SetKwInParam has been deleted since not useful itself because of different +% macros which can do the same in a better and a more consistent way as +% SetKwFunction or SetKw. +% * FIX: - line number is now correctly vertically aligned with math display. +% * FIX: - references with hyperref. No more same identifier or missing name error. BUT now +% you must NOT use naturalnames option of hyperref packages if you do PdfLaTeX +% * FIX: - autoref with hyperref package (thanks to Jörg Sommer who notices the problem). +% * FIX: - titlenumbered was not working! fixed. +% * FIX: - Else(){} acted like uElse. Corrected. +% * FIX: - noend management: when a block was inside another and end of block was following +% each other, a blank line was added: it's now corrected. +% * FIX: - Function and Procedure environment was no more working as defined originally: the +% label was no more name of the procedure, it acts always as if procumbered option +% has been used. +% * FIX: - line numbers had a fixed size which can be bigger than algorithm text accordingly +% to \AlFnt set (see also new command \SetAlgoNlRelativeSize above) +% * FIX: - semicolon in comments when dontprintsemicolon is used. +% * FIX: - listofalgorithms adds a vertical space before first algo of a chapter as for +% listoffigures or listoftables +% * FIX: - listofalgorithms with twocolumns mode and some classes which don't allow onecolumn +% and so don't define \if@restonecol as prescribed in LaTeX (sig-alternate for +% example) +% * FIX: - algorithm2e now works with elsart cls and some more classes. +% * FIX: - blocks defined by SetKwBlock act now as other blocks (if for instance) and don't +% write end in vlined mode, instead they print a small horizontal line as required +% by the option. +% * FIX: - underfull hbox warning at each end of algorithm environment removed. +% +% * INTERNAL CHANGE: - short end keyword are deduce from long end keyword by keeping the +% first one. Allows to avoid double definition. +% * INTERNAL CHANGE: - procedure, function and algorithm are now resolved by the same +% environment to avoid code duplication. +% +% - October 04 2005 - revision 3.9 - +% * ADD: - \setalcaphskip command which sets the horizontal skip before Algorithm: in caption +% when used in ruled algorithm. +% * ADD: - \SetAlgoInsideSkip command which allows to add an extra vertical space before and +% after the core of the algorithm (ie: \SetAlgoInsideSkip{bigskip}) +% * CHANGE: - caption, when used with figure option, is no more controlled by algorithm2e +% package and so follows the exact behaviour of figures. The drawback is that you +% cannot change the typo with AlTitleFnt or CapFnt. The avantage is that if you +% use caption package, it works. +% * FIX: - problem with numbering line and pdflatex +% * FIX: - error when algorithm2e package was used with beamer and listings together +% - February 12 2005 - revision 3.8 - +% * FIX: - extra line with noend option. +% - February 10 2005 - revision 3.7 - +% * ADD: - sidecomment: different macros allowing to put text right after code on the same +% line. They are defined in the same time comment macros are defined with a star +% after the macro name. By default comments are right justified but this can be +% change with appropriate option in the macro. Ex: +% . default: \tcc*{side comment} +% . same as previous: \tcc*[r]{side comment} +% . left justify: \tcc*[l]{side comment} +% . here: \tcc*[h]{side comment} don't put the end of line mark before +% comment (; by default) and don't end the line. +% . flushed: \tcc*[f]{side comment} same as the precedent but right +% justified +% * ADD: - OPTION scright (default): right justified side comments (side comments +% are flushed to the righr) +% * ADD: - OPTION scleft: left justified side comments (side comments are put right after the +% code line) +% * ADD: - \SetSideCommentLeft acts as scleft option +% * ADD: - \SetSideCommentRight acts as scright option +% * ADD: - block like macro side text: all macro defining a block allows now to put text right +% after key words by putting text into (). Done to be used with sidecomment macros, +% but all text can be used. +% Ex: \eIf(\tcc*[f]{then comment}){test}{then text}(else side text){else text} +% * ADD: - OPTION fillcomment (default): end mark of comment is flushed to the right so +% comments fill all the width of text. +% * ADD: - OPTION nofillcomment: end mark of comment is put right after the comment. +% * ADD: - \SetNoFillComment acts as nofillcomment option. +% * ADD: - \SetFillComment acts as fillcomment option. +% * ADD: - OPTION dotocloa: which adds an entry in the toc for the list of algorithms. This +% option load package tocbibind if not already done and so list of figures and list +% of tables are also added in the toc. If you want to control which ones of the lists +% will be added in the toc, please load package tocbibind before package algorithm +% and give it the options you want. +% * FIX: - vertical spacing for uif macro with noend option +% * FIX: - all the compatibility problems between caption and other packages +% * FIX: - typographical differences between list of algorithms and other lists when in +% report or book +% +% - January 24 2005 - revision 3.6 - +% * FIX: - vertical spacing and space characters at the beginning or end of comments. +% line numbers of comments not in the NlSty. +% Thanks to Arnaud Giersch for his comments and suggestions. +% * FIX: - Set*Sty macro: the styles defined was not protected and was modified by surrounding +% context. For example KwTo in a \For{}{} was in bold AND italic instead of just in +% bold. +% * FIX: - line number misplacement after \Indp +% +% - January 21 2005 - revision 3.5 - +% * ADD: - hidden numbering of the lines. Lines are auto-numbered but numbers are shown only +% on lines you specify: +% * linesnumberedhidden option or \LinesNumberedHidden macro activate this +% functionnality. +% * \ShowLn and \ShowLnLabel{lab} macros make the number visible on the +% line. \ShowLnLabel{lab} allows to set a label for this line. +% Thanks to Samson de Jager who makes this suggestion and provides the macros. +% * ADD: - \AlCapFnt and \SetAlCapFnt which allow to have a different font for +% caption. Works like \AlFnt and \SetAlFnt and by default is the same. +% * ADD: - \AlCapSkip skip length. This vertical space is added before caption in plain ou +% boxed mode. It allows to change distance between text and caption. +% * FIX: - caption compatible with IEEEtran class. +% * FIX: - some vertical spacing error with \uIf macros (Thanks to Arnaud Giersch) +% * FIX: - Procedure and Function: lines are also numbered like algorithms +% * FIX: - CommentSty was not used for Comments +% +% - January 10 2005 - revision 3.4 - +% * FIX: - caption compatible with new release of Beamer class. +% +% - June 16 2004 - revision 3.3 - +% * FIX: - Hyperlink references of Hyperref package works now if compiled with pdflatex +% and [naturalnames] option of hyperref package is used. +% * FIX: - algorithm[H] had problem in an list environment - corrected +% * FIX: - interline was not so regular in nested blocks - corrected +% * ADD - \SetVlineSkip macro which sets the vertical skip after the little horizontal +% rule which closes a block in Vlined mode. By default 0.8ex +% +% - June 11 2004 - revision 3.2 - AUTO NUMBERING LINES !!! +% * ADD: auto numbering of the lines (the so asked and so long awaiting feature) +% this feature is managed by 3 options and 3 commands: +% - linesnumbered option: lines of the algo are numbered except for comments and +% input/output (KwInput and KwInOut) +% - commentsnumbered option: makes comments be numbered +% - inoutnumbered option: makes data input/output be numbered +% - \nllabel{lab} labels the line so you can cite with \ref{lab} +% - \LinesNumbered make the following algorithms having auto-numbered lines +% - \linesnotnumbered make the following algorithms having no auto-numbered lines +% * Change: algo2e option renames listofalgorithms in listofalgorithmes +% * FIX: new solution for compatibility with color package, more robust and not tricky. +% Many thanks to David Carlisle for his advices +% +% - June 09 2004 - revision 3.1 - +% * Change: \SetKwSwitch command defines an additionnal macro \uCase and \Case prints end +% * Change: now macros SetKw* do a renewcommand if the keyword is already defined. So you can +% redefine default definition at your own convenience or change your definition +% without introducing a new macro and changing your text. +% * ADD: new macro \SetKwIF which do \SetKwIf and +% \SetKwIfElseIf.The following default definition has been added: +% \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif} +% and so you get the macros; +% \If \eIf \lIf \uIf \ElseIf \uElseIf \lElseIf \Else \uElse \lElse +% * ADD: new macro \SetAlgoSkip which allow to fix the vertical skip before and after the +% algorithms. Default is smallskip, do \SetAlgoSkip{} if you don't want an extra space +% or \SetAlgoSkip{medskip} or \SetAlgoSkip{bigskip} if you want bigger space. +% * ADD: macro \SetKwIf defines in addition a new macro \uElse (depending on wat name you +% have given in #2 arg). +% * ADD: macro \SetKwIfElseIf defines in addition a new macro \uElse and \ugElseIf (depending +% on what name you have given in #2 and #3 arg). +% * Change: baseline of algorithm is now top, so two algorithms can be put side by side. +% * FIX: Compatibility with color package solved. The problem was due to a redefinition of +% standard macros by color package. This solves compatibility problem with other +% packages as pstcol or colortbl. (notified by Dirk Fressmann, Antti Tarvainen and Koby +% Crammer) +% * Fix: extra little shift to the right with boxed style algorithm removed (notified by +% P. Tanovski) +% * Fix: algoln option was buggy (notified bye Jiaying Shen) +% * Fix: german and portuges option didn't work due to bad typo (notified by Martin Sievers, +% Thorsten Vitt and Jeronimo Pellegrini) +% +% - February 13 2004 - revision 3.0 - +% * Major revision which makes the package independent from float.sty, so now +% - algorithm* works better, in particular can be used in multicols environments +% - (known bug corrected) +% [H] works now for all sort of environment but is handled differently for classic +% environment and star environment (algorithm, figure, procedure and function). For star +% environment, H acts like for classical figure environment, so it doesn't stay here +% absolutely. +% - (known bug corrected) +% you can use now floatflt package with algorithm package and even with figure +% option. Beware that if you want to put an algorithm inside a floatingfigure, it cannot +% be floating, so [H] is required and then figure option should not be used, since +% standard figure[H] are still floating with LaTeX. +% * boxruled: a new style added. Possible now since no style no more defined by the float +% package. +% * nocaptionofalgo: dosen't print Algorithm #: in the caption for algorithm in ruled or +% algoruled style. +% note: this is just documentation of a macro which was already in the package. +% - December 14 2003 - revision 2.52 - +% * output message shorter +% * French keyword macro \PourTous was missing for longend option, it has been added. +% * TitleofAlgo prints Function or Procedure in corresponding environments. +% +% - October 27 2003 - revision 2.51 - Revision submitted to CTAN archive +% * correction of a minor which make caption in procedure +% and function to be blanck with pdfscreen package +% (thanks to Joel Gossens for the notification) +% * add two internal definition to avoid some errors when +% used with Hyperref package (Hyperref package need to +% define new counter macro from existing ones, and +% don't do it for algorithm2e package, so we do it) +% +% - October 17 2003 - revision 2.50 - first revision for CTAN archive +% * add \AlFnt and \SetAlFnt{font} macros: \AlFnt is used at the beginning of the caption and +% the body of algorithm in order to define the fonts used for typesetting algorithms. You +% can use it elsewhere you want to typeset text as algorithm. For example you can do +% \SetAlFnt{\small\sf} to have algorithms typeset in small sf font. Default is nothing so +% algorithm is typeset as the text of the document. +% * add \AlTitleFnt{text} and \SetAlTitleFnt{font} macros: The {Algorithm: } in the caption is +% typeset with \AlTitleFnt{Algorithm:}. You can use it to have text typeset as {Algorithm:} +% of captions. Default is textbf. Default can be redefined by \SetAlTitleFnt{font}, for +% example you can do \SetAlTitleFnt{emph} +% * add CommentSty typo for text comment. +% * add some compatibility with hyperref package (still an error on multiply defined refs but +% pdf correctly generated) +% * flush text to left in order to have correct indentation even with class as amsart which +% center all figures +% * add german, portuguese and czech options for title of algorithms and typo. +% * add portuguese translation of predefined keywords * add czech translation of some +% predefined keywords +% +% - December 23 2002 - revision 2.40 +% * add some French keyword missing +% * add function* and procedure* environment like algorithme* environment: print in one column +% even if twocolumn option is specified for the document. +% * add a new macro \SetKwComment to define macro which writes comments in the text. First +% argument is the name of the macro, second is the text put before the comment, third is the +% text put at the end of the comment.Default are \tcc and \tcp +% * add new options to change the way algo are numbered: +% [algopart] algo are numbered within part (counter must exist) +% [algochapter] algo are numbered within chapter +% [algosection] algo are numbered within section +% +% - March 27 2002 - revision 2.39 +% * Gilles Geeraerts: added the \SetKwIfElseIf to manage +% if (c) +% i; +% else if (c) +% i; +% ... +% else +% i; +% end +% * Also added \gIf \gElseIf \gElse. +% +% - January 02 2001 - revision 2.38 +% * bugs related to the caption in procedure and function +% environment are corrected. +% * bug related to option noend (extra vertical space added +% after block command as If or For) is corrected. +% * czech option language added (thanks to Libor Bus: l.bus@sh.cvut.cz). +% +% - October 16 2000 - revision 2.37 +% * option algo2e added: change the name of environment +% algorithm into algorithm2e. So allow to use the package +% with some journal style which already define an algorithm +% environment. +% +% - September 13 2000 - revision 2.36 +% * option slide added: require package color +% * Hack for slide class in order to have correct +% margins +% +% - November 25 1999 - revision 2.35 +% * revision number match RCS number +% * Thanks to David A. Bader, a new option is added: +% noend: no end keywords are printed. +% +% - November 19 1999 - revision 2.32 +% * minor bug on longend option corrected. +% +% - August 26 1999 - revision 2.31 +% * add an option: figure +% this option makes algorithms be figure and so are numbered +% as figures, have Figure as caption and are put in +% the \listoffigures +% +% - January 21 1999 - revision 2.3 beta +% add 2 new environments: procedure and function. +% These environments works like algorithm environment but: +% - the ruled (or algoruled) style is imperative. +% - the caption now writes Procedure name.... +% - the syntax of the \caption command is restricted as +% follow: you MUST put a name followed by 2 braces like +% this ``()''. You can put arguments inside the braces and +% text after. If no argument is given, the braces will be +% removed in the title. +% - label now puts the name (the text before the braces in the +% caption) of the procedure or function as reference (not +% the number like a classic algorithm environment). +% There are also two new styles: ProcNameSty and +% ProcArgSty. These style are by default the same as FuncSty +% and ArgSty but are used in the caption of a procedure or a +% function. +% +% - November 28 1996 - revision 2.22 +% add a new macro \SetKwInParam{arg1}{arg2}{arg3}: +% it defines a macro \arg1{name}{arg} which prints name in keyword +% style followed byt arg surrounded by arg2 and arg3. The main +% application is to a function working as \SetKwInput to be used +% in the head of the algorithm. For example +% \SetKwInParam{Func}{(}{)} allows +% \Func{functionname}{list of arguments} which prints: +% \KwSty{functioname(}list of arguments\KwSty{)} +% +% +% - November 27 1996 - revision 2.21: +% minor bug in length of InOut boxes fixed. +% add algorithm* environment. +% +% - July 12 1996 - revision 2.2: \SetArg and \SetKwArg macros removed. +% +% \SetArg has been removed since it never has been +% documented. +% \SetKwArg has been removed since \SetKw can now +% take an argument in order to be consistent with +% \SetKwData and \SetKwFunction macros. +% +% - July 04 1996 - revision 2.1: still more LaTeX2e! Minor compatibility break +% +% Macros use now \newcommand instead of \def, use of \setlength, +% \newsavebox, ... and other LaTeX2e specific stuff. +% The compatibility break: +% - \SetData becomes \SetKwData to be more consistent. So the old +% \SetKwData becomes \SetKwInput +% - old macros \titleofalgo, \Freetitleofalgo and \freetitleofalgo +% from LaTeX209 version which did print a warning message and call +% \Titleofalgo in version 2.0 are now removed! +% +% - March 13 1996 - revision 2.0: first official major revision. +% +% +%%%%%%%%%%%%%% +% +% Known bugs: +% ----------- +% - horizontal spacing (indent) doesn't work with revtex4 class. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% for more complete informations you can see algorithm2e.tex +% +% +%%%%%%%%%%%%%%%%%%%%%%%% Identification Part %%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +\NeedsTeXFormat{LaTeX2e}[1994/12/01] +% +\ProvidesPackage{algorithm2e}[2017/07/18 v5.2 algorithms environments] +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%% Initial Code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +\@makeother\*% some package redefined it as a letter (as color.sty) +\def\@firstword#1 #2\@nil{#1}% an useful fonction +%%%%%%% Utilities: +% \ifArgumentEmpty ; if c is empty, i.e. {}, then t, else e. +% Function used internally, but may as well expose it to the user; it's useful +\begingroup +\catcode`\Q=3 +\catcode`\T=3 +\long\gdef\ALGOCF@argemptyaux#1#2Q#3#4#5T{#4} +\long\gdef\ifArgumentEmpty#1{% + \begingroup\long\edef\@tempa{\endgroup + \ALGOCF@argemptyaux#1QQ{\noexpand\@secondoftwo}{\noexpand\@firstoftwo}T% + }\@tempa +} +\endgroup +% \long\def\ifArgumentEmpty#1{\bgroup +% \catcode`\Q=3 +% \catcode`\T=3 +% \long\def\@tempa##1##2Q##3##4##5T{##4}% +% \xdef\@tempa{\@tempa#1QQ{\noexpand\@secondoftwo}{\noexpand\@firstoftwo}T}% +% \egroup\@tempa} +%%%%%%%%%%% +% +% \algocf@longdef -> shorthand to reduce +% \expandafter\long\expandafter\def +% to +% \expandafter\algocf@longdef +% may look insignificant, but reads that much better ;) +\def\algocf@longdef{\long\def} +% +% \algocf@newcommand (and helper \algocf@new@command) behaves like LaTeX's newcommand, +% with two differences: +% - the argument is not "\", but rather ""; i.e. one level of indirection +% - if the command exists already, then \renewcommand, rather than \newcommand +\def\algocf@newcommand#1{\expandafter\algocf@new@command\csname#1\endcsname} +\def\algocf@new@command#1{% + \begingroup \escapechar\m@ne\xdef\@gtempa{{\string#1}}\endgroup + \expandafter\@ifundefined\@gtempa\newcommand\renewcommand#1}% +% +% \algocf@newcmdside +% The largest time-saver; many commands we define have the pattern: +% \()... +% where "()" is optional. By defining them with this function, +% the arguments are parsed and renumbered, i.e. the body works as if the +% command was: +% \... +% and can use \ifArgumentEmpty to see whether its #1 exists (default case +% for the side text is (), so there's no difference between calling +% \foo{bar} +% or +% \foo(){bar} +% Technically this is new behaviour, but it shouldn't really occur... +\algocf@longdef\algocf@newcmdside#1#2#3{% + \expandafter\def\csname#1\endcsname{% + \@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}% + }% + \expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1){\csname algocf@#1main\endcsname{##1}}% + \algocf@newcommand{algocf@#1main}[#2]{#3}% +} +% +% a serie of newcmdside macro for block that allows a comment after the end +% \()...()% +% +% 1. kind of begin-end : for command with only one block as begin-end +\algocf@longdef\algocf@newcmdside@kobe#1#2{% + % command starts by checking for side comment at beginning + \expandafter\def\csname#1\endcsname{% + \@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}% + }% + % next we strip comment and include it in cmd that get body and check last side comment + \expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1)##2{\csname algocf@#1checkcomfol\endcsname{##1}{##2}}% + % now check for last side comment; args are : , + \expandafter\algocf@longdef\csname algocf@#1checkcomfol\endcsname##1##2{\@ifnextchar({\csname algocf@#1withendcom\endcsname{##1}{##2}}{\csname algocf@#1noendcom\endcsname{##1}{##2}}}% call macro that manages end of command, with or without last side comment + % finally manage end of macro... with end side comment... + \expandafter\algocf@longdef\csname algocf@#1withendcom\endcsname##1##2(##3){% + \csname algocf@#1main\endcsname{##1}{##2}{##3}}% + % ... or without end side comment + \expandafter\algocf@longdef\csname algocf@#1noendcom\endcsname##1##2{% + \csname algocf@#1main\endcsname{##1}{##2}{}}% + \algocf@newcommand{algocf@#1main}[3]{#2}% +}% +% +% 2. kind of if-else : for command with two blocks as if-then-else +\algocf@longdef\algocf@newcmdside@koif#1#2{% + % command starts by checking for side comment at beginning + \expandafter\def\csname#1\endcsname{% + \@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}% + }% + % next we strip comment and include it in cmd that get body and check last side comment + \expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1)##2##3{\csname algocf@#1checkcomfol\endcsname{##1}{##2}{##3}}% + % now check for last side comment; args are : <1st side com>, <1st body of cmd>, <2nd body of cmd> + \expandafter\algocf@longdef\csname algocf@#1checkcomfol\endcsname##1##2##3{\@ifnextchar({\csname algocf@#1withendcom\endcsname{##1}{##2}{##3}}{\csname algocf@#1noendcom\endcsname{##1}{##2}{##3}}}% call macro that manages end of command, with or without last side comment + % finally manage end of macro... with end side comment... + \expandafter\algocf@longdef\csname algocf@#1withendcom\endcsname##1##2##3(##4){% + \csname algocf@#1main\endcsname{##1}{##2}{##3}{##4}}% + % ... or without end side comment + \expandafter\algocf@longdef\csname algocf@#1noendcom\endcsname##1##2##3{% + \csname algocf@#1main\endcsname{##1}{##2}{##3}{}}% + \algocf@newcommand{algocf@#1main}[4]{#2}% +}% +% +% \algocf@newcmdsides +% Like the command above, but with an optional side text at the end +% of the command as well, i.e.: +% \()() +% It may be a bit confusing that doesn't count , +% but since it is for internal use, the naming can be a little more +% fuzzy. This function behaves as if: +% = +\algocf@longdef\algocf@newcmdsides#1#2#3#4#5{% + \expandafter\def\csname#1\endcsname{% + \@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}% + }% + \expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1){\csname algocf@#1main\endcsname{##1}}% + \algocf@newcommand{algocf@#1main}[#2]{#3\@ifnextchar({\csname algocf@#1end\endcsname}{#4#5}}% + \expandafter\algocf@longdef\csname algocf@#1end\endcsname(##1){#4{##1}\strut\par}% +}% +% +% definition of commands which can be redefined in options of the package. +% +\newcounter{AlgoLine}% +\setcounter{AlgoLine}{0}% +% +\newcommand{\algocf@algocfref}{\relax}% +\newcommand{\listalgorithmcfname}{}% +\newcommand{\algorithmcfname}{}% +\@ifundefined{algorithmautorefname}{\newcommand{\algorithmautorefname}{algorithm}}{\renewcommand{\algorithmautorefname}{algorithm}}% +\newcommand{\algorithmcflinename}{}% +\newcommand{\algocf@typo}{}% +\newcommand{\@algocf@procname}{}\newcommand{\procedureautorefname}{}% +\newcommand{\SetAlgoProcName}[2]{\renewcommand{\@algocf@procname}{#1}\renewcommand{\procedureautorefname}{#2}}% +\newcommand{\@algocf@funcname}{}\newcommand{\functionautorefname}{}% +\newcommand{\SetAlgoFuncName}[2]{\renewcommand{\@algocf@funcname}{#1}\renewcommand{\functionautorefname}{#2}}% +\newcommand{\@algocf@titleofalgoname}{\algorithmcfname}% +\newcommand{\@algocf@algotitleofalgo}{% + \renewcommand{\@algocf@titleofalgoname}{\algorithmcfname}}% +\newcommand{\@algocf@proctitleofalgo}{% + \renewcommand{\@algocf@titleofalgoname}{\algocf@procname}}% +% +\newcommand{\algocf@style}{plain}% +\newcommand{\@ResetCounterIfNeeded}{}% +\newcommand{\@titleprefix}{}% +% +\newcommand{\algocf@numbering}[1]{\newcommand{\algocf@within}{#1}}% +% +\newcommand{\defaultsmacros@algo}{\algocf@defaults@shortend}% +% +\newcommand{\algocf@list}{loa}% +\newcommand{\algocf@float}{algocf}% +% +\newcommand{\algocf@envname}{algorithm}% +\newcommand{\algocf@listofalgorithms}{listofalgorithms}% +% +% +%% redefine chapter so that it adds a vspace in the loa as the original does for lof and lot +% \let\algocf@original@chapter=\chapter% +% \def\chapter{\expandafter\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}% +% +% bug correction with hyperref submitted by Hubert Meier +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname @chapter\endcsname\relax\else +% \let\algocf@original@chapter=\chapter% +% \def\chapter{\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}% +\let\algocf@original@chapter=\@chapter% +\@ifclassloaded{krantz}{% +\def\@chapter[#1][#2]#3{\algocf@original@chapter[#1][#2]{#3}\addtocontents{loa}{\protect\addvspace{10\p@}}}% +}{% +\def\@chapter[#1]#2{\algocf@original@chapter[#1]{#2}\addtocontents{loa}{\protect\addvspace{10\p@}}}% +}% +\fi +% +%% if@restonecol is defined in article and book but some other classes don't define it and we need it, so we do +\ifx\if@restonecol\relax\else\newif\if@restonecol\fi% +% +% +%%%%%%%%%%%%%%%%%%%%%% Declaration of Options %%%%%%%%%%%%%%%%%%%%%%%%%%% +% +\RequirePackage{ifthen}% +% +\newboolean{algocf@displayblockmarkers}\setboolean{algocf@displayblockmarkers}{false}% +\DeclareOption{displayblockmarkers}{% + \setboolean{algocf@displayblockmarkers}{true}% +}% +\newboolean{algocf@displaygroupmarkers}\setboolean{algocf@displaygroupmarkers}{false} +\DeclareOption{displaygroupmarkers}{% + \setboolean{algocf@displaygroupmarkers}{true}% +}% +% +\newboolean{algocf@nokwfunc}\setboolean{algocf@nokwfunc}{false}% +\DeclareOption{nokwfunc}{% + \setboolean{algocf@nokwfunc}{true}% +}% +% +\newboolean{algocf@oldcommands}\setboolean{algocf@oldcommands}{false}% +\DeclareOption{oldcommands}{% + \setboolean{algocf@oldcommands}{true}% +}% +% +\newboolean{algocf@leftlinenumber}\setboolean{algocf@leftlinenumber}{true}% +\newcommand{\setLeftLinesNumbers}{\setboolean{algocf@leftlinenumber}{true}}% +\newcommand{\setRightLinesNumbers}{\setboolean{algocf@leftlinenumber}{false}}% +\DeclareOption{rightnl}{% + \setRightLinesNumbers% +}% +% +\newboolean{algocf@endfloat}\setboolean{algocf@endfloat}{false}% +\DeclareOption{endfloat}{% + \setboolean{algocf@endfloat}{true}% + \newcounter{postalgo}\setcounter{postalgo}{0}% +}% +% +\newboolean{algocf@procnumbered}\setboolean{algocf@procnumbered}{false}% +\DeclareOption{procnumbered}{% + \setboolean{algocf@procnumbered}{true}% +}% +% +\DeclareOption{algo2e}{% + \renewcommand{\algocf@envname}{algorithm2e}% + \renewcommand{\algocf@listofalgorithms}{listofalgorithmes}% +}% +% +\newboolean{algocf@slide}\setboolean{algocf@slide}{false}% +\DeclareOption{slide}{% + \setboolean{algocf@slide}{true}% +}% +% +\newboolean{algocf@figurecaption}\setboolean{algocf@figurecaption}{false}% +\DeclareOption{figure}{% +\renewcommand{\algocf@list}{lof}% +\renewcommand{\algocf@float}{figure}% +\AtBeginDocument{\@ifpackageloaded{caption}{\setboolean{algocf@figurecaption}{true}}{}}% +}% +% +\newboolean{algocf@optonelanguage}\setboolean{algocf@optonelanguage}{false}% +\DeclareOption{onelanguage}{\setboolean{algocf@optonelanguage}{true}}% +% +\newcommand{\algocf@languagechoosen}{english}% +\newboolean{algocf@localkw@english}\setboolean{algocf@localkw@english}{true}% +\DeclareOption{englishkw}{% +\setboolean{algocf@localkw@english}{true}% +}% +% +\DeclareOption{english}{% +\renewcommand{\listalgorithmcfname}{List of Algorithms}% +\renewcommand{\algorithmcfname}{Algorithm}% +\renewcommand{\algorithmautorefname}{algorithm}% +\renewcommand{\algorithmcflinename}{line}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedure}% +\renewcommand{\@algocf@funcname}{Function}% +\renewcommand{\procedureautorefname}{procedure}% +\renewcommand{\functionautorefname}{function}% +\renewcommand{\algocf@languagechoosen}{english}% +}% +% +%---- +\newboolean{algocf@localkw@french}\setboolean{algocf@localkw@french}{false}% +\DeclareOption{frenchkw}{% +\setboolean{algocf@localkw@french}{true}% +}% +% +\DeclareOption{french}{% +\renewcommand{\listalgorithmcfname}{Liste des Algorithmes}% +\renewcommand{\algorithmcfname}{Algorithme}% +\renewcommand{\algorithmautorefname}{algorithme}% +\renewcommand{\algorithmcflinename}{ligne}% +\renewcommand{\algocf@typo}{\ }% +\renewcommand{\@algocf@procname}{Proc\'edure}% +\renewcommand{\@algocf@funcname}{Fonction}% +\renewcommand{\procedureautorefname}{proc\'edure}% +\renewcommand{\functionautorefname}{fonction}% +\renewcommand{\algocf@languagechoosen}{french}% +}% +% +%---- +\newboolean{algocf@localkw@czech}\setboolean{algocf@localkw@czech}{false}% +\DeclareOption{czechkw}{% +\setboolean{algocf@localkw@czech}{true}% +}% +% +\DeclareOption{czech}{% +\renewcommand{\listalgorithmcfname}{Seznam algoritm\r{u}}% +\renewcommand{\algorithmcfname}{Algoritmus}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{Radek}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedura}% +\renewcommand{\@algocf@funcname}{Funkce}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{czech}% +}% +% +%---- +\newboolean{algocf@localkw@german}\setboolean{algocf@localkw@german}{false}% +\DeclareOption{germankw}{% +\setboolean{algocf@localkw@german}{true}% +}% +% +\DeclareOption{german}{% +\renewcommand{\listalgorithmcfname}{Liste der Algorithmen}% +\renewcommand{\algorithmcfname}{Algorithmus}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{Zeile}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Prozedur}% +\renewcommand{\@algocf@funcname}{Funktion}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{german}% +}% +% +%---- +\DeclareOption{ngermankw}{% +\setboolean{algocf@localkw@german}{true}% +}% +% +\DeclareOption{ngerman}{% +\renewcommand{\listalgorithmcfname}{Liste der Algorithmen}% +\renewcommand{\algorithmcfname}{Algorithmus}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{Zeile}% +\renewcommand{\algocf@typo}{\ }% +\renewcommand{\@algocf@procname}{Prozedur}% +\renewcommand{\@algocf@funcname}{Funktion}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{german}% +}% +% +%---- +\newboolean{algocf@localkw@portuguese}\setboolean{algocf@localkw@portuguese}{false}% +\DeclareOption{portuguesekw}{% +\setboolean{algocf@localkw@portuguese}{true}% +}% +% +\DeclareOption{portuguese}{% +\renewcommand{\listalgorithmcfname}{Lista de Algoritmos}% +\renewcommand{\algorithmcfname}{Algoritmo}% +\renewcommand{\algorithmautorefname}{algoritmo}% +\renewcommand{\algorithmcflinename}{linha}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedimento}% +\renewcommand{\@algocf@funcname}{Fun\c{c}\~{a}o}% +\renewcommand{\procedureautorefname}{procedimento}% +\renewcommand{\functionautorefname}{fun\c{c}\~{a}o}% +\renewcommand{\algocf@languagechoosen}{portuguese}% +}% +% +%---- +\newboolean{algocf@localkw@italiano}\setboolean{algocf@localkw@italiano}{false}% +\DeclareOption{italianokw}{% +\setboolean{algocf@localkw@italiano}{true}% +}% +% +\DeclareOption{italiano}{% +\renewcommand{\listalgorithmcfname}{Elenco degli algoritmi}% +\renewcommand{\algorithmcfname}{Algoritmo}% +\renewcommand{\algorithmautorefname}{algoritmo}% +\renewcommand{\algorithmcflinename}{riga}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedura}% +\renewcommand{\@algocf@funcname}{Funzione}% +\renewcommand{\procedureautorefname}{procedura}% +\renewcommand{\functionautorefname}{funzione}% +\renewcommand{\algocf@languagechoosen}{italiano}% +}% +%---- +\newboolean{algocf@localkw@spanish}\setboolean{algocf@localkw@spanish}{false}% +\DeclareOption{spanishkw}{% +\setboolean{algocf@localkw@spanish}{true}% +}% +% +\DeclareOption{spanish}{% +\renewcommand{\listalgorithmcfname}{\'Indice de algoritmos}% +\renewcommand{\algorithmcfname}{Algoritmo}% +\renewcommand{\algorithmautorefname}{algoritmo}% +\renewcommand{\algorithmcflinename}{l\'inea}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedimiento}% +\renewcommand{\@algocf@funcname}{Funci\'on}% +\renewcommand{\procedureautorefname}{procedimiento}% +\renewcommand{\functionautorefname}{funci\'on}% +\renewcommand{\algocf@languagechoosen}{spanish}% +}% +%---- +\newboolean{algocf@localkw@slovak}\setboolean{algocf@localkw@slovak}{false}% +\DeclareOption{slovakkw}{% +\setboolean{algocf@localkw@slovak}{true}% +}% +% +\DeclareOption{slovak}{% +\renewcommand{\listalgorithmcfname}{Zoznam algoritmov}% +\renewcommand{\algorithmcfname}{Algoritmus}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{Radek}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Proced\'{u}ra}% +\renewcommand{\@algocf@funcname}{Funkcia}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{slovak}% +}% +% +%---- +\newboolean{algocf@localkw@croatian}\setboolean{algocf@localkw@croatian}{false}% +\DeclareOption{croatiankw}{% +\setboolean{algocf@localkw@croatian}{true}% +}% +% +\DeclareOption{croatian}{% +\renewcommand{\listalgorithmcfname}{Popis algoritama}% +\renewcommand{\algorithmcfname}{Algoritam}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{redak}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedura}% +\renewcommand{\@algocf@funcname}{Funkcija}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{croatian}% +}% +%%% adding 'turkish' option customization +% +%---- +\newboolean{algocf@localkw@turkish}\setboolean{algocf@localkw@turkish}{false}% +\DeclareOption{turkishkw}{% +\setboolean{algocf@localkw@turkish}{true}% +}% +\DeclareOption{turkish}{% +\renewcommand{\listalgorithmcfname}{Algoritma Listesi}% +\renewcommand{\algorithmcfname}{Algoritma}% +\renewcommand{\algorithmautorefname}{algoritma}% +\renewcommand{\algorithmcflinename}{\c{c}izgi}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Prosed\"ur}% +\renewcommand{\@algocf@funcname}{Fonksiyon}% +\renewcommand{\procedureautorefname}{prosed\"ur}% +\renewcommand{\functionautorefname}{fonksiyon}% +\renewcommand{\algocf@languagechoosen}{turkish}% +}% +% +% OPTIONs plain, boxed, ruled, algoruled & boxruled +% +\newcommand{\algocf@style@plain}{\renewcommand{\algocf@style}{plain}}% +\newcommand{\algocf@style@boxed}{\renewcommand{\algocf@style}{boxed}}% +\newcommand{\algocf@style@ruled}{\renewcommand{\algocf@style}{ruled}}% +\newcommand{\algocf@style@algoruled}{\renewcommand{\algocf@style}{algoruled}}% +\newcommand{\algocf@style@boxruled}{\renewcommand{\algocf@style}{boxruled}}% +\newcommand{\algocf@style@tworuled}{\renewcommand{\algocf@style}{tworuled}}% +\newcommand{\algocf@style@plainruled}{\renewcommand{\algocf@style}{plainruled}}% +\newcommand{\RestyleAlgo}[1]{\csname algocf@style@#1\endcsname}% +\DeclareOption{plain}{\algocf@style@plain}% +\DeclareOption{plainruled}{\algocf@style@plainruled}% +\DeclareOption{boxed}{\algocf@style@boxed}% +\DeclareOption{ruled}{\algocf@style@ruled}% +\DeclareOption{algoruled}{\algocf@style@algoruled}% +\DeclareOption{boxruled}{\algocf@style@boxruled}% +\DeclareOption{tworuled}{\algocf@style@tworuled}% +% +% OPTIONs algopart,algochapter & algosection +% +\DeclareOption{algopart}{\algocf@numbering{part}}% %algo part numbered +\DeclareOption{algochapter}{\algocf@numbering{chapter}}% %algo chapter numbered +\DeclareOption{algosection}{\algocf@numbering{section}}% %algo section numbered +% +% OPTIONs resetcount & noresetcount +% +\DeclareOption{resetcount}{\renewcommand{\@ResetCounterIfNeeded}{\setcounter{AlgoLine}{0}}}% +\DeclareOption{noresetcount}{\renewcommand{\@ResetCounterIfNeeded}{}}% +% +% OPTIONs algorithm hanging for long lines +% +\newlength{\algocf@hangindent}\setlength{\algocf@hangindent}{.5em} +\newcommand{\SetAlgoHangIndent}[1]{\setlength{\algocf@hangindent}{#1}} +% +\newboolean{algocf@hanging}\setboolean{algocf@hanging}{true}% hanging is handle by default +\newboolean{algocf@hanginginout}\setboolean{algocf@hanginginout}{false}% inout are managed as previously: hanging set by inout keywords +\newboolean{algocf@hangingcomment}\setboolean{algocf@hangingcomment}{false}% comment that are not side comment are indented accordingly to comment mark, not as normal text +\newcommand{\algocf@everyparnl}{\relax}% +\newcommand{\algocf@everyparhanging}{\hangafter=1\hangindent=\algocf@hangindent\relax}% +\newcommand{\algocf@everypar}{\algocf@everyparnl\algocf@everyparhanging}% +\newcommand{\algocf@seteverypar}{% + \ifthenelse{\boolean{algocf@hanging}}{\everypar{\algocf@everypar}}{\relax}% +}% +% +\newcommand{\algocf@seteveryparnl}[1]{\renewcommand{\algocf@everyparnl}{#1}\everypar{\algocf@everypar}}% +\newcommand{\algocf@seteveryparhanging}[1]{% +\let\algocf@oldeveryparhanging=\algocf@everyparhanging% +\renewcommand{\algocf@everyparhanging}{#1}\everypar{\algocf@everypar}% +}% +\newcommand{\algocf@reseteveryparhanging}{% +\let\algocf@everyparhanging=\algocf@oldeveryparhanging% +\everypar{\algocf@everypar}% +}% +\DeclareOption{hanginginout}{\setboolean{algocf@hanginginout}{true}}% +\DeclareOption{hangingcomment}{\setboolean{algocf@hangingcomment}{true}}% +\DeclareOption{noalgohanging}{% + \setboolean{algocf@hanginginout}{false}% + \setboolean{algocf@hangingcomment}{false}% + \setboolean{algocf@hanging}{false}% +}% +%\newcommand{ +% +% +% OPTION linesnumbered +% +\newboolean{algocf@linesnumbered}\setboolean{algocf@linesnumbered}{false}% +\newcommand{\algocf@linesnumbered}{\relax}% +\DeclareOption{linesnumbered}{% + \setboolean{algocf@linesnumbered}{true}% + \renewcommand{\algocf@linesnumbered}{\algocf@seteveryparnl{\nl}}% +}% +% +% OPTION linesnumberedhidden +% +\DeclareOption{linesnumberedhidden}{% + \setboolean{algocf@linesnumbered}{true}% + \renewcommand{\algocf@linesnumbered}{\algocf@seteveryparnl{\stepcounter{AlgoLine}}}% +}% +% +% OPTION commentsnumbered inoutnumbered +% +\newboolean{algocf@commentsnumbered}\setboolean{algocf@commentsnumbered}{false}% +\DeclareOption{commentsnumbered}{\setboolean{algocf@commentsnumbered}{true}}% +\newboolean{algocf@inoutnumbered}\setboolean{algocf@inoutnumbered}{false}% +\DeclareOption{inoutnumbered}{\setboolean{algocf@inoutnumbered}{true}}% +% +% OPTIONs titlenumbered & titlenotnumbered +% +\DeclareOption{titlenumbered}{% + \renewcommand{\@titleprefix}{% + \refstepcounter{\algocf@float}% + \AlTitleSty{\AlTitleFnt\@algocf@titleofalgoname\ \expandafter\csname the\algocf@float\endcsname\algocf@typo: }% + }% +}% +% +\DeclareOption{titlenotnumbered}{\renewcommand{\@titleprefix}{% + \AlTitleSty{\AlTitleFnt\@algocf@titleofalgoname\algocf@typo: }}% +}% +% +% OPTIONs algonl +% line numbered with the counter of the algorithm +% +\DeclareOption{algonl}{\renewcommand{\theAlgoLine}{\expandafter\csname the\algocf@float\endcsname.\arabic{AlgoLine}}}% +% +% OPTIONs lined, vlined & noline +% +\DeclareOption{lined}{\AtBeginDocument{\SetAlgoLined}}% \SetAlgoLined (default) +\DeclareOption{vlined}{\AtBeginDocument{\SetAlgoVlined}}% \SetAlgoVlined +\DeclareOption{noline}{\AtBeginDocument{\SetAlgoNoLine}}%\SetAlgoNoLine +% +% OPTIONs longend, shotend & noend +% +\DeclareOption{longend}{\AtBeginDocument{\SetAlgoLongEnd}}% \SetAlgoLongEnd +\DeclareOption{shortend}{\AtBeginDocument{\SetAlgoShortEnd}}%\SetAlgoShortEnd +\DeclareOption{noend}{\AtBeginDocument{\SetAlgoNoEnd}}% \SetAlgoNoEnd +% +\DeclareOption{nosemicolon}{\AtBeginDocument{\DontPrintSemicolon}}% \SetAlgoNoEnd +% +% OPTION dotoc +% +\newboolean{algocf@dotocloa}\setboolean{algocf@dotocloa}{false}% +\DeclareOption{dotocloa}{% + \setboolean{algocf@dotocloa}{true}% +} +% +% OPTION comments +% +\newboolean{algocf@optfillcomment}\setboolean{algocf@optfillcomment}{true}% +\DeclareOption{nofillcomment}{% + \setboolean{algocf@optfillcomment}{false}% +}% +\DeclareOption{fillcomment}{% + \setboolean{algocf@optfillcomment}{true}% +}% +% +% OPTION sidecommments +% +\newboolean{algocf@scleft}\setboolean{algocf@scleft}{false}% +\DeclareOption{scleft}{% + \setboolean{algocf@scleft}{true}% +}% +\DeclareOption{sright}{% default + \setboolean{algocf@scleft}{false}% +}% +% +% OPTION norelsize +% +\newboolean{algocf@norelsize}\setboolean{algocf@norelsize}{false}% +\DeclareOption{norelsize}{% + \setboolean{algocf@norelsize}{true}% +}% +% +% +%%%%%%%%%%%%%%%%%%%%%%% Execution of Options %%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +\ExecuteOptions{english,plain,resetcount,titlenotnumbered,lined,shortend}% +% +\ProcessOptions% +% +\@algocf@algotitleofalgo% fix name for \TitleOfAlgo to \algorithmcfname by default +% +%%%%%%%%%%%%%%%%%%%%%%%%%% Package Loading %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +\RequirePackage{ifoddpage}% +\RequirePackage{xspace}% +% +\ifthenelse{\boolean{algocf@endfloat}}{% + \RequirePackage{endfloat}% +}{\relax}% +% +\ifthenelse{\boolean{algocf@norelsize}}{% + \newcommand{\relsize}[1]{\scriptsize}% +}{% + \RequirePackage{relsize}% +}% +% +\ifthenelse{\boolean{algocf@slide}}{\RequirePackage{color}}{}% +% +% +\AtEndOfPackage{% + \ifthenelse{\boolean{algocf@dotocloa}}{% + \renewcommand{\listofalgorithms}{\tocfile{\listalgorithmcfname}{loa}}% + }{\relax}% +}% +% +% if loa in toc required, load tocbibind package if not already done. +\ifthenelse{\boolean{algocf@dotocloa}}{% + \ifx\@tocextra\undefined% + \RequirePackage{tocbibind}% + \fi% +}{\relax}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Part %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +\newcommand{\algocf@name}{algorithm2e}% +\newcommand{\algocf@date}{July 18 2017}% +\newcommand{\algocf@version}{Release 5.2}% +\newcommand{\algocf@id}{\algocf@version\space -- \algocf@date\space --}% +% \typeout{********************************************************^^JPackage `\algocf@name'\space\algocf@id^^J% +% - algorithm2e-announce@lirmm.fr mailing list for announcement about releases^^J% +% - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J% +% subscribe by emailing sympa@lirmm.fr with 'subscribe '^^J% +% - Author: Christophe Fiorio (christophe.fiorio@umontpellier.fr)^^J********************************************************}% +%% +%% +%% +%% +%% +%% +%%%% hyperref compatibility tricks: Hyperref package defines H counters from + % standard counters (i.e \theHpage from \thepage) and check some particular + % counters of some packages, unfortunately it doesn't do the same for + % algorithm2e package but act as Hcounter was defined. To avoid errors we + % defined \theHalgocf ourself +%%%% +% +\@ifundefined{theHalgocf}{\def\theHalgocf{\thealgocf}}{}% +\@ifundefined{theHAlgoLine}{\def\theHAlgoLine{\theAlgoLine}}{}% +\@ifundefined{theHalgocfproc}{\def\theHalgocfproc{0}}{}% +\@ifundefined{theHalgocffunc}{\def\theHalgocffunc{0}}{}% +\@ifundefined{toclevel@algocf}{\def\toclevel@algocf{0}}{}% +% +% autoref from hyperref needs an autorefname, so we give it. +\def\AlgoLineautorefname{\algorithmcflinename}% +\def\algocfautorefname{\algorithmautorefname}% +\def\algocfprocautorefname{\procedureautorefname}% +\def\algocffuncautorefname{\functionautorefname}% +%% +%% +%% +\newcommand{\@defaultskiptotal}{0.5em}% +\newskip\skiptotal\skiptotal=0.5em% +\newskip\skiplinenumber\skiplinenumber=\hsize\advance\skiplinenumber by-\skiptotal% +\newskip\skiprule% +\newskip\skiphlne% +\newskip\skiptext% +\newskip\skiplength% +\newskip\algomargin% +\newskip\skipalgocfslide\skipalgocfslide=1em% +\newdimen\algowidth% +\newdimen\inoutsize% +\newdimen\inoutindent% +\newdimen\interspacetitleruled\setlength{\interspacetitleruled}{2pt}% +\newdimen\interspacealgoruled\setlength{\interspacealgoruled}{2pt}% +\newdimen\interspacetitleboxruled\setlength{\interspacetitleboxruled}{2\lineskip}% +% +\newcommand{\@algoskip}{\smallskip}% +\newcommand{\SetAlgoSkip}[1]{\renewcommand{\@algoskip}{\csname#1\endcsname}}% +\newcommand{\@algoinsideskip}{\relax}% +\newcommand{\SetAlgoInsideSkip}[1]{\renewcommand{\@algoinsideskip}{\csname#1\endcsname}}% +% +% ruledwidth +% +\newlength{\algocf@ruledwidth}\setlength{\algocf@ruledwidth}{\linewidth}% +\newboolean{algocf@customruledwidth}\setboolean{algocf@customruledwidth}{false}% +\newcommand{\SetCustomAlgoRuledWidth}[1]{% + \setboolean{algocf@customruledwidth}{true}% + \ifthenelse{\boolean{algocf@customruledwidth}}{\setlength{\algocf@ruledwidth}{#1}}{\relax}% +}% +% +\newsavebox{\algocf@inoutbox}% +\newsavebox{\algocf@inputbox}% +%% +%% +\newcommand{\arg@e}{}% +\newcommand{\arg@space}{\ }% +\newcommand{\BlankLine}{\vskip 1ex}% +%% +\newcommand{\vespace}{1ex}% +\newcommand{\SetInd}[2]{% +\skiprule=#1% +\skiptext=#2% +\skiplength=\skiptext\advance\skiplength by \skiprule\advance\skiplength by 0.4pt}% +\SetInd{0.5em}{1em} +\algomargin=\leftskip\advance\algomargin by \parindent% +\newcommand{\IncMargin}[1]{\advance\algomargin by #1}% +\newcommand{\DecMargin}[1]{\advance\algomargin by -#1}% +\newcommand{\SetNlSkip}[1]{% + \renewcommand{\@defaultskiptotal}{#1}% + \setlength{\skiptotal}{#1}}% +%% +\newskip\AlCapSkip\AlCapSkip=0ex% +\newskip\AlCapHSkip\AlCapSkip=0ex% +\newcommand{\SetAlCapSkip}[1]{\setlength{\AlCapSkip}{#1}}% +\newcommand{\SetAlCapHSkip}[1]{\setlength{\AlCapHSkip}{#1}}% +\SetAlCapHSkip{.5\algomargin}% +%% +%% +\newskip\algoskipindent +\newcommand{\algocf@adjustskipindent}{% + \algoskipindent=\skiprule% + \advance\algoskipindent by \skiptext\advance\algoskipindent by 0.4pt} +\algocf@adjustskipindent% +% +\newcommand{\Indentp}[1]{\advance\leftskip by #1}% +\newcommand{\Indp}{\algocf@adjustskipindent\advance\leftskip by \algoskipindent} +\newcommand{\Indpp}{\advance\leftskip by 0.5em}% +\newcommand{\Indm}{\algocf@adjustskipindent\advance\leftskip by -\algoskipindent} +\newcommand{\Indmm}{\advance\leftskip by -0.5em}% +% +%% +%% +%% Line Numbering +%% +%% +% number line style +\newcommand{\algocf@nlrelsize}{-2}\newcommand{\SetAlgoNlRelativeSize}[1]{\renewcommand{\algocf@nlrelsize}{#1}}% +\newcommand{\NlSty}[1]{\textnormal{\textbf{\relsize{\algocf@nlrelsize}#1}}}% default definition +\newcommand{\SetNlSty}[3]{\renewcommand{\NlSty}[1]{\textnormal{\csname#1\endcsname{\relsize{\algocf@nlrelsize}#2##1#3}}}}% +% +% nl definitions +% +\newsavebox{\algocf@nlbox}% +\newcommand{\algocf@printnl}[1]{% + \ifthenelse{\boolean{algocf@leftlinenumber}}{% + \skiplinenumber=\skiptotal\advance\skiplinenumber by\leftskip% + \strut\raisebox{0pt}{\llap{\NlSty{#1}\kern\skiplinenumber}}\ignorespaces% + }{% + \sbox\algocf@nlbox{\NlSty{#1}}% + \skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip\advance\skiplinenumber by-\skiptext% + \advance\skiplinenumber by\algomargin\advance\skiplinenumber by.3em\advance\skiplinenumber by-\wd\algocf@nlbox% + % to handle particular case of until: printnl is after 'until' keyword has been writen, so we need to substract length of this keyword + \advance\skiplinenumber by-\algocf@skipuntil% + \strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\NlSty{#1\ignorespaces}}}\ignorespaces% + }% +}% +\newcommand{\algocf@nl@sethref}[1]{% + \renewcommand{\theHAlgoLine}{\thealgocfproc.#1}% + \hyper@refstepcounter{AlgoLine}\gdef\@currentlabel{#1}% +}% +\newcommand{\nl}{% + \@ifundefined{hyper@refstepcounter}{% if not hyperref then do a simple refstepcounter + \refstepcounter{AlgoLine}\gdef\@currentlabel{\theAlgoLine}% + }{% else if hyperref, do the anchor so 2 lines in two differents algorithms cannot have the same href + \stepcounter{AlgoLine}\algocf@nl@sethref{\theAlgoLine}% + }% now we can do the line numbering + \algocf@printnl{\theAlgoLine}% +}% +% +\newcommand{\nllabel}[1]{\label{#1}}% +% +\newcommand{\enl}{% + \@ifundefined{hyper@refstepcounter}{% if not hyperref then do a simple refstepcounter + \refstepcounter{AlgoLine}\gdef\@currentlabel{\theAlgoLine}% + }{% else if hyperref, do the anchor so 2 lines in two differents algorithms cannot have the same href + \stepcounter{AlgoLine}\algocf@nl@sethref{\theAlgoLine}% + }% now we can do the line numbering + \skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip% + \strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\strut\NlSty{\theAlgoLine}}}\ignorespaces% +}% +%% nlset +\newcommand{\nlset}[1]{% + \@ifundefined{hyper@refstepcounter}{\protected@edef\@currentlabel{#1}}{\algocf@nl@sethref{#1}}\algocf@printnl{#1}% +}% +% +%% lnl definitions +\newcommand{\lnl}[1]{\nl\label{#1}\ignorespaces}% +% +%% lnlset +\newcommand{\lnlset}[2]{\nlset{#2}\label{#1}}% +% +% set char put at end of each line +% +\newcommand{\algocf@endline}{\string;} +\newcommand{\SetEndCharOfAlgoLine}[1]{\renewcommand{\algocf@endline}{#1}} +% +% end of line definition +% +\newcommand{\@endalgocfline}{\algocf@endline}% default definition: printsemicolon +\newcommand{\DontPrintSemicolon}{\renewcommand{\@endalgocfline}{\relax}}% +\newcommand{\PrintSemicolon}{\renewcommand{\@endalgocfline}{\algocf@endline}}% +\newcommand{\@endalgoln}{\@endalgocfline\hfill\strut\par}% +% +% line numbering +% +\newcommand{\LinesNumbered}{\setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\algocf@seteveryparnl{\nl}}}% +\newcommand{\LinesNotNumbered}{% + \setboolean{algocf@linesnumbered}{false}% + \renewcommand{\algocf@linesnumbered}{\relax}% +}% +% +\newcommand{\LinesNumberedHidden}{% + \setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\algocf@seteveryparnl{\stepcounter{AlgoLine}}}}% +\newcommand{\ShowLn}{\nlset{\theAlgoLine}\ignorespaces}% display the line number on this line (without labelling) +\newcommand{\ShowLnLabel}[1]{\lnlset{#1}{\theAlgoLine}\ignorespaces}% display the line number and label this line +% +%% +% +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Styling text commands +% +\newcommand{\AlFnt}{\relax}% default definition +\newcommand{\SetAlFnt}[1]{\renewcommand{\AlFnt}{#1}}% +\newcommand{\AlTitleFnt}{\relax}% default definition +\newcommand{\SetAlTitleFnt}[1]{\renewcommand{\AlTitleFnt}{#1}}% +% +\newcommand{\AlCapFnt}{\relax}% default definition +\newcommand{\SetAlCapFnt}[1]{\renewcommand{\AlCapFnt}{#1}}% +\newcommand{\AlCapNameFnt}{\relax}% default definition +\newcommand{\SetAlCapNameFnt}[1]{\renewcommand{\AlCapNameFnt}{#1}}% +% +\newcommand{\ProcFnt}{\relax}% default definition +\newcommand{\SetProcFnt}[1]{\renewcommand{\ProcFnt}{#1}}% +\newcommand{\ProcNameFnt}{\relax}% default definition +\newcommand{\SetProcNameFnt}[1]{\renewcommand{\ProcNameFnt}{#1}}% +\newcommand{\ProcArgFnt}{\relax}% default definition +\newcommand{\SetProcArgFnt}[1]{\renewcommand{\ProcArgFnt}{#1}}% +% +\newcommand{\AlTitleSty}[1]{\textbf{#1}\unskip}% default definition +\newcommand{\SetAlTitleSty}[1]{\renewcommand{\AlTitleSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\AlCapSty}[1]{\textnormal{\textbf{#1}}\unskip}% default definition +\newcommand{\SetAlCapSty}[1]{\renewcommand{\AlCapSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\AlCapNameSty}[1]{\textnormal{#1}\unskip}% default definition +\newcommand{\SetAlCapNameSty}[1]{\renewcommand{\AlCapNameSty}[1]{\textnormal{\csname #1\endcsname{##1}}\unskip}}% +% +\newcommand{\ProcSty}[1]{\AlCapSty{#1}}% +\newcommand{\SetProcSty}[1]{\renewcommand{\ProcSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\ProcNameSty}[1]{\AlCapNameSty{#1}}% +\newcommand{\SetProcNameSty}[1]{\renewcommand{\ProcNameSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\ProcArgSty}[1]{\AlCapNameSty{#1}}% +\newcommand{\SetProcArgSty}[1]{\renewcommand{\ProcArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +% +\newcommand{\KwSty}[1]{\textnormal{\textbf{#1}}\unskip}% default definition +\newcommand{\SetKwSty}[1]{\renewcommand{\KwSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\ArgSty}[1]{\textnormal{\emph{#1}}\unskip}%\SetArgSty{emph} +\newcommand{\SetArgSty}[1]{\renewcommand{\ArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\FuncArgSty}[1]{\textnormal{\emph{#1}}\unskip}%\SetFuncArgSty{emph} +\newcommand{\SetFuncArgSty}[1]{\renewcommand{\FuncArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\FuncSty}[1]{\textnormal{\texttt{#1}}\unskip}%\SetFuncSty{texttt} +\newcommand{\SetFuncSty}[1]{\renewcommand{\FuncSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\ProgSty}[1]{\textnormal{\emph{#1}}\unskip}%\SetProgSty{emphg} +\newcommand{\SetProgSty}[1]{\renewcommand{\ArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\DataSty}[1]{\textnormal{\textsf{#1}}\unskip}%%\SetDataSty{textsf} +\newcommand{\SetDataSty}[1]{\renewcommand{\DataSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\CommentSty}[1]{\textnormal{\texttt{#1}}\unskip}%%\SetDataSty{texttt} +\newcommand{\SetCommentSty}[1]{\renewcommand{\CommentSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +\newcommand{\TitleSty}[1]{#1\unskip}%\SetTitleSty{}{} +\newcommand{\SetTitleSty}[2]{\renewcommand{\TitleSty}[1]{% +\csname#1\endcsname{\csname#2\endcsname##1}}\unskip}% +\newcommand{\BlockMarkersSty}[1]{\KwSty{#1}}% +\newcommand{\SetBlockMarkersSty}[1]{\renewcommand{\BlockMarkersSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% +% +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Block basic commands +% +\newcommand{\algocf@push}[1]{\advance\skiptotal by #1\moveright #1}% +\newcommand{\algocf@pop}[1]{\advance\skiptotal by -#1}% +\newcommand{\algocf@addskiptotal}{% + \advance\hsize by -\skiplength% +}% \skiplength=skiptext+0.4 pt that is the width of \vrule +\newcommand{\algocf@subskiptotal}{% + \advance\hsize by \skiplength% +}% \skiplength=skiptext+0.4 pt that is the width of \vrule +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% group of instructions definition +% +\skiphlne=.8ex% +\newcommand{\SetVlineSkip}[1]{\skiphlne=#1}% +\newcommand{\algocf@bblock}{\BlockMarkersSty{begin}}% +\newcommand{\algocf@eblock}{\BlockMarkersSty{end}}% +\newcommand{\AlgoDisplayBlockMarkers}{\setboolean{algocf@displayblockmarkers}{true}}% +\newcommand{\AlgoDontDisplayBlockMarkers}{\setboolean{algocf@displayblockmarkers}{false}}% +\newcommand{\AlgoDisplayGroupMarkers}{\setboolean{algocf@displaygroupmarkers}{true}}% +\newcommand{\AlgoDontDisplayGroupMarkers}{\setboolean{algocf@displaygroupmarkers}{false}}% +\newcommand{\algocf@bblockcode}{% + \ifthenelse{\boolean{algocf@displayblockmarkers}}{\algocf@bblock\par}{\relax}% +}% +\newcommand{\algocf@eblockcode}{% + \ifthenelse{\boolean{algocf@displayblockmarkers}}{\algocf@eblock\par}{\relax}% +}% +\newcommand{\algocf@bgroupcode}{% + \ifthenelse{\boolean{algocf@displaygroupmarkers}}{\algocf@bblock}{\relax}% +}% +\newcommand{\algocf@egroupcode}{% + \ifthenelse{\boolean{algocf@displaygroupmarkers}}{\algocf@eblock}{\relax}% +}% +\newcommand{\SetAlgoBlockMarkers}[2]{% + \ifArgumentEmpty{#1}{% + \renewcommand{\algocf@bblock}{\relax}% + }{% + \renewcommand{\algocf@bblock}{\BlockMarkersSty{#1}}% + }% begin marker set + \ifArgumentEmpty{#2}{% + \renewcommand{\algocf@eblock}{\relax}% + }{% + \renewcommand{\algocf@eblock}{\BlockMarkersSty{#2}}% + }% end marker set +} +% +%%%%%%%%% block with a vertical line end by a little horizontal line +\newcommand{\algocf@Vline}[1]{% no vskip in between boxes but a strut to separate them, + \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it + \algocf@push{\skiprule}% move to the right before the vertical rule + \hbox{\vrule% + \vtop{\algocf@push{\skiptext}%move the right after the rule + \vtop{\algocf@addskiptotal #1}\Hlne}}\vskip\skiphlne% inside the block + \algocf@pop{\skiprule}%\algocf@subskiptotal% restore indentation + \nointerlineskip}% no vskip after +% +%%%%%%%%% block with a vertical line +\newcommand{\algocf@Vsline}[1]{% no vskip in between boxes but a strut to separate them, + \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it + \algocf@bblockcode% + \algocf@push{\skiprule}% move to the right before the vertical rule + \hbox{\vrule% the vertical rule + \vtop{\algocf@push{\skiptext}%move the right after the rule + \vtop{\algocf@addskiptotal #1}}}% inside the block + \algocf@pop{\skiprule}% restore indentation + \algocf@eblockcode% +} +% +\newcommand{\algocf@Hlne}{\hrule height 0.4pt depth 0pt width .5em}% +% +%%%%%%%%% block without line +\newcommand{\algocf@Noline}[1]{% no vskip in between boxes but a strut to separate them, + \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it + \algocf@bblockcode% + \algocf@push{\skiprule}% + \hbox{% + \vtop{\algocf@push{\skiptext}% + \vtop{\algocf@addskiptotal #1}}}% inside the block + \algocf@pop{\skiprule}%\algocf@subskiptotal% + \algocf@eblockcode% + % \nointerlineskip% no vskip after +}% +%%%%%%%%% +% +%% default=NoLine +% +\newcommand{\algocf@group}[1]{\algocf@Noline{#1}}% group: set of instruction depending from another (ex: then part of the If) +\newcommand{\algocf@@@eblock}[2]{#1\ifArgumentEmpty{#2}{\relax}{\KwSty{\@algocf@endoption{#2}}\strut\par}}% block: group with a end keyword. +\newcommand{\algocf@@@block}[3]{#1\ifArgumentEmpty{#2}{\ifArgumentEmpty{#3}{\relax}{ #3\relax}}{\KwSty{\@algocf@endoption{#2}}\ifArgumentEmpty{#3}{\relax}{ #3}\strut\par}}% block: group with a end keyword. +\newcommand{\algocf@@block}[3]{\algocf@@@block{#1}{#2}{#3}}% block: group with a end keyword. +\newcommand{\algocf@block}[3]{\algocf@@block{#1}{#2}{#3}}% command that will be used and redefined accordingly to noend option +%\newcommand{\algocf@nblock}[3]{\algocf@@block{#1}{#2}{#3}}% command that will be used and redefined accordingly to noend option +\newcommand{\algocf@setBlock}{% + \ifthenelse{\boolean{algocf@optnoend}}{% if no end option + \renewcommand{\algocf@block}[3]{\algocf@group{##1}}% block will be a group + }{% else + \renewcommand{\algocf@block}[3]{\algocf@@block{##1}{##2}{##3}}% block stays a block + }% +}% +% +\newcommand{\Hlne}{}% little hrizontal line ending a block in vline mode +% +\newcommand{\@algocf@endoption}[1]{#1}% +\newboolean{algocf@optnoend}\setboolean{algocf@optnoend}{false}% +% +\newcommand{\SetAlgoLongEnd}{%%%%%%%%%%%%%%%%%%%%%%%%% Long End + \setboolean{algocf@optnoend}{false}% + \renewcommand{\@algocf@endoption}[1]{##1}% + \algocf@setBlock}% +% +\newcommand{\SetAlgoShortEnd}{%%%%%%%%%%%%%%%%%%%%%%%% ShortEnd + \setboolean{algocf@optnoend}{false}% + \renewcommand{\@algocf@endoption}[1]{\@firstword##1 \@nil}% + \algocf@setBlock}% +% +\newcommand{\SetAlgoNoEnd}{%%%%%%%%%%%%%%%%%%%%%%%%%%% NoEnd + \setboolean{algocf@optnoend}{true}% + \renewcommand{\@algocf@endoption}[1]{}% + \algocf@setBlock}% +% +\newboolean{algocf@optAlgoNoLine}\setboolean{algocf@optAlgoNoLine}{false} +\newcommand{\SetAlgoNoLine}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline +\setboolean{algocf@optAlgoNoLine}{true}% +\renewcommand{\algocf@@block}[2]{\algocf@@@block{\algocf@Noline{##1}}{##2}}% +\renewcommand{\algocf@group}[1]{\algocf@Noline{##1}}% +\renewcommand{\Hlne}{}}% +% +\newcommand{\SetAlgoVlined}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Vline +\setboolean{algocf@optAlgoNoLine}{false}% +\renewcommand{\algocf@@block}[2]{\algocf@Vline{##1}}% +\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}}%\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}% +\renewcommand{\Hlne}{\algocf@Hlne}}% +% +\newcommand{\SetAlgoLined}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line +\setboolean{algocf@optAlgoNoLine}{false}% +\renewcommand{\algocf@@block}[2]{\algocf@@@block{\strut\algocf@Vsline{##1}}{##2}}% no skip after a block so garantie at least one line +\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}}%\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}% +\renewcommand{\Hlne}{}}% +% +\newcommand{\SetNothing}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline +\setboolean{algocf@optAlgoNoLine}{true}% +\renewcommand{\algocf@@block}[2]{\algocf@Noline{##1}\par}% +%\long +\renewcommand{\algocf@group}[1]{\algocf@Noline{##1}}% +\renewcommand{\Hlne}{}}% +% +%% +%% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ``Input:'''s like command +% +%%% +% text staying at the right of the longer keyword of KwInOut commands +% (text of KwInOut commands are all vertically aligned) +% +\newcommand{\algocf@newinout}{\par\parindent=\inoutindent}% to put right indentation after a \\ in the KwInOut +\newcommand{\SetKwInOut}[2]{% + \sbox\algocf@inoutbox{\KwSty{#2\algocf@typo:}}% + \expandafter\ifx\csname InOutSizeDefined\endcsname\relax% if first time used + \newcommand\InOutSizeDefined{}\setlength{\inoutsize}{\wd\algocf@inoutbox}% + \sbox\algocf@inoutbox{\parbox[t]{\inoutsize}{\KwSty{#2\algocf@typo\hfill:}}~}\setlength{\inoutindent}{\wd\algocf@inoutbox}% + \else% else keep the larger dimension + \ifdim\wd\algocf@inoutbox>\inoutsize% + \setlength{\inoutsize}{\wd\algocf@inoutbox}% + \sbox\algocf@inoutbox{\parbox[t]{\inoutsize}{\KwSty{#2\algocf@typo\hfill:}}~}\setlength{\inoutindent}{\wd\algocf@inoutbox}% + \fi% + \fi% the dimension of the box is now defined. + \algocf@newcommand{#1}[1]{% + \ifthenelse{\boolean{algocf@hanginginout}}{\relax}{\algocf@seteveryparhanging{\relax}}% + \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\algocf@seteveryparnl{\relax}}% +% {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}% + {\let\\\algocf@newinout\hangindent=\inoutindent\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2\algocf@typo\hfill:}}~##1\par}% + \algocf@linesnumbered% reset the numbering of the lines + \ifthenelse{\boolean{algocf@hanginginout}}{\relax}{\algocf@reseteveryparhanging}% + }}% +% +%% allow to ajust the skip size of InOut +%% +\newcommand{\ResetInOut}[1]{% + \sbox\algocf@inoutbox{\hbox{\KwSty{#1\algocf@typo:}\ }}% + \setlength{\inoutsize}{\wd\algocf@inoutbox}% + }% +% +% +%%% +% text staying at the right of the keyword. +% +\newcommand{\algocf@newinput}{\par\parindent=\wd\algocf@inputbox}% to put right indentation after a \\ in the KwInput +\newcommand{\SetKwInput}[2]{% + \algocf@newcommand{#1}[1]{% + \sbox\algocf@inputbox{\hbox{\KwSty{#2\algocf@typo:} }}% + \ifthenelse{\boolean{algocf@hanginginout}}{\relax}{\algocf@seteveryparhanging{\relax}}% + \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\algocf@seteveryparnl{\relax}}% + {\let\\\algocf@newinput\hangindent=\wd\algocf@inputbox\hangafter=1\unhbox\algocf@inputbox##1\par}% + \algocf@linesnumbered% reset the numbering of the lines + \ifthenelse{\boolean{algocf@hanginginout}}{\relax}{\algocf@reseteveryparhanging}% + }}% +\newcommand{\SetKwData}[2]{% + \algocf@newcommand{@#1}[1]{\DataSty{#2(}\ArgSty{##1}\DataSty{)}}% + \algocf@newcommand{#1}{% + \@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}% + }% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% tallent: +% +% Add following macros: +% \SetKwHangingKw: [kw] ------------ <= hanging determined by [kw] +% ------------ +% Should act like a combination of \SetKwInput and \SetKw. +% Based on \SetKwInput: +% - remove ':' at end of keyword +% - do not reset numbering +% - use separate savebox +\newsavebox{\algocf@hangingbox} +\newcommand{\algocf@newhanging}{\par\parindent=\wd\algocf@hangingbox}% to put right indentation after a \\ in the KwInput +\newcommand{\SetKwHangingKw}[2]{% + \algocf@newcommand{#1}[1]{% + \sbox\algocf@hangingbox{\hbox{\KwSty{#2}\algocf@typo\ }}% + {\let\\\algocf@newhanging\hangindent=\wd\algocf@hangingbox\hangafter=1\unhbox\algocf@hangingbox##1\;}% + }% +}% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Comments macros +% +%%%% +% comment in the text, first argument is the name of the macro, second is +% the text put before the comment, third is the text put at the end of the +% comment. +% +% first side comment justification +\newcommand{\SetSideCommentLeft}{\setboolean{algocf@scleft}{true}}% +\newcommand{\SetSideCommentRight}{\setboolean{algocf@scleft}{false}}% +\newcommand{\SetNoFillComment}{\setboolean{algocf@optfillcomment}{false}}% +\newcommand{\SetFillComment}{\setboolean{algocf@optfillcomment}{true}}% +% +% next comment and side comment +% +\newcommand{\algocf@endmarkcomment}{\relax}% +\newcommand{\algocf@fillcomment}{% + \ifthenelse{\boolean{algocf@optfillcomment}}{\hfill}{\relax}}% +% +\newcommand{\algocf@startcomment}{% + \hangindent=\wd\algocf@inputbox\hangafter=1\usebox\algocf@inputbox}% +\newcommand{\algocf@endcomment}{\algocf@fillcomment\algocf@endmarkcomment\ignorespaces\par}% +\newcommand{\algocf@endstartcomment}{\algocf@endcomment\algocf@startcomment\ignorespaces}% +% +\newboolean{algocf@sidecomment}% +\newboolean{algocf@altsidecomment}\setboolean{algocf@altsidecomment}{false}% +\newcommand{\algocf@scpar}{\ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\par}}% +\newcommand{\algocf@sclfill}{\ifthenelse{\boolean{algocf@scleft}}{\algocf@fillcomment}{\relax}}% +\newcommand{\algocf@scrfill}{\ifthenelse{\boolean{algocf@scleft}}{\relax}{\hfill}}% +\newcommand{\algocf@startsidecomment}{\usebox\algocf@inputbox}% +\newcommand{\algocf@endsidecomment}{\algocf@endmarkcomment\algocf@scpar}% +\newcommand{\algocf@endstartsidecomment}{% + \algocf@sclfill\algocf@endsidecomment% + \algocf@scrfill\algocf@startsidecomment\ignorespaces}% +% +\newcommand{\SetKwComment}[3]{% + \algocf@newcommand{#1}{\@ifstar{\csname algocf@#1@star\endcsname}{\csname algocf@#1\endcsname}}% + \algocf@newcommand{algocf@#1}[1]{% + \ifthenelse{\boolean{algocf@hangingcomment}}{\relax}{\algocf@seteveryparhanging{\relax}}% + \sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}% + \ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\algocf@seteveryparnl{\relax}}% + {\renewcommand{\algocf@endmarkcomment}{#3}% + \let\\\algocf@endstartcomment% + \algocf@startcomment\CommentSty{% + \strut\ignorespaces##1\strut\algocf@fillcomment#3}\par}% + \algocf@linesnumbered% reset the numbering of the lines + \ifthenelse{\boolean{algocf@hangingcomment}}{\relax}{\algocf@reseteveryparhanging}% + }% + %%% side comment definitions + \algocf@newcommand{algocf@#1@star}[2][]{% + \ifArgumentEmpty{##1}\relax{% TODO: Is this even necessary, with all those \ifx's? + \ifthenelse{\boolean{algocf@scleft}}{\setboolean{algocf@sidecomment}{true}}{\setboolean{algocf@sidecomment}{false}}% + \ifx##1h\setboolean{algocf@altsidecomment}{true}\SetSideCommentLeft\fi% + \ifx##1f\setboolean{algocf@altsidecomment}{true}\SetSideCommentRight\fi% + \ifx##1l\setboolean{algocf@altsidecomment}{false}\SetSideCommentLeft\fi% + \ifx##1r\setboolean{algocf@altsidecomment}{false}\SetSideCommentRight\fi% + }% + \sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}% + \ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\algocf@seteveryparnl{\relax}}% + {% + \renewcommand{\algocf@endmarkcomment}{#3}% + \let\\\algocf@endstartsidecomment% + % here is the comment + \ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\@endalgocfline\ }% + \algocf@scrfill\algocf@startsidecomment\CommentSty{% + \strut\ignorespaces##2\strut\algocf@sclfill#3}\algocf@scpar% + }% + \algocf@linesnumbered% reset the numbering of the lines + \ifArgumentEmpty{##1}\relax{% + \ifthenelse{\boolean{algocf@sidecomment}}{\setboolean{algocf@scleft}{true}}{\setboolean{algocf@scleft}{false}}% + \setboolean{algocf@altsidecomment}{false}% + }% + }% + }% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% KwProg +% +\newcommand{\SetKwProg}[4]{%\SetKwProg{Env}{Title}{is}{end} + \algocf@newcmdside@koif{#1}{\KwSty{#2}\ifArgumentEmpty{#2}\relax{\ }\ProgSty{##2}\KwSty{#3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#4}{##4}}% + \algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}% + \algocf@newcmdside{algocf@l#1}{3}{\KwSty{#2} \ProgSty{##2}\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode\@endalgocfline\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}% + \algocf@newcmdside{algocf@l#1star}{3}{\KwSty{#2} \ProgSty{##2}\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode}% +}% +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% KwProgFn +% +\newcommand{\SetKwProgFn}[4]{%\SetKwProg{Env}{Title}{is}{end} + \algocf@newcmdsides{#1}{4}{\KwSty{#2}\ifArgumentEmpty{#2}\relax{\ }{##2}\KwSty{#3}{##3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@group{##4}\KwSty{#4}}{\relax}{\strut\par}% + \algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}% + \algocf@newcmdside{algocf@l#1}{3}{\KwSty{#2} \ProgSty{##2}\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode\@endalgocfline\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}% + \algocf@newcmdside{algocf@l#1star}{3}{\KwSty{#2} \ProgSty{##2}\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode}% +}% +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Kw +% +\newcommand{\SetKw}[2]{% + \algocf@newcommand{@#1}[1]{\KwSty{#2} \ArgSty{##1}} + \algocf@newcommand{#1}{\@ifnextchar\bgroup{\csname @#1\endcsname}{\KwSty{#2}\xspace}}% +}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% KwFunction +% +\newcommand{\SetKwFunction}[2]{% +%%% use of gdef since newcommand doesn't manage to define the macro when SetKwFunction is used in \algocf@caption@proc + \expandafter\gdef\csname @#1\endcsname##1{\FuncSty{#2(}\FuncArgSty{##1}\FuncSty{)}}% + \expandafter\gdef\csname#1\endcsname{% + \@ifnextchar\bgroup{\csname @#1\endcsname}{\FuncSty{#2}\xspace}}% +}% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% KwTab +% +\newcommand{\SetKwArray}[2]{% +%%% use of gdef since newcommand doesn't manage to define the macro when SetKwFunction is used in \algocf@caption@proc + \expandafter\gdef\csname @#1\endcsname##1{\DataSty{#2[}\ArgSty{##1}\DataSty{]}}% + \expandafter\gdef\csname#1\endcsname{% + \@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}% +}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% KwBlock +% +\newcommand{\SetKwBlock}[3]{% + \algocf@newcmdside@kobe{#1}% + {\KwSty{#2}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##2}{#3}{##3}\par}% +}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% condition typo +% +\newcommand{\algocf@scond}{\ } +\newcommand{\algocf@econd}{\ } +\newcommand{\algocf@ucond}{} +\newcommand{\SetStartEndCondition}[3]{% + \renewcommand{\algocf@scond}{#1}\renewcommand{\algocf@econd}{#2}\renewcommand{\algocf@ucond}{#3}}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% For Switch +% +\newcommand{\SetKwSwitch}[9]{% #1=\Switch #2=\Case #3=\Other #4=switch #5=do #6=case #7=otherwise #8=endcase #9=endsw +% \algocf@newcmdside{#1}{3}% + \algocf@newcmdside@koif{#1}% + {\KwSty{#4}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#9} {##4\relax}}% +%%%% Case + \algocf@newcmdside@koif{#2}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#8}{##4\relax}}% + %uCase + \algocf@newcmdside{u#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@group{##3}}% + %lcase + \algocf@newcommand{l#2}{\@ifstar{\csname algocf@l#2star\endcsname}{\csname algocf@l#2\endcsname}}% + \algocf@newcmdside{algocf@l#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\algocf@bgroupcode\ ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\ \relax{ ##1}\strut\par}% + \algocf@newcmdside{algocf@l#2star}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\algocf@bgroupcode\ ##3\algocf@egroupcode}% +%%%% Other + \algocf@newcmdside@kobe{#3}{\KwSty{#7} \KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##2}{#8}{##3\relax}}% + %lOther + \algocf@newcommand{l#3}{\@ifstar{\csname algocf@l#3star\endcsname}{\csname algocf@l#3\endcsname}}% + \algocf@newcmdside{algocf@l#3}{2}{\KwSty{#7} \KwSty{#5}\algocf@bgroupcode\ ##2\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}% + \algocf@newcmdside{algocf@l#3star}{2}{\KwSty{#7} \KwSty{#5}\algocf@bgroupcode\ ##2\algocf@egroupcode}% + %uOther + \algocf@newcmdside{u#3}{3}{\KwSty{#7} \KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@group{##2}}% +}% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% If macros +% +\newcommand{\SetKwIF}[8]{% #1=\If #2=\ElseIf #3=\Else #4=if #5=then #6=elseif #7=else #8=endif +% +% common text + \algocf@newcommand{#1@ifthen}[1]{\KwSty{#4}\algocf@scond\ArgSty{##1}\algocf@econd\KwSty{#5}}% + \algocf@newcommand{#1@endif} [2]{\algocf@block{##1}{#8}{##2}}% + \algocf@newcommand{#1@noend} [1]{\algocf@group{##1}}% + \algocf@newcommand{#1@else} [1]{\algocf@group{##1}\KwSty{#7}}% + \algocf@newcommand{#2@elseif}[1]{\KwSty{#6}\algocf@scond\ArgSty{##1}\algocf@econd\KwSty{#5}}% + \algocf@newcommand{#3@else} {\KwSty{#7}}% +%%%% If then { } endif + \algocf@newcmdside@koif{#1}{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##3}{##4\relax}}% +%%%% If then {} else {} endif + % first command to handle optional side comment of else (so just after first braces) + \algocf@newcmdside@kobe{algocf@e#1thenelse}{\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##2}{##3}}% + % the definition of if-then-else command using command above + \algocf@newcmdside{e#1}{3}{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@else\endcsname{##3}\csname algocf@e#1thenelse\endcsname}% + %%% leif + \algocf@newcommand{le#1}{\@ifstar{\csname algocf@le#1star\endcsname}{\csname algocf@le#1\endcsname}}% + \algocf@newcmdside{algocf@le#1}{4}{\csname #1@ifthen\endcsname{##2} \algocf@bgroupcode##3 \csname #3@else\endcsname\ ##4\@endalgocfline\ \algocf@egroupcode\ifArgumentEmpty{##1}\relax{##1}\strut\par}% + \algocf@newcmdside{algocf@le#1star}{4}{\csname #1@ifthen\endcsname{##2} \algocf@bgroupcode##3 \csname #3@else\endcsname\ ##4\algocf@egroupcode}% +%%%% If then + % \algocf@newcmdside{l#1}{3}{\csname #1@ifthen\endcsname{##2}\algocf@bgroupcode\ + % ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}% + \algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}% + \algocf@newcmdside{algocf@l#1}{3}{\csname #1@ifthen\endcsname{##2}\algocf@bgroupcode\ ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}% + \algocf@newcmdside{algocf@l#1star}{3}{\csname #1@ifthen\endcsname{##2}\algocf@bgroupcode\ ##3\algocf@egroupcode}% + \algocf@newcmdside{u#1}{3}{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@noend\endcsname{##3}}% +%%%% ElseIf {} endif + \algocf@newcmdside@koif{#2}{\csname #2@elseif\endcsname{##2}\relax\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##3}{##4\relax}}% +%%%% ElseIf + \algocf@newcommand{l#2}{\@ifstar{\csname algocf@l#2star\endcsname}{\csname algocf@l#2\endcsname}}% + \algocf@newcmdside{algocf@l#2}{3}{\csname #2@elseif\endcsname{##2}\algocf@bgroupcode\ ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}% + \algocf@newcmdside{algocf@l#2star}{3}{\csname #2@elseif\endcsname{##2}\algocf@bgroupcode\ ##3\algocf@egroupcode}% + \algocf@newcmdside{u#2}{3}{\csname #2@elseif\endcsname{##2}\relax\ifArgumentEmpty{##1}\relax{##1}\csname #1@noend\endcsname{##3}}% +%%%% Else {} endif + \algocf@newcmdside@kobe{#3}{\csname #3@else\endcsname\ifArgumentEmpty{##1}\relax\ ##1\csname #1@endif\endcsname{##2}{##3\relax}}% +%%%% Else + \algocf@newcommand{l#3}{\@ifstar{\csname algocf@l#3star\endcsname}{\csname algocf@l#3\endcsname}}% + \algocf@newcmdside{algocf@l#3}{2}{\csname #3@else\endcsname\algocf@bgroupcode\ ##2\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}% + \algocf@newcmdside{algocf@l#3star}{2}{\csname #3@else\endcsname\algocf@bgroupcode\ ##2\algocf@egroupcode}% + \algocf@newcmdside{u#3}{2}{\csname #3@else\endcsname\ifArgumentEmpty{##1}\relax\ {##1\relax}\csname #1@noend\endcsname{##2}}% +}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% For macros +% +\newcommand{\SetKwFor}[4]{% + \algocf@newcmdside@koif{#1}{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#4}{##4\relax}}% + \algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}% + \algocf@newcmdside{algocf@l#1}{3}{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3}\algocf@bgroupcode\ ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}% + \algocf@newcmdside{algocf@l#1star}{3}{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode}% +}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Repeat macros +% +\newsavebox{\algocf@untilbox}% to handle width of until keyword needed to have good skip + % for line numbers +\newskip\algocf@skipuntil +\newcommand{\SetKwRepeat}[3]{% + \algocf@newcmdsides{#1}{3}{% + \sbox\algocf@untilbox{\KwSty{#3}\algocf@scond}\algocf@skipuntil=\wd\algocf@untilbox% + \KwSty{#2}\ifArgumentEmpty{##1}\relax{##1}\algocf@group{##3}% + \KwSty{#3}\algocf@scond% until keyword and start condition typo + %\advance\skiptotal by\algocf@skipuntil% + \ArgSty{##2}% + %\advance\skiptotal by-\algocf@skipuntil% + \algocf@ucond% + \algocf@skipuntil=0pt% reset counter + }{\@endalgocfline}{\strut\par}% + \algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}% + \algocf@newcmdside{algocf@l#1}{3}{\KwSty{#2}\algocf@bgroupcode\ ##3\algocf@egroupcode\ \KwSty{#3}\algocf@scond\ArgSty{##2}\algocf@ucond\@endalgocfline\ifArgumentEmpty{##1}\relax{ ##1}\strut\par}% + \algocf@newcmdside{algocf@l#1star}{3}{\KwSty{#2}\algocf@bgroupcode\ ##3\algocf@egroupcode\ \KwSty{#3}\algocf@scond\ArgSty{##2}\algocf@ucond}% +}% +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%% Environments definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +%% +%% Caption management +%% +% for the following macros: +% #1 is given by caption and is equal to fnum@algocf +% #2 is the text given in argument by the user in the \caption macro +% +%%%%% text of caption +\newcommand{\algocf@captionlayout}[1]{#1}% +\newcommand{\SetAlgoCaptionLayout}[1]{% + \renewcommand{\algocf@captionlayout}[1]{\csname #1\endcsname{##1}}}% +\newcommand{\algocf@capseparator}{:}% +\newcommand{\SetAlgoCaptionSeparator}[1]{\renewcommand{\algocf@capseparator}{#1}}% +\newcommand{\algocf@captiontext}[2]{% + \algocf@captionlayout{\AlCapSty{\AlCapFnt #1\algocf@typo\algocf@capseparator}\nobreakspace% + \AlCapNameSty{\AlCapNameFnt{}#2\endgraf}}}% text of caption +% +%%%%% default caption of algorithm: used if no specific style caption is defined +\newcommand{\algocf@makecaption}[2]{% + \addtolength{\hsize}{\algomargin}% + \sbox\@tempboxa{\algocf@captiontext{#1}{#2}}% + \ifdim\wd\@tempboxa >\hsize% % if caption is longer than a line + \hskip .5\algomargin% + \parbox[t]{\hsize}{\algocf@captiontext{#1}{#2}}% then caption is not centered + \else% + \global\@minipagefalse% + \hbox to\hsize{\hfil\box\@tempboxa\hfil}% else caption is centered + \fi% + \addtolength{\hsize}{-\algomargin}% +}% +% +\newsavebox\algocf@capbox% +\newcommand{\algocf@makecaption@plain}[2]{% + \global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}}% +\newcommand{\algocf@makecaption@boxed}[2]{% + \addtolength{\hsize}{-\algomargin}% + \global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}% + \addtolength{\hsize}{\algomargin}% + }% +% +\newlength{\algocf@lcaptionbox}% +\newcommand{\algocf@makecaption@plainruled}[2]{\algocf@makecaption@plain{#1}{#2}}% +\newcommand{\algocf@makecaption@tworuled}[2]{\algocf@makecaption@ruled{#1}{#2}}% +\newcommand{\algocf@makecaption@algoruled}[2]{\algocf@makecaption@ruled{#1}{#2}}% +\newcommand{\algocf@makecaption@boxruled}[2]{\algocf@makecaption@ruled{#1}{#2}}% +\newcommand{\algocf@makecaption@ruled}[2]{% + \global\sbox\algocf@capbox{\hskip\AlCapHSkip% .5\algomargin% + \setlength{\algocf@lcaptionbox}{\hsize}\addtolength{\algocf@lcaptionbox}{-\AlCapHSkip}% + \parbox[t]{\algocf@lcaptionbox}{\algocf@captiontext{#1}{#2}}}% then caption is not centered +}% +% +\newlength{\algoheightruledefault}\setlength{\algoheightruledefault}{0.8pt}% +\newlength{\algoheightrule}\setlength{\algoheightrule}{\algoheightruledefault}% +\newlength{\algotitleheightruledefault}\setlength{\algotitleheightruledefault}{0.8pt}% +\newlength{\algotitleheightrule}\setlength{\algotitleheightrule}{\algotitleheightruledefault}% +\newcommand{\algocf@caption@plain}{\vskip\AlCapSkip\box\algocf@capbox}% +\newcommand{\algocf@caption@plainruled}{\algocf@caption@plain}% +\newcommand{\algocf@caption@boxed}{\vskip\AlCapSkip\box\algocf@capbox}% +\newcommand{\algocf@caption@ruled}{\box\algocf@capbox\kern\interspacetitleruled\hrule + width\algocf@ruledwidth height\algotitleheightrule depth0pt\kern\interspacealgoruled}% +\newcommand{\algocf@caption@tworuled}{\box\algocf@capbox\hrule height0pt depth0pt\kern\interspacealgoruled}% +\newcommand{\algocf@caption@algoruled}{\algocf@caption@ruled}% +\newcommand{\algocf@caption@boxruled}{% + \hbox{% + \vrule% + \vbox{% + \addtolength{\hsize}{-0.8pt}% + \hrule\vskip\interspacetitleboxruled% + \hbox to\hsize{\unhbox\algocf@capbox\hfill}\vskip\interspacetitleboxruled% + \addtolength{\hsize}{0.8pt}% + }% + \vrule% + }\nointerlineskip% +}% +% +% +%%%% set caption for the environment +\newcommand{\algocf@captionref}{% + \renewcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\algocf@algocfref}}% + \addtocounter{algocf}{-1}% \caption do a refstepcounter, so we restore the precedent value + \let\old@thealgocf=\thealgocf\renewcommand{\thealgocf}{{\relsize{\algocf@refrelsize}\algocf@algocfref}}% + \gdef\@currentlabel{\algocf@algocfref}% let the label use the new ref +}% +% +% Unfortunatly, we also need our own caption to set some specific stuff for special references. But after these +% settings, we call the original caption. +% +\long\def\algocf@caption@algo#1[#2]#3{% + \ifthenelse{\equal{\algocf@algocfref}{\relax}}{}{\algocf@captionref}% + \@ifundefined{hyper@refstepcounter}{\relax}{% if hyper@refstepcounter undefind, no hyperref, else... + \ifthenelse{\equal{\algocf@algocfref}{\relax}}{\renewcommand{\theHalgocf}{\thealgocf}}{% take algocf as Href + \renewcommand{\theHalgocf}{\algocf@algocfref}}%else if SetAlgoRefName done, take this name as ref. + \hyper@refstepcounter{algocf}%set algocf as category of ref + }% + \algocf@latexcaption{#1}[{#2}]{{#3}}% call original caption +}% +% +% beamer define is own caption overrinding latex caption! +% as we need it, we have put here the original definition +% to handle manual ref, unfortunately we have to add one line to handle algocf@algocfref +\long\def\algocf@latexcaption#1[#2]#3{% original definition of caption + \par% + \addcontentsline{\csname ext@#1\endcsname}{#1}% + {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% + \begingroup% + \@parboxrestore% + \if@minipage% + \@setminipage% + \fi% + \normalsize% + \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par% + \endgroup% +}% +% +% \ifx\beamer@makecaption\undefined% +% \else% beamer detected +\ifx\@makecaption\undefined% +\newcommand{\@makecaption}[2]{\relax}% +\fi% +%% + +% +% more and more packages redefine \@caption instead of just \@makecaption which makes algorithm2e +% caption not works since based on standard \@caption. So we force the definition of \@caption to be +% the standard one (the one from LaTeX) inside algorithm environment. +% +% unfortunately, makecaption is called with \ignorespace #3 so +% we can't do the @currentlabel definition inside \algocf@captionproctext +\long\def\algocf@caption@proc#1[#2]#3{% + \ifthenelse{\boolean{algocf@nokwfunc}}{\relax}{% + \SetKwFunction{\algocf@captname#3@}{\algocf@captname#3@}% + }% + % we tell hyperref to use algocfproc as category and to take the appropriate ref. + \ifthenelse{\boolean{algocf@func}}{\def\@proc@func{algocffunc}}{\def\@proc@func{algocfproc}}% + \@ifundefined{hyper@refstepcounter}{\relax}{% if hyper@refstepcounter undefind, no hyperref, else... + \ifthenelse{\boolean{algocf@procnumbered}}{% + \expandafter\def\csname theH\@proc@func\endcsname{\thealgocf}%if procnumbered, take \thealgocf as ref + }{% + \expandafter\def\csname theH\@proc@func\endcsname{\algocf@captname#3@}%else take procedure or function name + }% + \hyper@refstepcounter{\@proc@func}% + }% + \ifthenelse{\boolean{algocf@procnumbered}}{\relax}{% + \addtocounter{algocf}{-1}% \caption do a refstepcounter, so we restore the precedent value + \gdef\@currentlabel{\algocf@captname#3@}% let the label be the name of the function, not the counter + }% + \ifthenelse{\equal{\algocf@captparam#2@}{\arg@e}}{% if no paramater, we remove the () + \algocf@latexcaption{#1}[\algocf@procname\nobreakspace\algocf@captname#2@]{#3}% + }{% else we give the complete name + \algocf@latexcaption{#1}[\algocf@procname\nobreakspace#2]{#3}% + }% +}% +%% +%%% setcaption +\newcommand{\algocf@setcaption}{% + \ifthenelse{\boolean{algocf@procenvironment}}{% if proc environment, caption text must be changed + \let\algocf@oldcaptiontext=\algocf@captiontext% + \renewcommand{\algocf@captiontext}[2]{% + \algocf@captionproctext{##1}{##2}% + }% + }{}% + \let\algocf@savecaption=\@caption% + \ifthenelse{\boolean{algocf@procenvironment}}{\let\@caption=\algocf@caption@proc}{\let\@caption=\algocf@caption@algo}% + \let\algocf@oldmakecaption=\@makecaption% + \renewcommand{\@makecaption}[2]{% + \expandafter\csname algocf@makecaption@\algocf@style\endcsname{##1}{##2}% + }% +}% +% +%%%%% reset caption +% +% since we have force the LaTeX caption for algorithm environment, we must go back to the caption +% used in the text. +\newcommand{\algocf@resetcaption}{% + \ifthenelse{\boolean{algocf@procenvironment}}{% if proc environment + \let\thealgocf=\old@thealgocf% restore normal counter printing + \let\algocf@captiontext=\algocf@oldcaptiontext% restore normal caption text + }{}% + \let\@caption=\algocf@savecaption% now restore caption outside algo/proc/func environment + \let\@makecaption=\algocf@oldmakecaption% and restore makecaption outside outside algo/proc/func environment + \algocf@resetfnum% +}% +% +%%%%% nocaptionofalgo and restorecaptionofalgo -- +\newcommand{\NoCaptionOfAlgo}{% + \let\@old@algocf@captiontext=\algocf@captiontext% + \renewcommand{\algocf@captiontext}[2]{\AlCapNameSty{\AlCapNameFnt{}##2}}% +}% +\newcommand{\RestoreCaptionOfAlgo}{% + \let\algocf@captiontext=\@old@algocf@captiontext% +}% +% +% ---------------------- algocf environment +% +\newcounter{algocfline}% % new counter to make lines numbers be internally +\setcounter{algocfline}{0}% % different in different algorithms +\newcounter{algocfproc}% counter to count all algo environment (proc, func), just used by hyperref to avoir "same +\setcounter{algocfproc}{0}% identifier" error caused by algocf being set to '-' for procedure or function or not + % changed if no caption is given. +% +\expandafter\ifx\csname algocf@within\endcsname\relax% if \algocf@within doesn't exist +\newcounter{algocf}% % just define a new counter +\renewcommand{\thealgocf}{\@arabic\c@algocf}% and the way it is printed +\else% else +\newcounter{algocf}[\algocf@within]% % counter is numbered within \algocf@within +\renewcommand\thealgocf{\csname the\algocf@within\endcsname.\@arabic\c@algocf}% +\fi% +% +\def\fps@algocf{htbp}% % default +\def\ftype@algocf{10}% % float type +\def\ext@algocf{\algocf@list} % loa by default, lof if figure option used +\newcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}% +\newcommand{\algocf@resetfnum}{\renewcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}}% +\newenvironment{algocf}% % float environment for algorithms + {\@float{algocf}}% + {\end@float}% +\newenvironment{algocf*}% % float* environment for algorithms + {\@dblfloat{algocf}}% + {\end@dblfloat}% +% +\def\algocf@seclistalgo{}% +\ifx\l@chapter\undefined\let\algocf@seclistalgo=\section\else\let\algocf@seclistalgo=\chapter\fi% +\@ifundefined{if@restonecol}{\newif\if@restonecol}\relax% +\newcommand\listofalgocfs{% + \ifx\algocf@seclistalgo\chapter% + \if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi% + \fi% + \algocf@seclistalgo*{\listalgorithmcfname}% + \@mkboth{\MakeUppercase\listalgorithmcfname}% + {\MakeUppercase\listalgorithmcfname}% + \@starttoc{loa}% + \ifx\algocf@seclistalgo\chapter% + \if@restonecol\twocolumn\fi% + \fi% +} +% +\newcommand*\l@algocf{\@dottedtocline{1}{1em}{2.3em}}% line of the list +% +% ---------------------- algorithm environment +% +%%%%%%% +%% +%% Algorithm environment definition +%% +%%%%%%% +%% +% +\newsavebox\algocf@algoframe% +\def\@algocf@pre@plain{\relax}% action to be done before printing the algo. +\def\@algocf@post@plain{\relax}% action to be done after printing the algo. +\def\@algocf@capt@plain{bottom}% where the caption should be localized. +\def\@algocf@pre@boxed{\noindent\begin{lrbox}{\algocf@algoframe}} +\def\@algocf@post@boxed{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}% +\def\@algocf@capt@boxed{under}% +\def\@algocf@pre@ruled{\hrule width\algocf@ruledwidth height\algoheightrule depth0pt\kern\interspacetitleruled}% +\def\@algocf@post@ruled{\kern\interspacealgoruled\hrule width\algocf@ruledwidth height\algoheightrule\relax}% +\def\@algocf@capt@ruled{top}% +\def\@algocf@pre@algoruled{\hrule width\algocf@ruledwidth height\algoheightrule depth0pt\kern\interspacetitleruled}% +\def\@algocf@post@algoruled{\kern\interspacealgoruled\hrule width\algocf@ruledwidth height\algoheightrule \relax}% +\def\@algocf@capt@algoruled{top}% +\def\@algocf@pre@tworuled{\hrule height\algoheightrule depth0pt\kern\interspacetitleruled}% +\def\@algocf@post@tworuled{\kern\interspacealgoruled\hrule height\algoheightrule\relax}% +\def\@algocf@capt@tworuled{top}% +\def\@algocf@pre@boxruled{\noindent\begin{lrbox}{\algocf@algoframe}}% +\def\@algocf@post@boxruled{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}% +\def\@algocf@capt@boxruled{above}% +\def\@algocf@pre@plainruled{\@algocf@pre@ruled}% action to be done before printing the algo. +\def\@algocf@post@plainruled{\@algocf@post@ruled\kern\interspacealgoruled}% action to be done before printing the algo. +\def\@algocf@capt@plainruled{under}% +% +\newcommand{\noalgocaption}{\def\@algocf@capt@ruled{none}} +% +%% before algocf environment (not figure environment) +\newcommand{\@algocf@init@caption}{% + \ifthenelse{\boolean{algocf@procenvironment}}{% if we are inside a procedure/function environment + \@algocf@proctitleofalgo% set Titleofalgo to Procedure: or Function: + % accordingly to the environment + \let\old@thealgocf=\thealgocf\ifthenelse{\boolean{algocf@procnumbered}}{\relax}{% + \renewcommand{\thealgocf}{-}}% + }{% else inside environment algorithm + \@algocf@algotitleofalgo% fix name for \Titleofalgo to \algorithmcfname + }% + \algocf@setcaption% set caption to our caption style +}% +% +\newcommand{\@algofloatboxreset}{\@setminipage} +\newcommand{\@algocf@init}{% + \refstepcounter{algocfline}% + \stepcounter{algocfproc}%to have a different counter for each environment and being abble to make the difference + %between href of algoline in different algorithms. + \ifthenelse{\boolean{algocf@optnoend}}{% + \renewcommand{\algocf@block}[3]{\algocf@group{##1}}% + }{% + \renewcommand{\algocf@block}[3]{\algocf@@block{##1}{##2}{##3}}% + }% +}% +%% after the end of algocf or figure environment +\newcommand{\@algocf@term@caption}{% + \algocf@resetcaption% restore original caption +}% +% +\newcommand{\@algocf@term}{% + \setboolean{algocf@algoH}{false}% no H by default + \ifthenelse{\boolean{algocf@optnoend}}{% + \renewcommand{\algocf@block}[3]{\algocf@@block{##1}{##2}{##3}}% + }{% + \renewcommand{\algocf@block}[2]{\algocf@group{##1}}% + }% + \SetAlgoRefName{\relax}% +}% +% +%%%%%%%%%%%%%%%%% +%% makethealgo: macro which print effectively the algo in its box +%% +\newsavebox\algocf@algobox% +\newcommand{\algocf@makethealgo}{% + \vtop{% + % place caption above if needed bye the style + \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{above}}% + {\csname algocf@caption@\algocf@style\endcsname}{}% + % + % precommand according to the style + \csname @algocf@pre@\algocf@style\endcsname% + % place caption at top if needed bye the style + \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{top}}% + {\csname algocf@caption@\algocf@style\endcsname}{}% + % + \box\algocf@algobox% the algo + % place caption at bottom if needed bye the style + \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{bottom}}% + {\csname algocf@caption@\algocf@style\endcsname}{}% + % postcommand according to the style + \csname @algocf@post@\algocf@style\endcsname% + % place caption under if needed bye the style + \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{under}}% + {\csname algocf@caption@\algocf@style\endcsname}{}% + }% +}% +%%%%%%%%%%%%%%%%%%% +% +%% at the beginning of algocf or figure environment +\newenvironment{algomathdisplay}{\[}{\@endalgocfline\]\ifthenelse{\boolean{algocf@linesnumbered}}{\nl}{\relax}}% +\newcommand{\@algocf@start}{% + \@algoskip% + \begin{lrbox}{\algocf@algobox}% + \setlength{\algowidth}{\hsize}% + \vbox\bgroup% save all the algo in a box + \hbox to\algowidth\bgroup\hbox to \algomargin{\hfill}\vtop\bgroup% + \ifthenelse{\boolean{algocf@slide}}{\parskip 0.5ex\color{black}}{}% + % initialization + \addtolength{\hsize}{-\algomargin}\addtolength{\hsize}{-1.5em}% 1.5em to let space for line numbering + \let\@mathsemicolon=\;\def\;{\ifmmode\@mathsemicolon\else\@endalgoln\fi}% + \raggedright% + \AlFnt{}% + \ifthenelse{\boolean{algocf@slide}}{\IncMargin{\skipalgocfslide}}{}% + \@algoinsideskip% +% \let\@emathdisplay=\]\def\]{\algocf@endline\@emathdisplay\nl}% +}% +% +%% at the end of algocf or figure environment +\newcommand{\@algocf@finish}{% + \@algoinsideskip% + \egroup%end of vtop which contain all the text + \hfill\egroup%end of hbox wich contains [margin][vtop] + \ifthenelse{\boolean{algocf@slide}}{\DecMargin{\skipalgocfslide}}{}% + % + \egroup%end of main vbox + \end{lrbox}% + \algocf@makethealgo% print the algo + \@algoskip% + % restore dimension and macros + \setlength{\hsize}{\algowidth}% + \lineskip\normallineskip\setlength{\skiptotal}{\@defaultskiptotal}% + \let\;=\@mathsemicolon% + \let\]=\@emathdisplay% +}% +% +%%%%%%%%%%%%%%%%%%%% +%% basic definition of the environment algorithm +%% +% +\newboolean{algocf@procenvironment}\setboolean{algocf@procenvironment}{false}% +\newboolean{algocf@func}\setboolean{algocf@func}{false}% +\newboolean{algocf@algoH}\setboolean{algocf@algoH}{false}% +\newboolean{algocf@algostar}\setboolean{algocf@algostar}{false}% +% +%%% environment for {algorithm}[H] +\newenvironment{algocf@Here}{\noindent% + \def\@captype{algocf}% if not defined, caption exit with an error + \begin{minipage}{\hsize}% +}{% + \end{minipage}%\par% +}% +%%% real algorithm environment which manages H and * option +% \let\algocf@originalfloatboxreset=\@floatboxreset% +% \let\@floatboxreset=\@algofloatboxreset% +\newenvironment{algocf@algorithm}[1][htbp]{% + \@algocf@init% + \ifthenelse{\equal{\algocf@float}{figure}}{% if option figure set + \ifthenelse{\boolean{algocf@algostar}}{% if algorithm* with figure option + \begin{figure*}[#1]% call figure* + \ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}% + \let\algocf@oldeverypar=\everypar% + \algocf@seteverypar% + \addtolength{\linewidth}{-\algomargin}% caption package use \linewidth as basic width of caption + }{% else algorithm environment with figure option + \begin{figure}[#1]% call figure + \ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}% + \let\algocf@oldeverypar=\everypar% + \algocf@seteverypar% + \addtolength{\linewidth}{-\algomargin}% so now \linewidth==\hsize. Needed by caption package that uses \linewidth as basic width of caption + }% + }{% else normal algorithm environment + \@algocf@init@caption% + \ifthenelse{\equal{#1}{H}}{% if [H] algorithm + \if@twocolumn\@latex@error{[H] in two columns mode is not allowed for algorithms}\fi% TODO: SCREAM if H in two colums! + \setboolean{algocf@algoH}{true}\begin{algocf@Here}% call corresponding environment + \ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}% + \let\algocf@oldeverypar=\everypar% + \algocf@seteverypar% + }{% else floating algorithm environment + \ifthenelse{\boolean{algocf@algostar}}{% if algorithm* + \begin{algocf*}[#1]% call algocf* + \ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}% + \let\algocf@oldeverypar=\everypar% + \algocf@seteverypar% + }{% else algorithm environment + \begin{algocf}[#1]% call algocf + \ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}% + \let\algocf@oldeverypar=\everypar% + \algocf@seteverypar% + }% + }% + }% fin test option figure ou pas + \@algocf@start% + \@ResetCounterIfNeeded% + \algocf@linesnumbered\ignorespaces% +}{% + \@algocf@finish% + \ifthenelse{\equal{\algocf@float}{figure}}{% + \ifthenelse{\boolean{algocf@algostar}}{% if algorithm* with figure option + \let\everypar=\algocf@oldeverypar% + \end{figure*}% call figure* + }{% else algorithm environment with figure option + \let\everypar=\algocf@oldeverypar% + \end{figure}% call figure + }% + }{% + \@algocf@term@caption% + \ifthenelse{\boolean{algocf@algoH}}{% if [H] algorithm + \let\everypar=\algocf@oldeverypar% + \end{algocf@Here}\par% call corresponding environment + }{% else floating algorithm environment + \ifthenelse{\boolean{algocf@algostar}}{% if algorithm* + \let\everypar=\algocf@oldeverypar% + \end{algocf*}% call algocf* + }{% else algorithm environment + \let\everypar=\algocf@oldeverypar% + \end{algocf}% call algocf + }% + }% + }% + \@algocf@term\ignorespacesafterend% +}% +% +%%% user algorithm environment +\newenvironment{\algocf@envname}[1][htbp]{% + \setboolean{algocf@algostar}{false}% + \setboolean{algocf@procenvironment}{false}\gdef\algocfautorefname{\algorithmautorefname}% + \begin{algocf@algorithm}[#1]\ignorespaces% +}{% + \end{algocf@algorithm}\ignorespacesafterend% +}% +%%% user algorithm* environment +\newenvironment{\algocf@envname*}[1][htbp]{% + \setboolean{algocf@algostar}{true}% + \setboolean{algocf@procenvironment}{false}\gdef\algocfautorefname{\algorithmautorefname}% + \begin{algocf@algorithm}[#1]\ignorespaces% +}{% + \end{algocf@algorithm}\ignorespacesafterend% +}% +% +%%%%%%%%%%%%%%%%%%%%%%% +%%% +% +\expandafter\newcommand\csname\algocf@listofalgorithms\endcsname{% + \ifthenelse{\equal{\algocf@float}{figure}}{\listoffigures}{\listofalgocfs}% +}% +%%% +%%% +% +% ---------------------- procedure and function environments +% +% +% -- new style (used in particular in the caption of function and procedure environments) +% +% three macros to extract parts of the caption +\gdef\algocf@captname#1(#2)#3@{#1} % keep characters before the first brace +\gdef\algocf@captparam#1(#2)#3@{#2} % keep character in between the braces +\gdef\algocf@captother#1(#2)#3@{#3} % keep character after the braces +% +%%% Text of caption for Procedure or Function +\newcommand{\algocf@captionproctext}[2]{% + {% + \ProcSty{\ProcFnt\algocf@procname\ifthenelse{\boolean{algocf@procnumbered}}{\nobreakspace\thealgocf\algocf@typo\algocf@capseparator}{\relax}}% + \nobreakspace\ProcNameSty{\ProcNameFnt\algocf@captname #2@}% Name of the procedure in ProcName Style. + \ifthenelse{\equal{\algocf@captparam #2@}{\arg@e}}{}{% if no argument, write nothing + \ProcNameSty{\ProcNameFnt(}\ProcArgSty{\ProcArgFnt\algocf@captparam #2@}\ProcNameSty{\ProcNameFnt)}%else put arguments in ProcArgSty: + }% endif + \algocf@captother #2@% + }% +}% +% +% +% -- procedure and function environments are defined from algocf@algorithm environment +% +\newenvironment{procedure}[1][htbp]{% + \setboolean{algocf@algostar}{false}% + \setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{false}% + \newcommand{\algocf@procname}{\@algocf@procname}\gdef\algocfprocautorefname{\procedureautorefname}% + \begin{algocf@algorithm}[#1]\ignorespaces% +}{% + \end{algocf@algorithm}\ignorespacesafterend% +}% +\newenvironment{function}[1][htbp]{% + \setboolean{algocf@algostar}{false}% + \setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{true}% + \newcommand{\algocf@procname}{\@algocf@funcname}\gdef\algocffuncautorefname{\functionautorefname}% + \begin{algocf@algorithm}[#1]\ignorespaces% +}{% + \end{algocf@algorithm}\ignorespacesafterend% +}% +% +\newenvironment{procedure*}[1][htbp]{% + \setboolean{algocf@algostar}{true}% + \setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{false}% + \newcommand{\algocf@procname}{\@algocf@procname}\gdef\algocfprocautorefname{\procedureautorefname}% + \begin{algocf@algorithm}[#1]\ignorespaces% +}{% + \end{algocf@algorithm}\ignorespacesafterend% +}% +\newenvironment{function*}[1][htbp]{% + \setboolean{algocf@algostar}{true}% + \setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{true}% + \newcommand{\algocf@procname}{\@algocf@funcname}\gdef\algocffuncautorefname{\functionautorefname}% + \begin{algocf@algorithm}[#1]\ignorespaces% +}{% + \end{algocf@algorithm}\ignorespacesafterend% +}% +% +% +%%%%%%%%%%%%%%%%%%%% +%% definition of algondfloat environment +%% +\ifthenelse{\boolean{algocf@endfloat}}{% if endfloat option then +\newcommand{\algoplace}{% macro which is used to writhe algorithm about there + \begin{center}% + [\algorithmcfname~\thepostfig\ about here.]% + \end{center}% +}% +\newcommand{\algoendfloat}{% use as a \begin{algoendfloat} environment to start scanning of line +% \immediate\openout\@mainfff\jobname.fff% + \efloat@condopen{fff} + \efloat@iwrite{fff}{\string\begin{\algocf@envname}}% + \if@domarkers% + \ifthenelse{\equal{\algocf@list}{lof}}{% + \addtocounter{postfig}{1}% + }{% + \addtocounter{postalgo}{1}% + }% + \algoplace% + \fi% + \bgroup% + \let\do\ef@makeinnocent\dospecials% + \ef@makeinnocent\^^L% and whatever other special cases + \endlinechar`\^^M \catcode`\^^M=12 \ef@xalgocfendfloat}% +}{\relax}%%%% end of endfloat option ifthenelse +%% some macros useful for endfloat option that cannot be defined inside the ifthenelse +%scan algoendfloat algorithm and write the text into .fff file +{\catcode`\^^M=12 \endlinechar=-1 % + \gdef\ef@xalgocfendfloat#1^^M{% scan the lines inside algoendfloat environment being read by latex + \def\test{#1}% test is the line being currently scan by latex + \ifx\test\ef@endalgocftest% if it is \end{algoendfloat} + \def\next{% define next as to not continue the scan and write \end{algorithm} into .fff file + \egroup\end{algoendfloat}% + \efloat@iwrite{fff}{\string\end{\algocf@envname}}% + \efloat@iwrite{fff}{\string\efloatseparator}% + \efloat@iwrite{fff}{ }% + }% + \else% else write the current line being scanned by latex and set next to continue the scan + \efloat@iwrite{fff}{#1}% + \let\next\ef@xalgocfendfloat% + \fi% endif + \next}% next is continue if it was else condition, else it does not continue the scan and write end to file +}% +% test if the scan is finish by looking at the string \end{algoendfloat} +{\escapechar=-1% + \xdef\ef@endalgocftest{\string\\end\string\{algoendfloat\string\}}% +}% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +\newcommand{\TitleOfAlgo}[1]{\@titleprefix\ + \TitleSty{#1}\par\smallskip}% +% +\newcommand{\SetAlgorithmName}[3]{% + \renewcommand{\listalgorithmcfname}{#3}% + \renewcommand{\algorithmcfname}{#1}% + \renewcommand{\algorithmautorefname}{#2}% +}% +% +\newcommand{\algocf@refrelsize}{-2}\newcommand{\SetAlgoRefRelativeSize}[1]{\renewcommand{\algocf@refrelsize}{#1}}% +\newcommand{\SetAlgoRefName}[1]{% + \renewcommand{\algocf@algocfref}{#1}% +}% +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% ------------------------- Default Definitions +% +%% +%% +% +\SetKwComment{tcc}{/* }{ */}% +\SetKwComment{tcp}{// }{}% +% +%\newcommand{\algocf@defaults@common}{ +% +% +% english keywords (default) +% +\SetKwHangingKw{KwHData}{Data$\rightarrow$} +\SetKwInput{KwIn}{Input}% +\SetKwInput{KwOut}{Output}% +\SetKwInput{KwData}{Data}% +\SetKwInput{KwResult}{Result}% +\SetKw{KwTo}{to} +\SetKw{KwRet}{return}% +\SetKw{Return}{return}% +\SetKwBlock{Begin}{begin}{end}% +\SetKwRepeat{Repeat}{repeat}{until}% +% +\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{end switch}% +\SetKwFor{For}{for}{do}{end for}% +\SetKwFor{ForPar}{for}{do in parallel}{end forpar} +\SetKwFor{ForEach}{foreach}{do}{end foreach}% +\SetKwFor{ForAll}{forall}{do}{end forall}% +\SetKwFor{While}{while}{do}{end while}% +% +% French keywords +% +\ifthenelse{\boolean{algocf@localkw@french}\OR\equal{\algocf@languagechoosen}{french}}{% +%\SetKwInOut{AlgDonnees}{Donn\'ees}\SetKwInOut{AlgRes}{R\'esultat} +\SetKwHangingKw{HDonnees}{Donnees$\rightarrow$} +\SetKwInput{Donnees}{Donn\'ees}% +\SetKwInput{Res}{R\'esultat}% +\SetKwInput{Entree}{Entr\'ees}% +\SetKwInput{Sortie}{Sorties}% +\SetKw{KwA}{\`a}% +\SetKw{Retour}{retourner}% +\SetKwBlock{Deb}{d\'ebut}{fin}% +\SetKwRepeat{Repeter}{r\'ep\'eter}{jusqu'\`a}% +% +\SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin si}% +\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}% +\SetKwFor{Pour}{pour}{faire}{fin pour}% +\SetKwFor{PourPar}{pour}{faire en parall\`ele}{fin pour}% +\SetKwFor{PourCh}{pour chaque}{faire}{fin pour chaque}% +\SetKwFor{PourTous}{pour tous les}{faire}{fin pour tous}% +\SetKwFor{Tq}{tant que}{faire}{fin tq}% +}{}% +% +% --- German keywords +% +\ifthenelse{\boolean{algocf@localkw@german}\OR\equal{\algocf@languagechoosen}{german}}{% +\SetKwInput{Ein}{Eingabe}%KwIn +\SetKwInput{Aus}{Ausgabe}%KwOut +\SetKwInput{Daten}{Daten}%KwData +\SetKwInput{Ergebnis}{Ergebnis}%KwResult +\SetKw{Bis}{bis}%KwTo +\SetKw{KwZurueck}{zur\"uck}%KwRet +\SetKw{Zurueck}{zur\"uck}%Return +\SetKwBlock{Beginn}{Beginn}{Ende}%Begin +\SetKwRepeat{Wiederh}{wiederhole}{bis}%Repeat +% +\SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf +\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}{Ende Unt.}%Switch +\SetKwFor{Fuer}{f\"ur}{tue}{Ende f\"ur}%For +\SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar +\SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach +\SetKwFor{FuerAlle}{f\"ur alle}{tue}{Ende f\"ur}%ForAll +\SetKwFor{Solange}{solange}{tue}{Ende solange}%While +}{}% +% +% --- Czech keywords +% +\ifthenelse{\boolean{algocf@localkw@czech}\OR\equal{\algocf@languagechoosen}{czech}}{% +\SetKwInput{Vst}{Vstup}% +\SetKwInput{Vyst}{V\'{y}stup}% +\SetKwInput{Vysl}{V\'{y}sledek}% +}{}% +% +% --- Portuguese keywords +% +\ifthenelse{\boolean{algocf@localkw@portuguese}\OR\equal{\algocf@languagechoosen}{portuguese}}{% +\SetKwInput{Entrada}{Entrada}% +\SetKwInput{Saida}{Sa\'{i}da}% +\SetKwInput{Dados}{Dados}% +\SetKwInput{Resultado}{Resultado}% +\SetKw{Ate}{at\'{e}} +\SetKw{KwRetorna}{retorna}% +\SetKw{Retorna}{retorna}% +\SetKwBlock{Inicio}{in\'{i}cio}{fim}% +\SetKwRepeat{Repita}{repita}{at\'{e}}% +% +\SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% +\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}{fim selec}% +\SetKwFor{Para}{para}{fa\c{c}a}{fim para}% +\SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{fim para} +\SetKwFor{ParaCada}{para cada}{fa\c{c}a}{fim para cada}% +\SetKwFor{ParaTodo}{para todo}{fa\c{c}a}{fim para todo}% +\SetKwFor{Enqto}{enquanto}{fa\c{c}a}{fim enqto}% +}{}% +% +% --- Italian keywords +% +\ifthenelse{\boolean{algocf@localkw@italiano}\OR\equal{\algocf@languagechoosen}{italiano}}{% +\SetKwInput{KwIng}{Ingresso}% +\SetKwInput{KwUsc}{Uscita}% +\SetKwInput{KwDati}{Dati}% +\SetKwInput{KwRisult}{Risultato}% +\SetKw{KwA}{a}% +\SetKw{KwRitorna}{ritorna}% +\SetKw{Ritorna}{ritorna}% +\SetKwBlock{Inizio}{inizio}{fine}% +\SetKwRepeat{Ripeti}{ripeti}{finch\'e}% +% +\SetKwIF{Sea}{AltSe}{Altrimenti}{se}{allora}{altrimenti se}{allora}{fine se}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{endsw}% +\SetKwFor{Per}{per}{fai}{fine per}% +\SetKwFor{PerPar}{per}{fai in parallelo}{fine per}% +\SetKwFor{PerCiascun}{per ciascun}{fai}{fine per ciascun}% +\SetKwFor{PerTutti}{per tutti i}{fai}{fine per tutti}% +\SetKwFor{Finche}{finch\'e}{fai}{fine finch\'e}% +}{}% +% +% --- Spanish keywords +% +\ifthenelse{\boolean{algocf@localkw@spanish}\OR\equal{\algocf@languagechoosen}{spanish}}{% +\SetKwInput{Datos}{Datos} +\SetKwInput{Resultado}{Resultado} +\SetKwInput{Entrada}{Entrada} +\SetKwInput{Salida}{Salida} +\SetKw{KwA}{a} +\SetKw{KwDevolver}{devolver} +\SetKw{Devolver}{devolver} +\SetKwBlock{Inicio}{inicio}{fin} +\SetKwIF{SSi}{EnOtroCasoSi}{EnOtroCaso}{si}{entonces}{sin\'o, si}{sin\'o}{fin si} +\SetKwSwitch{Seleccionar}{Caso}{Otro}{seleccionar}{hacer}{caso}{sin\'o}{fin caso}{fin seleccionar} +\SetKwFor{Para}{para}{hacer}{fin para} +\SetKwFor{ParaPara}{par}{hacer en paralelo}{fin para} +\SetKwFor{EnParalelo}{para}{hacer en paralelo}{fin para} +\SetKwFor{Mientras}{mientras}{hacer}{fin mientras} +\SetKwFor{ParaCada}{para cada}{hacer}{fin para cada} +\SetKwFor{ParaTodo}{para todo}{hacer}{fin para todo} +\SetKwRepeat{Repetir}{repetir}{hasta que} +}{}% +% +% Croatian keywords +% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{croatian}}{% +\SetKwInput{KwUlaz}{Ulaz}%KwIn +\SetKwInput{KwIzlaz}{Izlaz}%KwOut +\SetKwInput{KwPodatci}{Podatci}%KwData +\SetKwInput{KwRezultat}{Rezultat}%KwResult +\SetKw{KwDo}{do}%KwTo +\SetKw{KwVrati}{vrati}%KwRet +\SetKw{Vrati}{vrati}%Return +\SetKwBlock{Pocetak}{po\v{c}etak}{kraj}%Begin +\SetKwRepeat{Ponavljaj}{ponavljaj}{dok ne bude}%Repeat +% +\SetKwIF{Ako}{InaceAko}{Inace}{ako}{onda}{ina\v{c}e ako}{ina\v{c}e}{kraj ako}%gIf +\SetKwSwitch{Granaj}{Slucaj}{OstaliSlucajevi}{granaj}{\v{c}ini}{slu\v{c}aj}{ostali slu\v{c}ajevi}{kraj slu\v{c}aj}{kraj granaj}%Switch +\SetKwFor{Za}{za}{\v{c}ini}{kraj za}%For +\SetKwFor{ZaPar}{za}{\v{c}ini paralelno}{kraj za paralelno}%ForPar +\SetKwFor{ZaSvaki}{za svaki}{\v{c}ini}{kraj za svaki}%mForEach +\SetKwFor{ZaSvaku}{za svaku}{\v{c}ini}{kraj za svaku}%fForEach +\SetKwFor{ZaSvako}{za svako}{\v{c}ini}{kraj za svako}%nForEach +\SetKwFor{ZaSve}{za sve}{\v{c}ini}{kraj za sve}%ForAll +\SetKwFor{Dok}{dok}{\v{c}ini}{kraj dok}%While +}{}% +% +% +% --- Turkish keywords +% +\ifthenelse{\boolean{algocf@localkw@turkish}\OR\equal{\algocf@languagechoosen}{turkish}}{% +\SetKwInput{KwIn}{Girdi}% +\SetKwInput{KwOut}{\c{C}{\i}kt{\i}}% +\SetKwInput{KwData}{Veri}% +\SetKwInput{KwResult}{Sonu\c{c}}% +\SetKw{KwTo}{to} +\SetKw{KwRet}{return}% +\SetKw{Return}{return}% +\SetKwBlock{Begin}{begin}{end}% +\SetKwRepeat{Repeat}{repeat}{until}% +% % +\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{end switch}% +\SetKwFor{For}{for}{do}{end for}% +\SetKwFor{ForPar}{for}{do in parallel}{end forpar} +\SetKwFor{ForEach}{foreach}{do}{end foreach}% +\SetKwFor{ForAll}{forall}{do}{end forall}% +\SetKwFor{While}{while}{do}{end while}% +}{}% +% +% --- End +%} +% +%\algocf@defaults@common +% +% option onelanguage redefinition +% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{french}}{% +\SetKwInput{KwIn}{Entr\'ees}% +\SetKwInput{KwOutSortie}{Sorties}% +\SetKwInput{KwData}{Donn\'ees}% +\SetKwInput{KwResult}{R\'esultat}% +\SetKw{KwTo}{\`a}% +\SetKw{KwRet}{retourner}% +\SetKw{Return}{retourner}% +\SetKwBlock{Begin}{d\'ebut}{fin}% +\SetKwRepeat{Repeat}{r\'ep\'eter}{jusqu'\`a}% +% +\SetKwIF{If}{ElseIf}{Else}{si}{alors}{sinon si}{sinon}{fin si}% +\SetKwSwitch{Switch}{Case}{Other}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}% +\SetKwFor{For}{pour}{faire}{fin pour}% +\SetKwFor{ForPar}{pour}{faire en parall\`ele}{fin pour}% +\SetKwFor{ForEach}{pour chaque}{faire}{fin pour chaque}% +\SetKwFor{ForAll}{pour tous}{faire}{fin pour tous}% +\SetKwFor{While}{tant que}{faire}{fin tq}% +}{}% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{german}}{% +\SetKwInput{KwIn}{Eingabe}%KwIn +\SetKwInput{KwOut}{Ausgabe}%KwOut +\SetKwInput{KwData}{Daten}%KwData +\SetKwInput{KwResult}{Ergebnis}%KwResult +\SetKw{KwTo}{bis}%KwTo +\SetKw{KwRet}{zur\"uck}%KwRet +\SetKw{Return}{zur\"uck}%Return +\SetKwBlock{Begin}{Beginn}{Ende}%Begin +\SetKwRepeat{Repeat}{wiederhole}{bis}%Repeat +% +\SetKwIF{If}{ElseIf}{Else}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf +\SetKwSwitch{Switch}{Case}{Other}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}{Ende Unt.}%Switch +\SetKwFor{For}{f\"ur}{tue}{Ende f\"ur}%For +\SetKwFor{ForPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar +\SetKwFor{ForEach}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach +\SetKwFor{ForAll}{f\"ur alle}{tue}{Ende f\"ur}%ForAll +\SetKwFor{While}{solange}{tue}{Ende solange}%While +}{}% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{portuguese}}{% +\SetKwInput{KwIn}{Entrada}% +\SetKwInput{KwOut}{Sa\'{i}da}% +\SetKwInput{KwData}{Dados}% +\SetKwInput{KwResult}{Resultado}% +\SetKw{KwTo}{at\'{e}} +\SetKw{KwRet}{retorna}% +\SetKw{Return}{retorna}% +\SetKwBlock{Begin}{in\'{i}cio}{fim}% +\SetKwRepeat{Repeat}{repita}{at\'{e}}% +% +\SetKwIF{If}{ElseIf}{Else}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% +\SetKwSwitch{Switch}{Case}{Other}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}{fim selec}% +\SetKwFor{For}{para}{fa\c{c}a}{fim para}% +\SetKwFor{ForPar}{para}{fa\c{c}a em paralelo}{fim para} +\SetKwFor{ForEach}{para cada}{fa\c{c}a}{fim para cada}% +\SetKwFor{ForAll}{para todo}{fa\c{c}a}{fim para todo}% +\SetKwFor{While}{enquanto}{fa\c{c}a}{fim enqto}% +}{}% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{italiano}}{% +\SetKwInput{KwIn}{Ingresso}% +\SetKwInput{KwOut}{Uscita}% +\SetKwInput{KwData}{Dati}% +\SetKwInput{KwResult}{Risultato}% +\SetKw{KwTo}{a}% +\SetKw{KwRet}{ritorna}% +\SetKw{Return}{ritorna}% +\SetKwBlock{Begin}{inizio}{fine}% +\SetKwRepeat{Repeat}{ripeti}{finch\'e}% +% +\SetKwIF{If}{ElseIf}{Else}{se}{allora}{altrimenti se}{allora}{fine se}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{endsw}% +\SetKwFor{For}{per}{fai}{fine per}% +\SetKwFor{ForPar}{per}{fai in parallelo}{fine per}% +\SetKwFor{ForEach}{per ciascun}{fai}{fine per ciascun}% +\SetKwFor{ForAll}{per tutti i}{fai}{fine per tutti}% +\SetKwFor{While}{finch\'e}{fai}{fine finch\'e}% +}{}% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{spanish}}{% +\SetKwInput{KwIn}{Entrada}% +\SetKwInput{KwOut}{Salida}% +\SetKwInput{KwData}{Datos}% +\SetKwInput{KwResult}{Resultado}% +\SetKw{KwTo}{a}% +\SetKw{KwRet}{devolver}% +\SetKw{Return}{devolver}% +\SetKwBlock{Begin}{inicio}{fin}% +\SetKwRepeat{Repeat}{repetir}{hasta que}% +% +\SetKwIF{If}{ElseIf}{Else}{si}{entonces}{si no, si}{en otro caso}{fin si} +\SetKwSwitch{Switch}{Case}{Other}{seleccionar}{hacer}{caso}{si no}{fin caso}{fin seleccionar} +\SetKwFor{For}{para}{hacer}{fin para}% +\SetKwFor{ForPar}{para}{hacer in paralelo}{fin para}% +\SetKwFor{ForEach}{para cada}{hacer}{fin para cada} +\SetKwFor{ForAll}{para todo}{hacer}{fin para todo} +\SetKwFor{While}{mientras}{hacer}{fin mientras} +}{}% +% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{croatian}}{% +\SetKwInput{KwIn}{Ulaz}%KwIn +\SetKwInput{KwOut}{Izlaz}%KwOut +\SetKwInput{KwData}{Podatci}%KwData +\SetKwInput{KwResult}{Rezultat}%KwResult +\SetKw{KwTo}{do}%KwTo +\SetKw{KwRet}{vrati}%KwRet +\SetKw{Return}{vrati}%Return +\SetKwBlock{Begin}{po\v{c}etak}{kraj}%Begin +\SetKwRepeat{Repeat}{ponavljaj}{dok ne bude}%Repeat +% +\SetKwIF{If}{ElseIf}{Else}{ako}{onda}{ina\v{c}e ako}{ina\v{c}e}{kraj ako}%gIf +\SetKwSwitch{Switch}{Case}{Other}{granaj}{\v{c}ini}{slu\v{c}aj}{ostali slu\v{c}ajevi}{kraj slu\v{c}aj}{kraj granaj}%Switch +\SetKwFor{For}{za}{\v{c}ini}{kraj za}%For +\SetKwFor{ForPar}{za}{\v{c}ini paralelno}{kraj za paralelno}%ForPar +\SetKwFor{ForEach}{za svaki}{\v{c}ini}{kraj za svaki}%ForEach +\SetKwFor{ForAll}{za sve}{\v{c}ini}{kraj za sve}%ForAll +\SetKwFor{While}{dok}{\v{c}ini}{kraj dok}%While +}{}% +% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{turkish}}{% +% +\SetKwInput{KwIn}{Girdi}% +\SetKwInput{KwOut}{\c{C}{\i}kt{\i}}% +\SetKwInput{KwData}{Veri}% +\SetKwInput{KwResult}{Sonu\c{c}}% +\SetKw{KwTo}{to} +\SetKw{KwRet}{return}% +\SetKw{Return}{return}% +\SetKwBlock{Begin}{begin}{end}% +\SetKwRepeat{Repeat}{repeat}{until}% +% +\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end switch}% +\SetKwFor{For}{for}{do}{end for}% +\SetKwFor{ForPar}{for}{do in parallel}{end forpar} +\SetKwFor{ForEach}{foreach}{do}{end foreach}% +\SetKwFor{ForAll}{forall}{do}{end forall}% +\SetKwFor{While}{while}{do}{end while}% +}{}% +% +% +%%%% old commands compatibility +% +\ifthenelse{\boolean{algocf@oldcommands}}{% +\newcommand{\SetNoLine}{\SetAlgoNoLine}% +\newcommand{\SetNoline}{\SetAlgoNoLine}% +\newcommand{\SetVline}{\SetAlgoVlined}% +\newcommand{\SetLine}{\SetAlgoLined}% +% +\newcommand{\dontprintsemicolon}{\DontPrintSemicolon}% +\newcommand{\printsemicolon}{\PrintSemicolon}% +\newcommand{\incmargin}[1]{\IncMargin{#1}}% +\newcommand{\decmargin}[1]{\DecMargin{-#1}}% +\newcommand{\setnlskip}[1]{\SetNlSkip{#1}}% +\newcommand{\Setnlskip}[1]{\SetNlSkip{#1}}% +\newcommand{\setalcapskip}[1]{\SetAlCapSkip{#1}}% +\newcommand{\setalcaphskip}[1]{\SetAlCapHSkip{#1}}% +\newcommand{\nlSty}[1]{\NlSty{#1}}% +\newcommand{\Setnlsty}[3]{\SetNlSty{#1}{#2}{#3}}% +\newcommand{\linesnumbered}{\LinesNumbered}% +\newcommand{\linesnotnumbered}{\LinesNotNumbered}% +\newcommand{\linesnumberedhidden}{\LinesNumberedHidden}% +\newcommand{\showln}{\ShowLn}% +\newcommand{\showlnlabel}[1]{\ShowLnLabel{#1}}% +\newcommand{\nocaptionofalgo}{\NoCaptionOfAlgo}% +\newcommand{\restorecaptionofalgo}{\RestoreCaptionOfAlgo}% +\newcommand{\restylealgo}[1]{\RestyleAlgo{#1}}% +% +\newcommand{\Titleofalgo}[1]{\TitleOfAlgo{#1}}% +% \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif} +\newcommand{\SetKwIf}[6]{\SetKwIF{#1}{#2#1}{#2}{#3}{#4}{#5 #1}{#5}{#6}} +% +\SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{fin si}% +\SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{end if}% +\SetKwIF{gIf}{gElseIf}{gElse}{if}{then}{else if}{else}{end if}% +\SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf +\SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% +\SetKwIF{gSea}{gAltSe}{gAltrimenti}{se}{allora}{altrimenti se}{allora}{fine se}% +\SetKw{Ret}{return}% +\SetKwInput{Data}{Data}% +\SetKwInput{Result}{Result}% +}{% + \relax% +}% +% +% +% +%% +%%% +%%%% END \ No newline at end of file -- cgit v1.2.3