summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/algorithm2e
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-12-16 00:53:28 +0000
committerKarl Berry <karl@freefriends.org>2009-12-16 00:53:28 +0000
commit5d71e79720301a8f2d96c9e573d4ff8bbc7a2b74 (patch)
tree8d6046077b39805dbc454e2e2f1f05719dbfa717 /Master/texmf-dist/tex/latex/algorithm2e
parent0ab576d596d5e6b9c0a5a9b8d0b6032612c94195 (diff)
algorithm2e 4.01 (15dec09)
git-svn-id: svn://tug.org/texlive/trunk@16417 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/algorithm2e')
-rw-r--r--Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty2542
1 files changed, 1528 insertions, 1014 deletions
diff --git a/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty b/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty
index e4532553afc..4377fa87fdf 100644
--- a/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty
+++ b/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty
@@ -1,5 +1,6 @@
% algorithm2e.sty --- style file for algorithms
-%% Copyright 1996-2005 Christophe Fiorio
+% almost everything can be customized by users. See the document for more explanations
+%% Copyright 1996-2008 Christophe Fiorio
%
% This program may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
@@ -9,42 +10,360 @@
% and version 1.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
%
-% This program consists of the files algorithm2e.sty and algorithm2e.tex
+% This program consists of the files algorithm2e.sty and algorithm2e.tex and algorithm2e-compatibility.sty
%
% Report bugs and comments to:
-% fiorio@lirmm.fr
+% - algorithm2e-announce@lirmm.fr mailing list for announcement about releases^^J%
+% - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J%
+% subscribe by emailing sympa@lirmm.fr with 'subscribe <list> <firstname name>'^^J%
%
-% $Id: algorithm2e.sty,v 3.9 2005/10/04 12:34:52 fiorio Exp $
+% $Id: algorithm2e.sty,v 4.1 2009/12/15 08:54:08 cfiorio Exp $
%
% PACKAGES REQUIRED:
%
-% - float (in contrib/supported/float)
-% - ifthen (in base)
-% - xspace (in packages/tools)
+% - float (in contrib/supported/float)
+% - ifthen (in base)
+% - xspace (in packages/tools)
+% - relsize (in contrib/misc/relsize.sty)
%
-%%%%%%%%%%%%%%% Release 3.9
+%%%%%%%%%%%%%%% Release 4.01
+%
+% Package options:
+% ---------------
+% - oldcommands : to use old command names
+% - french, english, german,
+% portuguese, czech, italiano,
+% slovak : for the name of the algorithm and some keyword code
+% - onelanguage : to simply switch keyword from one language to another without changing
+% keyword commands
+% - boxed, boxruled, ruled, tworuled,
+% algoruled, plain : layout of the algorithm
+% - algo2e : environment is algorithm2e instead of algorithms and \listofalgorithmes
+% instead of \listofalgorithms
+% - slide : to use when making slides
+% - noline,lined,vlined : how block are designed.
+% - shortend, longend, noend : short or long end keyword as endif for e.g.
+% - linesnumbered : auto numbering of the algorithm's lines
+% - linesnumberedhidden : to hide autonumbered lines (show number on a line with \ShowLn
+% - commentsnumbered, inoutnumbered : to autonumber comments and inout keywords (by defaut not numbered)
+% - rightnl : to have line number on the right instead of on the left as default
+% - algonl : line numbers preceded by algo number
+% - scright, scleft : right or left justified side comments
+% - fillcomment, nofillcomment : end mark of comment is flushed to the right so comments fill the line
+% - dotocloa : add an entry in the toc for list of algorithms (require tocbibind package)
+% - endfloat : add algoendfloat environment pushing algorithm so written to the end of document
+% - resetcount, noresetcount : start value of line numbers.
+% - algopart,algochapter,algosection : algo numbering within part, chapter or section
+% - titlenumbered,titlenotnumbered : numbering of title set by \Titleofalgo
+% - figure : algorithms are figures, numbered as figures, and put in the list of figures.
+% - procnumbered : procedure or function are numbered as algorithm
+% - nokwfunc : procedure or function name doens't become a command
+% - norelsize : don't use relsize package (useful if it breaks the compatibily)
+%
+% defaults are; english,plain,resetcount,titlenotnumbered
+%
+%%%%%%%%%%%%%%
+%
+% Short summary
+% -------------
+%
+% algorithm is an environment for writing algorithm in LaTeX2e.
+% Almost all is customizable. You can add keywords, change style, change the layout, ...
+% It provide macros that allow you to create differents sorts of key words, therefore a set of predefined key
+% word is gived.
+%
+% IT should be used as follows
+%
+% \begin{algorithm}
+% ...
+% ...
+% \end{algorithm}
+%
+%
+% IMPORTANT : each line MUST end with \;
+%
+% Note that if you define macros outside algorithm environment they
+% are avaible in all the document and particulary you can use then
+% inside all algorithms without re-define them.
+%
+% an example:
+%
+% \begin{algorithm}
+% \SetAlgoLined
+% \KwIn{this text}
+% \KwOut{how to write algorithm with \LaTeX2e }
+%
+% initialization\;
+% \While{not at end of this document}{
+% read current section\;
+% \eIf{understand}{
+% go to next section\;
+% current section becomes this one\;
+% }{
+% go back to the beginning of current section\;
+% }
+% }
+% \caption{How to write algorithm}
+% \end{algorithm}
+%
+%
+%%%%%%%%%%%%%% predefined keywords
+%
+% \KwIn{input}
+% \KwOut{output}
+% \KwData{input}
+% \KwResult{output}
+% \KwTo % a simple keyword
+% \KwFrom % a simple keyword
+% \KwRet{[value]}
+% \Return{[value]}
+% \Begin{block inside}
+% \eIf{condition}{Then Block}{Else block} % in blocks
+% \If{condition}{Then block} % in a block
+% \uIf{condition}{Then block} % in a block unended
+% \lIf{condition}{Else text} % on the same line
+% \Else{inside Else} % in a block
+% \lElse{Else text} % on the same line
+% \uElse{Else text} % in a block unended
+% \ElseIf{inside Elseif} % in a block
+% \lElseIf{Elseif text} % on the same line
+% \uElseIf{Elseif text} % in a block unended
+% \Switch{Condition}{Switch block}
+% \Case{a case}{case block} % in a block
+% \lCase{a case}{case text} % on the same line
+% \Other{otherwise block} % in a block
+% \lOther{otherwise block} % on the same line
+% \For{condition}{text loop} % in a block
+% \lFor{condition}{text} % on the same line
+% \ForEach{condition}{text loop} % in a block
+% \lForEach{condition}{text} % on the same line
+% \ForPar{condition}{text loop} % in a block
+% \lForPar{condition}{text} % on the same line
+% \While{condition}{text loop} % in a block
+% \lWhile{condition}{text loop} % on the same line
+% \Repeat{End condition}{text loop} % in a block
+% \lRepeat{condition}{text} % on the same line
+%
+%%%%%%%%%%%%%%
%
% History:
%
+% - december 14 2009 - revision 4.01
+% * ADD : new command \SetKwHangingKw{Name}{text} (hanging indent with keyword): This creates a
+% hanging indent much like \texttt{SetKwInput}, except that it removes the trailing `:'
+% and does not reset numbering.
+%
+% - november 17 2009 - revision 4.00 -
+%
+% * CHANGE : IMPORTANT : some commands have been renamed to have consistent naming (CamlCase
+% syntax) and old commands are no more available. If you doesn't want to change
+% your mind or use old latex files, you can use oldcommands option to enable old
+% commands back.
+% text. Here are these commands:
+% - \SetNoLine becomes \SetAlgoNoLine
+% - \SetVline becomes \SetAlgoVlined
+% - \Setvlineskip becomes \SetVlineSkip
+% - \SetLine becomes \SetAlgoLined
+% - \dontprintsemicolon becomes \DontPrintSemicolon
+% - \printsemicolon becomes \PrintSemicolon
+% - \incmargin becomes \IncMargin
+% - \decmargin becomes \DecMargin
+% - \setnlskip becomes \SetNlSkip
+% - \Setnlskip becomes \SetNlSkip
+% - \setalcapskip becomes \SetAlCapSkip
+% - \setalcaphskip becomes \SetAlCapHSkip
+% - \nlSty becomes \NlSty
+% - \Setnlsty becomes \SetNlSty
+% - \linesnumbered becomes \LinesNumbered
+% - \linesnotnumbered becomes \LinesNotNumbered
+% - \linesnumberedhidden becomes \LinesNumberedHidden
+% - \showln becomes \ShowLn
+% - \showlnlabel becomes \ShowLnLabel
+% - \nocaptionofalgo becomes \NoCaptionOfAlgo
+% - \restorecaptionofalgo becomes \RestoreCaptionOfAlgo
+% - \restylealgo becomes \RestyleAlgo
+% - gIf macros and so on do no more exist
+% * NEW: - Compatibily with other packages improven by changing name of internal
+% macros. Algorithm2e can now be used with arabtex for example, if this last is
+% loaded after algorithm2e package.
+% * ADD: - OPTION endfloat: endfloat packages doesn't allow float environment inside other
+% environment. So using it with figure option of algorithm2e makes error. This
+% option enables a new environment algoendfloat to be used instead of algorithm
+% environment that put algorithm at the end. algoendfloat environment make
+% algorithm acting as endfloat figures. This option requires endfloat packages.
+% * ADD: - OPTION norelsize: starting from this release (v4.00), algorithm2e package uses
+% relsize package in order to get relative size for lines numbers; but it seems
+% that some rare classes (such as inform1.cls) are not compatible with relsize; to
+% have algorithm2e working, this option makes algorithm2e not to load relsize
+% package and go back to previous definition by using \scriptsize font for lines
+% numbers.
+% * ADD: - OPTION onelanguage: allow, if using standard keywords listed below, to switch
+% from one language to another without changing keywords by using appropriate
+% language option :
+% . KwIn, KwOut, KwData, KwResult
+% . KwTo KwFrom
+% . KwRet, Return
+% . Begin
+% . Repeat
+% . If, ElseIf, Else
+% . Switch, Case, Other
+% . For, ForPar, ForEach, ForAll, While
+% .
+% * ADD: - OPTION rightnl: put lines numbers to the right of the algorithm instead of left.
+% * ADD: new commands \setRightLinesNumbers and \setLeftLinesNumbers which sets the lines
+% numbers to the right or to the left of the algorithm.
+% * ADD: - new kind of keywords : KwArray used to define arrays:
+% \SetKwArray{Kw}{array} defines an array keywords Kw called array and printed in
+% DataSty style when call with \Kw. It can be used with one argument which
+% denotes the element index: \Kw{n} prints array[n] with array in DataSty and n in
+% ArgSty.
+% * ADD/FIX: rules of ruled, algoruled, tworuled styles used rules of different sizes! This
+% is now fixed. Moreover size of the rules is now controlled by a length and so
+% can be customized by the user.
+% \algoheightrule is the height of the rules and can be changed via \setlength
+% \algoheightruledefault is the default height of he rules (0.8pt)
+% \algotitleheightrule is the height of the rule that comes just after the
+% caption in ruled and algoruled style; it can be changed via \setlength
+% \algotitleheightruledefault is the default height of this rules (0.8pt)
+% Thanks to Philippe Dumas who reports the bug and make the suggestion.
+% * ADD: - \SetAlgoCaptionSeparator which sets the separator between Algorithm 1 and the
+% title. By default it's ':' and caption looks like "Algorithm 2: title" but now
+% you can change it by using for example \SetAlgoCaptionSeparator{.} which will
+% give "Algorithm 3. title"
+% * ADD: - \SetAlgoLongEnd and \SetAlgoShortEnd and \SetAlgoNoEnd commands which act as
+% corresponding package options
+% * ADD: - OPTIONS italiano and slovak as new language (thanks to Roberto Posenato and
+% Miroslav Binas)
+% * CHANGE: - Fnt and Sty macro to have consistent use and naming (see below)
+% * ADD: - \AlCapSty, \AlCapNameSty, \AlCapFnt, \AlCapNameFnt, \ProcSty, \ProcFnt,
+% \ProcNameSty, \ProcNameFnt, \ProcArgSty, ProcArgFnt and corresponding "set macro"
+% \SetAlCapSty, \SetAlCapNameSty, \SetAlCapFnt, \SetAlCapNameFnt, \SetProcSty,
+% \SetProcFnt, \SetProcNameSty, \SetProcNameFnt, \SetProcArgSty, \SetProcArgFnt which
+% control the way caption is printed. Sty macro use command taking one parameter as
+% argument, Fnt macros use directly command. In Fact caption is printed as follow :
+% \AlCapSty{\AlCapFnt Algorithm 1:}\AlCapNameSty{\AlCapNameFnt my algorithm}
+% By default, \AlCapSty is textbf and \AlCapFnt is nothing. \AlCapNameSty keep text
+% as it is, and \AlCapNameFnt do nothing also.
+% You can redefine \AlCapFnt and \AlCapNameFnt by giving macro to \Set commands. For
+% example, you can do \SetAlCapFnt{\large} to see Algorithm printed in \large font.
+% You can redefine \AlCapSty, \AlCapFnt, \AlCapNameSty and \AlCapNameFnt with the
+% corresponding \Set command. For the Sty commands, you have to give in parameter
+% name of a macro (whithout \) which takes one argument. For example,
+% \SetAlCapFnt{textbf} defines the default behaviour. If you want to do more
+% complicated thing, you should define your own macro and give it to \SetAlCapFnt or
+% \SetAlCapNameFnt. Here are two examples:
+% - \newcommand{\mycapsty}[1]{\tiny #1}\SetAlCapNameSty{mycapsty}
+% - \newcommand{\mycapsty}[1]{\textsl{\small #1}}\SetAlCapNameSty{mycapsty}
+% Or you can combine the two, for the last example you can also do:
+% \SetAlCapNameSty{textsl}\SetAlCapNameFnt{\small}
+% Thanks to Jan Stilhammer who gives me the idea of \AlCapNameFnt.
+% * CHANGE \AlTitleFnt to match definition of all other Fnt macros and add a \AlTitleSty
+% macro (see below) . Now you set \AlTitleFnt by calling \SetAlTitleFnt with
+% directly a macro without parameter in argument:
+% Example: \SetAlTitleFnt{\small} to set title in small font.
+% * ADD: - \AlTitleSty and \SetAlTitleSty commands to set a style for title. These commands
+% are defined from a macro taking the text in argument, as \textbf for example.
+% To set the TitleSty you have to give name of the macro (without the '\')
+% to \SetAlTitleSty. For example \SetAlTitleSty{textbf} to set \textbf style.
+% * ADD: - new command \SetAlgorithmName{algorithmname}{list of algorithms name} which
+% redefines name of the algorithms and the sentence list of algorithms. Second
+% argument is the name that \autoref, from hyperref package, will use. Example:
+% \SetAlgorithmName{Protocol}{List of protocols} if you prefer protocol than
+% algorithm.
+% * ADD: - new \SetAlgoRefName{QXY} which change the default ref (number of the algorithm) by
+% the name given in parameter (QXY in the example).
+% * ADD: - new command \SetAlgoRefRelativeSize{-2} which sets the output size of refs, defined
+% by \SetAlgoRefName, used in list of algorithms.
+% * ADD: - two dimensions to control the layout of caption in ruled, algoruled and boxruled
+% algorithms:
+% - interspacetitleruled (2pt by defaut) which controls the vertical space between
+% rules and title in ruled and algoruled algorithms.
+% - interspaceboxruled (2\lineskip by default) which controls the vertical space
+% between rules and title in boxruled algorithms.
+% These two dimensions can be changed by using \setlength command.
+% * ADD: - With the fix (see below) of procedure and function environments, a new feature has
+% been added: the name of the procedure or function set in caption is automatically
+% defined as a KwFunction and so can be used as a macro. For example, if inside a
+% procedure environment you set \caption{myproc()}, you can use \myproc macro in you
+% main text. Beware that the macro is only defined after the \caption!
+% * ADD: - OPTION nokwfunc to unable the new feature described above in function and
+% procedure environment. Useful if you use name of procedure or function that cannot
+% be a command name as a math display for example.
+% * ADD: - \SetAlgoNlRelativeSize{number} command which sets the relative size of line
+% numbers. By default, line numbers are two size smaller than algorithm text. Use
+% this macro to change this behavior. For example, \SetAlgoNlRelativeSize{0} sets it
+% to the same size, \SetAlgoNlRelativeSize{-1} to one size smaller and
+% \SetAlgoNlRelativeSize{1} to one size bigger
+% * ADD: - \SetAlgoProcName{aname} command which sets the name of Procedure printed by
+% procedure environment (the environment prints Procedure by default). Second
+% argument is the name that \autoref, from hyperref package, will use.
+% * ADD: - \SetAlgoFuncName{aname} command which sets the name of Function printed by
+% procedure environment (the environment prints Function by default). Second
+% argument is the name that \autoref, from hyperref package, will use.
+% * ADD: - \SetAlgoCaptionLayout{style} command which sets style of the caption; style must
+% be the name of a macro taking one argument (the text of the caption). Examples
+% below show how to use it:
+% . \SetAlgoCaptionLayout{centerline} to have centered caption
+% . \SetAlgoCaptionLayout{textbf} to have bold caption
+% If you want to apply two styles in the same time, such as centered bold, you have
+% to define you own macro and then use \SetAlgoCaptionLayout with its name.
+% * ADD: - OPTION procnumbered: which makes the procedure and function to be numbered as
+% algorithm
+% * ADD: - OPTIONS tworuled and boxruled
+% these are two new layouts: tworuled acts like ruled but doesn't put a line after
+% caption ; boxruled surround algorithm by a box, puts caption above and add a line
+% after caption.
+% * REMOVE: - SetKwInParam has been deleted since not useful itself because of different
+% macros which can do the same in a better and a more consistent way as
+% SetKwFunction or SetKw.
+% * FIX: - line number is now correctly vertically aligned with math display.
+% * FIX: - references with hyperref. No more same identifier or missing name error. BUT now
+% you must NOT use naturalnames option of hyperref packages if you do PdfLaTeX
+% * FIX: - autoref with hyperref package (thanks to Jörg Sommer who notices the problem).
+% * FIX: - titlenumbered was not working! fixed.
+% * FIX: - Else(){} acted like uElse. Corrected.
+% * FIX: - noend management: when a block was inside another and end of block was following
+% each other, a blank line was added: it's now corrected.
+% * FIX: - Function and Procedure environment was no more working as defined originally: the
+% label was no more name of the procedure, it acts always as if procumbered option
+% has been used.
+% * FIX: - line numbers had a fixed size which can be bigger than algorithm text accordingly
+% to \AlFnt set (see also new command \SetAlgoNlRelativeSize above)
+% * FIX: - semicolon in comments when dontprintsemicolon is used.
+% * FIX: - listofalgorithms adds a vertical space before first algo of a chapter as for
+% listoffigures or listoftables
+% * FIX: - listofalgorithms with twocolumns mode and some classes which don't allow onecolumn
+% and so don't define \if@restonecol as prescribed in LaTeX (sig-alternate for
+% example)
+% * FIX: - algorithm2e now works with elsart cls and some more classes.
+% * FIX: - blocks defined by SetKwBlock act now as other blocks (if for instance) and don't
+% write end in vlined mode, instead they print a small horizontal line as required
+% by the option.
+% * FIX: - underfull hbox warning at each end of algorithm environment removed.
+%
+% * INTERNAL CHANGE: - short end keyword are deduce from long end keyword by keeping the
+% first one. Allows to avoid double definition.
+% * INTERNAL CHANGE: - procedure, function and algorithm are now resolved by the same
+% environment to avoid code duplication.
+%
% - October 04 2005 - revision 3.9 -
-% * ADD: - \setalcaphskip command which set the horizontal skip before Algorithm: in caption when
-% used in ruled algorithm.
-% * ADD: - SetAlgoInsideSkip command which allows to add an extra vertical space before and after
-% the core of the algorithm (ie: \SetAlgoInsideSkip{bigskip})
-% * CHANGE: - caption, when used with figure option, is no more controlled by algorithm2e package
-% and so follows the exact behaviour of figures. The drawback is that you cannot change
-% the typo with AlTitleFnt or CapFnt. The avantage is that if you use caption package,
-% it works.
+% * ADD: - \setalcaphskip command which sets the horizontal skip before Algorithm: in caption
+% when used in ruled algorithm.
+% * ADD: - \SetAlgoInsideSkip command which allows to add an extra vertical space before and
+% after the core of the algorithm (ie: \SetAlgoInsideSkip{bigskip})
+% * CHANGE: - caption, when used with figure option, is no more controlled by algorithm2e
+% package and so follows the exact behaviour of figures. The drawback is that you
+% cannot change the typo with AlTitleFnt or CapFnt. The avantage is that if you
+% use caption package, it works.
% * FIX: - problem with numbering line and pdflatex
% * FIX: - error when algorithm2e package was used with beamer and listings together
% - February 12 2005 - revision 3.8 -
% * FIX: - extra line with noend option.
% - February 10 2005 - revision 3.7 -
-% * ADD: - sidecomment: different macros allowing to put text right after code
-% on the same line. They are defined in the same time comment macros
-% are defined with a star after the macro name. By default comments
-% are right justified but this can be change with appropriate option
-% in the macro. Ex:
+% * ADD: - sidecomment: different macros allowing to put text right after code on the same
+% line. They are defined in the same time comment macros are defined with a star
+% after the macro name. By default comments are right justified but this can be
+% change with appropriate option in the macro. Ex:
% . default: \tcc*{side comment}
% . same as previous: \tcc*[r]{side comment}
% . left justify: \tcc*[l]{side comment}
@@ -52,57 +371,52 @@
% comment (; by default) and don't end the line.
% . flushed: \tcc*[f]{side comment} same as the precedent but right
% justified
-% * ADD: - scright OPTION (default): right justified side comments (side comments
+% * ADD: - OPTION scright (default): right justified side comments (side comments
% are flushed to the righr)
-% * ADD: - scleft OPTION: left justified side comments (side comments are
-% put right after the code line)
+% * ADD: - OPTION scleft: left justified side comments (side comments are put right after the
+% code line)
% * ADD: - \SetSideCommentLeft acts as scleft option
% * ADD: - \SetSideCommentRight acts as scright option
-% * ADD: - block like macro side text: all macro defining a block allows now
-% to put text right after key words by putting text into (). Done to
-% be used with sidecomment macros, but all text can be used. Ex:
-% \eIf(\tcc*[f]{then comment}){test}{then text}(else side text){else text}
-% * ADD: - fillcomment OPTION (default): end mark of comment is flushed to the
-% right so comments fill all the width of text
-% * ADD: - nofillcomment OPTION: end mark of comment is put right after the
-% comment
+% * ADD: - block like macro side text: all macro defining a block allows now to put text right
+% after key words by putting text into (). Done to be used with sidecomment macros,
+% but all text can be used.
+% Ex: \eIf(\tcc*[f]{then comment}){test}{then text}(else side text){else text}
+% * ADD: - OPTION fillcomment (default): end mark of comment is flushed to the right so
+% comments fill all the width of text.
+% * ADD: - OPTION nofillcomment: end mark of comment is put right after the comment.
% * ADD: - \SetNoFillComment acts as nofillcomment option.
% * ADD: - \SetFillComment acts as fillcomment option.
-% * ADD: - dotocloa OPTION which adds an entry in the toc for the list of
-% algorithms. This option load package tocbibind if not already done
-% and so list of figures and list of tables are also added in the toc.
-% If you want to control which ones of the lists will be added in the
-% toc, please load package tocbibind before package algorithm and give
-% it the options you want.
+% * ADD: - OPTION dotocloa: which adds an entry in the toc for the list of algorithms. This
+% option load package tocbibind if not already done and so list of figures and list
+% of tables are also added in the toc. If you want to control which ones of the lists
+% will be added in the toc, please load package tocbibind before package algorithm
+% and give it the options you want.
% * FIX: - vertical spacing for uif macro with noend option
% * FIX: - all the compatibility problems between caption and other packages
-% * FIX: - typographical differences between list of algorithms and other lists
-% when in report or book
+% * FIX: - typographical differences between list of algorithms and other lists when in
+% report or book
%
% - January 24 2005 - revision 3.6 -
-% * FIX: - vertical spacing and space characters at the beginning or end of
-% comments.
-% line numbers of comments not in the nlsty.
+% * FIX: - vertical spacing and space characters at the beginning or end of comments.
+% line numbers of comments not in the NlSty.
% Thanks to Arnaud Giersch for his comments and suggestions.
-% * FIX: - Set*Sty macro: the styles defined was not protected and was modified
-% by surrounding context. For example KwTo in a \For{}{} was in bold AND
-% italic instead of just in bold.
+% * FIX: - Set*Sty macro: the styles defined was not protected and was modified by surrounding
+% context. For example KwTo in a \For{}{} was in bold AND italic instead of just in
+% bold.
% * FIX: - line number misplacement after \Indp
%
% - January 21 2005 - revision 3.5 -
-% * ADD: - hidden numbering of the lines. Lines are auto-numbered but numbers
-% are shown only on lines you specify:
-% * linesnumberedhidden option or \linesnumberedhidden macro activate
-% this functionnality.
-% * \showln and \showlnlabel{lab} macros make the number visible on
-% the line. \showlnlabel{lab} allows to set a label for this line.
-% Thanks to Samson de Jager who makes this suggestion and provides the
-% macros.
+% * ADD: - hidden numbering of the lines. Lines are auto-numbered but numbers are shown only
+% on lines you specify:
+% * linesnumberedhidden option or \LinesNumberedHidden macro activate this
+% functionnality.
+% * \ShowLn and \ShowLnLabel{lab} macros make the number visible on the
+% line. \ShowLnLabel{lab} allows to set a label for this line.
+% Thanks to Samson de Jager who makes this suggestion and provides the macros.
% * ADD: - \AlCapFnt and \SetAlCapFnt which allow to have a different font for
% caption. Works like \AlFnt and \SetAlFnt and by default is the same.
-% * ADD: - \AlCapSkip skip length. This vertical space is added before caption
-% in plain ou boxed mode. It allows to change distance between text
-% and caption.
+% * ADD: - \AlCapSkip skip length. This vertical space is added before caption in plain ou
+% boxed mode. It allows to change distance between text and caption.
% * FIX: - caption compatible with IEEEtran class.
% * FIX: - some vertical spacing error with \uIf macros (Thanks to Arnaud Giersch)
% * FIX: - Procedure and Function: lines are also numbered like algorithms
@@ -116,7 +430,7 @@
% and [naturalnames] option of hyperref package is used.
% * FIX: - algorithm[H] had problem in an list environment - corrected
% * FIX: - interline was not so regular in nested blocks - corrected
-% * ADD - \Setvlineskip macro which set the vertical skip after the little horizontal
+% * ADD - \SetVlineSkip macro which sets the vertical skip after the little horizontal
% rule which closes a block in Vlined mode. By default 0.8ex
%
% - June 11 2004 - revision 3.2 - AUTO NUMBERING LINES !!!
@@ -127,82 +441,62 @@
% - commentsnumbered option: makes comments be numbered
% - inoutnumbered option: makes data input/output be numbered
% - \nllabel{lab} labels the line so you can cite with \ref{lab}
-% - \linesnumbered make the following algorithms having auto-numbered lines
+% - \LinesNumbered make the following algorithms having auto-numbered lines
% - \linesnotnumbered make the following algorithms having no auto-numbered lines
-% * Change: algo2e option renames listofalgorithm in listofalgorithme
+% * Change: algo2e option renames listofalgorithms in listofalgorithmes
% * FIX: new solution for compatibility with color package, more robust and not tricky.
% Many thanks to David Carlisle for his advices
%
% - June 09 2004 - revision 3.1 -
-% * Change: \SetKwSwitch command defines an additionnal
-% macro \uCase and \Case prints end
-% * Change: now macros SetKw* do a renewcommand if the
-% keyword is already defined. So you can redefine
-% default definition at your own convenience or
-% change your definition without introducing a
-% new macro and changing your text.
+% * Change: \SetKwSwitch command defines an additionnal macro \uCase and \Case prints end
+% * Change: now macros SetKw* do a renewcommand if the keyword is already defined. So you can
+% redefine default definition at your own convenience or change your definition
+% without introducing a new macro and changing your text.
% * ADD: new macro \SetKwIF which do \SetKwIf and
% \SetKwIfElseIf.The following default definition has been added:
% \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}
% and so you get the macros;
-% \If \eIf \lIf \uIf \ElseIf \uElseIf \lElseIf \Else
-% \uElse \lElse
-% * ADD: new macro \SetAlgoSkip which allow to fix the
-% vertical skip before and after the algorithms.
-% Default is smallskip, do \SetAlgoSkip{} if you
-% don't want an extra space or \SetAlgoSkip{medskip}
-% or \SetAlgoSkip{bigskip} if you want bigger space.
-% * ADD: macro \SetKwIf defines in addition a new macro
-% \uElse (depending on wat name you
+% \If \eIf \lIf \uIf \ElseIf \uElseIf \lElseIf \Else \uElse \lElse
+% * ADD: new macro \SetAlgoSkip which allow to fix the vertical skip before and after the
+% algorithms. Default is smallskip, do \SetAlgoSkip{} if you don't want an extra space
+% or \SetAlgoSkip{medskip} or \SetAlgoSkip{bigskip} if you want bigger space.
+% * ADD: macro \SetKwIf defines in addition a new macro \uElse (depending on wat name you
% have given in #2 arg).
-% * ADD: macro \SetKwIfElseIf defines in addition a new macro
-% \uElse and \ugElseIf (depending on what name you
-% have given in #2 and #3 arg).
-% * Change: baseline of algorithm is now top, so two
-% algorithms can be put side by side.
-% * FIX: Compatibility with color package solved. The problem
-% was due to a redefinition of standard macros by color package
-% This solves compatibility problem with other packages
-% as pstcol or colortbl.
-% (notified by Dirk Fressmann, Antti Tarvainen and Koby Crammer)
-% * Fix: extra little shift to the right with boxed style
-% algorithm removed (notified by P. Tanovski)
+% * ADD: macro \SetKwIfElseIf defines in addition a new macro \uElse and \ugElseIf (depending
+% on what name you have given in #2 and #3 arg).
+% * Change: baseline of algorithm is now top, so two algorithms can be put side by side.
+% * FIX: Compatibility with color package solved. The problem was due to a redefinition of
+% standard macros by color package. This solves compatibility problem with other
+% packages as pstcol or colortbl. (notified by Dirk Fressmann, Antti Tarvainen and Koby
+% Crammer)
+% * Fix: extra little shift to the right with boxed style algorithm removed (notified by
+% P. Tanovski)
% * Fix: algoln option was buggy (notified bye Jiaying Shen)
-% * Fix: german and portuges option didn't work due to bad
-% typo (notified by Martin Sievers, Thorsten Vitt
-% and Jeronimo Pellegrini)
+% * Fix: german and portuges option didn't work due to bad typo (notified by Martin Sievers,
+% Thorsten Vitt and Jeronimo Pellegrini)
%
% - February 13 2004 - revision 3.0 -
-% * Major revision which makes the package independent from
-% float.sty, so now
-% - algorithm* works better, in particular can be used in
-% multicols environments
+% * Major revision which makes the package independent from float.sty, so now
+% - algorithm* works better, in particular can be used in multicols environments
% - (known bug corrected)
-% [H] works now for all sort of environment but is
-% handled differently for classic environment and star
-% environment (algorithm, figure, procedure and
-% function). For star environment, H acts like for
-% classical figure environment, so it doesn't stay here
+% [H] works now for all sort of environment but is handled differently for classic
+% environment and star environment (algorithm, figure, procedure and function). For star
+% environment, H acts like for classical figure environment, so it doesn't stay here
% absolutely.
% - (known bug corrected)
-% you can use now floatflt package with algorithm
-% package and even with figure option. Beware that if
-% you want to put an algorithm inside a floatingfigure,
-% it cannot be floating, so [H] is required and then
-% figure option should not be used, since standard
-% figure[H] are still floating with LaTeX.
-% * boxruled: a new style added. Possible now since no
-% style no more defined by the float package.
-% * nocaptionofalgo: dosen't print Algorithm #: in the
-% caption for algorithm in ruled or algoruled style.
-% note: this is just documentation of a macro which was
-% already in the package.
+% you can use now floatflt package with algorithm package and even with figure
+% option. Beware that if you want to put an algorithm inside a floatingfigure, it cannot
+% be floating, so [H] is required and then figure option should not be used, since
+% standard figure[H] are still floating with LaTeX.
+% * boxruled: a new style added. Possible now since no style no more defined by the float
+% package.
+% * nocaptionofalgo: dosen't print Algorithm #: in the caption for algorithm in ruled or
+% algoruled style.
+% note: this is just documentation of a macro which was already in the package.
% - December 14 2003 - revision 2.52 -
% * output message shorter
-% * french keyword macro \PourTous was missing for
-% longend option, it has been added.
-% * TitleofAlgo prints Function or Procedure in
-% corresponding environments.
+% * french keyword macro \PourTous was missing for longend option, it has been added.
+% * TitleofAlgo prints Function or Procedure in corresponding environments.
%
% - October 27 2003 - revision 2.51 - Revision submitted to CTAN archive
% * correction of a minor which make caption in procedure
@@ -214,43 +508,31 @@
% don't do it for algorithm2e package, so we do it)
%
% - October 17 2003 - revision 2.50 - first revision for CTAN archive
-%
-% * add \AlFnt and \SetAlFnt{font} macros:
-% \AlFnt is used at the beginning of the caption and the
-% body of algorithm in order to define the fonts used
-% for typesetting algorithms. You can use it elsewhere
-% you want to typeset text as algorithm. For example
-% you can do \SetAlFnt{\small\sf} to have algorithms
-% typeset in small sf font. Default is nothing so
+% * add \AlFnt and \SetAlFnt{font} macros: \AlFnt is used at the beginning of the caption and
+% the body of algorithm in order to define the fonts used for typesetting algorithms. You
+% can use it elsewhere you want to typeset text as algorithm. For example you can do
+% \SetAlFnt{\small\sf} to have algorithms typeset in small sf font. Default is nothing so
% algorithm is typeset as the text of the document.
-% * add \AlTitleFnt{text} and \SetAlTitleFnt{font} macros:
-% The {Algorithm: } in the caption is typeset with
-% \AlTitleFnt{Algorithm:}. You can use it to have text
-% typeset as {Algorithm:} of captions. Default is
-% textbf.
-% Default can be redefined by \SetAlTitleFnt{font}.
-% * add CommentSty typo for text comment.
-% * add some compatibility with hyperref package (still
-% an error on multiply defined refs but pdf correctly
-% generated)
-% * flush text to left in order to have correct
-% indentation even with class as amsart which center
-% all figures
-% * add german, portugues and czech options for title of
-% algorithms and typo.
-% * add portuguese translation of predefined keywords
-% * add czech translation of some predefined keywords
+% * add \AlTitleFnt{text} and \SetAlTitleFnt{font} macros: The {Algorithm: } in the caption is
+% typeset with \AlTitleFnt{Algorithm:}. You can use it to have text typeset as {Algorithm:}
+% of captions. Default is textbf. Default can be redefined by \SetAlTitleFnt{font}, for
+% example you can do \SetAlTitleFnt{emph}
+% * add CommentSty typo for text comment.
+% * add some compatibility with hyperref package (still an error on multiply defined refs but
+% pdf correctly generated)
+% * flush text to left in order to have correct indentation even with class as amsart which
+% center all figures
+% * add german, portugues and czech options for title of algorithms and typo.
+% * add portuguese translation of predefined keywords * add czech translation of some
+% predefined keywords
%
% - December 23 2002 - revision 2.40
% * add some french keyword missing
-% * add function* and procedure* environment like
-% algorithme* environment: print in one column even
-% if twocolumn option is specified for the document.
-% * add a new macro \SetKwComment to define macro which
-% writes comments in the text. First argument is the
-% name of the macro, second is the text put before the
-% comment, third is the text put at the end of the
-% comment.Default are \tcc and \tcp
+% * add function* and procedure* environment like algorithme* environment: print in one column
+% even if twocolumn option is specified for the document.
+% * add a new macro \SetKwComment to define macro which writes comments in the text. First
+% argument is the name of the macro, second is the text put before the comment, third is the
+% text put at the end of the comment.Default are \tcc and \tcp
% * add new options to change the way algo are numbered:
% [algopart] algo are numbered within part (counter must exist)
% [algochapter] algo are numbered within chapter
@@ -266,7 +548,7 @@
% else
% i;
% end
-% * Also added \gIf \gElsIf \gElse.
+% * Also added \gIf \gElseIf \gElse.
%
% - January 02 2001 - revision 2.38
% * bugs related to the caption in procedure and function
@@ -361,132 +643,6 @@
% -----------
% - no more known bugs... all are corrected!
%
-%%%%%%%%%%%%%%
-%
-% Package options:
-% ---------------
-% - french, english, german, portuguese, czech : for the name of the algorithm, e.g.
-% - boxed, boxruled, ruled, algoruled, plain : layout of the algorithm
-% - algo2e : environment is algorithm2e instead of algorithms
-% and \listofalgorithmes instead of \listofalgorithms
-% - slide : to use when making slides
-% - noline,lined,vlined : how block are designed.
-% - linesnumbered : auto numbering of the algorithm's lines
-% - algopart,algochapter,algosection : algo numbering within part, chapter or section
-% - titlenumbered,titlenotnumbered : numbering of title set by \Titleofalgo
-% - figure : algorithms are figures, numbered as figures, and put in the list of figures.
-% - resetcount, noresetcount : start value of line numbers.
-% - algonl : line numbers preceded by algo number
-% - shortend, longend, noend : short or long end keyword as endif for e.g.
-%
-% defaults are; english,plain,resetcount,titlenotnumbered
-%
-%%%%%%%%%%%%%%
-%
-% Short summary
-% -------------
-%
-% algorithm is an environment for writing algorithm in LaTeX2e
-% It provide macros that allow you to create differents
-% sorts of key words, therefore a set of predefined key word
-% is gived.
-%
-% IT should be used as follows
-%
-% \begin{algorithm}
-% ...
-% ...
-% \end{algorithm}
-%
-%
-% IMPORTANT : each line MUST end with \;
-%
-% Note that if you define macros outside algorithm environment they
-% are avaible in all the document and particulary you can use then
-% inside all algorithms without re-define them.
-%
-% an example:
-%
-% \begin{algorithm}[H]
-% \SetLine
-% \AlgData{this text}
-% \AlgResult{how to write algorithm with \LaTeX2e }
-%
-% initialization\;
-% \While{not at end of this document}{
-% read current section\;
-% \eIf{understand}{
-% go to next section\;
-% current section becomes this one\;
-% }{
-% go back to the beginning of current section\;
-% }
-% }
-% \caption{How to write algorithm}
-% \end{algorithm}
-%
-%
-%%%%%%%%%%%%%% predefined english keywords
-%
-% \AlgData{input}
-% \AlgResult{output}
-% \KwIn{input}
-% \KwOut{output}
-% \KwData{input}
-% \KwResult{output}
-% \Ret{[value]}
-% \KwTo % a simple keyword
-% \Begin{block inside}
-% \If{condition}{Then block} % in a block
-% \uIf{condition}{Then block} % in a block unended
-% \Else{inside Else} % in a block
-% \eIf{condition}{Then Block}{Else block} % in blocks
-% \lIf{condition}{Else text} % on the same line
-% \lElse{Else text} % on the same line
-% \Switch{Condition}{Switch block}
-% \Case{a case}{case block} % in a block
-% \lCase{a case}{case text} % on the same line
-% \Other{otherwise block} % in a block
-% \lOther{otherwise block} % on the same line
-% \For{condition}{text loop} % in a block
-% \lFor{condition}{text} % on the same line
-% \ForEach{condition}{text loop} % in a block
-% \lForEach{condition}{text} % on the same line
-% \Repeat{End condition}{text loop} % in a block
-% \lRepeat{condition}{text} % on the same line
-% \While{condition}{text loop} % in a block
-% \lWhile{condition}{text loop} % on the same line
-%
-%
-%%%%%%%%%%%%%% predefined french keywords
-%
-% \AlgDonnees{input}
-% \AlgRes{input}
-% \Donnees{input}
-% \Res{input}
-% \Retour[valeur]}
-% \Deb{block inside}
-% \KwA % un mot clef simple
-% \Si{condition}{Bloc du Alors} % Dans un bloc
-% \uSi{condition}{Bloc du Alors} % Dans un bloc non termine
-% \eSi{condition}{Bloc du Alors}{Bloc du Sinon} % Dans un bloc
-% \lSi{condition}{texte du Alors} % sur la meme ligne
-% \lSinon{texte du Sinon} % sur la meme ligne
-% \Suivant{Condition}{Bloc de l'instruction}
-% \Cas{cas}{Bloc de ce cas} % Dans un bloc
-% \lCas{cas}{Bloc de ce cas} % sur la meme ligne
-% \Autres{Bloc de l'alternative} % Dans un bloc
-% \lAutres{Bloc de l'alternative} % sur la meme ligne
-% \Pour{condition}{texte de la boucle} % Dans un bloc
-% \lPour{condition}{texte} % sur la meme ligne
-% \PourCh{condition}{texte de la boucle} % Dans un bloc
-% \lPourCh{condition}{texte} % sur la meme ligne
-% \Repeter{End condition}{texte de la boucle} % Dans un bloc
-% \lRepeter{condition}{texte} % sur la meme ligne
-% \Tq{condition}{texte de la boucle} % Dans un bloc
-% \lTq{condition}{texte de la boucle} % sur la meme ligne
-%
-%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% for more complete informations you can see algorithm2e.tex
@@ -496,255 +652,365 @@
%
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
%
-\ProvidesPackage{algorithm2e}[2005/10/04 v3.9 algorithms environments]
+\ProvidesPackage{algorithm2e}[2008/00/00 v3.10 algorithms environments]
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%% Initial Code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\@makeother\*% some package redefined it as a letter (as color.sty)
+\def\@firstword#1 #2\@nil{#1}% an useful fonction
%
% definition of commands which can be redefined in options of the package.
%
-\newcounter{AlgoLine}
-\setcounter{AlgoLine}{0}
-%
-\newcommand{\listalgorithmcfname}{}
-\newcommand{\algorithmcfname}{}
-\newcommand{\algocf@typo}{}
-\newcommand{\@algocf@procname}{}
-\newcommand{\@algocf@funcname}{}
-\newcommand{\@algocf@titleofalgoname}{\algorithmcfname}
+\newcounter{AlgoLine}%
+\setcounter{AlgoLine}{0}%
+%
+\newcommand{\algocf@algocfref}{\relax}%
+\newcommand{\listalgorithmcfname}{}%
+\newcommand{\algorithmcfname}{}%
+\@ifundefined{algorithmautorefname}{\newcommand{\algorithmautorefname}{algorithm}}{\renewcommand{\algorithmautorefname}{algorithm}}%
+\newcommand{\algorithmcflinename}{}%
+\newcommand{\algocf@typo}{}%
+\newcommand{\@algocf@procname}{}\newcommand{\procedureautorefname}{}%
+\newcommand{\SetAlgoProcName}[2]{\renewcommand{\@algocf@procname}{#1}\renewcommand{\procedureautorefname}{#2}}%
+\newcommand{\@algocf@funcname}{}\newcommand{\functionautorefname}{}%
+\newcommand{\SetAlgoFuncName}[2]{\renewcommand{\@algocf@funcname}{#1}\renewcommand{\functionautorefname}{#2}}%
+\newcommand{\@algocf@titleofalgoname}{\algorithmcfname}%
\newcommand{\@algocf@algotitleofalgo}{%
- \renewcommand{\@algocf@titleofalgoname}{\algorithmcfname}}
+ \renewcommand{\@algocf@titleofalgoname}{\algorithmcfname}}%
\newcommand{\@algocf@proctitleofalgo}{%
- \renewcommand{\@algocf@titleofalgoname}{\algocf@procname}}
+ \renewcommand{\@algocf@titleofalgoname}{\algocf@procname}}%
+%
+\newcommand{\algocf@style}{plain}%
+\newcommand{\@ResetCounterIfNeeded}{}%
+\newcommand{\@titleprefix}{}%
+%
+\newcommand{\algocf@numbering}[1]{\newcommand{\algocf@within}{#1}}%
+%
+\newcommand{\defaultsmacros@algo}{\algocf@defaults@shortend}%
%
-\newcommand{\algocf@style}{plain}
-\newcommand{\@ResetCounterIfNeeded}{}
-\newcommand{\@titleprefix}{}
+\newcommand{\algocf@list}{loa}%
+\newcommand{\algocf@float}{algocf}%
%
-\newcommand{\algocf@numbering}[1]{\newcommand{\algocf@within}{#1}}
+\newcommand{\algocf@envname}{algorithm}%
+\newcommand{\algocf@listofalgorithms}{listofalgorithms}%
%
-\newcommand{\defaultsmacros@algo}{\algocf@defaults@shortend}
%
-\newcommand{\algocf@list}{loa}
-\newcommand{\algocf@float}{algocf}
+%% redefine chapter so that it adds a vspace in the loa as the original does for lof and lot
+\let\algocf@original@chapter=\chapter%
+\def\chapter{\expandafter\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}%
%
-\newcommand{\algocf@envname}{algorithm}
-\newcommand{\algocf@listofalgorithms}{listofalgorithms}
+%% if@restonecol is defined in article and book but some other classes don't define it and we need it, so we do
+\ifx\if@restonecol\relax\else\newif\if@restonecol\fi%
%
%
%%%%%%%%%%%%%%%%%%%%%% Declaration of Options %%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-\RequirePackage{ifthen}
+\RequirePackage{ifthen}%
+%
+\newboolean{algocf@nokwfunc}\setboolean{algocf@nokwfunc}{false}%
+\DeclareOption{nokwfunc}{%
+ \setboolean{algocf@nokwfunc}{true}%
+}%
+%
+\newboolean{algocf@oldcommands}\setboolean{algocf@oldcommands}{false}%
+\DeclareOption{oldcommands}{%
+ \setboolean{algocf@oldcommands}{true}%
+}%
+%
+\newboolean{algocf@leftlinenumber}\setboolean{algocf@leftlinenumber}{true}%
+\newcommand{\setLeftLinesNumbers}{\setboolean{algocf@leftlinenumber}{true}}%
+\newcommand{\setRightLinesNumbers}{\setboolean{algocf@leftlinenumber}{false}}%
+\DeclareOption{rightnl}{%
+ \setRightLinesNumbers%
+}%
+%
+\newboolean{algocf@endfloat}\setboolean{algocf@endfloat}{false}%
+\DeclareOption{endfloat}{%
+ \setboolean{algocf@endfloat}{true}%
+ \newcounter{postalgo}\setcounter{postalgo}{0}%
+}%
+%
+\newboolean{algocf@procnumbered}\setboolean{algocf@procnumbered}{false}%
+\DeclareOption{procnumbered}{%
+ \setboolean{algocf@procnumbered}{true}%
+}%
%
\DeclareOption{algo2e}{%
- \renewcommand{\algocf@envname}{algorithm2e}
- \renewcommand{\algocf@listofalgorithms}{listofalgorithmes}
-}
+ \renewcommand{\algocf@envname}{algorithm2e}%
+ \renewcommand{\algocf@listofalgorithms}{listofalgorithmes}%
+}%
%
-\newboolean{algocf@slide}\setboolean{algocf@slide}{false}
+\newboolean{algocf@slide}\setboolean{algocf@slide}{false}%
\DeclareOption{slide}{%
\setboolean{algocf@slide}{true}%
-}
+}%
%
-\DeclareOption{figure}{
-\renewcommand{\algocf@list}{lof}
-\renewcommand{\algocf@float}{figure}
-}
+\DeclareOption{figure}{%
+\renewcommand{\algocf@list}{lof}%
+\renewcommand{\algocf@float}{figure}%
+}%
+%
+\newboolean{algocf@optonelanguage}\setboolean{algocf@optonelanguage}{false}%
+\DeclareOption{onelanguage}{\setboolean{algocf@optonelanguage}{true}}%
+%
+\newcommand{\algocf@languagechoosen}{english}%
%
\DeclareOption{english}{%
\renewcommand{\listalgorithmcfname}{List of Algorithms}%
\renewcommand{\algorithmcfname}{Algorithm}%
+\renewcommand{\algorithmautorefname}{algorithm}%
+\renewcommand{\algorithmcflinename}{line}%
\renewcommand{\algocf@typo}{}%
-\renewcommand{\@algocf@procname}{Procedure}
-\renewcommand{\@algocf@funcname}{Function}
-}
+\renewcommand{\@algocf@procname}{Procedure}%
+\renewcommand{\@algocf@funcname}{Function}%
+\renewcommand{\procedureautorefname}{procedure}%
+\renewcommand{\functionautorefname}{function}%
+\renewcommand{\algocf@languagechoosen}{english}%
+}%
%
\DeclareOption{french}{%
\renewcommand{\listalgorithmcfname}{Liste des Algorithmes}%
\renewcommand{\algorithmcfname}{Algorithme}%
+\renewcommand{\algorithmautorefname}{algorithme}%
+\renewcommand{\algorithmcflinename}{ligne}%
\renewcommand{\algocf@typo}{\ }%
-\renewcommand{\@algocf@procname}{Procédure}
-\renewcommand{\@algocf@funcname}{Fonction}
-}
+\renewcommand{\@algocf@procname}{Procédure}%
+\renewcommand{\@algocf@funcname}{Fonction}%
+\renewcommand{\procedureautorefname}{procédure}%
+\renewcommand{\functionautorefname}{fonction}%
+\renewcommand{\algocf@languagechoosen}{french}%
+}%
%
\DeclareOption{czech}{%
\renewcommand{\listalgorithmcfname}{Seznam algoritm\v{u}}%
\renewcommand{\algorithmcfname}{Algoritmus}%
+\renewcommand{\algorithmautorefname}{\algorithmcfname}%
+\renewcommand{\algorithmcflinename}{Radek}%
\renewcommand{\algocf@typo}{}%
-\renewcommand{\@algocf@procname}{Procedura}
-\renewcommand{\@algocf@funcname}{Funkce}
-}
+\renewcommand{\@algocf@procname}{Procedura}%
+\renewcommand{\@algocf@funcname}{Funkce}%
+\renewcommand{\procedureautorefname}{\@algocf@procname}%
+\renewcommand{\functionautorefname}{\@algocf@funcname}%
+\renewcommand{\algocf@languagechoosen}{czech}%
+}%
%
\DeclareOption{german}{%
\renewcommand{\listalgorithmcfname}{Liste der Algorithmen}%
\renewcommand{\algorithmcfname}{Algorithmus}%
+\renewcommand{\algorithmautorefname}{\algorithmcfname}%
+\renewcommand{\algorithmcflinename}{Zeile}%
\renewcommand{\algocf@typo}{\ }%
\renewcommand{\@algocf@procname}{Prozedur}%
\renewcommand{\@algocf@funcname}{Funktion}%
-}
+\renewcommand{\procedureautorefname}{\@algocf@procname}%
+\renewcommand{\functionautorefname}{\@algocf@funcname}%
+\renewcommand{\algocf@languagechoosen}{german}%
+}%
%
-\DeclareOption{portugues}{%
+\DeclareOption{portuguese}{%
\renewcommand{\listalgorithmcfname}{Lista de Algoritmos}%
\renewcommand{\algorithmcfname}{Algoritmo}%
+\renewcommand{\algorithmautorefname}{algoritmo}%
+\renewcommand{\algorithmcflinename}{linha}%
\renewcommand{\algocf@typo}{}%
-\renewcommand{\@algocf@procname}{Procedimento}
-\renewcommand{\@algocf@funcname}{Fun\c{c}\~{a}o}
-}
+\renewcommand{\@algocf@procname}{Procedimento}%
+\renewcommand{\@algocf@funcname}{Fun\c{c}\~{a}o}%
+\renewcommand{\procedureautorefname}{procedimento}%
+\renewcommand{\functionautorefname}{fun\c{c}\~{a}o}%
+\renewcommand{\algocf@languagechoosen}{portuguese}%
+}%
+%
+\DeclareOption{italiano}{%
+\renewcommand{\listalgorithmcfname}{Elenco degli algoritmi}%
+\renewcommand{\algorithmcfname}{Algoritmo}%
+\renewcommand{\algorithmautorefname}{algoritmo}%
+\renewcommand{\algorithmcflinename}{riga}%
+\renewcommand{\algocf@typo}{}%
+\renewcommand{\@algocf@procname}{Procedura}%
+\renewcommand{\@algocf@funcname}{Funzione}%
+\renewcommand{\procedureautorefname}{procedura}%
+\renewcommand{\functionautorefname}{funzione}%
+\renewcommand{\algocf@languagechoosen}{italiano}%
+}%
+\DeclareOption{slovak}{%
+\renewcommand{\listalgorithmcfname}{Zoznam algoritmov}%
+\renewcommand{\algorithmcfname}{Algoritmus}%
+\renewcommand{\algorithmautorefname}{\algorithmcfname}%
+\renewcommand{\algorithmcflinename}{Radek}%
+\renewcommand{\algocf@typo}{}%
+\renewcommand{\@algocf@procname}{Proced\'{u}ra}%
+\renewcommand{\@algocf@funcname}{Funkcia}%
+\renewcommand{\procedureautorefname}{\@algocf@procname}%
+\renewcommand{\functionautorefname}{\@algocf@funcname}%
+\renewcommand{\algocf@languagechoosen}{slovak}%
+}%
%
% OPTIONs plain, boxed, ruled, algoruled & boxruled
%
-\newcommand{\algocf@style@plain}{\renewcommand{\algocf@style}{plain}}
-\newcommand{\algocf@style@boxed}{\renewcommand{\algocf@style}{boxed}}
-\newcommand{\algocf@style@ruled}{\renewcommand{\algocf@style}{ruled}}
-\newcommand{\algocf@style@algoruled}{\renewcommand{\algocf@style}{algoruled}}
-\newcommand{\algocf@style@boxruled}{\renewcommand{\algocf@style}{boxruled}}
-\newcommand{\restylealgo}[1]{\csname algocf@style@#1\endcsname}
-\DeclareOption{plain}{\algocf@style@plain}
-\DeclareOption{boxed}{\algocf@style@boxed}
-\DeclareOption{ruled}{\algocf@style@ruled}
-\DeclareOption{algoruled}{\algocf@style@algoruled}
-\DeclareOption{boxruled}{\algocf@style@boxruled}
+\newcommand{\algocf@style@plain}{\renewcommand{\algocf@style}{plain}}%
+\newcommand{\algocf@style@boxed}{\renewcommand{\algocf@style}{boxed}}%
+\newcommand{\algocf@style@ruled}{\renewcommand{\algocf@style}{ruled}}%
+\newcommand{\algocf@style@algoruled}{\renewcommand{\algocf@style}{algoruled}}%
+\newcommand{\algocf@style@boxruled}{\renewcommand{\algocf@style}{boxruled}}%
+\newcommand{\algocf@style@tworuled}{\renewcommand{\algocf@style}{tworuled}}%
+\newcommand{\RestyleAlgo}[1]{\csname algocf@style@#1\endcsname}%
+\DeclareOption{plain}{\algocf@style@plain}%
+\DeclareOption{boxed}{\algocf@style@boxed}%
+\DeclareOption{ruled}{\algocf@style@ruled}%
+\DeclareOption{algoruled}{\algocf@style@algoruled}%
+\DeclareOption{boxruled}{\algocf@style@boxruled}%
+\DeclareOption{tworuled}{\algocf@style@tworuled}%
%
% OPTIONs algopart,algochapter & algosection
%
-\DeclareOption{algopart}{\algocf@numbering{part}} %algo part numbered
-\DeclareOption{algochapter}{\algocf@numbering{chapter}} %algo chapter numbered
-\DeclareOption{algosection}{\algocf@numbering{section}} %algo section numbered
+\DeclareOption{algopart}{\algocf@numbering{part}}% %algo part numbered
+\DeclareOption{algochapter}{\algocf@numbering{chapter}}% %algo chapter numbered
+\DeclareOption{algosection}{\algocf@numbering{section}}% %algo section numbered
%
% OPTIONs resetcount & noresetcount
%
-\DeclareOption{resetcount}{\renewcommand{\@ResetCounterIfNeeded}{\setcounter{AlgoLine}{0}}}
-\DeclareOption{noresetcount}{\renewcommand{\@ResetCounterIfNeeded}{}}
+\DeclareOption{resetcount}{\renewcommand{\@ResetCounterIfNeeded}{\setcounter{AlgoLine}{0}}}%
+\DeclareOption{noresetcount}{\renewcommand{\@ResetCounterIfNeeded}{}}%
%
% OPTION linesnumbered
%
-\newboolean{algocf@linesnumbered}\setboolean{algocf@linesnumbered}{false}
-\newcommand{\algocf@linesnumbered}{\relax}
+\newboolean{algocf@linesnumbered}\setboolean{algocf@linesnumbered}{false}%
+\newcommand{\algocf@linesnumbered}{\relax}%
\DeclareOption{linesnumbered}{%
- \setboolean{algocf@linesnumbered}{true}
- \renewcommand{\algocf@linesnumbered}{\everypar={\nl}}
-}
+ \setboolean{algocf@linesnumbered}{true}%
+ \renewcommand{\algocf@linesnumbered}{\everypar={\nl}}%
+}%
%
% OPTION linesnumberedhidden
%
\DeclareOption{linesnumberedhidden}{%
- \setboolean{algocf@linesnumbered}{true}
- \renewcommand{\algocf@linesnumbered}{\everypar{\stepcounter{AlgoLine}}}
-}
+ \setboolean{algocf@linesnumbered}{true}%
+ \renewcommand{\algocf@linesnumbered}{\everypar{\stepcounter{AlgoLine}}}%
+}%
%
% OPTION commentsnumbered inoutnumbered
%
-\newboolean{algocf@commentsnumbered}\setboolean{algocf@commentsnumbered}{false}
-\DeclareOption{commentsnumbered}{\setboolean{algocf@commentsnumbered}{true}}
-\newboolean{algocf@inoutnumbered}\setboolean{algocf@inoutnumbered}{false}
-\DeclareOption{inoutnumbered}{\setboolean{algocf@inoutnumbered}{true}}
+\newboolean{algocf@commentsnumbered}\setboolean{algocf@commentsnumbered}{false}%
+\DeclareOption{commentsnumbered}{\setboolean{algocf@commentsnumbered}{true}}%
+\newboolean{algocf@inoutnumbered}\setboolean{algocf@inoutnumbered}{false}%
+\DeclareOption{inoutnumbered}{\setboolean{algocf@inoutnumbered}{true}}%
%
% OPTIONs titlenumbered & titlenotnumbered
%
\DeclareOption{titlenumbered}{%
\renewcommand{\@titleprefix}{%
- \refstepcounter{algocf@float}%
- \AlTitleFnt{\@algocf@titleofalgoname\
- \expandafter\csname the\algocf@float\endcsname\algocf@typo : }}%
-}
+ \refstepcounter{\algocf@float}%
+ \AlTitleSty{\AlTitleFnt\@algocf@titleofalgoname\ \expandafter\csname the\algocf@float\endcsname\algocf@typo: }%
+ }%
+}%
%
\DeclareOption{titlenotnumbered}{\renewcommand{\@titleprefix}{%
- \AlTitleFnt{\@algocf@titleofalgoname\algocf@typo : }}%
-}
-%
-% OPTIONs lined, vlined & noline
-%
-\DeclareOption{lined}{\AtBeginDocument{\SetLine}} % \SetLine
-\DeclareOption{vlined}{\AtBeginDocument{\SetVline}} % \SetVline
-\DeclareOption{noline}{\AtBeginDocument{\SetNoline}} % \Setnoline (default)
+ \AlTitleSty{\AlTitleFnt\@algocf@titleofalgoname\algocf@typo: }}%
+}%
%
% OPTIONs algonl
% line numbered with the counter of the algorithm
%
-\DeclareOption{algonl}{\renewcommand{\theAlgoLine}{\expandafter\csname the\algocf@float\endcsname.\arabic{AlgoLine}}}
+\DeclareOption{algonl}{\renewcommand{\theAlgoLine}{\expandafter\csname the\algocf@float\endcsname.\arabic{AlgoLine}}}%
+%
+% OPTIONs lined, vlined & noline
+%
+\DeclareOption{lined}{\AtBeginDocument{\SetAlgoLined}}% \SetAlgoLined
+\DeclareOption{vlined}{\AtBeginDocument{\SetAlgoVlined}}% \SetAlgoVlined
+\DeclareOption{noline}{\AtBeginDocument{\SetAlgoNoLine}}%\SetAlgoNoLine (default)
%
% OPTIONs longend, shotend & noend
%
-\DeclareOption{longend}{%
-\renewcommand{\defaultsmacros@algo}{\algocf@defaults@longend}}
-\DeclareOption{shortend}{%
-\renewcommand{\defaultsmacros@algo}{\algocf@defaults@shortend}}
-\newboolean{algocf@optnoend}\setboolean{algocf@optnoend}{false}
-\DeclareOption{noend}{%
- \setboolean{algocf@optnoend}{true}%
- \renewcommand{\defaultsmacros@algo}{\algocf@defaults@noend}}
+\DeclareOption{longend}{\AtBeginDocument{\SetAlgoLongEnd}}% \SetAlgoLongEnd
+\DeclareOption{shortend}{\AtBeginDocument{\SetAlgoShortEnd}}%\SetAlgoShortEnd
+\DeclareOption{noend}{\AtBeginDocument{\SetAlgoNoEnd}}% \SetAlgoNoEnd
%
% OPTION dotoc
%
-\newboolean{algocf@dotocloa}\setboolean{algocf@dotocloa}{false}
+\newboolean{algocf@dotocloa}\setboolean{algocf@dotocloa}{false}%
\DeclareOption{dotocloa}{%
- \setboolean{algocf@dotocloa}{true}
+ \setboolean{algocf@dotocloa}{true}%
}
%
% OPTION comments
%
-\newboolean{algocf@optfillcomment}\setboolean{algocf@optfillcomment}{true}
+\newboolean{algocf@optfillcomment}\setboolean{algocf@optfillcomment}{true}%
\DeclareOption{nofillcomment}{%
\setboolean{algocf@optfillcomment}{false}%
-}
+}%
\DeclareOption{fillcomment}{%
\setboolean{algocf@optfillcomment}{true}%
-}
+}%
%
% OPTION sidecommments
%
-\newboolean{algocf@scleft}\setboolean{algocf@scleft}{false}
+\newboolean{algocf@scleft}\setboolean{algocf@scleft}{false}%
\DeclareOption{scleft}{%
\setboolean{algocf@scleft}{true}%
-}
+}%
\DeclareOption{sright}{% default
\setboolean{algocf@scleft}{false}%
-}
+}%
+%
+% OPTION norelsize
+%
+\newboolean{algocf@norelsize}\setboolean{algocf@norelsize}{false}%
+\DeclareOption{norelsize}{%
+ \setboolean{algocf@norelsize}{true}%
+}%
%
%
%%%%%%%%%%%%%%%%%%%%%%% Execution of Options %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-\ExecuteOptions{english,plain,resetcount,titlenotnumbered}
+\ExecuteOptions{english,plain,resetcount,titlenotnumbered,lined,shortend}%
%
-\ProcessOptions
+\ProcessOptions%
%
-\@algocf@algotitleofalgo % fix name for \Titleofalgo to \algorithmcfname by default
+\@algocf@algotitleofalgo% fix name for \TitleOfAlgo to \algorithmcfname by default
%
%%%%%%%%%%%%%%%%%%%%%%%%%% Package Loading %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-%\RequirePackage{float}[2001/11/08]
%
-\RequirePackage{xspace}
+\RequirePackage{xspace}%
%
-\ifthenelse{\boolean{algocf@slide}}{\RequirePackage{color}}{}
+\ifthenelse{\boolean{algocf@endfloat}}{%
+ \RequirePackage{endfloat}%
+}{\relax}%
+%
+\ifthenelse{\boolean{algocf@norelsize}}{%
+ \newcommand{\relsize}[1]{\scriptsize}%
+}{%
+ \RequirePackage{relsize}%
+}%
+%
+\ifthenelse{\boolean{algocf@slide}}{\RequirePackage{color}}{}%
%
\AtEndOfPackage{%
\ifthenelse{\boolean{algocf@dotocloa}}{%
\renewcommand{\listofalgorithmes}{\tocfile{\listalgorithmcfname}{loa}}%
- }{\relax}
-}
-
+ }{\relax}%
+}%
+%
% if loa in toc required, load tocbibind package if not already done.
\ifthenelse{\boolean{algocf@dotocloa}}{%
\ifx\@tocextra\undefined%
- \RequirePackage{tocbibind}
+ \RequirePackage{tocbibind}%
\fi%
-}
-
+}%
+%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Part %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-\newcommand{\algocf@name}{algorithm2e}
-\newcommand{\algocf@date}{october 04 2005}
-\newcommand{\algocf@version}{Release 3.9}
-\newcommand{\algocf@id}{\algocf@version\space -- \algocf@date\space --}
+\newcommand{\algocf@name}{algorithm2e}%
+\newcommand{\algocf@date}{december 14 2009}%
+\newcommand{\algocf@version}{Release 4.01}%
+\newcommand{\algocf@id}{\algocf@version\space -- \algocf@date\space --}%
\typeout{********************************************************^^JPackage `\algocf@name'\space\algocf@id^^J%
- algorithm2e-announce@lirmm.fr mailing list for announcement about releases^^J%
- algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J%
subscribe by emailing sympa@lirmm.fr with 'subscribe <list> <firstname name>'^^J%
- - Author: Christophe Fiorio (fiorio@lirmm.fr)^^J********************************************************}
+ - Author: Christophe Fiorio (fiorio@lirmm.fr)^^J********************************************************}%
%%
%%
%%
@@ -757,135 +1023,133 @@
% algorithm2e package but act as Hcounter was defined. To avoid errors we
% defined \theHalgocf ourself
%%%%
-% \@ifundefined{theHalgocf}{\def\theHalgocf{\thealgocf}}{}%
-% \@ifundefined{theHAlgoLine}{\def\theHAlgoLine{\theAlgoLine}}{}%
-% \@ifundefined{theHalgocf}{\def\theHalgocf{\thealgocf}}{}%
-% \@ifundefined{theHAlgoLine}{\def\theHAlgoLine{\thealgocf}}{}%
-% \@ifundefined{toclevel@algocf}{\def\toclevel@algocf{0}}{}%
+%
+\@ifundefined{theHalgocf}{\def\theHalgocf{\thealgocf}}{}%
+\@ifundefined{theHAlgoLine}{\def\theHAlgoLine{\theAlgoLine}}{}%
+\@ifundefined{theHalgocfproc}{\def\theHalgocfproc{0}}{}%
+\@ifundefined{theHalgocffunc}{\def\theHalgocffunc{0}}{}%
+\@ifundefined{toclevel@algocf}{\def\toclevel@algocf{0}}{}%
+%
+% autoref from hyperref needs an autorefname, so we give it.
+\def\AlgoLineautorefname{\algorithmcflinename}%
+\def\algocfautorefname{\algorithmautorefname}%
+\def\algocfprocautorefname{\procedureautorefname}%
+\def\algocffuncautorefname{\functionautorefname}%
%%
%%
%%
-\newcommand{\@defaultskiptotal}{0.5em}%\Setnlskip{0.5em}
-\newskip\skiptotal\skiptotal=0.5em%\Setnlskip{0.5em}
-\newskip\skiprule
-\newskip\skiphlne
-\newskip\skiptext
-\newskip\skiplength
-\newskip\algomargin
-\newskip\skipalgocfslide\skipalgocfslide=1em
-\newdimen\algowidth
-\newdimen\inoutsize
-\newdimen\inoutline
+\newcommand{\@defaultskiptotal}{0.5em}%
+\newskip\skiptotal\skiptotal=0.5em%
+\newskip\skiplinenumber\skiplinenumber=\hsize\advance\skiplinenumber by-\skiptotal%
+\newskip\skiprule%
+\newskip\skiphlne%
+\newskip\skiptext%
+\newskip\skiplength%
+\newskip\algomargin%
+\newskip\skipalgocfslide\skipalgocfslide=1em%
+\newdimen\algowidth%
+\newdimen\inoutsize%
+\newdimen\inoutline%
+\newdimen\interspacetitleruled\setlength{\interspacetitleruled}{2pt}%
+\newdimen\interspacealgoruled\setlength{\interspacealgoruled}{2pt}%
+\newdimen\interspacetitleboxruled\setlength{\interspacetitleboxruled}{2\lineskip}%
%
\newcommand{\@algoskip}{\smallskip}%
\newcommand{\SetAlgoSkip}[1]{\renewcommand{\@algoskip}{\csname#1\endcsname}}%
\newcommand{\@algoinsideskip}{\relax}%
\newcommand{\SetAlgoInsideSkip}[1]{\renewcommand{\@algoinsideskip}{\csname#1\endcsname}}%
%
-\newsavebox{\algocf@inoutbox}
-\newsavebox{\algocf@inputbox}
+\newsavebox{\algocf@inoutbox}%
+\newsavebox{\algocf@inputbox}%
%%
%%
-\newcommand{\arg@e}{}
-\newcommand{\arg@space}{\ }
-\newcommand{\BlankLine}{\vskip 1ex}
+\newcommand{\arg@e}{}%
+\newcommand{\arg@space}{\ }%
+\newcommand{\BlankLine}{\vskip 1ex}%
%%
-\newcommand{\vespace}{1ex}
+\newcommand{\vespace}{1ex}%
\newcommand{\SetInd}[2]{%
\skiprule=#1%
\skiptext=#2%
-\skiplength=\skiptext\advance\skiplength by \skiprule\advance\skiplength by 0.4pt}
+\skiplength=\skiptext\advance\skiplength by \skiprule\advance\skiplength by 0.4pt}%
\SetInd{0.5em}{1em}
-\algomargin=\leftskip\advance\algomargin by \parindent
-\newcommand{\incmargin}[1]{\advance\algomargin by #1}
-\newcommand{\decmargin}[1]{\advance\algomargin by -#1}
-\newcommand{\Setnlskip}[1]{%
-\renewcommand{\@defaultskiptotal}{#1}%
-\setlength{\skiptotal}{#1}}
-\newcommand{\setnlskip}[1]{\Setnlskip{#1}}%kept for compatibility issue
+\algomargin=\leftskip\advance\algomargin by \parindent%
+\newcommand{\IncMargin}[1]{\advance\algomargin by #1}%
+\newcommand{\DecMargin}[1]{\advance\algomargin by -#1}%
+\newcommand{\SetNlSkip}[1]{%
+ \renewcommand{\@defaultskiptotal}{#1}%
+ \setlength{\skiptotal}{#1}}%
%%
-\newskip\AlCapSkip\AlCapSkip=0ex
-\newskip\AlCapHSkip\AlCapSkip=0ex
-\newcommand{\setalcapskip}[1]{\setlength{\AlCapSkip}{#1}}
-\newcommand{\setalcaphskip}[1]{\setlength{\AlCapHSkip}{#1}}
-\setalcaphskip{.5\algomargin}
+\newskip\AlCapSkip\AlCapSkip=0ex%
+\newskip\AlCapHSkip\AlCapSkip=0ex%
+\newcommand{\SetAlCapSkip}[1]{\setlength{\AlCapSkip}{#1}}%
+\newcommand{\SetAlCapHSkip}[1]{\setlength{\AlCapHSkip}{#1}}%
+\SetAlCapHSkip{.5\algomargin}%
%%
%%
-\newcommand{\Indentp}[1]{\advance\leftskip by #1}
-\newcommand{\Indp}{\advance\leftskip by 1em}
-\newcommand{\Indpp}{\advance\leftskip by 0.5em}
-\newcommand{\Indm}{\advance\leftskip by -1em}
-\newcommand{\Indmm}{\advance\leftskip by -0.5em}
+\newcommand{\Indentp}[1]{\advance\leftskip by #1}%
+\newcommand{\Indp}{\advance\leftskip by 1em}%
+\newcommand{\Indpp}{\advance\leftskip by 0.5em}%
+\newcommand{\Indm}{\advance\leftskip by -1em}%
+\newcommand{\Indmm}{\advance\leftskip by -0.5em}%
%%
%%
%% Line Numbering
%%
%%
% number line style
-\newcommand{\nlSty}[1]{\textnormal{\textbf{#1}}}% default definition
-\newcommand{\Setnlsty}[3]{\renewcommand{\nlSty}[1]{\textnormal{\csname#1\endcsname{#2##1#3}}}}
-%
-%
-\newcommand{\algocf@nlhlabel}[2]{%
- \immediate\write\@auxout{%
- \string\newlabel{#1}{%
- {#2}% current label
- {\thepage}% page
- {}% current label string
-% {AlgoLine\thealgocfline.\theAlgoLine}% current Href
- {AlgoLine\thealgocfline.\theAlgoLine}% current Href
- {}%
- }%
- }%
-}
+\newcommand{\algocf@nlrelsize}{-2}\newcommand{\SetAlgoNlRelativeSize}[1]{\renewcommand{\algocf@nlrelsize}{#1}}%
+\newcommand{\NlSty}[1]{\textnormal{\textbf{\relsize{\algocf@nlrelsize}#1}}}% default definition
+\newcommand{\SetNlSty}[3]{\renewcommand{\NlSty}[1]{\textnormal{\csname#1\endcsname{\relsize{\algocf@nlrelsize}#2##1#3}}}}%
%
% nl definitions
%
+\newsavebox{\algocf@nlbox}%
+\newcommand{\algocf@printnl}[1]{%
+ \ifthenelse{\boolean{algocf@leftlinenumber}}{%
+ \skiplinenumber=\skiptotal\advance\skiplinenumber by\leftskip%
+ \strut\raisebox{0pt}{\llap{\NlSty{#1}\kern\skiplinenumber}}\ignorespaces%
+ }{%
+ \sbox\algocf@nlbox{\NlSty{#1}}%
+ \skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip\advance\skiplinenumber by-\skiptext%
+ \advance\skiplinenumber by\algomargin\advance\skiplinenumber by.3em\advance\skiplinenumber by-\wd\algocf@nlbox%
+ \strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\NlSty{#1\ignorespaces}}}\ignorespaces%
+ }%
+}%
+\newcommand{\algocf@nl@sethref}[1]{%
+ \renewcommand{\theHAlgoLine}{\thealgocfproc.#1}%
+ \hyper@refstepcounter{AlgoLine}\gdef\@currentlabel{#1}%
+}%
\newcommand{\nl}{%
- \@ifundefined{href}{% if not hyperref then do a simple refstepcounter
+ \@ifundefined{hyper@refstepcounter}{% if not hyperref then do a simple refstepcounter
\refstepcounter{AlgoLine}%
}{% else if hyperref, do the anchor so 2 lines in two differents algorithms cannot have the same href
-% \stepcounter{AlgoLine}\Hy@raisedlink{\hyper@anchorstart{AlgoLine\thealgocfline.\theAlgoLine}\hyper@anchorend}%
- \stepcounter{AlgoLine}\Hy@raisedlink{\hyper@anchorstart{AlgoLine\thealgocfline.\theAlgoLine}\hyper@anchorend}%
+ \stepcounter{AlgoLine}\algocf@nl@sethref{\theAlgoLine}%
}% now we can do the line numbering
- \strut\vadjust{\kern-\dp\strutbox\vtop to \dp\strutbox{%
- \baselineskip\dp\strutbox\vss\llap{\scriptsize{\nlSty{\theAlgoLine}\hskip\skiptotal}}\null}}%
+ \algocf@printnl{\theAlgoLine}%
}%
-\newcommand{\nllabel}[1]{%
- \@ifundefined{href}{\label{#1}}{\algocf@nlhlabel{#1}{\theAlgoLine}}}%
%
-\newcommand{\enl}{;%
- \@ifundefined{href}{% if not hyperref then do a simple refstepcounter
+\newcommand{\nllabel}[1]{\label{#1}}%
+%
+\newcommand{\enl}{%
+ \@ifundefined{hyper@refstepcounte}{% if not hyperref then do a simple refstepcounter
\refstepcounter{AlgoLine}%
}{% else if hyperref, do the anchor so 2 lines in two differents algorithms cannot have the same href
-% \stepcounter{AlgoLine}\Hy@raisedlink{\hyper@anchorstart{AlgoLine\thealgocfline.\theAlgoLine}\hyper@anchorend}%
- \stepcounter{AlgoLine}\Hy@raisedlink{\hyper@anchorstart{AlgoLine\thealgocfline.\theAlgoLine}\hyper@anchorend}%
+ \stepcounter{AlgoLine}\algocf@nl@sethref{\theAlgoLine}%
}% now we can do the line numbering
- \hfill\rlap{%
- \scriptsize{\nlSty{\theAlgoLine}}}\par}
-\newcommand{\nlset}[1]{%
- \hskip 0pt\llap{%
- \scriptsize{\nlSty{#1}}\hskip\skiptotal}\ignorespaces}
-%
-% lnl definitions
-%
-\@ifundefined{href}{% if not hyperref
- \newcommand{\lnl}[1]{\nl\label{#1}\ignorespaces}%
-}{% else hyperref
- \newcommand{\lnl}[1]{\nl\algocf@nlhlabel{#1}{\theAlgoLine}\ignorespaces}%
+ \skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip%
+ \strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\strut\NlSty{\theAlgoLine}}}\ignorespaces%
}
+%% nlset
+\newcommand{\nlset}[1]{%
+ \@ifundefined{hyper@refstepcounter}{\protected@edef\@currentlabel{#1}}{\algocf@nl@sethref{#1}}\algocf@printnl{#1}%
+}%
%
-% nlset
+%% lnl definitions
+\newcommand{\lnl}[1]{\nl\label{#1}}%
%
-\@ifundefined{href}{%
- \newcommand{\lnlset}[2]{\nlset{#2}\protected@edef\@currentlabel{#2}\label{#1}}%
-}{%else hyperref
- \newcommand{\lnlset}[2]{\nlset{#2}%
- \Hy@raisedlink{\hyper@anchorstart{AlgoLine.#2}\hyper@anchorend}\algocf@nlhlabel{#1}{#2}%
- \ignorespaces%
- }%
-}
-
+%% lnlset
+\newcommand{\lnlset}[2]{\nlset{#2}\label{#1}}%
%
% set char put at end of each line
%
@@ -894,22 +1158,23 @@
%
% end of line definition
%
-\newcommand{\@endalgoln}{\algocf@endline\par}% default definition: printsemicolon
-\newcommand{\dontprintsemicolon}{\renewcommand{\@endalgoln}{\par}}
-\newcommand{\printsemicolon}{\renewcommand{\@endalgoln}{\algocf@endline\par}}
+\newcommand{\@endalgocfline}{\algocf@endline}% default definition: printsemicolon
+\newcommand{\DontPrintSemicolon}{\renewcommand{\@endalgocfline}{\relax}}%
+\newcommand{\PrintSemicolon}{\renewcommand{\@endalgocfline}{\algocf@endline}}%
+\newcommand{\@endalgoln}{\@endalgocfline\hfill\strut\par}%
%
% line numbering
%
-\newcommand{\linesnumbered}{\setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\everypar={\nl}}}
-\newcommand{\linesnotnumbered}{%
+\newcommand{\LinesNumbered}{\setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\everypar={\nl}}}%
+\newcommand{\LinesNotNumbered}{%
\setboolean{algocf@linesnumbered}{false}%
\renewcommand{\algocf@linesnumbered}{\relax}%
-}
+}%
%
-\newcommand{\linesnumberedhidden}{%
- \setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\everypar{\stepcounter{AlgoLine}}}}
-\newcommand{\showln}{\nlset{\theAlgoLine}\ignorespaces} % display the line number on this line (without labelling)
-\newcommand{\showlnlabel}[1]{\lnlset{#1}{\theAlgoLine}\ignorespaces} % display the line number and label this line
+\newcommand{\LinesNumberedHidden}{%
+ \setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\everypar{\stepcounter{AlgoLine}}}}%
+\newcommand{\ShowLn}{\nlset{\theAlgoLine}\ignorespaces}% display the line number on this line (without labelling)
+\newcommand{\ShowLnLabel}[1]{\lnlset{#1}{\theAlgoLine}\ignorespaces}% display the line number and label this line
%
%%
%
@@ -918,12 +1183,37 @@
%
% Styling text commands
%
-\newcommand{\AlTitleFnt}[1]{\textbf{#1}\unskip}% default definition
-\newcommand{\SetAlTitleFnt}[1]{\renewcommand{\AlTitleFnt}[1]{\csname#1\endcsname{##1}\unskip}}%
\newcommand{\AlFnt}{\relax}% default definition
\newcommand{\SetAlFnt}[1]{\renewcommand{\AlFnt}{#1}}%
-\newcommand{\AlCapFnt}{\AlFnt{}}% default definition
+\newcommand{\AlTitleFnt}{\relax}% default definition
+\newcommand{\SetAlTitleFnt}[1]{\renewcommand{\AlTitleFnt}{#1}}%
+%
+\newcommand{\AlCapFnt}{\relax}% default definition
\newcommand{\SetAlCapFnt}[1]{\renewcommand{\AlCapFnt}{#1}}%
+\newcommand{\AlCapNameFnt}{\relax}% default definition
+\newcommand{\SetAlCapNameFnt}[1]{\renewcommand{\AlCapNameFnt}{#1}}%
+%
+\newcommand{\ProcFnt}{\relax}% default definition
+\newcommand{\SetProcFnt}[1]{\renewcommand{\ProcFnt}{#1}}%
+\newcommand{\ProcNameFnt}{\relax}% default definition
+\newcommand{\SetProcNameFnt}[1]{\renewcommand{\ProcNameFnt}{#1}}%
+\newcommand{\ProcArgFnt}{\relax}% default definition
+\newcommand{\SetProcArgFnt}[1]{\renewcommand{\ProcArgFnt}{#1}}%
+%
+\newcommand{\AlTitleSty}[1]{\textbf{#1}\unskip}% default definition
+\newcommand{\SetAlTitleSty}[1]{\renewcommand{\AlTitleSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
+\newcommand{\AlCapSty}[1]{\textnormal{\textbf{#1}}\unskip}% default definition
+\newcommand{\SetAlCapSty}[1]{\renewcommand{\AlCapSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
+\newcommand{\AlCapNameSty}[1]{\textnormal{#1}\unskip}% default definition
+\newcommand{\SetAlCapNameSty}[1]{\renewcommand{\AlCapNameSty}[1]{\textnormal{\csname #1\endcsname{##1}}\unskip}}%
+%
+\newcommand{\ProcSty}[1]{\AlCapSty{#1}}%
+\newcommand{\SetProcSty}[1]{\renewcommand{\ProcSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
+\newcommand{\ProcNameSty}[1]{\AlCapNameSty{#1}}%
+\newcommand{\SetProcNameSty}[1]{\renewcommand{\ProcNameSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
+\newcommand{\ProcArgSty}[1]{\AlCapNameSty{#1}}%
+\newcommand{\SetProcArgSty}[1]{\renewcommand{\ProcArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
+%
\newcommand{\KwSty}[1]{\textnormal{\textbf{#1}}\unskip}% default definition
\newcommand{\SetKwSty}[1]{\renewcommand{\KwSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\ArgSty}[1]{\textnormal{\emph{#1}}\unskip}%\SetArgSty{emph}
@@ -936,80 +1226,110 @@
\newcommand{\SetCommentSty}[1]{\renewcommand{\CommentSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\TitleSty}[1]{#1\unskip}%\SetTitleSty{}{}
\newcommand{\SetTitleSty}[2]{\renewcommand{\TitleSty}[1]{%
-\csname#1\endcsname{\csname#2\endcsname##1}}\unskip}
+\csname#1\endcsname{\csname#2\endcsname##1}}\unskip}%
%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Block basic commands
%
-\newcommand{\al@push}[1]{\advance\skiptotal by #1\moveright #1}
-\newcommand{\al@pop}[1]{\advance\skiptotal by -#1}
-\newcommand{\al@addskiptotal}{\advance\skiptotal by 0.4pt\advance\hsize by -0.4pt} % 0.4 pt=width of \vrule
-\newcommand{\al@subskiptotal}{\advance\skiptotal by -0.4pt\advance\hsize by 0.4pt} % 0.4 pt=width of \vrule
+\newcommand{\algocf@push}[1]{\advance\skiptotal by #1\moveright #1}%
+\newcommand{\algocf@pop}[1]{\advance\skiptotal by -#1}%
+\newcommand{\algocf@addskiptotal}{\advance\skiptotal by 0.4pt\advance\hsize by -0.4pt}% 0.4 pt=width of \vrule
+\newcommand{\algocf@subskiptotal}{\advance\skiptotal by -0.4pt\advance\hsize by 0.4pt}% 0.4 pt=width of \vrule
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%
+%% group of instructions definition
%
\skiphlne=.8ex%
-\newcommand{\Setvlineskip}[1]{\skiphlne=#1}
-\newcommand{\V@line}[1]{% no vskip in between boxes but a strut to separate them,
+\newcommand{\SetVlineSkip}[1]{\skiphlne=#1}%
+%
+%% block with a vertical line end by a little horizontal line
+\newcommand{\algocf@Vline}[1]{% no vskip in between boxes but a strut to separate them,
\strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
- \al@push{\skiprule}% move to the right before the vertical rule
+ \algocf@push{\skiprule}% move to the right before the vertical rule
\hbox{\vrule%
- \vtop{\al@push{\skiptext}%move the right after the rule
- \vtop{\al@addskiptotal\advance\hsize by -\skiplength #1}\Hlne}}\vskip\skiphlne% inside the block
- \al@pop{\skiprule}%\al@subskiptotal% restore indentation
+ \vtop{\algocf@push{\skiptext}%move the right after the rule
+ \vtop{\algocf@addskiptotal\advance\hsize by -\skiplength #1}\Hlne}}\vskip\skiphlne% inside the block
+ \algocf@pop{\skiprule}%\algocf@subskiptotal% restore indentation
\nointerlineskip}% no vskip after
%
-\newcommand{\V@sline}[1]{% no vskip in between boxes but a strut to separate them,
+%% block with a vertical line
+\newcommand{\algocf@Vsline}[1]{% no vskip in between boxes but a strut to separate them,
\strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
- \al@push{\skiprule}% move to the right before the vertical rule
+ \algocf@push{\skiprule}% move to the right before the vertical rule
\hbox{\vrule% the vertical rule
- \vtop{\al@push{\skiptext}%move the right after the rule
- \vtop{\al@addskiptotal\advance\hsize by -\skiplength #1}}}% inside the block
- \al@pop{\skiprule}}% restore indentation
- %\nointerlineskip}% no vskip after
+ \vtop{\algocf@push{\skiptext}%move the right after the rule
+ \vtop{\algocf@addskiptotal\advance\hsize by -\skiplength #1}}}% inside the block
+ \algocf@pop{\skiprule}}% restore indentation
%
-\newcommand{\H@lne}{\hrule height 0.4pt depth 0pt width .5em}
+\newcommand{\algocf@Hlne}{\hrule height 0.4pt depth 0pt width .5em}%
%
-\newcommand{\No@line}[1]{% no vskip in between boxes but a strut to separate them,
+%% block without line
+\newcommand{\algocf@Noline}[1]{% no vskip in between boxes but a strut to separate them,
\strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
- \al@push{\skiprule}%
+ \algocf@push{\skiprule}%
\hbox{%
- \vtop{\al@push{\skiptext}%
+ \vtop{\algocf@push{\skiptext}%
\vtop{\advance\hsize by -\skiplength #1}}}% inside the block
- \al@pop{\skiprule}}%
- %\nointerlineskip}% no vskip after
+ \algocf@pop{\skiprule}%
+ % \nointerlineskip% no vskip after
+}%
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%
%% default=NoLine
%
-\newcommand{\a@@block}[2]{\No@line{##1}\KwSty{##2}\par}
-\newcommand{\a@block}[2]{\a@@block{#1}{#2}} % this to be redefined as a@group in
- % case of noend option
-\newcommand{\a@group}[1]{\No@line{##1}}
-\newcommand{\Hlne}{}
+\newcommand{\algocf@group}[1]{\algocf@Noline{##1}}% group: set of instruction depending from another (ex: then part of the If)
+\newcommand{\algocf@@block}[2]{\algocf@Noline{##1}\KwSty{##2}\par}% block: group with a end keyword.
+\newcommand{\algocf@block}[2]{\algocf@@block{#1}{#2}}% command that will be used and redefined accordingly to noend option
+\newcommand{\algocf@setBlock}{%
+ \ifthenelse{\boolean{algocf@optnoend}}{% if no end option
+ \renewcommand{\algocf@block}[2]{\algocf@group{##1}}% block will be a group
+ }{% else
+ \renewcommand{\algocf@block}[2]{\algocf@@block{##1}{##2}}% block stays a block
+ }%
+}%
+%
+\newcommand{\Hlne}{}% little hrizontal line ending a block in vline mode
+%
+\newcommand{\@algocf@endoption}[1]{#1}%
+\newboolean{algocf@optnoend}\setboolean{algocf@optnoend}{false}%
%
+\newcommand{\SetAlgoLongEnd}{%%%%%%%%%%%%%%%%%%%%%%%%% Long End
+ \setboolean{algocf@optnoend}{false}%
+ \renewcommand{\@algocf@endoption}[1]{##1}%
+ \algocf@setBlock}%
%
-\newcommand{\SetNoline}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline
-\renewcommand{\a@@block}[2]{\No@line{##1}\KwSty{##2}\strut\par}%
-\renewcommand{\a@group}[1]{\No@line{##1}}
-\renewcommand{\Hlne}{}}
+\newcommand{\SetAlgoShortEnd}{%%%%%%%%%%%%%%%%%%%%%%%% ShortEnd
+ \setboolean{algocf@optnoend}{false}%
+ \renewcommand{\@algocf@endoption}[1]{\@firstword##1 \@nil}%
+ \algocf@setBlock}%
%
-\newcommand{\SetVline}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Vline
-\renewcommand{\a@@block}[2]{\V@line{##1}}%
-\renewcommand{\a@group}[1]{\V@sline{##1}\strut\ignorespaces}
-\renewcommand{\Hlne}{\H@lne}}
+\newcommand{\SetAlgoNoEnd}{%%%%%%%%%%%%%%%%%%%%%%%%%%% NoEnd
+ \setboolean{algocf@optnoend}{true}%
+ \renewcommand{\@algocf@endoption}[1]{}%
+ \algocf@setBlock}%
+%
+\newcommand{\SetAlgoNoLine}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline
+\renewcommand{\algocf@@block}[2]{\algocf@Noline{##1}\KwSty{##2}\strut\par}%
+\renewcommand{\algocf@group}[1]{\algocf@Noline{##1}}%
+\renewcommand{\Hlne}{}}%
%
-\newcommand{\SetLine}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line
-\renewcommand{\a@@block}[2]{\strut\V@sline{##1}\KwSty{##2}\strut\par}% no skip after a block so garantie at least a line
-\renewcommand{\a@group}[1]{\V@sline{##1}\strut\ignorespaces}
-\renewcommand{\Hlne}{}}
+\newcommand{\SetAlgoVlined}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Vline
+\renewcommand{\algocf@@block}[2]{\algocf@Vline{##1}}%
+\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}%
+\renewcommand{\Hlne}{\algocf@Hlne}}%
+%
+\newcommand{\SetAlgoLined}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line
+\renewcommand{\algocf@@block}[2]{\strut\algocf@Vsline{##1}\KwSty{##2}\strut\par}% no skip after a block so garantie at least a line
+\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}%
+\renewcommand{\Hlne}{}}%
%
\newcommand{\SetNothing}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline
-\renewcommand{\a@@block}[2]{\No@line{##1}\par}%
+\renewcommand{\algocf@@block}[2]{\algocf@Noline{##1}\par}%
%\long
-\renewcommand{\a@group}[1]{\No@line{##1}}
-\renewcommand{\Hlne}{}}
+\renewcommand{\algocf@group}[1]{\algocf@Noline{##1}}%
+\renewcommand{\Hlne}{}}%
%
%%
%%
@@ -1025,7 +1345,7 @@
%
\newcommand{\algocf@newinout}{\par\parindent=\wd\algocf@inoutbox}% to put right indentation after a \\ in the KwInOut
\newcommand{\SetKwInOut}[2]{%
- \sbox\algocf@inoutbox{\hbox{\KwSty{#2}\algocf@typo:\ }}%
+ \sbox\algocf@inoutbox{\KwSty{#2}\algocf@typo:}%
\expandafter\ifx\csname InOutSizeDefined\endcsname\relax% if first time used
\newcommand\InOutSizeDefined{}\setlength{\inoutsize}{\wd\algocf@inoutbox}%
\else% else keep the larger dimension
@@ -1033,8 +1353,8 @@
\fi% the dimension of the box is now defined.
\@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
\expandafter\algocf@mkcmd\csname#1\endcsname[1]{%
- \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\everypar={\relax}}
- {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\hfill:\mbox{\ }}##1\par}
+ \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\everypar={\relax}}%
+ {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}%
\algocf@linesnumbered% reset the numbering of the lines
}}%
%
@@ -1043,7 +1363,7 @@
\newcommand{\ResetInOut}[1]{%
\sbox\algocf@inoutbox{\hbox{\KwSty{#1}\algocf@typo:\ }}%
\setlength{\inoutsize}{\wd\algocf@inoutbox}%
- }
+ }%
%
%
%%%
@@ -1063,7 +1383,31 @@
\expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\DataSty{#2(}\ArgSty{##1}\DataSty{)}}%
\expandafter\algocf@mkcmd\csname#1\endcsname{%
\@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}%
- }
+ }%
+%
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% tallent:
+%
+% Add following macros:
+% \SetKwHangingKw: [kw] ------------ <= hanging determined by [kw]
+% ------------
+% Should act like a combination of \SetKwInput and \SetKw.
+% Based on \SetKwInput:
+% - remove ':' at end of keyword
+% - do not reset numbering
+% - use separate savebox
+\newsavebox{\algocf@hangingbox}
+\newcommand{\algocf@newhanging}{\par\parindent=\wd\algocf@hangingbox}% to put right indentation after a \\ in the KwInput
+\newcommand{\SetKwHangingKw}[2]{%
+ \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
+ \expandafter\algocf@mkcmd\csname#1\endcsname[1]{%
+ \sbox\algocf@hangingbox{\hbox{\KwSty{#2}\algocf@typo\ }}%
+ {\let\\\algocf@newhanging\hangindent=\wd\algocf@hangingbox\hangafter=1\unhbox\algocf@hangingbox##1\;}%
+ }%
+}%
+%
+%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Comments macros
@@ -1074,10 +1418,10 @@
% comment.
%
% first side comment justification
-\newcommand{\SetSideCommentLeft}{\setboolean{algocf@scleft}{true}}
-\newcommand{\SetSideCommentRight}{\setboolean{algocf@scleft}{false}}
-\newcommand{\SetNoFillComment}{\setboolean{algocf@optfillcomment}{false}}
-\newcommand{\SetFillComment}{\setboolean{algocf@optfillcomment}{true}}
+\newcommand{\SetSideCommentLeft}{\setboolean{algocf@scleft}{true}}%
+\newcommand{\SetSideCommentRight}{\setboolean{algocf@scleft}{false}}%
+\newcommand{\SetNoFillComment}{\setboolean{algocf@optfillcomment}{false}}%
+\newcommand{\SetFillComment}{\setboolean{algocf@optfillcomment}{true}}%
%
% next comment and side comment
%
@@ -1094,7 +1438,7 @@
\newboolean{algocf@altsidecomment}\setboolean{algocf@altsidecomment}{false}%
\newcommand{\algocf@scpar}{\ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\par}}%
\newcommand{\algocf@sclfill}{\ifthenelse{\boolean{algocf@scleft}}{\algocf@fillcomment}{\relax}}%
-\newcommand{\algocf@scrfill}{\ifthenelse{\boolean{algocf@scleft}}{\relax}{\hfill}}
+\newcommand{\algocf@scrfill}{\ifthenelse{\boolean{algocf@scleft}}{\relax}{\hfill}}%
\newcommand{\algocf@startsidecomment}{\usebox\algocf@inputbox}%
\newcommand{\algocf@endsidecomment}{\algocf@endmarkcomment\algocf@scpar}%
\newcommand{\algocf@endstartsidecomment}{%
@@ -1138,13 +1482,14 @@
\renewcommand{\algocf@endmarkcomment}{#3}%
\let\\\algocf@endstartsidecomment%
% here is the comment
- \ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\algocf@endline\ }%
+ %\ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\algocf@endline\ }%
+ \ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\@endalgocfline\ }%
\algocf@scrfill\algocf@startsidecomment\CommentSty{%
\strut\ignorespaces##1\strut\algocf@sclfill#3}\algocf@scpar%
}%
\algocf@linesnumbered% reset the numbering of the lines
}
- \expandafter\algocf@mkcmd\csname#1\endcsname{\@ifstar{\csname algocf@#1@star\endcsname}{\csname algocf@#1\endcsname}}
+ \expandafter\algocf@mkcmd\csname#1\endcsname{\@ifstar{\csname algocf@#1@star\endcsname}{\csname algocf@#1\endcsname}}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1156,18 +1501,30 @@
\expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\KwSty{#2} \ArgSty{##1}}%
\expandafter\algocf@mkcmd\csname#1\endcsname{%
\@ifnextchar\bgroup{\csname @#1\endcsname}{\KwSty{#2}\xspace}}%
- }
+ }%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% KwFunction
%
\newcommand{\SetKwFunction}[2]{%
- \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
- \expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\FuncSty{#2(}\ArgSty{##1}\FuncSty{)}}%
- \expandafter\algocf@mkcmd\csname#1\endcsname{%
+%%% use of gdef since newcommand doesn't manage to define the macro when SetKwFunction is used in \algocf@caption@proc
+ \expandafter\gdef\csname @#1\endcsname##1{\FuncSty{#2(}\ArgSty{##1}\FuncSty{)}}%
+ \expandafter\gdef\csname#1\endcsname{%
\@ifnextchar\bgroup{\csname @#1\endcsname}{\FuncSty{#2}\xspace}}%
-}
+}%
+%
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% KwTab
+%
+\newcommand{\SetKwArray}[2]{%
+%%% use of gdef since newcommand doesn't manage to define the macro when SetKwFunction is used in \algocf@caption@proc
+ \expandafter\gdef\csname @#1\endcsname##1{\DataSty{#2[}\ArgSty{##1}\DataSty{]}}%
+ \expandafter\gdef\csname#1\endcsname{%
+ \@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}%
+}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
@@ -1176,19 +1533,19 @@
\newcommand{\SetKwBlock}[3]{%
\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
% side text or not?
-\expandafter\def\csname#1\endcsname{ %Begin
- \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
+\expandafter\def\csname#1\endcsname{%Begin
+ \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}%
% with side text
\expandafter\def\csname algocf@#1opt\endcsname(##1)##2{% \Begin(){}
- \KwSty{#2} ##1\a@group{##2}\KwSty{#3}%
+ \KwSty{#2} ##1\algocf@block{##2}{\@algocf@endoption{#3}}%
\@ifnextchar({\csname algocf@#1end\endcsname}{\par}}%
% without side text at the beginning
\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[1]{% \Begin{}
- \KwSty{#2}\a@group{##1}\KwSty{#3}\@ifnextchar({\csname algocf@#1end\endcsname}{\par}}%
+ \KwSty{#2}\algocf@block{##1}{\@algocf@endoption{#3}}\@ifnextchar({\csname algocf@#1end\endcsname}{\par}}%
% side text at the end
\expandafter\def\csname algocf@#1end\endcsname(##1){% \Begin{}
\ ##1\par}%
-}
+}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
@@ -1198,60 +1555,59 @@
%%%% Switch
\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
% side text or not?
-\expandafter\def\csname#1\endcsname{ %Switch
- \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
+\expandafter\def\csname#1\endcsname{%Switch
+ \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}%
% with side text
\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \Switch(){}{}
- \KwSty{#4} \ArgSty{##2} \KwSty{#5} ##1\a@block{##3}{#8}}%
+ \KwSty{#4} \ArgSty{##2} \KwSty{#5} ##1\algocf@block{##3}{\@algocf@endoption{#8}}}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \Switch{}{}
- \KwSty{#4} \ArgSty{##1} \KwSty{#5}\a@block{##2}{#8}}%
+ \KwSty{#4} \ArgSty{##1} \KwSty{#5}\algocf@block{##2}{\@algocf@endoption{#8}}}%
% side text at the end
\expandafter\def\csname algocf@#1end\endcsname(##1){% \Switch{}{}()
-
-}
-
+}%
+%
%%%% Case
\@ifundefined{algocf@#2}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
% side text or not?
-\expandafter\def\csname#2\endcsname{ %Case
- \@ifnextchar({\csname algocf@#2opt\endcsname}{\csname algocf@#2\endcsname}}
-\expandafter\def\csname u#2\endcsname{ %uCase
- \@ifnextchar({\csname algocf@u#2opt\endcsname}{\csname algocf@u#2\endcsname}}
-\expandafter\def\csname l#2\endcsname{ %lCase
- \@ifnextchar({\csname algocf@l#2opt\endcsname}{\csname algocf@l#2\endcsname}}
+\expandafter\def\csname#2\endcsname{%Case
+ \@ifnextchar({\csname algocf@#2opt\endcsname}{\csname algocf@#2\endcsname}}%
+\expandafter\def\csname u#2\endcsname{%uCase
+ \@ifnextchar({\csname algocf@u#2opt\endcsname}{\csname algocf@u#2\endcsname}}%
+\expandafter\def\csname l#2\endcsname{%lCase
+ \@ifnextchar({\csname algocf@l#2opt\endcsname}{\csname algocf@l#2\endcsname}}%
% with side text
\expandafter\def\csname algocf@#2opt\endcsname(##1)##2##3{% \Case(){}{}
- \KwSty{#6} \ArgSty{##2} ##1\a@block{##3}{#8}}%
+ \KwSty{#6} \ArgSty{##2} ##1\algocf@block{##3}{\@algocf@endoption{#8}}}%
\expandafter\def\csname algocf@u#2opt\endcsname(##1)##2##3{% \uCase(){}{}
- \KwSty{#6} \ArgSty{##2} ##1\a@group{##3}}%
+ \KwSty{#6} \ArgSty{##2} ##1\algocf@group{##3}}%
\expandafter\def\csname algocf@l#2opt\endcsname(##1)##2##3{% \lCase(){}{}
\KwSty{#6} \ArgSty{##2} ##3\algocf@endline\ ##1\par}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@#2\endcsname[2]{% \Case{}{}
- \KwSty{#6} \ArgSty{##1}\a@block{##2}{#8}}%
+ \KwSty{#6} \ArgSty{##1}\algocf@block{##2}{\@algocf@endoption{#8}}}%
\expandafter\algocf@mkcmd\csname algocf@u#2\endcsname[2]{% \uCase{}{}
- \KwSty{#6} \ArgSty{##1}\a@group{##2}}%
+ \KwSty{#6} \ArgSty{##1}\algocf@group{##2}}%
\expandafter\algocf@mkcmd\csname algocf@l#2\endcsname[2]{% \lCase{}{}
\KwSty{#6} \ArgSty{##1} ##2}%
%%%% Other
\@ifundefined{algocf@#3}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
-% side text or not?
-\expandafter\def\csname#3\endcsname{ %Other
- \@ifnextchar({\csname algocf@#3opt\endcsname}{\csname algocf@#3\endcsname}}
-\expandafter\def\csname l#3\endcsname{ %Other
- \@ifnextchar({\csname algocf@l#3opt\endcsname}{\csname algocf@l#3\endcsname}}
+% side text or not?
+\expandafter\def\csname#3\endcsname{%Other
+ \@ifnextchar({\csname algocf@#3opt\endcsname}{\csname algocf@#3\endcsname}}%
+\expandafter\def\csname l#3\endcsname{%Other
+ \@ifnextchar({\csname algocf@l#3opt\endcsname}{\csname algocf@l#3\endcsname}}%
% with side text
\expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \Other(){}{}
- \KwSty{#7} ##1\a@block{##2}{#8}}%
+ \KwSty{#7} ##1\algocf@block{##2}{\@algocf@endoption{#8}}}%
\expandafter\def\csname algocf@l#3opt\endcsname(##1)##2{% \Other(){}{}
\KwSty{#7} ##2\algocf@endline\ ##1\par}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@#3\endcsname[1]{% default
- \KwSty{#7}\a@block{##1}{#8}}%
+ \KwSty{#7}\algocf@block{##1}{\@algocf@endoption{#8}}}%
\expandafter\algocf@mkcmd\csname algocf@l#3\endcsname[1]{% ldefault
\KwSty{#7} ##1}%
-}
+}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% If macros
@@ -1262,9 +1618,9 @@
\@ifundefined{#1@ifthen}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
\expandafter\algocf@mkcmd\csname #1@ifthen\endcsname[1]{%
\KwSty{#4} \ArgSty{##1} \KwSty{#5}}%
-\expandafter\algocf@mkcmd\csname #1@endif\endcsname[1]{\a@block{##1}{#8}}%
-\expandafter\algocf@mkcmd\csname #1@noend\endcsname[1]{\a@group{##1}}%
-\expandafter\algocf@mkcmd\csname #1@else\endcsname[1]{\a@group{##1}\KwSty{#7}}%
+\expandafter\algocf@mkcmd\csname #1@endif\endcsname[1]{\algocf@block{##1}{\@algocf@endoption{#8}}}%
+\expandafter\algocf@mkcmd\csname #1@noend\endcsname[1]{\algocf@group{##1}}%
+\expandafter\algocf@mkcmd\csname #1@else\endcsname[1]{\algocf@group{##1}\KwSty{#7}}%
\@ifundefined{#2@elseif}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
\expandafter\algocf@mkcmd\csname #2@elseif\endcsname[1]{%
\KwSty{#6} \ArgSty{##1} \KwSty{#5}}%
@@ -1275,7 +1631,7 @@
\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
% side text or not?
\expandafter\def\csname#1\endcsname{%
- \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
+ \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}%
% with side text
\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \If(){}{}
\csname #1@ifthen\endcsname{##2} ##1\csname #1@endif\endcsname{##3}}%
@@ -1287,32 +1643,32 @@
%
% side text or not?
\expandafter\def\csname e#1\endcsname{%
- \@ifnextchar({\csname algocf@e#1opt\endcsname}{\csname algocf@e#1optif\endcsname}}
+ \@ifnextchar({\csname algocf@e#1thenopt\endcsname}{\csname algocf@e#1then\endcsname}}%
% with side text after if
-\expandafter\def\csname algocf@e#1opt\endcsname(##1)##2##3{% \eIf()
+\expandafter\def\csname algocf@e#1thenopt\endcsname(##1)##2##3{% \eIf()
\csname #1@ifthen\endcsname{##2} ##1\csname #1@else\endcsname{##3}%
- \csname algocf@e#1opte\endcsname}
+ \csname algocf@e#1thenelse\endcsname}%
% without side text after if
-\expandafter\def\csname algocf@e#1optif\endcsname##1##2{% \eIf()
+\expandafter\def\csname algocf@e#1then\endcsname##1##2{% \eIf()
\csname #1@ifthen\endcsname{##1}\csname #1@else\endcsname{##2}%
- \csname algocf@e#1opte\endcsname}%
+ \csname algocf@e#1thenelse\endcsname}%
% side text after else or not ?
-\expandafter\def\csname algocf@e#1opte\endcsname{%
- \@ifnextchar({\csname algocf@e#1optopt\endcsname}{\csname algocf@e#1\endcsname}}
+\expandafter\def\csname algocf@e#1thenelse\endcsname{%
+ \@ifnextchar({\csname algocf@e#1elseopt\endcsname}{\csname algocf@e#1else\endcsname}}%
% else with a side text
-\expandafter\def\csname algocf@e#1optopt\endcsname(##1)##2{%
- ##1\csname #1@endif\endcsname{##2}}
+\expandafter\def\csname algocf@e#1elseopt\endcsname(##1)##2{%
+ ##1\csname #1@endif\endcsname{##2}}%
% else without side text
-\expandafter\algocf@mkcmd\csname algocf@e#1\endcsname[1]{%
- \csname #1@endif\endcsname{##1}}
+\expandafter\algocf@mkcmd\csname algocf@e#1else\endcsname[1]{%
+ \csname #1@endif\endcsname{##1}}%
%
%%%% If then
%
% side text or not?
\expandafter\def\csname l#1\endcsname{% lif
- \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}
+ \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}%
\expandafter\def\csname u#1\endcsname{% uif
- \@ifnextchar({\csname algocf@u#1opt\endcsname}{\csname algocf@u#1\endcsname}}
+ \@ifnextchar({\csname algocf@u#1opt\endcsname}{\csname algocf@u#1\endcsname}}%
% with side text
\expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lIf(){}{}
\csname #1@ifthen\endcsname{##2} ##3\algocf@endline\ ##1\par}%
@@ -1329,41 +1685,41 @@
\@ifundefined{algocf@#2}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
% side text or not?
\expandafter\def\csname#2\endcsname{% ElseIf
- \@ifnextchar({\csname algocf@#2opt\endcsname}{\csname algocf@#2\endcsname}}
+ \@ifnextchar({\csname algocf@#2opt\endcsname}{\csname algocf@#2\endcsname}}%
% with side text
\expandafter\def\csname algocf@#2opt\endcsname(##1)##2##3{% \ElseIf(){}{}
- \csname #2@elseif\endcsname{##2} ##1\csname #1@endif\endcsname{##3}}
+ \csname #2@elseif\endcsname{##2} ##1\csname #1@endif\endcsname{##3}}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@#2\endcsname[2]{% \ElseIf{}{}
- \csname #2@elseif\endcsname{##1}\csname #1@endif\endcsname{##2}}
+ \csname #2@elseif\endcsname{##1}\csname #1@endif\endcsname{##2}}%
%
%%%% ElseIf
%
% side text or not?
\expandafter\def\csname l#2\endcsname{% lElseIf
- \@ifnextchar({\csname algocf@l#2opt\endcsname}{\csname algocf@l#2\endcsname}}
+ \@ifnextchar({\csname algocf@l#2opt\endcsname}{\csname algocf@l#2\endcsname}}%
\expandafter\def\csname u#2\endcsname{% uElseIf
- \@ifnextchar({\csname algocf@u#2opt\endcsname}{\csname algocf@u#2\endcsname}}
+ \@ifnextchar({\csname algocf@u#2opt\endcsname}{\csname algocf@u#2\endcsname}}%
% with side text
\expandafter\def\csname algocf@l#2opt\endcsname(##1)##2##3{% \lElseIf(){}{}
- \csname #2@elseif\endcsname{##2} ##3\algocf@endline\ ##1\par}
+ \csname #2@elseif\endcsname{##2} ##3\algocf@endline\ ##1\par}%
\expandafter\def\csname algocf@u#2opt\endcsname(##1)##2##3{% \uElseIf(){}{}
- \csname #2@elseif\endcsname{##2} ##1\csname #1@noend\endcsname{##3}}
+ \csname #2@elseif\endcsname{##2} ##1\csname #1@noend\endcsname{##3}}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@l#2\endcsname[2]{% \lElseIf{}{}
\csname #2@elseif\endcsname{##1} ##2}%
\expandafter\algocf@mkcmd\csname algocf@u#2\endcsname[2]{% \uElseIf{}{}
- \csname #2@elseif\endcsname{##1}\csname #1@noend\endcsname{##2}}
+ \csname #2@elseif\endcsname{##1}\csname #1@noend\endcsname{##2}}%
%
%%%% Else {} endif
%
\@ifundefined{algocf@#3}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
% side text or not?
\expandafter\def\csname#3\endcsname{% Else
- \@ifnextchar({\csname algocf@#3opt\endcsname}{\csname algocf@#3\endcsname}}
+ \@ifnextchar({\csname algocf@#3opt\endcsname}{\csname algocf@#3\endcsname}}%
% with side text
\expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \Else(){}
- \csname #3@else\endcsname\ ##1\csname #1@endif\endcsname{##2}}
+ \csname #3@else\endcsname\ ##1\csname #1@endif\endcsname{##2}}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@#3\endcsname[1]{% \Else{}
\csname #3@else\endcsname\csname #1@endif\endcsname{##1}}%
@@ -1372,29 +1728,19 @@
%
% side text or not?
\expandafter\def\csname l#3\endcsname{% lElse
- \@ifnextchar({\csname algocf@l#3opt\endcsname}{\csname algocf@l#3\endcsname}}
+ \@ifnextchar({\csname algocf@l#3opt\endcsname}{\csname algocf@l#3\endcsname}}%
\expandafter\def\csname u#3\endcsname{% uElse
- \@ifnextchar({\csname algocf@u#3opt\endcsname}{\csname algocf@u#3\endcsname}}
+ \@ifnextchar({\csname algocf@u#3opt\endcsname}{\csname algocf@u#3\endcsname}}%
% with side text
\expandafter\def\csname algocf@l#3opt\endcsname(##1)##2{% \lElse(){}
- \csname #3@else\endcsname\ ##2\algocf@endline\ ##1\par}
-\expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \uElse(){}
- \csname #3@else\endcsname\ ##1\csname #1@noend\endcsname{##2}}
+ \csname #3@else\endcsname\ ##2\algocf@endline\ ##1\par}%
+\expandafter\def\csname algocf@u#3opt\endcsname(##1)##2{% \uElse(){}
+ \csname #3@else\endcsname\ ##1\csname #1@noend\endcsname{##2}}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@l#3\endcsname[1]{% \lElse{}
\csname #3@else\endcsname\ ##1}%
\expandafter\algocf@mkcmd\csname algocf@u#3\endcsname[1]{% \uElse{}
\csname #3@else\endcsname\csname #1@noend\endcsname{##1}}%
-}
-%
-% old for backward compatibility
-\newcommand{\SetKwIf}[6]{%
- \SetKwIF{#1}{cf@dumb}{#2}{#3}{#4}{cf@dumb}{#5}{#6}%
- \typeout{**** WARNING: SetKwIf deprecated: use SetKwIF instead*****^^J}%
-}%
-\newcommand{\SetKwIfElseIf}[8]{%
- \SetKwIF{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
- \typeout{**** WARNING: SetKwIfElseIf deprecated: use SetKwIF instead*****^^J}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1404,21 +1750,21 @@
\newcommand{\SetKwFor}[4]{%
\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
% side text or not?
-\expandafter\def\csname#1\endcsname{ %For
- \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
-\expandafter\def\csname l#1\endcsname{ %For
- \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}
+\expandafter\def\csname#1\endcsname{%For
+ \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}%
+\expandafter\def\csname l#1\endcsname{%For
+ \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}%
% with side text
\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \For(){}{}
- \KwSty{#2} \ArgSty{##2} \KwSty{#3} ##1\a@block{##3}{#4}}%
+ \KwSty{#2} \ArgSty{##2} \KwSty{#3} ##1\algocf@block{##3}{\@algocf@endoption{#4}}}%
\expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lFor(){}{}
- \KwSty{#2} \ArgSty{##2} \KwSty{#3} ##3\algocf@endline\ ##1\par}
+ \KwSty{#2} \ArgSty{##2} \KwSty{#3} ##3\algocf@endline\ ##1\par}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \For{}{}
- \KwSty{#2} \ArgSty{##1} \KwSty{#3}\a@block{##2}{#4}}%
+ \KwSty{#2} \ArgSty{##1} \KwSty{#3}\algocf@block{##2}{\@algocf@endoption{#4}}}%
\expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lFor{}{}
\KwSty{#2} \ArgSty{##1} \KwSty{#3} ##2}%
-}
+}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
@@ -1426,14 +1772,14 @@
%
\newcommand{\SetKwRepeat}[3]{%
\@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
-% side text or not?
-\expandafter\def\csname#1\endcsname{ %Repeat
- \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
-\expandafter\def\csname l#1\endcsname{ %lRepeat
- \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}
+% side text or not?
+\expandafter\def\csname#1\endcsname{% Repeat
+ \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}%
+\expandafter\def\csname l#1\endcsname{% lRepeat
+ \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}%
% with side text
\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \Repeat(){}{}
- \KwSty{#2} ##1\a@group{##3}\KwSty{#3} \ArgSty{##2}%
+ \KwSty{#2} ##1\algocf@group{##3}\KwSty{#3} \ArgSty{##2}%
\@ifnextchar({\csname algocf@#1optopt\endcsname}{\@endalgoln}%
}%
\expandafter\def\csname algocf@#1optopt\endcsname(##1){% \Repeat(){}{}()
@@ -1442,12 +1788,12 @@
\KwSty{#2} ##3 \KwSty{#3} \ArgSty{##2}\algocf@endline\ ##1\par}%
% without side text
\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \Repeat{}{}
- \KwSty{#2}\a@group{##2}\KwSty{#3} \ArgSty{##1}
+ \KwSty{#2}\algocf@group{##2}\KwSty{#3} \ArgSty{##1}%
\@ifnextchar({\csname algocf@#1optopt\endcsname}{\@endalgoln}%
}%
\expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lRepeat{}{}
\KwSty{#2} ##2 \KwSty{#3} \ArgSty{##1}}%
-}
+}%
%
%
%
@@ -1463,7 +1809,14 @@
% #2 is the text given in argument by the user in the \caption macro
%
%%%%% text of caption
-\newcommand{\algocf@captiontext}[2]{#1\algocf@typo: \AlCapFnt{}#2} % text of caption
+\newcommand{\algocf@captionlayout}[1]{#1}%
+\newcommand{\SetAlgoCaptionLayout}[1]{%
+ \renewcommand{\algocf@captionlayout}[1]{\csname #1\endcsname{##1}}}%
+\newcommand{\algocf@capseparator}{:}%
+\newcommand{\SetAlgoCaptionSeparator}[1]{\renewcommand{\algocf@capseparator}{#1}}%
+\newcommand{\algocf@captiontext}[2]{%
+ \algocf@captionlayout{\AlCapSty{\AlCapFnt #1\algocf@typo\algocf@capseparator}\nobreakspace%
+ \AlCapNameSty{\AlCapNameFnt{}#2}}}% text of caption
%
%%%%% default caption of algorithm: used if no specific style caption is defined
\newcommand{\algocf@makecaption}[2]{%
@@ -1477,146 +1830,209 @@
\hbox to\hsize{\hfil\box\@tempboxa\hfil}% else caption is centered
\fi%
\addtolength{\hsize}{-\algomargin}%
-}
+}%
%
-\newsavebox\algocf@capbox
+\newsavebox\algocf@capbox%
\newcommand{\algocf@makecaption@plain}[2]{%
\global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}}%
\newcommand{\algocf@makecaption@boxed}[2]{%
\addtolength{\hsize}{-\algomargin}%
- \global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}
+ \global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}%
\addtolength{\hsize}{\algomargin}%
}%
%
+\newcommand{\algocf@makecaption@tworuled}[2]{\algocf@makecaption@ruled{#1}{#2}}%
\newcommand{\algocf@makecaption@algoruled}[2]{\algocf@makecaption@ruled{#1}{#2}}%
\newcommand{\algocf@makecaption@boxruled}[2]{\algocf@makecaption@ruled{#1}{#2}}%
\newcommand{\algocf@makecaption@ruled}[2]{%
\global\sbox\algocf@capbox{\hskip\AlCapHSkip% .5\algomargin%
\parbox[t]{\hsize}{\algocf@captiontext{#1}{#2}}}% then caption is not centered
-}
+}%
%
+\newlength{\algoheightruledefault}\setlength{\algoheightruledefault}{0.8pt}%
+\newlength{\algoheightrule}\setlength{\algoheightrule}{\algoheightruledefault}%
+\newlength{\algotitleheightruledefault}\setlength{\algotitleheightruledefault}{0.8pt}%
+\newlength{\algotitleheightrule}\setlength{\algotitleheightrule}{\algotitleheightruledefault}%
\newcommand{\algocf@caption@plain}{\vskip\AlCapSkip\box\algocf@capbox}%
\newcommand{\algocf@caption@boxed}{\vskip\AlCapSkip\box\algocf@capbox}%
-\newcommand{\algocf@caption@ruled}{\box\algocf@capbox\kern2pt\hrule height.8pt depth0pt\kern2pt}%
+\newcommand{\algocf@caption@ruled}{\box\algocf@capbox\kern\interspacetitleruled\hrule height\algotitleheightrule depth0pt\kern\interspacealgoruled}%
+\newcommand{\algocf@caption@tworuled}{\box\algocf@capbox\kern\interspacetitleruled}%
\newcommand{\algocf@caption@algoruled}{\algocf@caption@ruled}%
\newcommand{\algocf@caption@boxruled}{%
\addtolength{\hsize}{-0.8pt}%
\hbox to\hsize{%
\vrule%\hskip-0.35pt%
\vbox{%
- \hrule\vskip2\lineskip%
- \hbox to\hsize{\unhbox\algocf@capbox\hfill}\vskip2\lineskip%
+ \hrule\vskip\interspacetitleboxruled%
+ \hbox to\hsize{\unhbox\algocf@capbox\hfill}\vskip\interspacetitleboxruled%
}%
%\hskip-0.35pt%
\vrule%
- }\vskip-2\lineskip\nointerlineskip%
+ }\nointerlineskip%
\addtolength{\hsize}{0.8pt}%
-}
+}%
%
%
%%%% set caption for the environment
-
+\newcommand{\algocf@captionref}{%
+ \renewcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\algocf@algocfref}}%
+ \addtocounter{algocf}{-1}% \caption do a refstepcounter, so we restore the precedent value
+ \let\old@thealgocf=\thealgocf\renewcommand{\thealgocf}{{\relsize{\algocf@refrelsize}\algocf@algocfref}}%
+ \gdef\@currentlabel{\algocf@algocfref}% let the label use the new ref
+}%
+%
+% Unfortunatly, we also need our own caption to set some specific stuff for special references. But after these
+% settings, we call the original caption.
+%
+\long\def\algocf@caption@algo#1[#2]#3{%
+ \ifthenelse{\equal{\algocf@algocfref}{\relax}}{}{\algocf@captionref}%
+ \@ifundefined{hyper@refstepcounter}{\relax}{% if hyper@refstepcounter undefind, no hyperref, else...
+ \ifthenelse{\equal{\algocf@algocfref}{\relax}}{\renewcommand{\theHalgocf}{\thealgocf}}{% take algocf as Href
+ \renewcommand{\theHalgocf}{\algocf@algocfref}}%else if SetAlgoRefName done, take this name as ref.
+ \hyper@refstepcounter{algocf}%set algocf as category of ref
+ }%
+ \algocf@latexcaption{#1}[#2]{#3}% call original caption
+}%
+%
% beamer define is own caption overrinding latex caption!
% as we need it, we have put here the original definition
+% to handle manual ref, unfortunately we have to add one line to handle algocf@algocfref
\long\def\algocf@latexcaption#1[#2]#3{% original definition of caption
- \par
+ \par%
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
- \begingroup
- \@parboxrestore
- \if@minipage
- \@setminipage
- \fi
- \normalsize
- \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
+ \begingroup%
+ \@parboxrestore%
+ \if@minipage%
+ \@setminipage%
+ \fi%
+ \normalsize%
+ \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par%
\endgroup%
-}
-
-\ifx\beamer@makecaption\undefined%
-\else% beamer detected
+}%
+%
+% \ifx\beamer@makecaption\undefined%
+% \else% beamer detected
\ifx\@makecaption\undefined%
\newcommand{\@makecaption}[2]{\relax}%
\fi%
-\fi
+%%
%
% more and more packages redefine \@caption instead of just \@makecaption which makes algorithm2e
% caption not works since based on standard \@caption. So we force the definition of \@caption to be
% the standard one (the one from LaTeX) inside algorithm environment.
%
+% unfortunately, makecaption is called with \ignorespace #3 so
+% we can't do the @currentlabel definition inside \algocf@captionproctext
+\long\def\algocf@caption@proc#1[#2]#3{%
+ \ifthenelse{\boolean{algocf@nokwfunc}}{\relax}{%
+ \SetKwFunction{\algocf@captname#3@}{\algocf@captname#3@}%
+ }%
+ % we tell hyperref to use algocfproc as category and to take the appropriate ref.
+ \ifthenelse{\boolean{algocf@func}}{\def\@proc@func{algocffunc}}{\def\@proc@func{algocfproc}}%
+ \@ifundefined{hyper@refstepcounter}{\relax}{% if hyper@refstepcounter undefind, no hyperref, else...
+ \ifthenelse{\boolean{algocf@procnumbered}}{%
+ \expandafter\def\csname theH\@proc@func\endcsname{\algocf@captname#3@}%if procnumbered, take \thealgocf as ref
+ }{%
+ \expandafter\def\csname theH\@proc@func\endcsname{\algocf@captname#3@}%else take procedure or function name
+ }%
+ \hyper@refstepcounter{\@proc@func}%
+ }%
+ \ifthenelse{\boolean{algocf@procnumbered}}{\relax}{%
+ \addtocounter{algocf}{-1}% \caption do a refstepcounter, so we restore the precedent value
+ \gdef\@currentlabel{\algocf@captname#3@}% let the label be the name of the function, not the counter
+ }%
+ \ifthenelse{\equal{\algocf@captparam#2@}{\arg@e}}{% if no paramater, we remove the ()
+ \algocf@latexcaption{#1}[\algocf@procname\nobreakspace\algocf@captname#2@]{#3}%
+ }{% else we give the complete name
+ \algocf@latexcaption{#1}[\algocf@procname\nobreakspace#2]{#3}%
+ }%
+}%
+%%
+%%% setcaption
\newcommand{\algocf@setcaption}{%
+ \ifthenelse{\boolean{algocf@procenvironment}}{% if proc environment, caption text must be changed
+ \let\algocf@oldcaptiontext=\algocf@captiontext%
+ \renewcommand{\algocf@captiontext}[2]{%
+ \algocf@captionproctext{##1}{##2}%
+ }%
+ }{}%
\let\algocf@savecaption=\@caption%
- \let\@caption=\algocf@latexcaption%
+ \ifthenelse{\boolean{algocf@procenvironment}}{\let\@caption=\algocf@caption@proc}{\let\@caption=\algocf@caption@algo}%
\let\algocf@oldmakecaption=\@makecaption%
\renewcommand{\@makecaption}[2]{%
- \expandafter\csname algocf@makecaption@\algocf@style\endcsname{##1}{##2}}%
-}
+ \expandafter\csname algocf@makecaption@\algocf@style\endcsname{##1}{##2}%
+ }%
+}%
%
%%%%% reset caption
%
% since we have force the LaTeX caption for algorithm environment, we must go back to the caption
% used in the text.
\newcommand{\algocf@resetcaption}{%
- \let\@caption=\algocf@savecaption%
- \let\@makecaption=\algocf@oldmakecaption%
-}
+ \ifthenelse{\boolean{algocf@procenvironment}}{% if proc environment
+ \let\thealgocf=\old@thealgocf% restore normal counter printing
+ \let\algocf@captiontext=\algocf@oldcaptiontext% restore normal caption text
+ }{}%
+ \let\@caption=\algocf@savecaption% now restore caption outside algo/proc/func environment
+ \let\@makecaption=\algocf@oldmakecaption% and restore makecaption outside outside algo/proc/func environment
+ \algocf@resetfnum%
+}%
%
%%%%% nocaptionofalgo and restorecaptionofalgo --
-\newcommand{\nocaptionofalgo}{%
+\newcommand{\NoCaptionOfAlgo}{%
\let\@old@algocf@captiontext=\algocf@captiontext%
- \renewcommand{\algocf@captiontext}[2]{\AlCapFnt{}##2}%
-}
-\newcommand{\restorecaptionofalgo}{%
+ \renewcommand{\algocf@captiontext}[2]{\AlCapNameSty{\AlCapNameFnt{}##2}}%
+}%
+\newcommand{\RestoreCaptionOfAlgo}{%
\let\algocf@captiontext=\@old@algocf@captiontext%
-}
+}%
%
% ---------------------- algocf environment
%
-\newcounter{algocfline} % new counter to make lines numbers be internally
-\setcounter{algocfline}{0} % different in different algorithms
+\newcounter{algocfline}% % new counter to make lines numbers be internally
+\setcounter{algocfline}{0}% % different in different algorithms
+\newcounter{algocfproc}% counter to count all algo environment (proc, func), just used by hyperref to avoir "same
+\setcounter{algocfproc}{0}% identifier" error caused by algocf being set to '-' for procedure or function or not
+ % changed if no caption is given.
%
\expandafter\ifx\csname algocf@within\endcsname\relax% if \algocf@within doesn't exist
-\newcounter{algocf} % just define a new counter
-\renewcommand\thealgocf{\@arabic\c@algocf} % and the way it is printed
-\else% else
-\newcounter{algocf}[\algocf@within] % counter is numbered within \algocf@within
-\renewcommand\thealgocf{\csname the\algocf@within\endcsname.\@arabic\c@algocf}
-\fi
-%
-\def\fps@algocf{htbp} % default
-\def\ftype@algocf{10} % float type
+\newcounter{algocf}% % just define a new counter
+\renewcommand{\thealgocf}{\@arabic\c@algocf}% and the way it is printed
+\else% else
+\newcounter{algocf}[\algocf@within]% % counter is numbered within \algocf@within
+\renewcommand\thealgocf{\csname the\algocf@within\endcsname.\@arabic\c@algocf}%
+\fi%
+%
+\def\fps@algocf{htbp}% % default
+\def\ftype@algocf{10}% % float type
\def\ext@algocf{\algocf@list} % loa by default, lof if figure option used
-\def\fnum@algocf{{\AlCapFnt\AlTitleFnt{\algorithmcfname\nobreakspace\thealgocf}}}
+\newcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}%
+\newcommand{\algocf@resetfnum}{\renewcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}}%
\newenvironment{algocf}% % float environment for algorithms
{\@float{algocf}}%
- {\end@float}
+ {\end@float}%
\newenvironment{algocf*}% % float* environment for algorithms
- {\@dblfloat{algocf}}
- {\end@dblfloat}
-
-\ifx\l@chapter\undefined%
-\newcommand\listofalgocfs{ % list of algorithms
- \section*{\listalgorithmcfname}%
- \@mkboth{\MakeUppercase\listalgorithmcfname}%
- {\MakeUppercase\listalgorithmcfname}%
- \@starttoc{loa}%
- }
-\else%
+ {\@dblfloat{algocf}}%
+ {\end@dblfloat}%
+%
+\def\algocf@seclistalgo{}%
+\ifx\l@chapter\undefined\let\algocf@seclistalgo=\section\else\let\algocf@seclistalgo=\chapter\fi%
+\@ifundefined{if@restonecol}{\newif\if@restonecol}\relax%
\newcommand\listofalgocfs{%
- \if@twocolumn
- \@restonecoltrue\onecolumn
- \else
- \@restonecolfalse
- \fi
- \chapter*{\listalgorithmcfname}%
- \@mkboth{\MakeUppercase\listalgorithmcfname}%
- {\MakeUppercase\listalgorithmcfname}%
- \@starttoc{loa}%
- \if@restonecol\twocolumn\fi
- }
-\fi
-
-
+ \ifx\algocf@seclistalgo\chapter%
+ \if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi%
+ \fi%
+ \algocf@seclistalgo*{\listalgorithmcfname}%
+ \@mkboth{\MakeUppercase\listalgorithmcfname}%
+ {\MakeUppercase\listalgorithmcfname}%
+ \@starttoc{loa}%
+ \ifx\algocf@seclistalgo\chapter%
+ \if@restonecol\twocolumn\fi%
+ \fi%
+}
+%
\newcommand*\l@algocf{\@dottedtocline{1}{1em}{2.3em}}% line of the list
%
% ---------------------- algorithm environment
@@ -1628,53 +2044,71 @@
%%%%%%%
%%
%
-\newsavebox\algocf@algoframe
+\newsavebox\algocf@algoframe%
\def\@algocf@pre@plain{\relax}% action to be done before printing the algo.
\def\@algocf@post@plain{\relax}% action to be done after printing the algo.
\def\@algocf@capt@plain{bottom}% where the caption should be localized.
\def\@algocf@pre@boxed{\noindent\begin{lrbox}{\algocf@algoframe}}
\def\@algocf@post@boxed{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}%
\def\@algocf@capt@boxed{under}%
-\def\@algocf@pre@ruled{\hrule height.8pt depth0pt\kern2pt}%
-\def\@algocf@post@ruled{\kern2pt\hrule\relax}%
+\def\@algocf@pre@ruled{\hrule height\algoheightrule depth0pt\kern\interspacetitleruled}%
+\def\@algocf@post@ruled{\kern\interspacealgoruled\hrule height\algoheightrule\relax}%
\def\@algocf@capt@ruled{top}%
-\def\@algocf@pre@algoruled{\hrule height.8pt depth0pt\kern2pt}%
-\def\@algocf@post@algoruled{\kern2pt\hrule\relax}%
+\def\@algocf@pre@algoruled{\hrule height\algoheightrule depth0pt\kern\interspacetitleruled}%
+\def\@algocf@post@algoruled{\kern\interspacealgoruled\hrule height\algoheightrule \relax}%
\def\@algocf@capt@algoruled{top}%
+\def\@algocf@pre@tworuled{\hrule height\algoheightrule depth0pt\kern\interspacetitleruled}%
+\def\@algocf@post@tworuled{\kern\interspacealgoruled\hrule height\algoheightrule\relax}%
+\def\@algocf@capt@tworuled{top}%
\def\@algocf@pre@boxruled{\noindent\begin{lrbox}{\algocf@algoframe}}%
\def\@algocf@post@boxruled{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}%
\def\@algocf@capt@boxruled{above}%
%
+\newcommand{\noalgocaption}{\def\@algocf@capt@ruled{none}}
+%
%% before algocf or figure environment
\newcommand{\@algocf@init@caption}{%
- \@algocf@algotitleofalgo% fix name for \Titleofalgo to \algorithmcfname
+ \ifthenelse{\boolean{algocf@procenvironment}}{% if we are inside a procedure/function environment
+ \@algocf@proctitleofalgo% set Titleofalgo to Procedure: or Function:
+ % accordingly to the environment
+ \let\old@thealgocf=\thealgocf\ifthenelse{\boolean{algocf@procnumbered}}{\relax}{%
+ \renewcommand{\thealgocf}{-}}%
+ }{% else inside environment algorithm
+ \@algocf@algotitleofalgo% fix name for \Titleofalgo to \algorithmcfname
+ }%
\algocf@setcaption% set caption to our caption style
}%
+%
+\newcommand{\@algofloatboxreset}{\@setminipage}
\newcommand{\@algocf@init}{%
\refstepcounter{algocfline}%
+ \stepcounter{algocfproc}%to have a different counter for each environment and being abble to make the difference
+ %between href of algoline in different algorithms.
\ifthenelse{\boolean{algocf@optnoend}}{%
- \renewcommand{\a@block}[2]{\a@group{##1}}%
+ \renewcommand{\algocf@block}[2]{\algocf@group{##1}}%
}{%
- \renewcommand{\a@block}[2]{\a@@block{##1}{##2}}%
+ \renewcommand{\algocf@block}[2]{\algocf@@block{##1}{##2}}%
}%
-}
+}%
%% after the end of algocf or figure environment
\newcommand{\@algocf@term@caption}{%
\algocf@resetcaption% restore original caption
}%
+%
\newcommand{\@algocf@term}{%
\setboolean{algocf@algoH}{false}% no H by default
\ifthenelse{\boolean{algocf@optnoend}}{%
- \renewcommand{\a@block}[2]{\a@@block{##1}{##2}}
- }{%
- \renewcommand{\a@block}[2]{\a@group{##1}}%
- }%
-}
+ \renewcommand{\algocf@block}[2]{\algocf@@block{##1}{##2}}%
+ }{%
+ \renewcommand{\algocf@block}[2]{\algocf@group{##1}}%
+ }%
+ \SetAlgoRefName{\relax}%
+}%
%
%%%%%%%%%%%%%%%%%
%% makethealgo: macro which print effectively the algo in its box
%%
-\newsavebox\algocf@algobox
+\newsavebox\algocf@algobox%
\newcommand{\algocf@makethealgo}{%
\vtop{%
% place caption above if needed bye the style
@@ -1694,10 +2128,10 @@
% postcommand according to the style
\csname @algocf@post@\algocf@style\endcsname%
% place caption under if needed bye the style
- \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{under}}
+ \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{under}}%
{\csname algocf@caption@\algocf@style\endcsname}{}%
}%
-}
+}%
%%%%%%%%%%%%%%%%%%%
%
%% at the beginning of algocf or figure environment
@@ -1712,88 +2146,116 @@
\addtolength{\hsize}{-1.5\algomargin}%
\let\@mathsemicolon=\;\def\;{\ifmmode\@mathsemicolon\else\@endalgoln\fi}%
\raggedright\AlFnt{}%
- \ifthenelse{\boolean{algocf@slide}}{\incmargin{\skipalgocfslide}}{}%
+ \ifthenelse{\boolean{algocf@slide}}{\IncMargin{\skipalgocfslide}}{}%
\@algoinsideskip%
- %
-}
+}%
%
%% at the end of algocf or figure environment
\newcommand{\@algocf@finish}{%
\@algoinsideskip%
\egroup%end of vtop which contain all the text
- \egroup%end of hbox wich contains [margin][vtop]
- \ifthenelse{\boolean{algocf@slide}}{\decmargin{\skipalgocfslide}}{}%
+ \hfill\egroup%end of hbox wich contains [margin][vtop]
+ \ifthenelse{\boolean{algocf@slide}}{\DecMargin{\skipalgocfslide}}{}%
%
\egroup%end of main vbox
\end{lrbox}%
- %\egroup% end of algo box
\algocf@makethealgo% print the algo
\@algoskip%
% restore dimension and macros
\setlength{\hsize}{\algowidth}%
\lineskip\normallineskip\setlength{\skiptotal}{\@defaultskiptotal}%
\let\;=\@mathsemicolon%
- %
-}
+}%
+%
%%%%%%%%%%%%%%%%%%%%
%% basic definition of the environment algorithm
%%
-
-\newboolean{algocf@algoH}\setboolean{algocf@algoH}{false}
+%
+\newboolean{algocf@procenvironment}\setboolean{algocf@procenvironment}{false}%
+\newboolean{algocf@func}\setboolean{algocf@func}{false}%
+\newboolean{algocf@algoH}\setboolean{algocf@algoH}{false}%
+\newboolean{algocf@algostar}\setboolean{algocf@algostar}{false}%
+%
+%%% environment for {algorithm}[H]
\newenvironment{algocf@Here}{\noindent%
\def\@captype{algocf}% if not defined, caption exit with an error
-% \hbox\bgroup%
- \begin{minipage}{\hsize}
+ \begin{minipage}{\hsize}%
}{%
- \end{minipage}
-% \egroup%
+ \end{minipage}%\par%
}%
-\newenvironment{\algocf@envname}[1][htbp]{%
+%%% real algorithm environment which manages H and * option
+% \let\algocf@originalfloatboxreset=\@floatboxreset%
+% \let\@floatboxreset=\@algofloatboxreset%
+\newenvironment{algocf@algorithm}[1][htbp]{
\@algocf@init%
- \ifthenelse{\equal{\algocf@float}{figure}}%
- {\begin{figure}[#1]}%
- {\@algocf@init@caption\ifthenelse{\equal{#1}{H}}%
- {\setboolean{algocf@algoH}{true}\begin{algocf@Here}}%
- {\begin{algocf}[#1]}%
- }%
- \@algocf@start%
- \@ResetCounterIfNeeded%
- \algocf@linesnumbered%
+ \ifthenelse{\equal{\algocf@float}{figure}}{% if option figure set
+ \ifthenelse{\boolean{algocf@algostar}}{% if algorithm* with figure option
+ \begin{figure*}[#1]% call figure*
+ }{% else algorithm environment with figure option
+ \begin{figure}[#1]% call figure
+ }%
+ }{% else normal algorithm environment
+ \@algocf@init@caption%
+ \ifthenelse{\equal{#1}{H}}{% if [H] algorithm
+ \if@twocolumn\@latex@error{[H] in two columns mode is not allowed for algorithms}\fi% TODO: SCREAM if H in two colums!
+ \setboolean{algocf@algoH}{true}\begin{algocf@Here}% call corresponding environment
+ }{% else floating algorithm environment
+ \ifthenelse{\boolean{algocf@algostar}}{% if algorithm*
+ \begin{algocf*}[#1]% call algocf*
+ }{% else algorithm environment
+ \begin{algocf}[#1]% call algcf
+ }%
+ }%
+ }% fin test option figure ou pas
+ \@algocf@start%
+ \@ResetCounterIfNeeded%
+ \algocf@linesnumbered\ignorespaces%
}{%
- \@algocf@finish%
- \ifthenelse{\equal{\algocf@float}{figure}}%
- {\end{figure}}%
- {\@algocf@term@caption\ifthenelse{\boolean{algocf@algoH}}%
- {\end{algocf@Here}}%
- {\end{algocf}}%
- }%
- \@algocf@term
-}
-%%%
-%%% algorithm*
-%%%
+ \@algocf@finish%
+ \ifthenelse{\equal{\algocf@float}{figure}}{%
+ \ifthenelse{\boolean{algocf@algostar}}{% if algorithm* with figure option
+ \end{figure*}% call figure*
+ }{% else algorithm environment with figure option
+ \end{figure}% call figure
+ }%
+ }{%
+ \@algocf@term@caption%
+ \ifthenelse{\boolean{algocf@algoH}}{% if [H] algorithm
+ \end{algocf@Here}\par% call corresponding environment
+ }{% else floating algorithm environment
+ \ifthenelse{\boolean{algocf@algostar}}{% if algorithm*
+ \end{algocf*}% call algocf*
+ }{% else algorithm environment
+ \end{algocf}% call algocf
+ }%
+ }%
+ }%
+ \@algocf@term\ignorespacesafterend%
+}%
+%
+%%% user algorithm environment
+\newenvironment{\algocf@envname}[1][htbp]{%
+ \setboolean{algocf@algostar}{false}%
+ \setboolean{algocf@procenvironment}{false}\gdef\algocfautorefname{\algorithmautorefname}%
+ \begin{algocf@algorithm}[#1]\ignorespaces%
+}{%
+ \end{algocf@algorithm}\ignorespacesafterend%
+}%
+%%% user algorithm* environment
\newenvironment{\algocf@envname*}[1][htbp]{%
- \@algocf@init%
- \ifthenelse{\equal{\algocf@float}{figure}}%
- {\begin{figure*}[#1]}%
- {\begin{algocf*}[#1]}%
- \@algocf@start%
- \@ResetCounterIfNeeded%
- \algocf@linesnumbered%
-}{
- \@algocf@finish%
- \ifthenelse{\equal{\algocf@float}{figure}}%
- {\end{figure*}}%
- {\end{algocf*}}%
- \@algocf@term%
-}
+ \setboolean{algocf@algostar}{true}%
+ \setboolean{algocf@procenvironment}{false}\gdef\algocfautorefname{\algorithmautorefname}%
+ \begin{algocf@algorithm}[#1]\ignorespaces%
+}{%
+ \end{algocf@algorithm}\ignorespacesafterend%
+}%
%
%%%%%%%%%%%%%%%%%%%%%%%
%%%
%
\expandafter\newcommand\csname\algocf@listofalgorithms\endcsname{%
- \ifthenelse{\equal{\algocf@float}{figure}}{\listoffigures}{\listofalgocfs}
-}
+ \ifthenelse{\equal{\algocf@float}{figure}}{\listoffigures}{\listofalgocfs}%
+}%
%%%
%%%
%
@@ -1802,10 +2264,6 @@
%
% -- new style (used in particular in the caption of function and procedure environments)
%
-\newcommand{\ProcNameSty}[1]{\FuncSty{#1}}%
-\newcommand{\SetProcNameSty}[1]{\renewcommand{\ProcNameSty}[1]{\textnormal{\csname#1\endcsname{##1}}}}
-\newcommand{\ProcArgSty}[1]{\ArgSty{#1}}%
-\newcommand{\SetProcArgSty}[1]{\renewcommand{\ProcArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}}}
% three macros to extract parts of the caption
\gdef\algocf@captname#1(#2)#3@{#1} % keep characters before the first brace
\gdef\algocf@captparam#1(#2)#3@{#2} % keep character in between the braces
@@ -1813,110 +2271,139 @@
%
%%% Text of caption for Procedure or Function
\newcommand{\algocf@captionproctext}[2]{%
- {\AlCapFnt{}\AlTitleFnt{\algocf@procname} %
- \ProcNameSty{\algocf@captname #2@}% Name of the procedure in ProcName Style.
- \ifthenelse{\equal{\algocf@captparam #2@}{\arg@e}}{}% if no argument, write nothing
- {% else put arguments in ProcArgSty:
- \ProcNameSty{(}\ProcArgSty{\algocf@captparam #2@}\ProcNameSty{)}%
- }% endif
- \algocf@captother #2@%
- }
-}
-%%%% set caption for the environment
-% unfortunately, makecaption is called with \ignorespace #3 so
-% we can't do the @currentlabel definition inside \algocf@captionproctext
-\long\def\algocf@caption@proc#1[#2]#3{%
- \gdef\@currentlabel{\algocf@captname #3@}%
- \algocf@old@caption{#1}[\algocf@procname\nobreakspace #2]{\ #3}%
-}%
-\newcommand{\algocf@setcaptionproc}{%
- \let\algocf@oldcaptiontext=\algocf@captiontext%
- \renewcommand{\algocf@captiontext}[2]{%
- \algocf@captionproctext{##1}{##2}}%
- \let\algocf@old@caption=\@caption%
- \let\@caption=\algocf@caption@proc%
-}
-%%%%% reset caption
-\newcommand{\algocf@resetcaptionproc}{%
- \let\algocf@captiontext=\algocf@oldcaptiontext%
- \let\@caption=\algocf@old@caption%
-}
+ {%
+ \ProcSty{\ProcFnt\algocf@procname\ifthenelse{\boolean{algocf@procnumbered}}{\nobreakspace\thealgocf\algocf@typo\algocf@capseparator}{\relax}}%
+ \nobreakspace\ProcNameSty{\ProcNameFnt\algocf@captname #2@}% Name of the procedure in ProcName Style.
+ \ifthenelse{\equal{\algocf@captparam #2@}{\arg@e}}{}{% if no argument, write nothing
+ \ProcNameSty{\ProcNameFnt(}\ProcArgSty{\ProcArgFnt\algocf@captparam #2@}\ProcNameSty{\ProcNameFnt)}%else put arguments in ProcArgSty:
+ }% endif
+ \algocf@captother #2@%
+ }%
+}%
%
%
-%%%%% algocf@proc is the generic environment for procedure and function environment.
+% -- procedure and function environments are defined from algocf@algorithm environment
%
-\newboolean{algocf@procstar}\setboolean{algocf@procstar}{false}
-\newenvironment{algocf@proc}[1][htbp]{%
- \@algocf@proctitleofalgo% set Titleofalgo to Procedure: or Function:
- % accordingly to the environment
- \let\old@thealgocf=\thealgocf%\renewcommand{\thealgocf}{--}%
- \algocf@setcaptionproc% set the text of caption to proc
- \algocf@setcaption% set caption to our caption style
- \refstepcounter{algocfline}%
- \ifthenelse{\equal{\algocf@float}{figure}}{%
- \ifthenelse{\boolean{algocf@procstar}}{\begin{figure*}[#1]}{\begin{figure}[#1]}%
- }{%
- \ifthenelse{\boolean{algocf@procstar}}%
- {\begin{algocf*}[#1]}%
- {\ifthenelse{\equal{#1}{H}}%
- {\setboolean{algocf@algoH}{true}\begin{algocf@Here}}%
- {\begin{algocf}[#1]}%
- }%
- }%
- \@algocf@start%
- \@ResetCounterIfNeeded%
- \algocf@linesnumbered%
+\newenvironment{procedure}[1][htbp]{%
+ \setboolean{algocf@algostar}{false}%
+ \setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{false}%
+ \newcommand{\algocf@procname}{\@algocf@procname}\gdef\algocfprocautorefname{\procedureautorefname}%
+ \begin{algocf@algorithm}[#1]\ignorespaces%
}{%
- \@algocf@finish%
- \ifthenelse{\equal{\algocf@float}{figure}}{%
- \ifthenelse{\boolean{algocf@procstar}}{\end{figure*}}{\end{figure}}%
- }{%
- \ifthenelse{\boolean{algocf@procstar}}
- {\end{algocf*}}
- {\ifthenelse{\boolean{algocf@algoH}}
- {\end{algocf@Here}}%
- {\end{algocf}}%
- }%
- }%
- \let\thealgocf=\old@thealgocf%
- \@algocf@term% restore original caption and H boolean
- \algocf@resetcaptionproc%
-}
-
+ \end{algocf@algorithm}\ignorespacesafterend%
+}%
+\newenvironment{function}[1][htbp]{%
+ \setboolean{algocf@algostar}{false}%
+ \setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{true}%
+ \newcommand{\algocf@procname}{\@algocf@funcname}\gdef\algocffuncautorefname{\functionautorefname}%
+ \begin{algocf@algorithm}[#1]\ignorespaces%
+}{%
+ \end{algocf@algorithm}\ignorespacesafterend%
+}%
%
-% -- procedure and function environments are defined from algocf@proc environment
+\newenvironment{procedure*}[1][htbp]{%
+ \setboolean{algocf@algostar}{true}%
+ \setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{false}%
+ \newcommand{\algocf@procname}{\@algocf@procname}\gdef\algocfprocautorefname{\procedureautorefname}%
+ \begin{algocf@algorithm}[#1]\ignorespaces%
+}{%
+ \end{algocf@algorithm}\ignorespacesafterend%
+}%
+\newenvironment{function*}[1][htbp]{%
+ \setboolean{algocf@algostar}{true}%
+ \setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{true}%
+ \newcommand{\algocf@procname}{\@algocf@funcname}\gdef\algocffuncautorefname{\functionautorefname}%
+ \begin{algocf@algorithm}[#1]\ignorespaces%
+}{%
+ \end{algocf@algorithm}\ignorespacesafterend%
+}%
%
-\newenvironment{procedure}[1][htbp]%
-{\setboolean{algocf@procstar}{false}%
- \newcommand{\algocf@procname}{\@algocf@procname}\begin{algocf@proc}[#1]}%
-{\end{algocf@proc}}
-\newenvironment{function}[1][htbp]%
-{\setboolean{algocf@procstar}{false}%
- \newcommand{\algocf@procname}{\@algocf@funcname}\begin{algocf@proc}[#1]}%
-{\end{algocf@proc}}
%
-\newenvironment{procedure*}[1][htbp]%
-{\setboolean{algocf@procstar}{true}%
- \newcommand{\algocf@procname}{\@algocf@procname}\begin{algocf@proc}[#1]}%
-{\end{algocf@proc}}
-\newenvironment{function*}[1][htbp]%
-{\setboolean{algocf@procstar}{true}%
- \newcommand{\algocf@procname}{\@algocf@funcname}\begin{algocf@proc}[#1]}%
-{\end{algocf@proc}}
+%%%%%%%%%%%%%%%%%%%%
+%% definition of algondfloat environment
+%%
+\ifthenelse{\boolean{algocf@endfloat}}{% if endfloat option then
+\newcommand{\algoplace}{% macro which is used to writhe algorithm about there
+ \begin{center}%
+ [\algorithmcfname~\thepostfig\ about here.]%
+ \end{center}%
+}%
+\newcommand{\algoendfloat}{% use as a \begin{algoendfloat} environment to start scanning of line
+% \immediate\openout\@mainfff\jobname.fff%
+ \efloat@condopen{fff}
+ \efloat@iwrite{fff}{\string\begin{\algocf@envname}}%
+ \if@domarkers%
+ \ifthenelse{\equal{\algocf@list}{lof}}{%
+ \addtocounter{postfig}{1}%
+ }{%
+ \addtocounter{postalgo}{1}%
+ }%
+ \algoplace%
+ \fi%
+ \bgroup%
+ \let\do\ef@makeinnocent\dospecials%
+ \ef@makeinnocent\^^L% and whatever other special cases
+ \endlinechar`\^^M \catcode`\^^M=12 \ef@xalgocfendfloat}%
+}{\relax}%%%% end of endfloat option ifthenelse
+%% some macros useful for endfloat option that cannot be defined inside the ifthenelse
+%scan algoendfloat algorithm and write the text into .fff file
+{\catcode`\^^M=12 \endlinechar=-1 %
+ \gdef\ef@xalgocfendfloat#1^^M{% scan the lines inside algoendfloat environment being read by latex
+ \def\test{#1}% test is the line being currently scan by latex
+ \ifx\test\ef@endalgocftest% if it is \end{algoendfloat}
+ \def\next{% define next as to not continue the scan and write \end{algorithm} into .fff file
+ \egroup\end{algoendfloat}%
+ \efloat@iwrite{fff}{\string\end{\algocf@envname}}%
+ \efloat@iwrite{fff}{\string\efloatseparator}%
+ \efloat@iwrite{fff}{ }%
+ }%
+ \else% else write the current line being scanned by latex and set next to continue the scan
+ \efloat@iwrite{fff}{#1}%
+ \let\next\ef@xalgocfendfloat%
+ \fi% endif
+ \next}% next is continue if it was else condition, else it does not continue the scan and write end to file
+}%
+% test if the scan is finish by looking at the string \end{algoendfloat}
+{\escapechar=-1%
+ \xdef\ef@endalgocftest{\string\\end\string\{algoendfloat\string\}}%
+}%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
-\newcommand{\Titleofalgo}[1]{\@titleprefix\TitleSty{#1}\par\smallskip}
+\newcommand{\TitleOfAlgo}[1]{\@titleprefix\
+ \TitleSty{#1}\par\smallskip}%
+%
+\newcommand{\SetAlgorithmName}[3]{%
+ \renewcommand{\listalgorithmcfname}{#3}%
+ \renewcommand{\algorithmcfname}{#1}%
+ \renewcommand{\algorithmautorefname}{#2}%
+}%
%
+\newcommand{\algocf@refrelsize}{-2}\newcommand{\SetAlgoRefRelativeSize}[1]{\renewcommand{\algocf@refrelsize}{#1}}%
+\newcommand{\SetAlgoRefName}[1]{%
+ \renewcommand{\algocf@algocfref}{#1}%
+}%
%
+%
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%
% ------------------------- Default Definitions
%
%%
%%
%
-\newcommand{\algocf@defaults@common}{
+\SetKwComment{tcc}{/* }{ */}%
+\SetKwComment{tcp}{// }{}%
+%
+%\newcommand{\algocf@defaults@common}{
+%
+%
+% french keywords
+%
%\SetKwInOut{AlgDonnees}{Donn\'ees}\SetKwInOut{AlgRes}{R\'esultat}
\SetKwInput{Donnees}{Donn\'ees}%
\SetKwInput{Res}{R\'esultat}%
@@ -1927,10 +2414,16 @@
\SetKwBlock{Deb}{d\'ebut}{fin}%
\SetKwRepeat{Repeter}{r\'ep\'eter}{jusqu'\`a}%
%
-\SetKwComment{tcc}{/* }{ */}
-\SetKwComment{tcp}{// }{}
+\SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin si}%
+\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin d'alternative}%
+\SetKwFor{Pour}{pour}{faire}{fin pour}%
+\SetKwFor{PourPar}{pour}{faire en parallèle}{fin pour}%
+\SetKwFor{PourCh}{pour chaque}{faire}{fin pour chaque}%
+\SetKwFor{PourTous}{pour tous les}{faire}{fin pour tous}%
+\SetKwFor{Tq}{tant que}{faire}{fin tq}%
+%
+% english keywords
%
-%\SetKwInOut{AlgData}{Data}\SetKwInOut{AlgResult}{Result}
\SetKwInput{KwIn}{Input}%
\SetKwInput{KwOut}{Output}%
\SetKwInput{KwData}{Data}%
@@ -1941,10 +2434,16 @@
\SetKwBlock{Begin}{begin}{end}%
\SetKwRepeat{Repeat}{repeat}{until}%
%
+\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}%
+\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end switch}%
+\SetKwFor{For}{for}{do}{end for}%
+\SetKwFor{ForPar}{for}{do in parallel}{end forpar}
+\SetKwFor{ForEach}{foreach}{do}{end foreach}%
+\SetKwFor{ForAll}{forall the}{do}{end forall}%
+\SetKwFor{While}{while}{do}{end while}%
+%
% --- German keywords
%
-% \SetKwInOut{AlgDaten}{Daten}%AlgData
-% \SetKwInOut{AlgErgebnis}{Ergebnis}%AlgResult
\SetKwInput{Ein}{Eingabe}%KwIn
\SetKwInput{Aus}{Ausgabe}%KwOut
\SetKwInput{Daten}{Daten}%KwData
@@ -1955,16 +2454,22 @@
\SetKwBlock{Beginn}{Beginn}{Ende}%Begin
\SetKwRepeat{Wiederh}{wiederhole}{bis}%Repeat
%
+\SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf
+\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende Unt.}%Switch
+\SetKwFor{Fuer}{f\"ur}{tue}{Ende f\"ur}%For
+\SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar
+\SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach
+\SetKwFor{FuerAlle}{f\"ur alle}{tue}{Ende f\"ur}%ForAll
+\SetKwFor{Solange}{solange}{tue}{Ende solange}%While
+%
% --- Czech keywords
%
-% \SetKwInOut{AlgVst}{Vstup}\SetKwInOut{AlgVyst}{V\'{y}stup}
\SetKwInput{Vst}{Vstup}%
\SetKwInput{Vyst}{V\'{y}stup}%
\SetKwInput{Vysl}{V\'{y}sledek}%
%
% --- Portuguese keywords
%
-% \SetKwInOut{AlgDados}{Dados}\SetKwInOut{AlgResultado}{Result.}
\SetKwInput{Entrada}{Entrada}%
\SetKwInput{Saida}{Sa\'{i}da}%
\SetKwInput{Dados}{Dados}%
@@ -1974,44 +2479,7 @@
\SetKw{Retorna}{retorna}%
\SetKwBlock{Inicio}{in\'{i}cio}{fim}%
\SetKwRepeat{Repita}{repita}{at\'{e}}%
-% --- End
-}
-%
-%
-\newcommand{\algocf@defaults@longend}{%
-\algocf@defaults@common
-\SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{finsi}%
-\SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{finsi}%
-\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin d'alternative}%
-\SetKwFor{Pour}{pour}{faire}{finpour}%
-\SetKwFor{PourPar}{pour}{faire en parallèle}{finpour}%
-\SetKwFor{PourCh}{pour chaque}{faire}{finprch}%
-\SetKwFor{PourTous}{pour tous les}{faire}{finprts}%
-\SetKwFor{Tq}{tant que}{faire}{fintq}%
-%
-\SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{endif}%
-\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}%
-\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}%
-\SetKwFor{For}{for}{do}{endfor}%
-\SetKwFor{ForPar}{for}{do in parallel}{endfpar}
-\SetKwFor{ForEach}{foreach}{do}{endfch}%
-\SetKwFor{ForAll}{forall the}{do}{endfall}%
-\SetKwFor{While}{while}{do}{endw}%
-%
-% --- German for longend
-%
-\SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende-wenn}%gIf
-\SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende-wenn}%gIf
-\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende-Unt.}%Switch
-\SetKwFor{Fuer}{f\"ur}{tue}{Ende-f\"ur}%For
-\SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende-gleichzeitig}%ForPar
-\SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende-f\"ur}%ForEach
-\SetKwFor{FuerAlle}{f\"ur alle}{tue}{Ende-f\"ur}%ForAll
-\SetKwFor{Solange}{solange}{tue}{Ende-solange}%While
-%
-% --- Portuguese
%
-\SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
\SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}%
\SetKwFor{Para}{para}{fa\c{c}a}{fim para}%
@@ -2019,104 +2487,150 @@
\SetKwFor{ParaCada}{para cada}{fa\c{c}a}{fim para cada}%
\SetKwFor{ParaTodo}{para todo}{fa\c{c}a}{fim para todo}%
\SetKwFor{Enqto}{enquanto}{fa\c{c}a}{fim enqto}%
-}
-%
-%
-\newcommand{\algocf@defaults@shortend}{%
-\algocf@defaults@common
-\SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{fin}%
-\SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin}%
-\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin}%
-\SetKwFor{Pour}{pour}{faire}{fin}%
-\SetKwFor{PourPar}{pour}{faire en parallèle}{fin}%
-\SetKwFor{PourCh}{pour chaque}{faire}{fin}%
-\SetKwFor{PourTous}{pour tous les}{faire}{fin}%
-\SetKwFor{Tq}{tant que}{faire}{fin}%
-%
-%
-\SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{end}%
-\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end}%
-\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end}%
-\SetKwFor{For}{for}{do}{end}%
-\SetKwFor{ForPar}{for}{do in parallel}{end}
-\SetKwFor{ForEach}{foreach}{do}{end}%
-\SetKwFor{ForAll}{forall}{do}{end}%
-\SetKwFor{While}{while}{do}{end}%
-%
-% --- German for shortend
-%
-\SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende}%gIf
-\SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende}%gIf
-\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{}%Switch
-\SetKwFor{Fuer}{f\"ur}{tue}{Ende}%For
-\SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende}%ForPar
-\SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende}%ForEach
-\SetKwFor{FuerAlle}{f\"ur alle}{tue}{Ende}%ForAll
-\SetKwFor{Solange}{solange}{tue}{Ende}%While
-%
-% --- Portuguese
-%
-\SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim}%
-\SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim}%
-\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim}%
-\SetKwFor{Para}{para}{fa\c{c}a}{fim}%
-\SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{fim}
-\SetKwFor{ParaCada}{para cada}{fa\c{c}a}{fim}%
-\SetKwFor{ParaTodo}{para todo}{fa\c{c}a}{fim}%
-\SetKwFor{Enqto}{enquanto}{fa\c{c}a}{fim}%
-}
%
+% --- Italian keywords
%
-\newcommand{\algocf@defaults@noend}{%
-\renewcommand{\a@block}[2]{\a@group{##1}}
-\algocf@defaults@common
-\SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{}%
-\SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{}%
-\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas où}{autres cas}{}%
-\SetKwFor{Pour}{pour}{faire}{}%
-\SetKwFor{PourPar}{pour}{faire en parallèle}{}%
-\SetKwFor{PourCh}{pour chaque}{faire}{}%
-\SetKwFor{PourTous}{pour tous les}{faire}{}%
-\SetKwFor{Tq}{tant que}{faire}{}%
-%
-\SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{}%
-\SetKwIF{If}{ElsIf}{Else}{if}{then}{else if}{else}{}%
-\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{}%
-\SetKwFor{For}{for}{do}{}%
-\SetKwFor{ForPar}{for}{do in parallel}{}
-\SetKwFor{ForEach}{foreach}{do}{}%
-\SetKwFor{ForAll}{forall}{do}{}%
-\SetKwFor{While}{while}{do}{}%
-% --- German for noend
-\SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{}%gIf
-\SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{}%gIf
-\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{}%Switch
-\SetKwFor{Fuer}{f\"ur}{tue}{}%For
-\SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{}%ForPar
-\SetKwFor{FuerJedes}{f\"ur jedes}{tue}{}%ForEach
-\SetKwFor{FuerAlle}{f\"ur alle}{tue}{}%ForAll
-\SetKwFor{Solange}{solange}{tue}{}%While
-% --- Portuguese
-\SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{}%
-\SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{}%
-\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{}%
-\SetKwFor{Para}{para}{fa\c{c}a}{}%
-\SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{}
-\SetKwFor{ParaCada}{para cada}{fa\c{c}a}{}%
-\SetKwFor{ParaTodo}{para todo}{fa\c{c}a}{}%
-\SetKwFor{Enqto}{enquanto}{fa\c{c}a}{}%
-}
+\SetKwInput{KwIng}{Ingresso}%
+\SetKwInput{KwUsc}{Uscita}%
+\SetKwInput{KwDati}{Dati}%
+\SetKwInput{KwRisult}{Risultato}%
+\SetKw{KwA}{a}%
+\SetKw{KwRitorna}{ritorna}%
+\SetKw{Ritorna}{ritorna}%
+\SetKwBlock{Inizio}{inizio}{fine}%
+\SetKwRepeat{Ripeti}{ripeti}{finché}%
%
-%%
-%%
-%%
+\SetKwIF{Sea}{AltSe}{Altrimenti}{se}{allora}{altrimenti se}{allora}{fine se}%
+\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}%
+\SetKwFor{Per}{per}{fai}{fine per}%
+\SetKwFor{PerPar}{per}{fai in parallelo}{fine per}%
+\SetKwFor{PerCiascun}{per ciascun}{fai}{fine per ciascun}%
+\SetKwFor{PerTutti}{per tutti i}{fai}{fine per tutti}%
+\SetKwFor{Finche}{finché}{fai}{fine finché}%
%
-% default macros are:
-\defaultsmacros@algo
-\SetNoline
+% --- End
+%}
+%
+%\algocf@defaults@common
+%
+% option onelanguage redefinition
+%
+\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{french}}{%
+\SetKwInput{KwIn}{Entr\'ees}%
+\SetKwInput{KwOutSortie}{Sorties}%
+\SetKwInput{KwData}{Donn\'ees}%
+\SetKwInput{KwResult}{R\'esultat}%
+\SetKw{KwTo}{\`a}%
+\SetKw{KwRet}{retourner}%
+\SetKw{Return}{retourner}%
+\SetKwBlock{Begin}{d\'ebut}{fin}%
+\SetKwRepeat{Repeat}{r\'ep\'eter}{jusqu'\`a}%
+%
+\SetKwIF{If}{ElseIf}{Else}{si}{alors}{sinon si}{sinon}{fin si}%
+\SetKwSwitch{Switch}{Case}{Other}{suivant}{faire}{cas o\`u}{autres cas}{fin d'alternative}%
+\SetKwFor{For}{pour}{faire}{fin pour}%
+\SetKwFor{ForPar}{pour}{faire en parallèle}{fin pour}%
+\SetKwFor{ForEach}{pour chaque}{faire}{fin pour chaque}%
+\SetKwFor{ForAll}{pour tous les}{faire}{fin pour tous}%
+\SetKwFor{While}{tant que}{faire}{fin tq}%
+}{}%
+\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{german}}{%
+\SetKwInput{KwIn}{Eingabe}%KwIn
+\SetKwInput{KwOut}{Ausgabe}%KwOut
+\SetKwInput{KwData}{Daten}%KwData
+\SetKwInput{KwResult}{Ergebnis}%KwResult
+\SetKw{KwTo}{bis}%KwTo
+\SetKw{KwRet}{zur\"uck}%KwRet
+\SetKw{Return}{zur\"uck}%Return
+\SetKwBlock{Begin}{Beginn}{Ende}%Begin
+\SetKwRepeat{Repeat}{wiederhole}{bis}%Repeat
+%
+\SetKwIF{If}{ElseIf}{Else}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf
+\SetKwSwitch{Switch}{Case}{Other}{unterscheide}{tue}{Fall}{sonst}{Ende Unt.}%Switch
+\SetKwFor{For}{f\"ur}{tue}{Ende f\"ur}%For
+\SetKwFor{ForPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar
+\SetKwFor{ForEach}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach
+\SetKwFor{ForAll}{f\"ur alle}{tue}{Ende f\"ur}%ForAll
+\SetKwFor{While}{solange}{tue}{Ende solange}%While
+}{}%
+\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{portugues}}{%
+\SetKwInput{KwIn}{Entrada}%
+\SetKwInput{KwOut}{Sa\'{i}da}%
+\SetKwInput{KwData}{Dados}%
+\SetKwInput{KwResult}{Resultado}%
+\SetKw{KwTo}{at\'{e}}
+\SetKw{KwRet}{retorna}%
+\SetKw{Return}{retorna}%
+\SetKwBlock{Begin}{in\'{i}cio}{fim}%
+\SetKwRepeat{Repeat}{repita}{at\'{e}}%
+%
+\SetKwIF{If}{ElseIf}{Else}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
+\SetKwSwitch{Switch}{Case}{Other}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}%
+\SetKwFor{For}{para}{fa\c{c}a}{fim para}%
+\SetKwFor{ForPar}{para}{fa\c{c}a em paralelo}{fim para}
+\SetKwFor{ForEach}{para cada}{fa\c{c}a}{fim para cada}%
+\SetKwFor{ForAll}{para todo}{fa\c{c}a}{fim para todo}%
+\SetKwFor{While}{enquanto}{fa\c{c}a}{fim enqto}%
+}{}%
+\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{italiano}}{%
+\SetKwInput{KwIn}{Ingresso}%
+\SetKwInput{KwOut}{Uscita}%
+\SetKwInput{KwData}{Dati}%
+\SetKwInput{KwResult}{Risultato}%
+\SetKw{KwTo}{a}%
+\SetKw{KwRet}{ritorna}%
+\SetKw{Return}{ritorna}%
+\SetKwBlock{Begin}{inizio}{fine}%
+\SetKwRepeat{Repeat}{ripeti}{finché}%
+%
+\SetKwIF{If}{ElseIf}{Else}{se}{allora}{altrimenti se}{allora}{fine se}%
+\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}%
+\SetKwFor{For}{per}{fai}{fine per}%
+\SetKwFor{ForPar}{per}{fai in parallelo}{fine per}%
+\SetKwFor{ForEach}{per ciascun}{fai}{fine per ciascun}%
+\SetKwFor{ForAll}{per tutti i}{fai}{fine per tutti}%
+\SetKwFor{While}{finché}{fai}{fine finché}%
+}{}%
+%
+%%%% old commands compatibility
+%
+\ifthenelse{\boolean{algocf@oldcommands}}{%
+\newcommand{\SetNoLine}{\SetAlgoNoLine}%
+\newcommand{\SetVline}{\SetAlgoVlined}%
+\newcommand{\SetLine}{\SetAlgoLined}%
+%
+\newcommand{\dontprintsemicolon}{\DontPrintSemicolon}%
+\newcommand{\printsemicolon}{\PrintSemicolon}%
+\newcommand{\incmargin}[1]{\IncMargin{#1}}%
+\newcommand{\decmargin}[1]{\DecMargin{-#1}}%
+\newcommand{\setnlskip}[1]{\SetNlSkip{#1}}%
+\newcommand{\Setnlskip}[1]{\SetNlSkip{#1}}%
+\newcommand{\setalcapskip}[1]{\SetAlCapSkip{#1}}%
+\newcommand{\setalcaphskip}[1]{\SetAlCapHSkip{#1}}%
+\newcommand{\nlSty}[1]{\NlSty{#1}}%
+\newcommand{\Setnlsty}[3]{\SetNlSty{#1}{#2}{#3}}%
+\newcommand{\linesnumbered}{\LinesNumbered}%
+\newcommand{\linesnotnumbered}{\LinesNotNumbered}%
+\newcommand{\linesnumberedhidden}{\LinesNumberedHidden}%
+\newcommand{\showln}{\ShowLn}%
+\newcommand{\showlnlabel}[1]{\ShowLnLabel{#1}}%
+\newcommand{\nocaptionofalgo}{\NoCaptionOfAlgo}%
+\newcommand{\restorecaptionofalgo}{\RestoreCaptionOfAlgo}%
+\newcommand{\restylealgo}[1]{\RestyleAlgo{#1}}%
+%
+\newcommand{\Titleofalgo}[1]{\TitleOfAlgo{#1}}%
+\SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{fin si}%
+\SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{end if}%
+\SetKwIF{gIf}{gElseIf}{gElse}{if}{then}{else if}{else}{end if}%
+\SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf
+\SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
+\SetKwIF{gSea}{gAltSe}{gAltrimenti}{se}{allora}{altrimenti se}{allora}{fine se}%
+}{%
+ \relax%
+}%
%
%
%
%%
%%%
-%%%% END
+%%%% END \ No newline at end of file