# algorithm2e.sty — package for algorithms
release 5.2

(c) 1995-1997 Christophe Fiorio, Tu-Berlin, Germany
(c) 1998-2017 Christophe Fiorio, LIRMM, Montpellier University, France
Report bugs and comments to<EMAIL_ADDRESS>
<EMAIL_ADDRESS>mailing list for announcements
<EMAIL_ADDRESS>mailing list for discussion The author is
very grateful to David Carlisle, one of the authors of the LaTeX Companion
book, for his advicesMartin Blais for his suggestionsDavid A. Bader for his
new option noendGilles Geeraerts for his new command SetKwIfElseIfRicardo
Fukasawa for the portuguese keywordsChristian Icking for the german
translation of keywordsArnaud Giersch for his suggestions and corrections on
SetKwCommentsand the many users as Jean-Baptiste Rouquier for their remarks

(July 18 2017)

###### Contents

  1. 1 Introduction
  2. 2 How to use it: abstract
  3. 3 Two more detailed examples
    1. 3.1 Algorithm disjoint decomposition
    2. 3.2 Algorithm: IntervalRestriction
  4. 4 Genericity and example of languages
  5. 5 Compatibility issues
  6. 6 Environments defined in the package
  7. 7 The options of the package
    1. 7.1 language option
    2. 7.2 compatibility issue
    3. 7.3 environment display and use
      1. 7.3.1 boxed, ruled, plain environment
      2. 7.3.2 algorithm numbering
      3. 7.3.3 figure and toc
    4. 7.4 code typesetting
      1. 7.4.1 indentation of long statements
      2. 7.4.2 blocks display
      3. 7.4.3 end keywords
      4. 7.4.4 comments
      5. 7.4.5 lines numbers
      6. 7.4.6 title of algorithms
  8. 8 Typesetting
  9. 9 Commands provided with the package
    1. 9.1 global code typesetting commands
    2. 9.2 algorithm environment, caption, list of algorithms, …
      1. 9.2.1 caption, title and changind reference of algorithms
      2. 9.2.2 setting style and layout of algorithm, caption and title
    3. 9.3 line numbering
      1. 9.3.1 labelling and numbering lines
      2. 9.3.2 setting style of lines numbers
    4. 9.4 math display
    5. 9.5 standard styles
      1. 9.5.1 standard font shapes and styles
      2. 9.5.2 caption and title font style
      3. 9.5.3 setting font standard font shapes and styles
      4. 9.5.4 setting caption and title font style
    6. 9.6 controlling the layout of algorithms
    7. 9.7 comments
  10. 10 The predefined language keywords
    1. 10.1 Input, output macros…
    2. 10.2 basic keywords and blocks
    3. 10.3 comments
    4. 10.4 if-then-else macros
    5. 10.5 multiple condition selection:
    6. 10.6 loops with ”end condition” test at the beginning
    7. 10.7 loops with ”end condition” test at the end
    8. 10.8 how default keywords are obtained
  11. 11 To define your own language keywords
    1. 11.1 to define Input, output macros…
    2. 11.2 to define basic keywords or blocks
    3. 11.3 to define keywords as function
    4. 11.4 to define comments
    5. 11.5 to define if-then-else macros
    6. 11.6 to define multiple condition selection:
    7. 11.7 to define loops with ”end condition” test at the beginning
    8. 11.8 to define loops with ”end condition” test at the end
  12. 12 Other language predefined keywords
    1. 12.1 French keywords
    2. 12.2 German keywords
    3. 12.3 Spanish keywords
    4. 12.4 Italian keywords
    5. 12.5 Portuguese keywords
    6. 12.6 Some Czech keywords
  13. 13 Known bugs

###  1 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 section 3
for two long examples of algorithms written with this package.

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<EMAIL_ADDRESS>with
subscribe algorithm2e-announce Firstname Name or
subscribe algorithm2e-discussion Firstname Name in the body of the message.

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.

###  2 How to use it: abstract

You must set $\backslash$usepackage[_options_]{algorithm2e} before
$\backslash$begin{document} command. The available options are described in
section 7.

The optional arguments [Hhtbp] works like those of figure environment. The 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 example111For longer and more complexe examples see section 3:

    \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}

which gives

Data: this text

Result: how to write algorithm with LaTeX2e

initialization;

while  _not at end of this document_ do

read current section;

if  _understand_ then

go to next section;

current section becomes this one;

else

go back to the beginning of current section;

end if

end while

Algorithm 1 How to write algorithms

Very Important : each line MUST end with $\backslash$; only those with a macro
beginning a block should not end with $\backslash$;. Note then that you can
always use the $\backslash$; 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 $\backslash$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.

###  3 Two more detailed examples

The algorithm 2 and algorithm 3 are written with this package.

####  3.1 Algorithm disjoint decomposition

Here we suppose that we have done:

    \usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}

The algorithm 2 was written in LaTeX2e code as presented next page. You can
label lines, and for example algorithm 2 denotes the second For (see
$\backslash$label command in the example). Notice also some ways of doing
comments at lines 2, 2, 2 and 2. Star comment commands are for comment on
lines of code, else comment is a line by itself as at algorithm 2. The
different option in star comments defines if it is left (l and h) or right
justified (r and f). The first ones (l and r) add ; at the end of line code,
the second ones (f and h) doesn’t. These last are useful when used in side
comment (introduced by ()) of alternatives of loops keyword commands.

1

input : A bitmap $Im$ of size $w\times l$

output : A partition of the bitmap

2 _special treatment of the first line_ ;

3 for  _$i\leftarrow 2$ to $l$_ do

4 _special treatment of the first element of line $i$_;

5 for  _$j\leftarrow 2$ to $w$_ do

6 left $\leftarrow$ FindCompress(_$Im[i,j-1]$_);

7 up $\leftarrow$ FindCompress(_$Im[i-1,]$_);

8 this $\leftarrow$ FindCompress(_$Im[i,j]$_);

9 if  _left compatible with this_ then // O(left,this)==1

10 if  _left $<$ this_ then Union(_left ,this_);

11 else Union(_this ,left_);

12

13 end if

14 if  _up compatible with this_ then // O(up,this)==1

15 if  _up $<$ this_ then Union(_up ,this_);

16 // this is put under up to keep tree as flat as possible

17 else Union(_this ,up_);

18 // this linked to up

19 end if

20

21 end for

22 foreach  _element $e$ of the line $i$_ do FindCompress(_p_);

23

24 end for

Algorithm 2 disjoint decomposition

    \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}

####  3.2 Algorithm: IntervalRestriction

Here we suppose we that have done:

    \usepackage[ruled,vlined]{algorithm2e}

The LaTeX2e code on next page gives algorithm 3. Here lines are not
autonumbered but you can number them individually with $\backslash$nl command
as for algorithm 3 or algorithm 3. You even can set your own reference with
$\backslash$nlset command and get back this reference by simply using
classical $\backslash$ref. For example $\backslash$ref{InResR} gives 3.

Data: $G=(X,U)$ such that $G^{tc}$ is an order.

Result: $G^{\prime}=(X,V)$ with $V\subseteq U$ such that $G^{\prime tc}$ is an
interval order.

begin

$V\longleftarrow U$

$S\longleftarrow\emptyset$

for  _$x\in X$_ do

$NbSuccInS(x)\longleftarrow 0$

$NbPredInMin(x)\longleftarrow 0$

$NbPredNotInMin(x)\longleftarrow|ImPred(x)|$

for  _$x\in X$_ do

if  _$NbPredInMin(x)=0$ and $NbPredNotInMin(x)=0$_ then

$AppendToMin(x)$

1while  _$S\neq\emptyset$_ do

REM remove $x$ from the list of $T$ of maximal index

2 while  _$|S\cap ImSucc(x)|\neq|S|$_ do

for  _$y\in S-ImSucc(x)$_ do

{ remove from $V$ all the arcs $zy$ : }

for  _$z\in ImPred(y)\cap Min$_ do

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)$

Algorithm 3 IntervalRestriction

    \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}

###  4 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:

    \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<n$}{
        a while loop including a repeat--until loop\;
        \Repeat{this end condition}{
          do this things\;
        }
      }
      They are many other possibilities and customization possible that you have to
      discover by reading the documentation.
    }

To handle 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:

    \newcommand{\forcond}{$i=0$ \KwTo $n$}
    \SetKwFunction{FRecurs}{FnRecursive}%

The algorithm 4 shows how algorithm is displayed in pseudo-code with default
behaviour and options boxed, commentsnumbered and longend set. Note that by
default, lines are used to show block of code. Note also that longend option
makes package use special _end_ keyword for each command222Default behaviour
uses _short end_ keywords, it means typeseting only _end_..

1 Function  _FnRecursive(_some args_)_ /* algorithm as a recursive function */

Data: Some input data

these inputs can be displayed on several lines and one input can be wider than
line’s width.

Result: Same for output data

2 /* this is a comment to tell you that we will now really start code */

3 if  _this is true_ then /* a simple if but with a comment on the same line
*/

4 we do that, else nothing

5 /* we will include other if so you can see this is possible */

6 if  _we agree that_ then

7 we do that

8

9 else

10 else we will do a more complicated if using else if

11 if  _this first condition is true_ then

12 we do that

13

14 else if  _this other condition is true_ then

15 this is done

16 /* else if */

17

18 else

19 in other case, we do this

20 /* else */

21

22 end if

23

24 end if

25

26 end if

27 /* now loops */

28 for  _$i=0$ to $n$_ do

29 a for loop

30

31 end for

32 while  _$i <n$_ do

33 a while loop including a repeat–until loop

34 repeat

35 do this things

36

37 until  _this end condition_

38 end while

39 They are many other possibilities and customization possible that you have
to discover by reading the documentation.

40 end

Algorithm 4 Generic example with most classical expressions derived in pseudo-
code

The algorithm 5 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:

    \AlgoDisplayBlockMarkers\SetAlgoBlockMarkers{begin}{end}%
    \SetAlgoNoEnd

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).

1 Function  _FnRecursive(_some args_)_ /* algorithm as a recursive function */

Data: Some input data

these inputs can be displayed on several lines and one input can be wider than
line’s width.

Result: Same for output data

2 /* this is a comment to tell you that we will now really start code */

3 if  _this is true_ then /* a simple if but with a comment on the same line
*/

4 we do that, else nothing

5 /* we will include other if so you can see this is possible */

6 if  _we agree that_ then

7 we do that

8

9 else

10 else we will do a more complicated if using else if

11 if  _this first condition is true_ then

12 we do that

13

14 else if  _this other condition is true_ then

15 this is done

16 /* else if */

17

18 else

19 in other case, we do this

20 /* else */

21

22 /* now loops */

23 for  _$i=0$ to $n$_ do

24 a for loop

25

26 while  _$i <n$_ do

27 a while loop including a repeat–until loop

28 repeat

29 do this things

30

31 until  _this end condition_

32 They are many other possibilities and customization possible that you have
to discover by reading the documentation.

Algorithm 5 Generic example in pseudo-code with begin-end block set

Not that since release 5.1, you can also have block tagged for one line
display. The algorithm 6 is based on algorithm 5 but uses “l macros” as e.g.
$\backslash$lIf to display command on one line ;
$\backslash$AlgoDisplayGroupMarkers is added to have also block tagged with
markers defined by $\backslash$SetAlgoBlockMarkers. To achieve this display,
we replace preamble of algorithm 5 by:

      \AlgoDisplayBlockMarkers\AlgoDisplayGroupMarkers\SetAlgoBlockMarkers{ \{}{ \}\ }%
      \SetAlgoNoEnd\SetAlgoNoLine

1 Function  _FnRecursive(_some args_)_ /* algorithm as a recursive function */

Data: Some input data

Result: Same for output data

2 if  _this is true_ then /* a simple if but with a comment on the same line
*/

3 we do that, else nothing

4 if  _we agree that_ then { we do that

5 }  else

6 if  _this first condition is true_ then { we do that

7 }  else if  _this other condition is true_ then { this is done

8 }  /* else if */ else { in other case, we do this

9 }  /* else */

10

11 for  _$i=0$ to $n$_ do { a for loop

12 }  while  _$i <n$_ do

13 a while loop including a repeat–until loop

14 repeat { do this things }  until  _this end condition_

15 /* a comment */

16 They are many other possibilities and customization possible that you have
to discover by reading the documentation.

Algorithm 6 algorithm 5 with {} block set even for one line command.

The algorithm 7 shows how algorithm looks like with a python-style syntax. To
achieve this display, we need to make following changes before the algorithm:

    \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%

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 _def_ in
python, so we redefine $\backslash$Fn macro. Range is a new macro for _range_
python function. Next are redefined _For_ , _If_ and _While_ commands
accordingly to python syntax. Note that we do nothing for _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.

1 def  _FnRecursive(_some args_)_: /* algorithm as a recursive function */

Data: Some input data

these inputs can be displayed on several lines and one input can be wider than
line’s width.

Result: Same for output data

2 /* this is a comment to tell you that we will now really start code */

3 if _this is true_ : /* a simple if but with a comment on the same line */

4 we do that, else nothing

5 /* we will include other if so you can see this is possible */

6 if _we agree that_ :

7 we do that

8

9 else:

10 else we will do a more complicated if using else if

11 if _this first condition is true_ :

12 we do that

13

14 elif _this other condition is true_ :

15 this is done

16 /* else if */

17

18 else:

19 in other case, we do this

20 /* else */

21

22

23

24 /* now loops */

25 for _$i$ in range(_$n$_)_:

26 a for loop

27

28 while _$i <n$_:

29 a while loop including a repeat–until loop

30 repeat

31 do this things

32

33 until _this end condition_

34 They are many other possibilities and customization possible that you have
to discover by reading the documentation.

Algorithm 7 Generic example in python-style like syntax

The algorithm 8 shows how algorithm looks like with a c-style syntax. To
achieve this display, we need to make following changes before the algorithm:

    \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%

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
$\backslash$SetAlgoBlockMarkers macro. $\backslash$Fn is redefined with no
keyword since in C, name of function defines it. Then we redefin FnRecursive
with its type. Next, _For_ , _If_ , _While_ and _Repeat_ are redefined
accordingly to C syntax. At last, we tell the package to display block
markers.

1 _void FnRecursive(_some args_)_ /* algorithm as a recursive function */

Data: Some input data

these inputs can be displayed on several lines and one input can be wider than
line’s width.

Result: Same for output data

2 /* this is a comment to tell you that we will now really start code */

3 if (_this is true_) /* a simple if but with a comment on the same line */

4 we do that, else nothing

5 /* we will include other if so you can see this is possible */

6 if (_we agree that_)

7 we do that

8

9 else

10 else we will do a more complicated if using else if

11 if (_this first condition is true_)

12 we do that

13

14 elif (_this other condition is true_)

15 this is done

16 /* else if */

17

18 else

19 in other case, we do this

20 /* else */

21

22

23

24

25

26

27 /* now loops */

28 for (_$i$ to range(_$n$_)_)

29 a for loop

30

31

32 while (_$i <n$_)

33 a while loop including a repeat–until loop

34 repeat

35 do this things

36

37 until (_this end condition_)

38

39 They are many other possibilities and customization possible that you have
to discover by reading the documentation.

40

Algorithm 8 Generic example in c-style like syntax

The algorithm 9 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:

    \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%

If you look at algorithm 4, you can see that some command doesn’t put a end.
For example, it is a case for a _if_ followed by an _else_ , same thing for a
_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 algorithm 5 or algorithm 8. 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 _If_ , _For_ , _While_ and _Repeat_ command.

1 _void FnRecursive(_some args_)_{ /* algorithm as a recursive function */

Data: Some input data

these inputs can be displayed on several lines and one input can be wider than
line’s width.

Result: Same for output data

2 /* this is a comment to tell you that we will now really start code */

3 if (_this is true_){ /* a simple if but with a comment on the same line */

4 we do that, else nothing

5 /* we will include other if so you can see this is possible */

6 if (_we agree that_){

7 we do that

8

9 else{

10 else we will do a more complicated if using else if

11 if (_this first condition is true_){

12 we do that

13

14 elif (_this other condition is true_){

15 this is done

16 /* else if */

17

18 else{

19 in other case, we do this

20 /* else */

21

22

23

24

25

26

27 /* now loops */

28 for (_$i$ to range(_$n$_)_){

29 a for loop

30

31

32 while (_$i <n$_){

33 a while loop including a repeat–until loop

34 repeat{

35 do this things

36

37 until (_this end condition_)

38

39 They are many other possibilities and customization possible that you have
to discover by reading the documentation.

40

Algorithm 9 Generic example in c-style like syntax with compact block

###  5 Compatibility issues

Compatibily with other packages improven by changing name of internal macros.
Algorithm2e can now be used with almost all package, as elsart, hermes,
arabtex for example, if this last is loaded after algorithm2e package. So, at
this time, release 5.2has few known compatibility problem with other packages.
The packages or classes that are known to be not compatible with algorithm2e
package is:

  * •

ascelike

  * •

pstcol

Nevertheless, when use with some packages, some of their options cannot be
used, or you need to specify some particular options (as algo2e to change name
of environment if algorithm is already defined by the class), either from
algorithm2e package or from the other packages.

hyperref

if you want to compile in PdfLaTeX, you must not use naturalnames option.
Beware this has changed from release 3 where you should use it!

article-hermes

is not compatible with relsize used by algorithm2e package, so you have to use
norelsize option to get algorithm works with article-hermes class.

Note also that, if you use packages changing the way references are printed,
you must define labels of algorithm after the caption to ensure a correct
printing. You cannot use $\backslash$label inside a caption without errors.

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 oldcommands option
to enable old commands back. Here are these commands:

  * •

$\backslash$SetNoLine becomes $\backslash$SetAlgoNoLine

  * •

$\backslash$SetVline becomes $\backslash$SetAlgoVlined

  * •

$\backslash$Setvlineskip becomes $\backslash$SetVlineSkip

  * •

$\backslash$SetLine becomes $\backslash$SetAlgoLined

  * •

$\backslash$dontprintsemicolon becomes $\backslash$DontPrintSemicolon

  * •

$\backslash$printsemicolon becomes $\backslash$PrintSemicolon

  * •

$\backslash$incmargin becomes $\backslash$IncMargin

  * •

$\backslash$decmargin becomes $\backslash$DecMargin

  * •

$\backslash$setnlskip becomes $\backslash$SetNlSkip

  * •

$\backslash$Setnlskip becomes $\backslash$SetNlSkip

  * •

$\backslash$setalcapskip becomes $\backslash$SetAlCapSkip

  * •

$\backslash$setalcaphskip becomes $\backslash$SetAlCapHSkip

  * •

$\backslash$nlSty becomes $\backslash$NlSty

  * •

$\backslash$Setnlsty becomes $\backslash$SetNlSty

  * •

$\backslash$linesnumbered becomes $\backslash$LinesNumbered

  * •

$\backslash$linesnotnumbered becomes $\backslash$LinesNotNumbered

  * •

$\backslash$linesnumberedhidden becomes $\backslash$LinesNumberedHidden

  * •

$\backslash$showln becomes $\backslash$ShowLn

  * •

$\backslash$showlnlabel becomes $\backslash$ShowLnLabel

  * •

$\backslash$nocaptionofalgo becomes $\backslash$NoCaptionOfAlgo

  * •

$\backslash$restorecaptionofalgo becomes $\backslash$RestoreCaptionOfAlgo

  * •

$\backslash$restylealgo becomes $\backslash$RestyleAlgo

  * •

$\backslash$gIf macros and so on do no more exist

###  6 Environments defined in the package

This package provides 4 environments :

algorithm:

the main environment, the one you will used most of the time.

algorithm*:

same as the precedent, but used in a two columns text, puts the algorithm
across the two columns.

procedure:

This environment works like algorithm environment but:

  * •

the ruled (or algoruled) style is recommended.

  * •

the caption now writes Procedure name…

  * •

the syntax of the $\backslash$caption command is restricted as follow: you
MUST put a name followed by 2 braces like this “ _Name()_ ”. 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).

  * •

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 $\backslash$caption{myproc()}, you can use
$\backslash$myproc macro in you main text. Beware that the macro is only
defined after the $\backslash$caption!

  * •

nokwfunc 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.

procedure*:

same as the precedent, but used in a two columns text outs the procedure
across the two columns.

function:

as the precedent but with Function instead of procedure in the title.

function*:

same as the precedent, but used in a two columns text outs the function across
the two columns.

If you don’t like algorithm or look for something else, you can change the
name of algorithm by using command below:

$\backslash$SetAlgorithmName{algorithmname}{algorithmautorefname}{list of
algorithms name}

which redefines name of the algorithms and the sentence list of algorithms.
Example:
$\backslash$SetAlgorithmName{Protocol}{List of protocols} if you prefer
protocol than algorithm. Second argument is the name that $\backslash$autoref,
from hyperref package, will use.

The same exists for procedure and function environment, the difference is that
list of algorithms is not change and keep its original name:

$\backslash$SetAlgoProcName{aname}{anautorefname}

sets the name of Procedure printed by procedure environment (the environment
prints Procedure by default). Second argument is the name that
$\backslash$autoref, from hyperref package, will use.

$\backslash$SetAlgoFuncName{aname}{anautorefname}

sets the name of Function printed by procedure environment (the environment
prints Function by default). Second argument is the name that
$\backslash$autoref, from hyperref package, will use.

###  7 The options of the package

####  7.1 language option

There are predefined keywords in different languages already defined (see
section 12 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 _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.

english:

the default.

french:

to have French keywords, for example algorithme : instead of algorithm:.

frenchkw:

to add French keywords definition.

german:

to have German keywords, for example Prozedur : instead of procedure:.

germankw:

to add German keywords definition.

ngerman:

German option as babel

spanish:

to have Spanish keywords, for example Algoritmo: instead of algorithm:.

spanishkw:

to add Spanish keywords definition.

italiano:

to have Italian keywords, for example Algoritmo: instead of algorithm:.

italianokw:

to add Italian keywords definition.

portuguese:

to have Portuguese keywords, for example Algoritmo: instead of algorithm:.

portuguesekw:

to add Portuguese keywords definition.

croatian:

to have Croatian keywords, for example Algoritam: instead of algorithm:.

croatiankw:

to add Croatian keywords definition.

czech:

to have Czech keywords, for example Algoritmus: instead of algorithm:.

czechkw:

to add Czech keywords definition.

turkish:

to have Turkish keywords, for example Algoritma: instead of algorithm:.

turkishkw:

to add Turkish keywords definition.

czech:

to have for example Algoritmus: instead of algorithm:.

czechkw:

to add Czech keywords definition.

onelanguage:

allows, 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

####  7.2 compatibility issue

algo2e:

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 $\backslash$listofalgorithmes

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 load endfloat package, so it is required to have
it.

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 $\backslash$scriptsize font for
lines numbers.

slide:

require package color. To be used with slide class in order to have correct
margins.

nokwfunc

disable the setting in $\backslash$KwFunction of procedure’s or function’s
name (see section 6) 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.

####  7.3 environment display and use

#####  7.3.1 boxed, ruled, plain environment

boxed:

to have algorithms enclosed in a box.

boxruled:

surround algorithm by a box, puts caption above and add a line after caption.

ruled:

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.

algoruled:

as above but with extra spaces after the rules.

tworuled:

tworuled acts like ruled but doesn’t put a line after the title.

plain:

the default, with no feature.

#####  7.3.2 algorithm numbering

algochapter:

algorithms are numbered within chapter numbers.

algosection:

(default) algorithms are numbered within section numbers.

algopart:

algorithms are numbered within part numbers.

procnumbered:

makes the procedure and function to be numbered as algorithm.

#####  7.3.3 figure and toc

figure:

algorithms are put in classical figures and so are numbered as figures and
putted in the $\backslash$listoffigures.

dotocloa

adds an entry in the toc for the list of algorithms. This option loads 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.

####  7.4 code typesetting

#####  7.4.1 indentation of long statements

noalgohanging

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.

hangingcomment

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.

opthanginginout

As for comment, by default, in/out keywords and input keywords (defined by
$\backslash$SetKwInOut or $\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.

#####  7.4.2 blocks display

###### lines

lined:

$\backslash$SetAlgoLined becomes the default, see section 9.6 for explanations
about the $\backslash$SetAlgoLined macros.

vlined:

$\backslash$SetAlgoVlined becomes the default, see section 9.6 for
explanations about the $\backslash$SetAlgoVlined macros.

noline:

$\backslash$SetNoline becomes the default, see section 9.6 for explanations
about the $\backslash$SetNoline macros.

###### block markers

displayblockmarkers

$\backslash$AlgoDisplayBlockMarkers becomes the default, see section 9.6 for
explanations about the $\backslash$AlgoDisplayBlockMarkers macro.

displaygroupmarkers

$\backslash$AlgoDisplayGroupMarkers becomes the default, see section 9.6 for
explanations about the $\backslash$AlgoDisplayGroupMarkers macro.

#####  7.4.3 end keywords

longend

the end keyword are longer and different for each macro. For example _endif_
for a if-then-else macro.

shortend

the “end keyword” of the macros is just _end_ (default).

noend

the “end keyword” of the macros is not printed.

#####  7.4.4 comments

scright (default)

right justified side comments (side comments are flushed to the right)

scleft

left justified side comments (side comments are put right after the code line)

fillcomment (default)

end mark of comment is flushed to the right so comments fill all the width of
text

nofillcomment

end mark of comment is put right after the comment

#####  7.4.5 lines numbers

linesnumbered:

lines of the algorithms are numbered except for comments and input/output
(KwInput and KwInOut). You must use $\backslash$nllabel{label} to label thoses
lines.

linesnumberedhidden:

lines of the algorithms are numbered as linesnumbered but numbers are not
shown. $\backslash$ShowLn and $\backslash$ShowLnLabel{label} show the number
on line they are put.

commentsnumbered:

makes comments be numbered if numbering is active.

inoutnumbered:

makes data input/output be numbered if numbering is active.

rightnl:

put lines numbers to the right of the algorithm instead of left.

resetcount

the line numbers are reset to 0 at the beginning of each algorithm (by
default).

noresetcount

the contreverse of the precedent. To reset the line counter to 0 do:
$\backslash$setcounter{AlgoLine}{0}

algonl

the line numbers will be prefixed with the number of the current algorithm.
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.

#####  7.4.6 title of algorithms

titlenumbered:

$\backslash$TitleOfAlgo{title} prints Algorithm n: thetitle where _n_ is the
counter of the algo.
Beware: $\backslash$TitleOfAlgo don’t insert an entry in the list of
algorithms. So do not use $\backslash$TitleOfAlgo with a caption. Both
increment the counter of the algorithms.

titlenotnumbered (default)

the macro $\backslash$TitleOfAlgo{title} doesn’t number the algorithm.

###  8 Typesetting

There are eight text types in an algorithm environment:

  1. 1.

The keywords (Kw): Macros which usually indicate words of the language. Some
are predefined and given with _the algorithm package_.

The user can define his own language keywords by using the different macros
presented in section 11 (see below for a short, non exhaustive list). He can
also define simple keywords with the $\backslash$SetKw{Kw}{thetext} macro.

  2. 2.

The Functions: (Func) Macros defined by the user which denote local functions
or other algorithms defined in the text. (See also function environment at
section 6, which defines not only function keyword but algorithm of the
function.

They are defined using $\backslash$SetKwFunction{KwFn}{Fn} where
$\backslash$KwFn will be the macro and Fn the text printed.

  3. 3.

The Arguments (Arg): The arguments of the _Kw_ or _Func_ macros.

  4. 4.

The procedure and function name environment style ($\backslash$ProcNameSty and
$\backslash$ProcNameFnt): The type style of the caption of _procedure_ and
_function_ environment.

  5. 5.

The arguments of procedure and function environments style
($\backslash$ProcArgSty and $\backslash$ProcArgFnt): the type style of the
argument of _procedure_ and _function_ environments.

  6. 6.

Data (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 $\backslash$SetKwData{KwDat}{data}
macro, where $\backslash$KwDat will be the macro and data the text printed.

  7. 7.

Block markers : BlockMarkersSty is style of keywords that are print at begin
and end of block when displayblockmarkers and/or displaygroupmarkers option
are set, or $\backslash$AlgoDisplayBlockMarkers and/or
$\backslash$AlgoDisplaygroupMarkers macro are used. By default,
$\backslash$BlockMarkersSty is set to $\backslash$KwSty.

  8. 8.

The text (the default): All the remaining text of the algorithm.

###  9 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.

####  9.1 global code typesetting commands

$\backslash$;

marks the end of a line. Don’t forget it !. By default, it prints a ‘;’. You
can change this with $\backslash$DontPrintSemicolon.

$\backslash$DontPrintSemicolon

the ‘;’ are no more printed at the end of each line.

$\backslash$PrintSemicolon

prints a ‘; ’ at the end of each line (by default)

$\backslash$BlankLine

prints a blank line. In fact puts a vertical space of one ex.

$\backslash$Indp

indents plus $\rightarrow$ the text is shifted to the right.

$\backslash$Indm

indents minus $\rightarrow$ the text is shifted to the left.

$\backslash$SetStartEndCondition{typo1}{typo2}{typo3}

which sets typo around condition in For, If, Switch, Case and Repeat macros.
First two are used around For, If, Switch, Case conditions, First and third
are used for Repeat condition. Default definition is:
`\SetStartEndCondition{ }{ }{}`.
A common alternative is `\SetStartEndCondition{ (}{) }{)}`.
It can also be used to remove space around condition, for example if you want
python style commands: `\SetStartEndCondition{ }{}{}` and
`\SetKwFor{For}{for}{:}{}`

$\backslash$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
$\backslash$SetAlgoBlockMarkersbegin keywordsend keywords{c}{o}mmand. By
default, these keywords are not printed but _begin_ and _end_ are default
keywords used if `\AlgoDisplayBlockMarkers` is called.

$\backslash$AlgoDisplayGroupMarkers

is related to $\backslash$AlgoDisplayBlockMarkers and do the same but for
command that are displayed on a single line.

####  9.2 algorithm environment, caption, list of algorithms, …

#####  9.2.1 caption, title and changind reference of algorithms

Algorithm environment are float environment. So you can use classical
$\backslash$caption, $\backslash$listofalgorithms{,} $\backslash$label. If you
want a title but not a caption (for example to not add an enter in the list of
algorithm) you have $\backslash$TitleOfAlgo{.} And if you want to name your
algorithm and not number it, you can change the reference of it by using
$\backslash$SetAlgoRefName{ref}:

$\backslash$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.

$\backslash$TitleOfAlgo{thetitle}

prints: “Algorithm n∘: thetitle” in the typography and size defined by
$\backslash$SetTitleSty. Puts a vertical space below.
Beware: $\backslash$TitleOfAlgo doesn’t insert an entry in the list of
algorithms. So don’t use $\backslash$TitleOfAlgo with $\backslash$caption.
Both increment the counter of the algorithms.
note:_with the french option prints _Algorithme n ∘:__

$\backslash$listofalgorithms

inserts the list of all algorithms having a _caption_.

$\backslash$SetAlgoRefName{ref}

which changes the default ref (number of the algorithm) by the name given in
parameter. For example $\backslash$SetAlgoRefName{QXY} sets reference of the
algorithm to QXY. If you label your algorithm and reference it, you will get
QXY. On the same manner, entry in the list of algorithm will name it QXY.

$\backslash$SetAlgoRefRelativeSize{relative integer}

which sets the output size of reference in list of algorithms for references
set by $\backslash$SetAlgoRefName. The default is
$\backslash$SetAlgoRefRelativeSize{-2}.

#####  9.2.2 setting style and layout of algorithm, caption and title

The following commands help you to define the style and the layout of the
caption:

$\backslash$SetAlgoCaptionSeparator{sep}

which sets the separator between title of algorithms (Algorithm 1) and the
name of the algorithm. By default it’s ’:’ and caption looks like ”Algorithm
2: name” but now you can change it by using for example which will give
”Algorithm 3. name”.

$\backslash$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.

$\backslash$AlCapSkip

is the dimension of the distance between algorithm body and caption in _plain_
and _boxed_ mode. You can change by hands or by using
$\backslash$SetAlCapSkip{0ex}.

$\backslash$SetAlCapSkip{length}

sets the lenght of $\backslash$AlCapSkip) dimension between algorithm body and
caption.

$\backslash$SetAlCapHSkip{length}

sets the horizontal skip before Algorithm: in caption when used in ruled
algorithm.

$\backslash$SetTitleSty{type style}{type size}

sets the typography and size of the titles defined with the macro
$\backslash$TitleOfAlgo{} (not with $\backslash$caption).

$\backslash$NoCaptionOfAlgo

doesn’t print Algorithm and its number in the caption. This macros is ONLY
active for _“ algoruled”_ or _“ ruled”_ 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.

$\backslash$RestoreCaptionOfAlgo

restores correct captions that was corrupted by a $\backslash$NoCaptionOfAlgo
macro.

$\backslash$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:

  * •

$\backslash$SetAlgoCaptionLayout{centerline} to have centered caption;

  * •

$\backslash$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 $\backslash$SetAlgoCaptionLayout
with its name. $\backslash$AlCapFnt and $\backslash$AlCapNameFnt can change
the font used in caption, beware of interactions between this three commands.

Note that two length control the layout of ruled, algoruled, boxruled
algorithms caption. $\backslash$interspacetitleruled and
$\backslash$interspacetitleboxruled are described section 9.6.

####  9.3 line numbering

#####  9.3.1 labelling and numbering lines

AlgoLine is the counter used to number the lines. It’s a standard counter, so
LaTeXcommands works with it.

linesnumbered, linesnumberedhidden and commentsnumbered (see above section 7)
are the options controlling auto-numbering of lines. You can also control this
feature manually and precisely with the following commands:

$\backslash$LinesNumbered

makes lines of the following algorithms be auto-numbered. This command
corresponds to linesnumbered option.

$\backslash$LinesNumberedHidden

makes lines of the following algorithms be auto-numbered, but numbers stay
hidden. You have to use $\backslash$ShowLn and $\backslash$ShowLnLabel to see
them. This command corresponds to linesnumberedhidden option.

$\backslash$LinesNotNumbered

makes lines of the following algorithms no be auto-numbered.

$\backslash$nllabel{label}

macro for labelling lines when auto-numbering is active.

$\backslash$nl

numbers the line: must begin the line. You can use $\backslash$label to label
the line and reference it further.

$\backslash$lnl{label}

numbers and labels the line : must begin the line. Do a Beware this has
changed from release 3$\backslash$nl$\backslash$label{label} in one time.
Prefer to use a classical $\backslash$label as it is more readable.

$\backslash$nlset{text}

works as $\backslash$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 $\backslash$ref will print it instead of classical number.

$\backslash$lnlset{text}{label}

works for $\backslash$nlset as $\backslash$lnl for $\backslash$nl. Prefer to
use a classical $\backslash$label as it is more readable.

$\backslash$ShowLn

shows number of the line when linesnumberedhidden is activated.

$\backslash$ShowLn{label}

same as precedent but with a label. Prefer to use $\backslash$ShowLn with a
classical $\backslash$label.

#####  9.3.2 setting style of lines numbers

The following command allows you to change the way line numbers are printed:

$\backslash$SetNlSty{$<$font$>$}{$<$txt before$>$}{$<$txt after$>$}

defines how to print line numbers:
will print {$<$font$>$ $<$txt bef$>$ thelinenumber $<$txt aft$>$}.
By default $\backslash$SetNlSty{textbf}{}{}.

$\backslash$SetNlSkip{length}

sets the value of the space between the line numbers and the text, by default
1em.

$\backslash$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, $\backslash$SetAlgoNlRelativeSize{$0$} sets it to the same size,
$\backslash$SetAlgoNlRelativeSize{$-1$} to one size smaller and
$\backslash$SetAlgoNlRelativeSize{$1$} to one size bigger.

Example below shows use of these macros:

    \SetNlSty{texttt}{[}{]}
    \SetAlgoNlRelativeSize{0}
    \SetNlSkip{0em}
    \nl\KwIn{input data}
    \nl\KwOut{output data}
    \nl\tcc{a comment line in C-style}
    \nl\Repeat{\nl$e<\tau$}{
      \nl$f_n\leftarrow Y_1$\;
      \nl$f_{n+1}\leftarrow f_n\times f_{n-1}$\;
      \nl$e\leftarrow \frac{f_n}{2}$\;
    }
    \nl\KwRet{$e$}

$\Longrightarrow$ 1 Input: input data  2 Output: output data  43 /* a comment
line in C-style */ 65 repeat 8 7 $f_{n}\leftarrow Y_{1}$ 10 9
$f_{n+1}\leftarrow f_{n}\times f_{n-1}$ 12 11 $e\leftarrow\frac{f_{n}}{2}$ 13
15 _14_ until  __$e <\tau$ 16return _$e$_

####  9.4 math display

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 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

####  9.5 standard styles

#####  9.5.1 standard font shapes and styles

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 “$\backslash$Set commands” (see
section 9.5.3)

$\backslash$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 to have algorithms typeset in small sf font. Default is
nothing so algorithm is typeset as the text of the document.

$\backslash$KwSty{$<$text$>$}

sets $<$text$>$ in keyword type style.

$\backslash$FuncSty{$<$text$>$}

sets $<$text$>$ in function type style.

$\backslash$FuncArgSty{$<$text$>$}

sets $<$text$>$ in function argument type style.

$\backslash$ProgSty{$<$text$>$}

sets $<$text$>$ in programm (KwProg) type style.

$\backslash$ArgSty{$<$text$>$}

sets $<$text$>$ in argument type style.

$\backslash$DataSty{$<$text$>$}

sets $<$text$>$ in data typography.

$\backslash$CommentSty{$<$text$>$}

sets $<$text$>$ in comment typography.

$\backslash$NlSty{$<$text$>$}

sets $<$text$>$ in number line typography.

$\backslash$ProcNameSty{$<$text$>$}

sets $<$text$>$ in procedure style of procedure and function environment (by
default the same as $\backslash$AlCapSty{)}. (see section 9.5.2 for more
explanations and details)

$\backslash$ProcFnt{$<$text$>$}

sets $<$text$>$ in procedure typography of procedure and function environment
(by default the same as $\backslash$AlCapFnt{)}. (see section 9.5.2 for more
explanations and details)

$\backslash$ProcArgSty{$<$text$>$}

sets $<$text$>$ in argument style of procedure and function environment (by
default the same as $\backslash$AlCapNameSty{)}. (see section 9.5.2 for more
explanations and details)

$\backslash$ProcArgFnt{$<$text$>$}

sets $<$text$>$ in argument typography of procedure and function environment
(by default the same as $\backslash$AlCapNameFnt{)}. (see section 9.5.2 for
more explanations and details)

$\backslash$BlockMarkersSty{$<$text$>$}

sets $<$text$>$ in block markers typography (by default the same as
$\backslash$KwSty{)} (see section 9.6 for more explanations and details on
block markers).

#####  9.5.2 caption and title font style

$\backslash$AlCapSty, $\backslash$AlCapNameSty, $\backslash$AlCapFnt,
$\backslash$AlCapNameFnt, $\backslash$ProcSty, $\backslash$ProcFnt,
$\backslash$ProcNameSty, $\backslash$ProcNameFnt, $\backslash$ProgArgSty,
$\backslash$ProgArgFnt and corresponding “$\backslash$Set commands” (see
section 9.5.4) $\backslash$SetAlCapSty, $\backslash$SetAlCapNameSty,
$\backslash$SetAlCapFnt, $\backslash$SetAlCapNameFnt, $\backslash$SetProcSty,
$\backslash$SetProcFnt, $\backslash$SetProcNameSty,
$\backslash$SetProcNameFnt, $\backslash$SetProgArgSty,
$\backslash$SetProgArgFnt control the way caption of algorithm and
procedure/function environment are printed.

$\backslash$AlCapSty and $\backslash$AlCapFnt are used to define style and
font shape of “Algorithm #:” in caption. $\backslash$AlCapNameSty and
$\backslash$AlCapNameFnt are used to define style and font shape of the
caption text. In fact a caption $\backslash$caption{my algorithm} is printed
as follow :

$\backslash$AlCapSty{$\backslash$AlCapFnt Algorithm
#:}$\backslash$AlCapNameSty{$\backslash$AlCapNameFnt my algorithm}.

By default, $\backslash$AlCapSty is textbf and $\backslash$AlCapFnt is
nothing. $\backslash$AlCapNameSty keeps text as it is, and
$\backslash$AlCapNameFnt do nothing.

$\backslash$ProcSty and $\backslash$ProcFnt are used to define style and font
shape of “Procedure” in caption of procedure and function environment.
$\backslash$ProcNameSty and $\backslash$ProcNameFnt are used to define style
and font shape of the procedure or function name. $\backslash$ProcArgSty and
$\backslash$ProgArgFnt are used to define style and font shape of arguments in
procedure/function environment. In fact a caption $\backslash$caption{Proc(int
i)} of procedure/function environment is printed as follow :

$\backslash$ProcSty{$\backslash$ProcFnt
Procedure}$\backslash$ProcNameSty{$\backslash$ProcNameFnt Proc(}%
$\backslash$ProgArgSty{$\backslash$ProgArgFnt int
i}$\backslash$ProcNameSty{$\backslash$ProcNameFnt )}.

By default, $\backslash$ProcSty is $\backslash$AlCapSty and
$\backslash$ProcFnt is $\backslash$AlCapFnt. $\backslash$ProcNameSty keeps
text as it is, and $\backslash$ProcNameFnt do nothing.

$\backslash$AlCapSty{$<$text$>$}

sets $<$text$>$ in caption title typography, that is the same used, together
with $\backslash$AlCapFnt, to print Algorithm #:, more precisely it is printed
as follow:
$\backslash$AlCapSty{$\backslash$AlCapFnt Algorithm #:}
which gives actually “Algorithm #:”. By default $\backslash$AlCapSty is
textbf.

$\backslash$AlCapNameSty{$<$text$>$}

sets $<$text$>$ in caption name typography, that is the same used, together
with $\backslash$AlCapNameFnt to print the name of caption you set by calling
$\backslash$caption{name}. More precisely it is printed as follow:
$\backslash$AlCapNameSty{$\backslash$AlCapNameFnt name}
which gives “name”. By default $\backslash$AlCapNameSty is textnormal which
means print in standard text.

$\backslash$AlCapFnt{$<$text$>$}

sets $<$text$>$ in font shape of caption title, that is the same used,
together with $\backslash$AlCapSty, to print Algorithm #:, more precisely it
is printed as follow:
$\backslash$AlCapSty{$\backslash$AlCapFnt Algorithm #:}
which gives actually “Algorithm #:”. By default $\backslash$AlCapFnt is
$\backslash$relax which means keep text as it is.

$\backslash$AlCapNameFnt{$<$text$>$}

sets $<$text$>$ in caption name typography, that is the same used, together
with $\backslash$AlCapNameSty to print the name of caption you set by calling
$\backslash$caption{name}. More precisely it is printed as follow:
$\backslash$AlCapNameSty{$\backslash$AlCapNameFnt name}
which gives “name”. By default $\backslash$AlCapNameFnt is $\backslash$relax
which means keep text as it is.

$\backslash$ProcSty{$<$text$>$}

sets $<$text$>$ in procedure/function caption title typography, that is the
same used, together with $\backslash$ProcFnt, to print Procedure, more
precisely it is printed as follow:
$\backslash$ProcSty{$\backslash$ProcFnt Procedure}
which gives actually “Procedure”. By default $\backslash$ProcSty is
$\backslash$AlCapSty.

$\backslash$ProcNameSty{$<$text$>$}

sets $<$text$>$ in procedure name typography, that is the same used, together
with $\backslash$ProcNameFnt to print the name of caption you set by calling
$\backslash$caption{Proc(int i)}. More precisely it is printed as follow:
$\backslash$ProcNameSty{$\backslash$ProcNameFnt Proc(}
which gives “Proc(”. By default $\backslash$ProcNameSty is
$\backslash$AlCapNameSty which means print in standard text.

$\backslash$ProcArgSty{$<$text$>$}

sets $<$text$>$ in argument of procedure/function typography, that is the same
used, together with $\backslash$ProcArgFnt, to print int i if
$\backslash$caption{Proc(int i)} was called. More precisely it is printed as
follow:
$\backslash$ProcArgSty{$\backslash$ProcArgFnt int i}
which gives actually “int i”. By default $\backslash$ProcArgSty is
$\backslash$AlCapNameSty;

$\backslash$ProcFnt{$<$text$>$}

sets $<$text$>$ in font shape of caption title, that is the same used,
together with $\backslash$ProcSty, to print Procedure, more precisely it is
printed as follow:
$\backslash$ProcSty{$\backslash$ProcFnt Procedure}
which gives actually “Procedure”. By default $\backslash$ProcFnt is
$\backslash$relax which means keep text as it is.

$\backslash$ProcNameFnt{$<$text$>$}

sets $<$text$>$ in procedure/function name typography, that is the same used,
together with $\backslash$ProcNameSty to print the name of caption you set by
calling $\backslash$caption{Proc(int i)}. More precisely it is printed as
follow:
$\backslash$ProcNameSty{$\backslash$ProcNameFnt Proc(}
which gives “Proc(”. By default $\backslash$ProcNameFnt is $\backslash$relax
which means keep text as it is.

$\backslash$ProcArgFnt{$<$text$>$}

sets $<$text$>$ in font shape of argument of procedure/environment caption,
that is the same used, together with $\backslash$ProcArgSty, to print int i if
$\backslash$caption{int i} was called. More precisely it is printed as follow:
$\backslash$ProcArgSty{$\backslash$ProcFnt int i}
which gives actually “int i”. By default $\backslash$ProcArgFnt do nothing.

$\backslash$AlTitleSty{$<$text$>$}

is used to typeset “Algorithm #:” in title, together with
$\backslash$AlTitleFnt. You can use it to have text as your titles. Precisely,
titles are typeset as follow:
$\backslash$AlTitleSty{$\backslash$AlTitleFnt{Algorithm #:}}.

$\backslash$AlTitleFnt{$<$text$>$}

is used to typeset “Algorithm #:” in title, together with
$\backslash$AlTitleSty. You can use it to have text as your titles. Precisely,
titles are typeset as follow:
$\backslash$AlTitleSty{$\backslash$AlTitleFnt{Algorithm #:}}.

#####  9.5.3 setting font standard font shapes and styles

With the following commands you can customize the style and have the look you
want for your algorithms:

$\backslash$SetAlFnt{$<$font$>$}

define the fonts used for typesetting algorithms.

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
$\backslash$SetAlFnt{$\backslash$small$\backslash$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,
$\backslash$SetAlCapFnt{textbf} (see section 9.2.2) defines the default
behaviour of $\backslash$AlCapFnt. If you want to do more complicated thing,
you should define your own macro and give it to $\backslash$SetAlCapFnt or
$\backslash$SetAlCapNameFnt. Here are two examples:

  * •

$\backslash$newcommand{$\backslash$mycapfn}[1]{$\backslash$tiny
#1}$\backslash$SetAlCapNameFnt{mycapfnt}

  * •

$\backslash$newcommand{$\backslash$mycapfn}[1]{$\backslash$textsl{$\backslash$small
#1}}$\backslash$SetAlCapNameFnt{mycapfnt}

Here is the complete list of these macros:

$\backslash$SetKwSty{$<$font$>$}

sets the Kw typography to $<$font$>$ (by default: textbf).

$\backslash$SetFuncSty{$<$font$>$}

sets the function typography (by default: texttt).

$\backslash$SetFuncArgSty{$<$font$>$}

sets the typography of function argument (by default: emph).

$\backslash$SetProgSty{$<$font$>$}

sets the KwProg typography to $<$font$>$ (by default: emph).

$\backslash$SetArgSty{$<$font$>$}

sets the argument typography (by default: emph).

$\backslash$SetDataSty{$<$font$>$}

sets the data typography (by default: textsf).

$\backslash$SetCommentSty{$<$font$>$}

sets the comment text typography (by default: texttt).

$\backslash$SetNlSty{$<$font$>$}

sets the number line typography (by default: $\backslash$relsize{-2})

$\backslash$SetProcNameSty{$<$font$>$}

sets caption typography of procedure and function environment (by default the
same as $\backslash$AlCapSty{)}.

$\backslash$SetProcArgSty{$<$font$>$}

sets argument typography of procedure and function environment (by default the
same as $\backslash$AlCapNameSty{)}.

$\backslash$SetBlockMarkersSty{$<$font$>$}

sets block markers typography (by default the same as $\backslash$KwSty{)}.

#####  9.5.4 setting caption and title font style

The following commands allow to redefine Fnt macros. This ones requires to
give directly commands that define the font shape you want. They works as
$\backslash$SetAlFnt{d}escribed above. For example you can do
$\backslash$SetAlCapFnt{$\backslash$large$\backslash$color{red}} to have
Algorithm #: in caption printed in large red font.

$\backslash$SetAlCapFnt{$<$font$>$}

sets the font used for {algorithm: } in caption of algorithm (default is set
to $\backslash$relax).

$\backslash$SetAlCapNameFnt{$<$font$>$}

sets the font used by caption text. Default is $\backslash$relax and text is
kept as it is.

$\backslash$SetAlTitleFnt{$<$font$>$}

sets the font used in $\backslash$TitleOfAlgo command (default is set to
$\backslash$relax, so text is kept as it is).

The next commands allow to redefine Sty macros for caption or title. As
“$\backslash$Set commands” of basic font style (see section 9.5.3), 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:

  * •

$\backslash$newcommand{$\backslash$mycapsty}[1]{$\backslash$textbf{$\backslash$emph{#1}}}$\backslash$SetAlCapNameSty{mycapsty}
caption will be print emphased and in bold face.

  * •

$\backslash$SetAlCapNameFnt{$\backslash$tiny} set font to tiny size.

  * •

if you combine $\backslash$SetAlCapNameSty{mycapsty} and
$\backslash$SetAlCapNameFnt{$\backslash$tiny} will give tiny bold empased
caption.

Now the commands:

$\backslash$SetAlCapSty{$<$commandname$>$}:

sets the command that will be used by $\backslash$AlCapSty to define style of
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: $\backslash$SetAlCapSty{textbf}.

$\backslash$SetAlCapNameSty{$<$commandname$>$}:

sets the command that will be used by $\backslash$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: $\backslash$SetAlCapSty{textnormal}.

$\backslash$SetAlTitleSty{$<$commandname$>$}

sets the command that will be used by $\backslash$AlTitleSty to define style
of algorithm title given by $\backslash$TitleOfAlgo (default is set to
$\backslash$SetAlTitleSty{textbf}).

Note that by combining Fnt and 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:

  * •

$\backslash$SetAlCapNameSty{textsl}$\backslash$SetAlCapNameFnt{$\backslash$small}

####  9.6 controlling the layout of algorithms

$\backslash$RestyleAlgo{style}

change the layout of the algorithms as do options _boxed_ , _boxruled_ ,
_ruled_ and _algoruled_.

$\backslash$RestyleAlgo{style}

sets the style of the following algorithms to that given by this macro (plain,
boxed, ruled, algoruled) unlike those indicated in the options of the package
(see options of the package).

$\backslash$SetAlgoVlined

prints a vertical line followed by a little horizontal line between the start
and the end of each block. Looks like that :

$\backslash$SetNoline

Doesn’t print vertical lines (by default). The block is marked with keywords
such as _begin_ , _end_.

$\backslash$SetAlgoLined

prints vertical lines between bloc start-end keywords as _begin_ , _end_.

$\backslash$SetAlgoLongEnd

acts like longend option.

$\backslash$SetAlgoShortEnd

acts like shortend option.

$\backslash$SetAlgoNoEnd

acts like noend option.

$\backslash$SetInd{before rule space}{after rule space}

sets the size of the space before the vertical rule and after. In
$\backslash$NoLine mode the indentation space is the sum of these two values,
by default 0.5em and 1em

$\backslash$SetAlgoHangIndent{length}

sets the value of indent length used by hangindent to indent subsequent lines
after the first on a long statement.

$\backslash$Setvlineskip{length}

sets the value of the vertical space after the little horizontal line which
closes a block in vlined mode.

$\backslash$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 . You can
change this value with this macro. The four possibilities are:

  * •

$\backslash$SetAlgoSkip{}] for no extra vertical skip

  * •

$\backslash$SetAlgoSkip{smallskip}] to act as the default behaviour

  * •

$\backslash$SetAlgoSkip{medskip}] to have a bigger skip

  * •

$\backslash$SetAlgoSkip{bigskip}] to have the bigger skip

Note that you can apply the skip you want by defining a macro doing it and
passing its name (without $\backslash$) to $\backslash$SetAlgoSkip

$\backslash$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 $\backslash$SetAlgoInsideSkip{skip command}, for
example $\backslash$SetAlgoInsideSkip{smallskip}, like for
$\backslash$SetAlgoSkip{skip command}.

$\backslash$algomargin

this is the value of the margin of all algorithms. You can change it by
setting: $\backslash$setlength{$\backslash$algomargin}{2em} for example. The
default value is the sum of the two dimensions $\backslash$leftskip and
$\backslash$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 _inside_ an algorithm environment, it will not affect
the current algorithm.

$\backslash$IncMargin{length}

increases the size of the $\backslash$algomargin by the length given in
argument.

$\backslash$DecMargin{length}

decreases the size of the $\backslash$algomargin by the length given in
argument.

$\backslash$DecMargin{length}

decreases the size of the $\backslash$algomargin by the length given in
argument.

$\backslash$SetAlgoNlRelativeSize{number}

sets the relative size of line number (see section 9.3) for more details on
this command.

$\backslash$SetAlgoCaptionLayout{style}

sets the global style of caption (see section 9.2 for more details).

$\backslash$DisplayBlockMarkers

acts like displayblockmarkers option: each block will be started by a _begin_
keyword and be ended by an _end_ keywords. This is tricky to use but allows to
customize syntax to match almost every language (see section 4 for examples
showing how to use it). $\backslash$SetAlgoBlockMarkers{begin keyword}{end
keyword} defines _begin_ and _end_ keywords that will be used by
`\DisplayBlockMarkers`. Default keywords are begin and end. but for example
you can set `\DisplayBlockMarkers{\{}{\}}` to match c-style syntax.

$\backslash$DisplayGroupMarkers

acts like displaygroupmarkers option: each block of single line command will
be started by a _begin_ keyword and be ended by an _end_ keywords.
$\backslash$SetAlgoBlockMarkers{begin keyword}{end keyword} defines _begin_
and _end_ keywords that will be used by `\DisplayGroupMarkers`. Note that
begin-end group markers are necessarly the same as `\DisplayBlockMarkers`.

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 $\backslash$setlength commmand:

interspacetitleruled

(2pt by defaut) which controls the vertical space between rules and title in
ruled and algoruled algorithms.

interspacetitleboxruled

(2$\backslash$lineskip by default) which controls the vertical space between
rules and title in boxruled algorithms.

####  9.7 comments

There are two ways to do comments in algorithm :

  1. 1.

by using a comment macro defined by $\backslash$SetKwComment{command}{right
mark}{left mark} (see below) like $\backslash$tcc;

  2. 2.

by using side comment, it means comment put in between ( ) after control
command like if-then-else, for, … macros.

At section 10.3, you can see how $\backslash$tcc is defined and at section
10.4 you can look at some examples how to use it with if then else like
commands and finally you can look at section 11.4 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 linesnumbered option. You
have to set commentsnumbered to number them also.

The following macro control how comment are typeseted.

$\backslash$SetSideCommentLeft

right justified side comments (side comments are flushed to the right),
equivalent to scleft option.

$\backslash$SetSideCommentRight

left justified side comments (side comments are put right after the code line)
, equivalent to scright option.

$\backslash$SetFillComment

end mark of comment is flushed to the right so comments fill all the width of
text, equivalent to fillcomment option.

$\backslash$SetNoFillComment

end mark of comment is put right after the comment, equivalent to
nofillcomment option.

###  10 The predefined language keywords

Here are the English keywords predefined in the package. There are other
language predefined macros provided, such as French keywords, see section 12
for a list of other language keywords. All these keywords are defined using
macros provided by the package and described in section 11.

####  10.1 Input, output macros…

  * •

$\backslash$KwIn{input}

  * •

$\backslash$KwOut{output}

  * •

$\backslash$KwData{input}

  * •

$\backslash$KwResult{output}

####  10.2 basic keywords and blocks

  1. 1.

One simple common keyword:

     * •

$\backslash$KwTo

  2. 2.

One keyword requiring an argument:

     * •

$\backslash$KwRet{[value]}

     * •

$\backslash$Return{[value]}

  3. 3.

A block:

     * •

$\backslash$Begin{block inside}

     * •

$\backslash$Begin(begin comment){block inside}

####  10.3 comments

  * •

$\backslash$tcc{line(s) of comment}: comment “ la” C

  * •

$\backslash$tcc*{right justified side comment}: comment “ la” C

  * •

$\backslash$tcc*[r]{right justified side comment, ends the line (default)}:
comment “ la” C

  * •

$\backslash$tcc*[l]{left justified side comment, ends the line}: comment “ la”
C

  * •

$\backslash$tcc*[h]{left justified comment, without end line; useful with ”if-
then-else” macros for example}: comment “ la” C

  * •

$\backslash$tcc*[f]{right justified comment, without end line; useful with
”if-then-else” macros for example}: comment “ la” C

  * •

$\backslash$tcp{line(s) of comment}: comment “ la” C++

  * •

$\backslash$tcp*{right justified side comment}: comment “ la” C++

  * •

$\backslash$tcp*[r]{right justified side comment, ends the line (default)}:
comment “ la” C++

  * •

$\backslash$tcp*[l]{left justified side comment, ends the line}: comment “ la”
C++

  * •

$\backslash$tcp*[h]{left justified comment, without end line; useful with ”if-
then-else” macros for example}: comment “ la” C++

  * •

$\backslash$tcp*[f]{right justified comment, without end line; useful with
”if-then-else” macros for example}: comment “ la” C++

You can see some examples of this macros with if then else at the end of
section 11.5

####  10.4 if-then-else macros

  * •

$\backslash$If{condition}{then block}

  * •

$\backslash$If(then comment){condition}{then block}

  * •

$\backslash$uIf{condition}{then block without end}

  * •

$\backslash$uIf(then comment){condition}{then block without end}

  * •

$\backslash$lIf{condition}{then’s line text}

  * •

$\backslash$lIf(if comment){condition}{then’s line text}

  * •

$\backslash$ElseIf{elseif block}

  * •

$\backslash$ElseIf(elseif comment){elseif block}

  * •

$\backslash$uElseIf{elseif block without end}

  * •

$\backslash$uElseIf(elseif comment){elseif block without end}

  * •

$\backslash$lElseIf{elseif’s line text}

  * •

$\backslash$lElseIf(elseif comment){elseif’s line text}

  * •

$\backslash$Else{else block}

  * •

$\backslash$Else(else comment){else block}

  * •

$\backslash$uElse{else block without end}

  * •

$\backslash$uElse(else comment){else block without end}

  * •

$\backslash$lElse{else’s line text}

  * •

$\backslash$lElse(else comment){else’s line text}

  * •

$\backslash$eIf{condition}{then block}{else block}

  * •

$\backslash$eIf(then comment){condition}{then block}(else comment){else block}

  * •

$\backslash$eIf(then comment){condition}{then block}{else block}

  * •

$\backslash$eIf{condition}{then block}(else comment){else block}

  * •

$\backslash$leIf{condition}{then block}{else block}

  * •

$\backslash$leIf(comment){condition}{then block}{else block}

####  10.5 multiple condition selection:

  * •

$\backslash$Switch(switch comment){condition}{Switch block}

  * •

$\backslash$Switch{condition}{Switch block}

  * •

$\backslash$Case{a case}{case block}

  * •

$\backslash$Case(case comment){a case}{case block}

  * •

$\backslash$uCase{a case}{case block without end}

  * •

$\backslash$uCase(case comment){a case}{case block without end}

  * •

$\backslash$lCase{a case}{case’s line}

  * •

$\backslash$lCase(case comment){a case}{case’s line}

  * •

$\backslash$Other{otherwise block}

  * •

$\backslash$Other(other comment){otherwise block}

  * •

$\backslash$lOther{otherwise’s line}

  * •

$\backslash$lOther(other comment){otherwise’s line}

####  10.6 loops with ”end condition” test at the beginning

  * •

$\backslash$For{condition}{text loop}

  * •

$\backslash$For(for comment){condition}{text loop}

  * •

$\backslash$lFor{condition}{line text loop}

  * •

$\backslash$lFor(for comment){condition}{line text loop}

  * •

$\backslash$While{condition}{text loop}

  * •

$\backslash$While(while comment){condition}{text loop}

  * •

$\backslash$lWhile{condition}{line text loop}

  * •

$\backslash$lWhile(while comment){condition}{line text loop}

  * •

$\backslash$ForEach{condition}{text loop}

  * •

$\backslash$ForEach(foreach comment){condition}{text loop}

  * •

$\backslash$lForEach{condition}{line text loop}

  * •

$\backslash$lForEach(foreach comment){condition}{line text loop}

  * •

$\backslash$ForAll{condition}{text loop}

  * •

$\backslash$ForAll(forall comment){condition}{text loop}

  * •

$\backslash$lForAll{condition}{line text loop}

  * •

$\backslash$lForAll(forall comment){condition}{line text loop}

####  10.7 loops with ”end condition” test at the end

  * •

$\backslash$Repeat{end condition}{text loop}

  * •

$\backslash$Repeat(repeat comment){end condition}{text loop}(until comment)

  * •

$\backslash$Repeat(repeat comment){end condition}{text loop}

  * •

$\backslash$Repeat{end condition}{text loop}(until comment)

  * •

$\backslash$lRepeat{end condition}{line text loop}

  * •

$\backslash$lRepeat(repeat comment){end condition}{line text loop}

####  10.8 how default keywords are obtained

  1. 1.

$\backslash$SetKwInput{KwData}{Data}

$\backslash$SetKwInput{KwResult}{Result}

$\backslash$SetKwInput{KwIn}{Input}

$\backslash$SetKwInput{KwOut}{Output}

  2. 2.

$\backslash$SetKw{KwTo}{to}

  3. 3.

$\backslash$SetKw{KwRet}{return}

$\backslash$SetKw{Return}{return}

  4. 4.

$\backslash$SetKwBlock{Begin}{begin}{end}

  5. 5.

$\backslash$SetKwComment{tcc}{/*}{*/}

$\backslash$SetKwComment{tcp}{//}{}

  6. 6.

$\backslash$SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}

  7. 7.

$\backslash$SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}endsw

  8. 8.

$\backslash$SetKwFor{For}{for}{do}{endfor}

$\backslash$SetKwFor{While}{while}{do}{endw}

$\backslash$SetKwFor{ForEach}{foreach}{do}{endfch}

$\backslash$SetKwAll{ForEach}{forall}{do}{endfall}

  9. 9.

$\backslash$SetKwRepeat{Repeat}{repeat}{until}

###  11 To define your own language keywords

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.

####  11.1 to define Input, output macros…

$\backslash$SetKwInput{Kw}{input}

defines the macro $\backslash$Kw{arg} which prints _input_ followed by ‘:’ in
key word typography, and behind the argument _arg_. Typically used to define
macros such as $\backslash$Input{data} or $\backslash$Output{result}. Note
that _arg_ will be shifted so that all the text is vertically aligned and to
the right of the ‘:’.

$\backslash$SetKwInOut{Kw}{input}

works as $\backslash$SetKwInput{Kw}{input}. But the position of the ‘:’ is
fixed and set by the longest keyword defined by this macro.

$\backslash$ResetInOut{input} resets the position of the ‘:’ for all macros
defined previously by $\backslash$SetKwInOut{Kw}{input}. The new position is
fixed depending on the size of the text _input_ given in argument.

####  11.2 to define basic keywords or blocks

$\backslash$SetKw{Kw}{thetext}

defines the macro $\backslash$Kw which defines a keyword _thetext_ and prints
it in keyword typography. It can take one argument: $\backslash$Kw{arg}. If
so, _arg_ is printed in argument typography. For example `\Kw{thetext}` could
give: Kw _thetext_

$\backslash$SetKwHangingKw{Kw}{thetext}

defines a hanging keyword that should act like a combination of
$\backslash$SetKwInput and $\backslash$SetKw. In comparison with
$\backslash$SetKwInput, it doesn’t print ’:’ at end of keyword and line is
numbering if linesnumbered is set.
For example `\SetKwHangingKw{HData}{Data$\rightarrow$}` could gives:

1 Data$\rightarrow$ a list of data and a long description of this data to be
sure that text requires several lines to be printed

$\backslash$SetKwData{Kw}{thetext}

defines the macro $\backslash$Kw{w}hich defines a data text. Prints _thetext_
in data typography. Note that this macros can takes one argument as function
macros.

$\backslash$SetKwArray{Kw}{array}

which defines an array keywords Kw called _array_ and printed in DataSty style
when call with $\backslash$Kw. It can be used with one argument which denotes
the element index: $\backslash$Kw{n} prints array[_n_] with _array_ in
$\backslash$DataSty and _n_ in $\backslash$ArgSty.

$\backslash$SetKwBlock{Begin}{begin}{end}

defines a macro $\backslash$Begin{txt} which denotes a block. The text is
surrounded by the words _begin_ and _end_ in keyword typography and shifted to
the right (indented). In $\backslash$Vline _or_ $\backslash$Line _mode_ a
straight vertical line is added.
`\Begin(side text){text}` gives also text in a block surrounded by _begin_ and
_end_ , but _side text_ if put after the _begin_ keyword. Combined with
$\backslash$tcc*[f] macro, it allows you to put comments on the same line as
_begin_.

You can also use alternativ $\backslash$uBegin{txt} which acts as
$\backslash$Begin{txt} but without _end_. Useful for example as a part
separator that doesn’t necessary need an _end_ keyword.

$\backslash$SetKwProg{Prog}{Title}{ is}{end}

Env is a block with ’Title’ (in CapSty style) at the beginning followed by
args in ProgSty followed by ’is’ then ’text’ 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:

    \SetAlgoLined
    \SetKwProg{Fn}{Function}{ is}{end}
    \Fn{afunc(i: int) : int}{return 0\;}

    \SetKwProg{Def}{def}{:}{}
    \Def{afunc(i: int)}{return 0\;}

$\Longrightarrow$ 1 Function  _afunc(i: int) : int_ is 2 return 0  3 end  4 5
def  _afunc(i: int)_ : 6 return 0  7

####  11.3 to define keywords as function

If you want describe the function by an algorithm, use instead _function_ or
_procedure_ environment.

$\backslash$SetKwFunction{KwFn}{Fn}

defines a macro $\backslash$KwFn{arg} which prints _Fn_ in FuncSty typography
and its argument _arg_ in FuncArgSty typography, surrounded by a pair of
parentheses.

$\backslash$SetKwFunction{Dothat}{Do that} defines the macro
$\backslash$DoThat{this}, which is equivalent to $\backslash$FuncSty{Do
that(}$\backslash$ArgSty{this}$\backslash$FuncSty{)} which gives: Do
that(_this_).

Note that you can also use it without arguments, it will be printed without
‘()’, example: $\backslash$SetKwFunction{Fn}{TheFunction} use as
$\backslash$Fn gives 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 $\backslash$DoThat{toto} (for a function
defined by $\backslash$SetKwFunction{Dothat}{Do that}), you will obtain Do
That(_toto_).

####  11.4 to define comments

$\backslash$SetKwComment{Comment}{start}{end}

defines a macro $\backslash$Comment{text comment} which writes _text comment_
between _start_ and _end_. Note that _start_ or _end_ can be empty.
It defines also $\backslash$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:
`\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.
`\Comment*[l]{side comment text}` same thing but side comment text is left
justified.
`\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 `\;`
to end the line).
`\Comment*[f]{side comment text}` same as the previous one but with side
comment text right justified.

####  11.5 to define if-then-else macros

$\backslash$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:

  * •

$\backslash$If{cond}{Then’s text}
Then’s text is writen in a block (below then and on several lines) and
terminating by the endif given in the last argument.

  * •

$\backslash$If(comment){cond}{Then’s text}
as previous but put _comment_ after then keyword. Usually use with comment
macro like $\backslash$tcc*[f]{comment} or $\backslash$tcp*[f]{comment}

  * •

$\backslash$If{cond}{Then’s text(comment)}
as previous but put _comment_ after end keyword. Usually use with comment
macro like $\backslash$tcc*[f]{comment} or $\backslash$tcp*[f]{comment}

  * •

$\backslash$If(comment1){cond}{Then’s text(comment2)}
as previous but put _comment1_ after then keyword and _comment2_ after end.
Usually use with comment macro like $\backslash$tcc*[f]{comment} or
$\backslash$tcp*[f]{comment}

  * •

$\backslash$ElseIf{ElseIf’s text}
ElseIf’s text is writen in a block and terminating by the endif.

  * •

$\backslash$ElseIf(comment){ElseIf’s text}
the same with comment.

  * •

$\backslash$ElseIf{ElseIf’s text(comment)}
the same with comment.

  * •

$\backslash$ElseIf(comment){ElseIf’s text(comment)}
the same with comment.

  * •

$\backslash$Else{Else’s text}
Else’s text is writen in a block and terminating by the endif.

  * •

$\backslash$Else(comment){Else’s text}
the same with comment.

  * •

$\backslash$Else{(}comment)Else’s text(comment)
the same with comment.

  * •

$\backslash$lIf{cond}{Then’s text}
Then’s text is written on the same line as then. No endif is printed. Do not
put $\backslash$; after _Then’s text_ neither after $\backslash$lIf.

  * •

$\backslash$lIf(comment){cond}{Then’s text}
the same with comment.

  * •

$\backslash$lIf*{cond}{Then’s text}
Then’s text is written on the same line as then. No endif and no end of line
are printed. Do not put $\backslash$; after _Then’s text_ neither after
$\backslash$lIf.

  * •

$\backslash$lElseIf{ElseIf’s text}
ElseIf’s text is written on the same line as else if. No endif is printed.

  * •

$\backslash$lElseIf(comment){ElseIf’s text}
the same with comment.

  * •

$\backslash$lElseIf*{ElseIf’s text}
ElseIf’s text is written on the same line as else if. No endif and no end of
line are printed.

  * •

$\backslash$lElse{Else’s text}
Else’s text is written on the same line as else. No endif is printed.

  * •

$\backslash$lElse(comment){Else’s text}
the same with comment.

  * •

$\backslash$lElse*{Else’s text}
Else’s text is written on the same line as else. No endif is printed and no
end of line are printed.

  * •

$\backslash$uIf{cond}{Then’s text} (for uncomplete if)
defines a If block unterminated like in a $\backslash$eIf block, i.e. don’t
print the endif or don’t put the little horizontal line in _Vline_ mode (see
examples below).

  * •

$\backslash$uIf(comment){cond}{Then’s text}
the same with comment.

  * •

$\backslash$uElseIf{ElseIf’s text} (for uncomplete elseif)
Same explanation as for $\backslash$uIf but with else if.

  * •

$\backslash$uElseIf(comment){ElseIf’s text}
the same with comment.

  * •

$\backslash$uElse{Else’s text} (for uncomplete else)
Same explanation as for $\backslash$uElseIf but with else.

  * •

$\backslash$uElse{Else’s text}
the same with comment.

  * •

$\backslash$eIf{cond}{Then’s text}{Else’s text}
equivalent to the use of $\backslash$uIf followed by $\backslash$Else.

The macros which begin with a ‘l’ (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 $\backslash$; at the end of “l
macros”.

The macros which begin with a ‘u’ (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 _then_ and _else_ are automatically printed. _cond_ is always
printed in argument typography just behind the keyword if.

All this macros can be combined with () and $\backslash$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 `\SetKwIF{If}{ElseIf}{Else}{if}{then}{else
if}{else}{endif}` the default definition given in the package:

    \SetAlgoVlined
    \eIf{cond1}{
      a line\;
      a line\;
    }{
      another line\;
      another line\;
    }

$\Longrightarrow$ 1if  _cond1_ then 2 a line  3 a line  4 5else 6 another line
7 another line  8

—

    \SetAlgoNoLine
    \If{cond2}{
      second if\;
      second if\;
    }

$\Longrightarrow$ 1if  _cond2_ then 2 second if  3 second if  4 5 end if

—

    \lIf{cond4}{ok} \lElse{wrong}
    \leIf{cond4}{ok}{wrong}

$\Longrightarrow$ 1if  _cond4_ then ok  2 else wrong  3 if  _cond4_ then ok
else wrong

—

    \SetAlgoVlined
    \lIf{cond5}{cond5 true}
    \uElseIf{cond51}{
      cond 5 false\;
      but cond51 true\;
    }
    \ElseIf{}{
      all is wrong\;
      \Return result52\;
    }

$\Longrightarrow$ 1if  _cond5_ then cond5 true  2 else if  _cond51_ then 3
cond 5 false  4 but cond51 true  5 6 else if  __ then 7 all is wrong  8 return
result52  9

—

    \SetAlgoLined
    \uIf{cond6}{
      cond6 is ok\;
      always ok\;
    }
    \uElseIf{cond62}{
      choose result62\;
      \Return result62\;
    }
    \Else{
      all is wrong\;
      do something else\;
    }

$\Longrightarrow$ 1if  _cond6_ then 2 cond6 is ok  3 always ok  4 5 else if
_cond62_ then 6 choose result62  7 return result62  8 9 else 10 all is wrong
11 do something else  12 13 end if

—

    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}

$\Longrightarrow$ 1Let’s have a look at what we can do with if-then-else and
side comments  2 if  _if-then-else test_ then 3 no comment here  4 neither in
then  5 6else 7 nor in else  8 9 end if  10if  _test_ then /* then comment */
11 then with a comment  12 13else /* comment in else */ 14 here we are in else
15 16 end if  17if  _test_ then /* then comment */ 18 again a comment in then
19 20else 21 but not in else  22 23 end if  24if  _if-then-else test_ then 25
this time, no comment in then  26 27else /* else comment */ 28 but one comment
in else  29 30 end if  31Let’s try with other if possibilities  32 if  _test_
then text  33 /* lif comment */ if  _test_ then /* uif comment */ 34 then text
35 36 else if  _test_ then /* comment */ 37 elseif text  38 39 else if  _test_
then text  40 /* comment */ else text  /* comment */

####  11.6 to define multiple condition selection:

$\backslash$SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}endsw

defines several macros to give a complete Switch-do-case-otherwise
environment:

  * •

$\backslash$Switch{iden}{switch’s block}

  * •

$\backslash$Switch(comment){iden}{switch’s block}

  * •

$\backslash$Switch{iden}{switch’s block(comment)}

  * •

$\backslash$Switch(comment){iden}{switch’s block(comment)}

  * •

$\backslash$Case{cond}{Case’s block}

  * •

$\backslash$Case(comment){cond}{Case’s block}

  * •

$\backslash$Case{cond}{Case’s block(comment)}

  * •

$\backslash$Case(comment){cond}{Case’s block(comment)}

  * •

$\backslash$uCase{cond}{Case’s block}

  * •

$\backslash$uCase(comment){cond}{Case’s block}

  * •

$\backslash$lCase{cond}{Case’s text}

  * •

$\backslash$lCase*{cond}{Case’s text}

  * •

$\backslash$lCase(comment){cond}{Case’s text}

  * •

$\backslash$Other{Otherwise’s block}

  * •

$\backslash$Other(comment){Otherwise’s block}

  * •

$\backslash$Other{Otherwise’s block(comment)}

  * •

$\backslash$Other(comment){Otherwise’s block(comment)}

  * •

$\backslash$lOther{Otherwise’s text}

  * •

$\backslash$lOther*{Otherwise’s text}

  * •

$\backslash$lOther(comment){Otherwise’s text}

  * •

$\backslash$uOther{Otherwise’s text}

  * •

$\backslash$uOther{(}comment)Otherwise’s text

The keywords _do_ and _endsw_ are automatically printed. _iden_ and _cond_ are
always printed in argument typography just behind the keywords Switch, Case
and Otherwise. Here is an example with the default keywords:

    \Switch{the value of T}{
      \uCase{a value}{
        do this\;
        do that\;
      }
      \lCase{another value}{one line}
      \Case{last value}{
        do this\;
        break\;
      }
      \Other{
        for the other values\;
        do that\;
      }
    }

$\Longrightarrow$ 1switch  _the value of T_ do 2 case  _a value_ do 3 do this
4 do that  5 6 case  _another value_ do one line  7 case  _last value_ do 8 do
this  9 break  10 11 end case  12 otherwise do 13 for the other values  14 do
that  15 16 end case  17 18 end switch

As for If-then-elseif-else-endif macro, you can use () to put comments after
main keywords.

####  11.7 to define loops with ”end condition” test at the beginning

$\backslash$SetKwFor{For}{for}{do}{endfor}

defines a loop environment with stop-test done at the beginning of the loop.

  * •

$\backslash$For{loop’s condition}{For’s text}

  * •

$\backslash$For(comment){loop’s condition}{For’s text}

  * •

$\backslash$For{loop’s condition}{For’s text(comment)}

  * •

$\backslash$For(comment){loop’s condition}{For’s text(comment)}

  * •

$\backslash$lFor{loop’s condition}{For’s text}

  * •

$\backslash$lFor(comment){loop’s condition}{For’s text}

  * •

$\backslash$lFor*{loop’s condition}{For’s text}

The keywords _do_ and _endfor_ are automatically printed. The loop condition
is printed in argument typography. For example:

    \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$\;
    }

$\Longrightarrow$ 1forall  _elements of $S_{1}$_ do 2 remove an element e from
$S_{1}$ 3 put e in the set $S_{2}$ 4 5 end forall  6for  _i=1 _to_ max_ do
mark i  7 8 foreach  _$e$ in the set_ do 9 put $e$ in ${\cal E}$ 10 mark $e$
11 12 end foreach

As for If-then-elseif-else-endif macro, you can use () to put comments after
main keywords.

####  11.8 to define loops with ”end condition” test at the end

$\backslash$SetKwRepeat{Repeat}{repeat}{until}

defines a repeat-until environment (loop with stop-test at the end of the
loop):

  * •

$\backslash$Repeat{end loop condition}{the loop}

  * •

$\backslash$Repeat(comment after repeat){end loop condition}{the loop}

  * •

$\backslash$Repeat{end loop condition}{the loop(comment after until)}

  * •

$\backslash$Repeat(comment after repeat){end loop condition}{the loop(comment
after until)}

  * •

$\backslash$lRepeat{end loop condition}{only one line}

  * •

$\backslash$lRepeat*{end loop condition}{only one line}

  * •

$\backslash$lRepeat(comment){end loop condition}{only one line}

It prints the loop condition behind the _until_ after the text of the loop.For
example:

    \Repeat{this stop condition}{
      the text of the loop\;
      another line\;
      always in the loop\;
      }
    \lRepeat{stop}{a one line loop}

$\Longrightarrow$ 1repeat 2 the text of the loop  3 another line  4 always in
the loop  5 6until  _this stop condition_ 7repeat a one line loop until
_stop_

As for If-then-elseif-else-endif macro, you can use () to put comments after
main keywords.

###  12 Other language predefined keywords

####  12.1 French keywords

Hey, I am a frenchy , so I have defined the same as in section 10 but in
french.

  1. 1.

$\backslash$Donnees{données}

$\backslash$Res{résultats}

$\backslash$Entree{entrées}

$\backslash$Sortie{sorties}

  2. 2.

$\backslash$KwA

$\backslash$Retour{[valeur]}

  3. 3.

$\backslash$Deb{intérieur du bloc}

  4. 4.

$\backslash$eSi{condition}{bloc du alors}{bloc du sinon}

$\backslash$Si{condition}{bloc du alors}

$\backslash$uSi{condition}{bloc du alors sans fin}

$\backslash$lSi{condition}{ligne du alors}

$\backslash$SinonSi{condition}{bloc du sinonsi}

$\backslash$uSinonSi{condition}{bloc du sinonsi sans fin}

$\backslash$lSinonSi{condition}{ligne du sinonsi sans fin}

$\backslash$Sinon{bloc du sinon}

$\backslash$uSinon{bloc du sinon sans fin}

$\backslash$lSinon{ligne du sinon}

  5. 5.

$\backslash$Suivant{condition}{bloc du Suivant-cas-alors} $\backslash$uCas{cas
où}{bloc de ce cas sans fin}

$\backslash$Cas{cas où}{bloc de ce cas}

$\backslash$lCas{cas où}{ligne de ce cas}

$\backslash$Autre{bloc de l’alternative}

$\backslash$lAutre{ligne de l’alternative}

  6. 6.

$\backslash$Pour{condition}{bloc de la boucle}

$\backslash$lPour{condition}{ligne de la boucle}

  7. 7.

$\backslash$Tq{condition}{bloc de la boucle}

$\backslash$lTq{condition}{ligne de la boucle}

  8. 8.

$\backslash$PourCh{condition}{bloc de la boucle}

$\backslash$lPourCh{condition}{ligne de la boucle}

  9. 9.

$\backslash$PourTous{condition}{bloc de la boucle}

$\backslash$lPourTous{condition}{ligne de la boucle}

  10. 10.

$\backslash$Repeter{condition d’arrêt}{bloc de la boucle}

$\backslash$lRepeter{condition d’arrêt}{ligne de la boucle}

Here we describe how they are obtained:

  1. 1.

$\backslash$SetKwInput{Donnes}{Données}

$\backslash$SetKwInput{Res}{Résultat}

$\backslash$SetKwInput{Entree}{Entrées}

$\backslash$SetKwInput{Sortie}{Sorties}

  2. 2.

$\backslash$SetKw{KwA}{à}

$\backslash$SetKw{Retour}{retourner}

  3. 3.

$\backslash$SetKwBlock{Deb}{début}{fin}

  4. 4.

$\backslash$SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{alors}{finsi}

  5. 5.

$\backslash$SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas où}{autres
cas}{fin cas}fin d’alternative

  6. 6.

$\backslash$SetKwFor{Pour}{pour}{faire}{finpour}

  7. 7.

$\backslash$SetKwFor{Tq}{tant que}{faire}{fintq}

  8. 8.

$\backslash$SetKwFor{PourCh}{pour chaque}{faire}{finprch}

  9. 9.

$\backslash$SetKwFor{PourTous}{pour tous}{faire}{finprts}

  10. 10.

$\backslash$SetKwRepeat{Repeter}{répéter}{jusqu’à}

####  12.2 German keywords

  * •

$\backslash$Ein{Eingabe}

$\backslash$Aus{Ausgabe}

$\backslash$Daten{Daten}

$\backslash$Ergebnis{Ergebnis}

  * •

$\backslash$Bis{bis}

$\backslash$KwZurueck{zurück}

$\backslash$Zurueck{zurück}

  * •

$\backslash$Beginn{Beginn}

  * •

$\backslash$Wiederh{stop condition}{loop}

$\backslash$lWiederh{stop condition}{line loop}

  * •

$\backslash$eWenn{condition}{then text}{else text}

$\backslash$Wenn{condition}{then text}

$\backslash$uWenn{condition}{then text without end}

$\backslash$lWenn{condition}{then line}

$\backslash$SonstWenn{condition}{elseif text}

$\backslash$uSonstWenn{condition}{elseif text without end}

$\backslash$lSonstWenn{condition}{elseif line}

$\backslash$Sonst{else text}

$\backslash$uSonst{else text without end}

$\backslash$lSonst{else line}

  * •

$\backslash$Unterscheide{conditions}switch-case-default
text$\backslash$Fall{case of}{text}

$\backslash$uFall{case of}{text}

$\backslash$lFall{case of}{line text}

$\backslash$Anderes{default text}

$\backslash$lAnderes{default line}

  * •

$\backslash$Fuer{condition}{loop}

$\backslash$lFuer{condition}{line loop}

  * •

$\backslash$FuerPar{condition}{loop}

$\backslash$lFuerPar{condition}{line}

  * •

$\backslash$FuerJedes{condition}{loop}

$\backslash$lFuerJedes{condition}{line}

  * •

$\backslash$FuerAlle{condition}{loop}

$\backslash$lFuerAlle{condition}{line}Ende

  * •

$\backslash$Solange{condition}{loop}Ende

$\backslash$lSolange{condition}{line}

Here we describe how they are obtained:

  * •

$\backslash$SetKwInput{Ein}{Eingabe}

$\backslash$SetKwInput{Aus}{Ausgabe}

$\backslash$SetKwInput{Daten}{Daten}

$\backslash$SetKwInput{Ergebnis}{Ergebnis}

  * •

$\backslash$SetKw{Bis}{bis}

$\backslash$SetKw{KwZurueck}{zurück}

$\backslash$SetKw{Zurueck}{zurück}

  * •

$\backslash$SetKwBlock{Beginn}{Beginn}{Ende}

  * •

$\backslash$SetKwRepeat{Wiederh}{wiederhole}{bis}

  * •

$\backslash$SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst
wenn}{sonst}{Ende}

  * •

$\backslash$SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende
Fall}Ende.

  * •

$\backslash$SetKwFor{Fuer}{für}{tue}{Ende}

  * •

$\backslash$SetKwFor{FuerPar}{für}{tue gleichzeitig}{Ende}

  * •

$\backslash$SetKwFor{FuerJedes}{für jedes}{tue}{Ende}

  * •

$\backslash$SetKwFor{FuerAlle}{für alle}{tue}{Ende}

  * •

$\backslash$SetKwFor{Solange}{solange}{tue}{Ende}

####  12.3 Spanish keywords

  1. 1.

$\backslash$Datos{Datos}

$\backslash$Resultado{Resultado}

$\backslash$Entrada{Entrada}

$\backslash$Salida{Salida}

  2. 2.

$\backslash$KwA

$\backslash$Devolver{[value]}

  3. 3.

$\backslash$Inicio{inside block}

  4. 4.

$\backslash$eSSi{condition}{then block}{else block}

$\backslash$SSi{condition}{then block}

$\backslash$uSSi{condition}{then block without end}

$\backslash$lSSi{condition}{then line}

$\backslash$EnOtroCasoSi{condition}{elseif block}

$\backslash$uEnOtroCasoSi{condition}{elseif block}

$\backslash$lEnOtroCasoSi{condition}{elseif line without end}

$\backslash$EnOtroCaso{else block}

$\backslash$uEnOtroCaso{else block without end}

$\backslash$lEnOtroCaso{else line}

  5. 5.

$\backslash$Seleccionar{condition}{Seleccionar caso block}
$\backslash$uSeleccionar{seleccionar}{caso block without end}

$\backslash$Caso{seleccionar}{caso block}

$\backslash$lCaso{seleccionar}{caso line}

$\backslash$Otro{sinó block}

$\backslash$lOtro{sinó line}

  6. 6.

$\backslash$Para{condition}{loop block}

$\backslash$lPara{condition}{loop line}

  7. 7.

$\backslash$ParaPara{condition}{loop block}

$\backslash$lParaPara{condition}{loop line}

  8. 8.

$\backslash$Mientras{condition}{loop block}

$\backslash$lMientras{condition}{loop line}

  9. 9.

$\backslash$ParaCada{condition}{loop block}

$\backslash$lParaCada{condition}{loop line}

  10. 10.

$\backslash$ParaTodo{condition}{loop block}

$\backslash$lParaTodo{condition}{loop line}

  11. 11.

$\backslash$Repetir{stop condition}{loop block}

$\backslash$lRepetir{stop condition}{line loop}

Here we describe how they are obtained:

  1. 1.

$\backslash$SetKwInput{Datos}{Datos}

$\backslash$SetKwInput{Resultado}{Resultado}

$\backslash$SetKwInput{Entrada}{Entrada}

$\backslash$SetKwInput{Salida}{Salida}

  2. 2.

$\backslash$SetKw{KwA}{a}

$\backslash$SetKw{Devolver}{devolver}

  3. 3.

$\backslash$SetKwBlock{Inicio}{inicio}{fin}

  4. 4.

$\backslash$SetKwIF{SSi}{EnOtroCasoSi}{EnOtroCaso}{si}{entonces}{sinó,
si}{sinó}{fin si}

  5. 5.

$\backslash$SetKwSwitch{Seleccionar}{Caso}{Otro}{seleccionar}{hacer}{caso}{sinó}{fin
caso}fin seleccionar

  6. 6.

$\backslash$SetKwFor{Para}{para}{hacer}{fin para}

  7. 7.

$\backslash$SetKwFor{ParaPara}{par}{hacer en paralelo}{fin para}

  8. 8.

$\backslash$SetKwFor{Mientras}{mientras}{hacer}{fin mientras}

  9. 9.

$\backslash$SetKwFor{ParaCada}{ParaCada}{hacer}{fin para cada}

  10. 10.

$\backslash$SetKwFor{ParaTodo}{para todo}{hacer}{fin para todo}

  11. 11.

$\backslash$SetKwRepeat{Repetir}{repetir}{hasta que}

####  12.4 Italian keywords

  * •

$\backslash$KwIng{Ingresso}

$\backslash$KwUsc{Uscita}

$\backslash$KwDati{Dati}

$\backslash$KwRisult{Risultato}

  * •

$\backslash$KwA

$\backslash$KwRitorna{ritorna}

$\backslash$Ritorna{ritorna}

  * •

$\backslash$Inizio{inside block}

  * •

$\backslash$Ripeti{stop condition}{text loop}

$\backslash$lRipeti{stop condition}{line of the loop}

  * •

$\backslash$eSea{condition}{then block}{else block}

$\backslash${condition}{then block}

$\backslash$uSea{condition}{then block without end}

$\backslash$lSea{condition}{then’s line text}

$\backslash$AltSe{else block}

$\backslash$uAltSe{else block without else}

$\backslash$lAltSe{else’s line text}

$\backslash$Altrimenti{condition}{elseif block}

$\backslash$uAltrimenti{condition}{elseif block without end}

$\backslash$lAltrimenti{condition}{elseif’s line text}

  * •

$\backslash$Switch{condition}{Switch block}

$\backslash$Case{a case}{case block}

$\backslash$uCase{a case}{case block without end}

$\backslash$lCase{a case}{case’s line}

$\backslash$Other{otherwise block}

$\backslash$lOther{otherwise’s line}

  * •

$\backslash$Per{condition}{text loop}

$\backslash$lPer{condition}{line text loop}

  * •

$\backslash$PerPar{condition}{text loop}

$\backslash$lPerPar{condition}{line text loop}

  * •

$\backslash$PerCiascun{condition}{text loop}

$\backslash$lPerCiascun{condition}{line text loop}

  * •

$\backslash$PerTutti{condition}{text loop}

$\backslash$lPerTutti{condition}{line text loop}

  * •

$\backslash$Finche{stop condition}{text loop}

$\backslash$lFinche{stop condition}{text loop}

Here we describe how they are obtained:

  1. 1.

$\backslash$SetKwInput{KwIng}{Ingresso}

  2. 2.

$\backslash$SetKwInput{KwUsc}{Uscita}

  3. 3.

$\backslash$SetKwInput{KwDati}{Dati}

  4. 4.

$\backslash$SetKwInput{KwRisult}{Risultato}

  5. 5.

$\backslash$SetKw{KwA}{a}

  6. 6.

$\backslash$SetKw{KwRitorna}{ritorna}

  7. 7.

$\backslash$SetKw{Ritorna}{ritorna}

  8. 8.

$\backslash$SetKwBlock{Inizio}{inizio}{fine}

  9. 9.

$\backslash$SetKwRepeat{Ripeti}{ripeti}{finch }

  10. 10.

$\backslash$SetKwIF{Sea}{AltSe}{Altrimenti}{se}{allora}{altrimenti
se}{allora}{fine se}

  11. 11.

$\backslash$SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}endsw

  12. 12.

$\backslash$SetKwFor{Per}{per}{fai}{fine per}

  13. 13.

$\backslash$SetKwFor{PerPar}{per}{fai in parallelo}{fine per}

  14. 14.

$\backslash$SetKwFor{PerCiascun}{per ciascun}{fai}{fine per ciascun}

  15. 15.

$\backslash$SetKwFor{PerTutti}{per tutti i}{fai}{fine per tutti}

  16. 16.

$\backslash$SetKwFor{Finche}{finch }{fai}{fine finch }

####  12.5 Portuguese keywords

  * •

$\backslash$Entrada{Entrada}

$\backslash$Saida{Saída}

$\backslash$Dados{Dados}

$\backslash$Resultado{Resultado}

  * •

$\backslash$Ate

$\backslash$KwRetorna{[val]}

$\backslash$Retorna{[val]}

  * •

$\backslash$Iniciob{inside block}

  * •

$\backslash$eSe{condition}{then block}{else block}

$\backslash$Se{condition}{then block}

$\backslash$uSe{condition}{then block without end}

$\backslash$lSe{condition}{then’s line text}

$\backslash$Senao{else block}

$\backslash$uSenao{else block without else}

$\backslash$lSenao{else’s line text}

$\backslash$SenaoSe{condition}{elseif block}

$\backslash$uSenaoSe{condition}{elseif block without end}

$\backslash$lSenaoSe{condition}{elseif’s line text}

  * •

$\backslash$Selec{condition}{Switch block}

$\backslash$Caso{a case}{case block}

$\backslash$uCaso{a case}{case block without end}

$\backslash$lCaso{a case}{case’s line}

$\backslash$Outro{otherwise block}

$\backslash$lOutro{otherwise’s line}

  * •

$\backslash$Para{condition}{text loop}

$\backslash$lPara{condition}{line text loop}

  * •

$\backslash$ParaPar{condition}{text loop}

$\backslash$lParaPar{condition}{line text loop}

  * •

$\backslash$ParaCada{condition}{text loop}

$\backslash$lParaCada{condition}{line text loop}

  * •

$\backslash$ParaTodo{condition}{text loop}

$\backslash$lParaTodo{condition}{line text loop}

  * •

$\backslash$Enqto{stop condition}{text loop}

$\backslash$lEnqto{stop condition}{text loop}

  * •

$\backslash$Repita{stop condition}{text loop}

$\backslash$lRepita{stop condition}{line of the loop}

Here we describe how they are obtained:

  1. 1.

$\backslash$SetKwInput{Entrada}{Entrada}

$\backslash$SetKwInput{Saida}{Saída}

$\backslash$SetKwInput{Dados}{Dados}

$\backslash$SetKwInput{Resultado}{Resultado}

  2. 2.

$\backslash$SetKw{Ate}{até} $\backslash$SetKw{KwRetorna}{retorna}

$\backslash$SetKw{Retorna}{retorna}

  3. 3.

$\backslash$SetKwBlock{Inicio}{início}{fim}

  4. 4.

$\backslash$SetKwIF{Se}{SenaoSe}{Senao}{se}{então}{senão se}{senão}{fim se}

  5. 5.

$\backslash$SetKwSwitch{Selec}{Caso}{Outro}{selecione}{faça}{caso}{senão}{fim
caso}fim selec

  6. 6.

$\backslash$SetKwFor{Para}{para}{faça}{fim para}

  7. 7.

$\backslash$SetKwFor{ParaPar}{para}{faça em paralelo}{fim para}

  8. 8.

$\backslash$SetKwFor{ParaCada}{para cada}{faça}{fim para cada}

  9. 9.

$\backslash$SetKwFor{ParaTodo}{para todo}{faça}{fim para todo}

  10. 10.

$\backslash$SetKwFor{Enqto}{enquanto}{faça}{fim enqto}

  11. 11.

$\backslash$SetKwRepeat{Repita}{repita}{até}

####  12.6 Some Czech keywords

Here are some czech keywords, please feel free to send me the others.

  * •

$\backslash$Vst

  * •

$\backslash$Vyst

  * •

$\backslash$Vysl

How they are obtained:

  1. 1.

$\backslash$SetKwInput{Vst}Vstup

  2. 2.

$\backslash$SetKwInput{Vyst}Výstup

  3. 3.

$\backslash$SetKwInput{Vysl}Výsledek

###  13 Known bugs

  * •

no more known bugs actually; if you find one, please send it to me.

## Release notes

    %   -  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

### List of Algorithms

loa

## Index

  * $\backslash$; §11.5, §2, §2, §2, item $\backslash$;, item $\backslash$;
  * $\backslash$a 2nd item