From a9ec77a042693fd60429f18a8c4a095105f624e6 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 6 Jan 2013 23:44:11 +0000 Subject: algorithm2e (6jan13) git-svn-id: svn://tug.org/texlive/trunk@28749 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/algorithm2e/algorithm2e.sty | 921 ++++++++++++--------- 1 file changed, 551 insertions(+), 370 deletions(-) (limited to 'Master/texmf-dist/tex/latex/algorithm2e') diff --git a/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty b/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty index 4377fa87fdf..c2ebe93dc01 100644 --- a/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty +++ b/Master/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty @@ -1,6 +1,6 @@ % algorithm2e.sty --- style file for algorithms % almost everything can be customized by users. See the document for more explanations -%% Copyright 1996-2008 Christophe Fiorio +%% Copyright 1996-2013 Christophe Fiorio % % This program may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.2 @@ -17,7 +17,7 @@ % - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J% % subscribe by emailing sympa@lirmm.fr with 'subscribe '^^J% % -% $Id: algorithm2e.sty,v 4.1 2009/12/15 08:54:08 cfiorio Exp $ +% $Id: algorithm2e.sty,v 5.0 2013/01/06 14:40:35 cfiorio Exp $ % % PACKAGES REQUIRED: % @@ -26,14 +26,14 @@ % - xspace (in packages/tools) % - relsize (in contrib/misc/relsize.sty) % -%%%%%%%%%%%%%%% Release 4.01 +%%%%%%%%%%%%%%% Release 5.0 % % 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 +% - french, english, german, ngerman +% portuguese, czech, italiano, +% slovak, croatian, spanish : for the name of the algorithm and some keyword code % - onelanguage : to simply switch keyword from one language to another without changing % keyword commands % - boxed, boxruled, ruled, tworuled, @@ -59,6 +59,7 @@ % - procnumbered : procedure or function are numbered as algorithm % - nokwfunc : procedure or function name doens't become a command % - norelsize : don't use relsize package (useful if it breaks the compatibily) +% - displayblockmarkers : display begin, end keywords at start of each block % % defaults are; english,plain,resetcount,titlenotnumbered % @@ -148,41 +149,132 @@ % % 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. +% - January 06 2013 - revision 5.0 +% * CHANGE: SetKwSwith takes now 9 args: 9th arg is the same as +% previous 8th arg ('end of switch' keyword). New 8th arg is +% 'end of case' keyword. This is due to change of release +% 3.2 which introduce end after case block... as I never +% test with longend option, I never see that the 'end +% switch' used for case was not good. +% * CHANGE: when no end keyword is defined in a block macro, then +% algorithm2e does no more try to print it. So even with lined or noline +% option, no empty line is printed (before: a blank end was +% printed, so a blank line appeared) +% * Internal Change: add some internal function to improve readibility +% (thanks to Philip K. F. H\ölzenspies) +% * ADD: Block markers. +% You can now ask package to put begin and end keywords automatically at begin +% and end of blocks, it means each group of commands shifted and enclosed in +% braces. +% This is tricky to use but, combined with \SetStartEndCondition and +% redefinition of keywords, you should be abble to simulate any syntax. See +% examples in documentation where a generic example is derived in pseudo-code, +% python and C by keeping code and changing only style using block markers +% macros, \SetStartEndCondition and some redefinition of keywords. +% These new block markers macros are: +% - \AlgoDisplayBlockMarkers and \AlgoDontDisplayBlockMarkers +% - \SetAlgoBlockMarkers{begin marker}{end marker} +% - \BlockMarkersSty{text} and \SetBlockMarkersSty +% Note that a new option has also been added: displayblockmarkers +% * ADD: \leIf macro automatically defined by \SetKwIF: allow to define +% an if-then-else on a single line. +% * ADD: new macro \SetStartEndCondition{typo1}{typo2}{typo3} which +% sets typo around condition in For, If, Switch, Case and +% Repeat macros. First two are used around For, If, Swith +% conditions, First and third are used for Case and Repeat +% condition where condition ends the line. Default definition +% is \SetStartEndCondition{ }{ }{}. +% A common alternative is \SetStartEndCondition{ (}{) }{)} +% Can also be used to remove space around condition, for +% example if you want python style commands: +% \SetStartEndCondition{ }{}{} and \SetKwFor{For}{for}{:}{} +% * ADD: new environment algomathdisplay which allow display math (like inside \[ \] or $$ $$) +% handling end line and line number +% * ADD: new command \SetKwProg{Env}{Title}{is}{end} which defines a macro +% \Env{args}{text}. Env is a block with 'Title' (in \CapSty) at the beginning +% followed by args followed by 'is' then 'text' is put below inside a block ended +% by 'end'. If no 'end' is specified, nothing is written (no +% blank line is inserted). Useful to typeset function or prog for example: +% \SetKwProg{Fn}{Function}{is}{end} makes \Fn{afunc(i: int) : int}{return 0\;} +% writes: +% Function afunc(i: int) : int is +% | return 0; +% end +% or \SetKwProg{Def}{def}{:}{} makes \Def{afunc(i: int)}{return 0\;} writes: +% def afunc(i: int): +% | return 0 +% Tip: combine it with \SetKwFunction to write recursive function algorithm. With +% example above, you could define \SetKwFunction{\Afunc}{afunc} and then write: +% \Def{\Afunc{i:int}{\eIf{i>0}{\KwRet \Afunc{i-1}}{\KwRet 0\;}} that writes: +% def afunc(i: int): +% | if(i>0): +% | return afunc(i-1) +% | else: +% | return 0 +% with appropriate typo. +% * ADD: option croatian: croation keywords (thanks to Ivan Gavran) +% * ADD: option ngerman: same as german option but so can be used with global option ngerman +% of babel +% * ADD: option spanish: Spanish support (thanks to Mario Abarca) +% * ADD: unterminated block: useful to add part separator that doesn't necessary need an end +% keyword. +% Designed on the pattern of unterminated if (see \uIf macro) allowing to +% add a block that is not terminated by a keyword. Such block are defined in the same +% time as a block is defined by adding a macro beginning with u. So, for example, +% predefined \SetKwBlock{Begin}{begin}{end} defines now two commands: +% - \Begin{} as previously which print a begin - end block +% - \uBegin{} that defines a begin only block +% * FIX: problem when numbering line inside until condition of +% \SetKwRepeat macro: line number was not correctly aligned. +% * FIX: dotocloa option which was broken +% * FIX: uIf and uCase didn't have same behavior when used with +% noline, vlined or lined option. This is fixed. Side effect: no empty +% line after an uIf or uCase when used with options lined or vlined +% * FIX: a bug with Repeat Until command when use with side comment on Until +% * FIX: a bug with side text -- text put into () -- of command macro (SetKwIf and so on) +% which was always setting a ';' even after a \DontPrintSemicolon +% * FIX: a bug with hyperref and chapter definition (thanks to Hubert Meier) +% * FIX: bugs with l macro and side comment +% * FIX: revision number +% * FIX: fix non ascii character (utf8 not yet recognized by all latex engine) +% * FIX: fnum@algocf had an useless parameter which sometimes broke expansion and output an error +% * FIX: works now with multicol package +% +% - december 14 2009 - revision 4.1 +% * ADD: new command \SetKwHangingKw{Name}{text} (hanging indent with keyword): This creates a +% hanging indent much like \texttt{SetKwInput}, except that it removes the trailing `:' +% and does not reset numbering (thanks to Nathan Tallent) % % - november 17 2009 - revision 4.00 - % -% * CHANGE : IMPORTANT : some commands have been renamed to have consistent naming (CamlCase -% syntax) and old commands are no more available. If you doesn't want to change -% your mind or use old latex files, you can use oldcommands option to enable old -% commands back. -% text. Here are these commands: -% - \SetNoLine becomes \SetAlgoNoLine -% - \SetVline becomes \SetAlgoVlined -% - \Setvlineskip becomes \SetVlineSkip -% - \SetLine becomes \SetAlgoLined -% - \dontprintsemicolon becomes \DontPrintSemicolon -% - \printsemicolon becomes \PrintSemicolon -% - \incmargin becomes \IncMargin -% - \decmargin becomes \DecMargin -% - \setnlskip becomes \SetNlSkip -% - \Setnlskip becomes \SetNlSkip -% - \setalcapskip becomes \SetAlCapSkip -% - \setalcaphskip becomes \SetAlCapHSkip -% - \nlSty becomes \NlSty -% - \Setnlsty becomes \SetNlSty -% - \linesnumbered becomes \LinesNumbered -% - \linesnotnumbered becomes \LinesNotNumbered -% - \linesnumberedhidden becomes \LinesNumberedHidden -% - \showln becomes \ShowLn -% - \showlnlabel becomes \ShowLnLabel -% - \nocaptionofalgo becomes \NoCaptionOfAlgo -% - \restorecaptionofalgo becomes \RestoreCaptionOfAlgo -% - \restylealgo becomes \RestyleAlgo -% - gIf macros and so on do no more exist +% * 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. @@ -199,7 +291,7 @@ % 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 : +% language option: % . KwIn, KwOut, KwData, KwResult % . KwTo KwFrom % . KwRet, Return @@ -212,7 +304,7 @@ % * 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: +% * 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 @@ -240,7 +332,7 @@ % \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 : +% 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. @@ -522,7 +614,7 @@ % 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 german, portuguese and czech options for title of algorithms and typo. % * add portuguese translation of predefined keywords * add czech translation of some % predefined keywords % @@ -577,7 +669,7 @@ % * minor bug on longend option corrected. % % - August 26 1999 - revision 2.31 -% * add an option : figure +% * add an option: figure % this option makes algorithms be figure and so are numbered % as figures, have Figure as caption and are put in % the \listoffigures @@ -595,7 +687,7 @@ % - label now puts the name (the text before the braces in the % caption) of the procedure or function as reference (not % the number like a classic algorithm environment). -% There are also two new styles : ProcNameSty and +% There are also two new styles: ProcNameSty and % ProcArgSty. These style are by default the same as FuncSty % and ArgSty but are used in the caption of a procedure or a % function. @@ -611,11 +703,11 @@ % \KwSty{functioname(}list of arguments\KwSty{)} % % -% - November 27 1996 - revision 2.21 : +% - November 27 1996 - revision 2.21: % minor bug in length of InOut boxes fixed. % add algorithm* environment. % -% - July 12 1996 - revision 2.2 : \SetArg and \SetKwArg macros removed. +% - July 12 1996 - revision 2.2: \SetArg and \SetKwArg macros removed. % % \SetArg has been removed since it never has been % documented. @@ -623,7 +715,7 @@ % take an argument in order to be consistent with % \SetKwData and \SetKwFunction macros. % -% - July 04 1996 - revision 2.1 : still more LaTeX2e! Minor compatibility break +% - July 04 1996 - revision 2.1: still more LaTeX2e! Minor compatibility break % % Macros use now \newcommand instead of \def, use of \setlength, % \newsavebox, ... and other LaTeX2e specific stuff. @@ -641,7 +733,7 @@ % % Known bugs: % ----------- -% - no more known bugs... all are corrected! +% - horizontal spacing (indent) doesn't work with revtex4 class. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -652,13 +744,76 @@ % \NeedsTeXFormat{LaTeX2e}[1994/12/01] % -\ProvidesPackage{algorithm2e}[2008/00/00 v3.10 algorithms environments] +\ProvidesPackage{algorithm2e}[2013/01/06 v5.00 algorithms environments] % % %%%%%%%%%%%%%%%%%%%%%%%%%%% Initial Code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \@makeother\*% some package redefined it as a letter (as color.sty) \def\@firstword#1 #2\@nil{#1}% an useful fonction +%%%%%%% Utilities: +% \ifArgumentEmpty ; if c is empty, i.e. {}, then t, else e. +% Function used internally, but may as well expose it to the user; it's useful +\long\def\ifArgumentEmpty#1{\bgroup + \catcode`\Q=3 + \catcode`\T=3 + \long\def\@tempa##1##2Q##3##4##5T{##4}% + \xdef\@tempa{\@tempa#1QQ{\noexpand\@secondoftwo}{\noexpand\@firstoftwo}T}% +\egroup\@tempa} +% +% \algocf@longdef -> shorthand to reduce +% \expandafter\long\expandafter\def +% to +% \expandafter\algocf@longdef +% may look insignificant, but reads that much better ;) +\def\algocf@longdef{\long\def} +% +% \algocf@newcommand (and helper \algocf@new@command) behaves like LaTeX's newcommand, +% with two differences: +% - the argument is not "\", but rather ""; i.e. one level of indirection +% - if the command exists already, then \renewcommand, rather than \newcommand +\def\algocf@newcommand#1{\expandafter\algocf@new@command\csname#1\endcsname} +\def\algocf@new@command#1{% + \begingroup \escapechar\m@ne\xdef\@gtempa{{\string#1}}\endgroup + \expandafter\@ifundefined\@gtempa\newcommand\renewcommand#1}% +% +% \algocf@newcmdside +% The largest time-saver; many commands we define have the pattern: +% \()... +% where "()" is optional. By defining them with this function, +% the arguments are parsed and renumbered, i.e. the body works as if the +% command was: +% \... +% and can use \ifArgumentEmpty to see whether its #1 exists (default case +% for the side text is (), so there's no difference between calling +% \foo{bar} +% or +% \foo(){bar} +% Technically this is new behaviour, but it shouldn't really occur... +\algocf@longdef\algocf@newcmdside#1#2#3{% + \expandafter\def\csname#1\endcsname{% + \@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}% + }% + \expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1){\csname algocf@#1main\endcsname{##1}}% + \algocf@newcommand{algocf@#1main}[#2]{#3}% +} +% +% \algocf@newcmdsides +% Like the command above, but with an optional side text at the end +% of the command as well, i.e.: +% \()() +% It may be a bit confusing that doesn't count , +% but since it is for internal use, the naming can be a little more +% fuzzy. This function behaves as if: +% = +\algocf@longdef\algocf@newcmdsides#1#2#3#4#5{% + \expandafter\def\csname#1\endcsname{% + \@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}% + }% + \expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1){\csname algocf@#1main\endcsname{##1}}% + \algocf@newcommand{algocf@#1main}[#2]{#3\@ifnextchar({\csname algocf@#1end\endcsname}{#4#5}}% + \expandafter\algocf@longdef\csname algocf@#1end\endcsname(##1){#4{##1}\strut\par}% +}% % % definition of commands which can be redefined in options of the package. % @@ -697,8 +852,17 @@ % % %% 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}% +% \let\algocf@original@chapter=\chapter% +% \def\chapter{\expandafter\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}% +% +% bug correction with hyperref submitted by Hubert Meier +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname @chapter\endcsname\relax\else +% \let\algocf@original@chapter=\chapter% +% \def\chapter{\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}% +\let\algocf@original@chapter=\@chapter% +\def\@chapter[#1]#2{\algocf@original@chapter[#1]{#2}\addtocontents{loa}{\protect\addvspace{10\p@}}}% +\fi % %% if@restonecol is defined in article and book but some other classes don't define it and we need it, so we do \ifx\if@restonecol\relax\else\newif\if@restonecol\fi% @@ -708,6 +872,11 @@ % \RequirePackage{ifthen}% % +\newboolean{algocf@displayblockmarkers}\setboolean{algocf@displayblockmarkers}{false}% +\DeclareOption{displayblockmarkers}{% + \setboolean{algocf@displayblockmarkers}{true}% +} +% \newboolean{algocf@nokwfunc}\setboolean{algocf@nokwfunc}{false}% \DeclareOption{nokwfunc}{% \setboolean{algocf@nokwfunc}{true}% @@ -775,9 +944,9 @@ \renewcommand{\algorithmautorefname}{algorithme}% \renewcommand{\algorithmcflinename}{ligne}% \renewcommand{\algocf@typo}{\ }% -\renewcommand{\@algocf@procname}{Procédure}% +\renewcommand{\@algocf@procname}{Proc\'edure}% \renewcommand{\@algocf@funcname}{Fonction}% -\renewcommand{\procedureautorefname}{procédure}% +\renewcommand{\procedureautorefname}{proc\'edure}% \renewcommand{\functionautorefname}{fonction}% \renewcommand{\algocf@languagechoosen}{french}% }% @@ -808,6 +977,19 @@ \renewcommand{\algocf@languagechoosen}{german}% }% % +\DeclareOption{ngerman}{% +\renewcommand{\listalgorithmcfname}{Liste der Algorithmen}% +\renewcommand{\algorithmcfname}{Algorithmus}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{Zeile}% +\renewcommand{\algocf@typo}{\ }% +\renewcommand{\@algocf@procname}{Prozedur}% +\renewcommand{\@algocf@funcname}{Funktion}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{german}% +}% +% \DeclareOption{portuguese}{% \renewcommand{\listalgorithmcfname}{Lista de Algoritmos}% \renewcommand{\algorithmcfname}{Algoritmo}% @@ -833,6 +1015,18 @@ \renewcommand{\functionautorefname}{funzione}% \renewcommand{\algocf@languagechoosen}{italiano}% }% +\DeclareOption{spanish}{% +\renewcommand{\listalgorithmcfname}{\'Indice de algoritmos}% +\renewcommand{\algorithmcfname}{Algoritmo}% +\renewcommand{\algorithmautorefname}{algoritmo}% +\renewcommand{\algorithmcflinename}{l\'inea}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedimiento}% +\renewcommand{\@algocf@funcname}{Funci\'on}% +\renewcommand{\procedureautorefname}{procedimiento}% +\renewcommand{\functionautorefname}{funci\'on}% +\renewcommand{\algocf@languagechoosen}{spanish}% +}% \DeclareOption{slovak}{% \renewcommand{\listalgorithmcfname}{Zoznam algoritmov}% \renewcommand{\algorithmcfname}{Algoritmus}% @@ -846,6 +1040,19 @@ \renewcommand{\algocf@languagechoosen}{slovak}% }% % +\DeclareOption{croatian}{% +\renewcommand{\listalgorithmcfname}{Popis algoritama}% +\renewcommand{\algorithmcfname}{Algoritam}% +\renewcommand{\algorithmautorefname}{\algorithmcfname}% +\renewcommand{\algorithmcflinename}{linija}% +\renewcommand{\algocf@typo}{}% +\renewcommand{\@algocf@procname}{Procedura}% +\renewcommand{\@algocf@funcname}{Funkcija}% +\renewcommand{\procedureautorefname}{\@algocf@procname}% +\renewcommand{\functionautorefname}{\@algocf@funcname}% +\renewcommand{\algocf@languagechoosen}{croatian}% +}% +% % OPTIONs plain, boxed, ruled, algoruled & boxruled % \newcommand{\algocf@style@plain}{\renewcommand{\algocf@style}{plain}}% @@ -854,8 +1061,10 @@ \newcommand{\algocf@style@algoruled}{\renewcommand{\algocf@style}{algoruled}}% \newcommand{\algocf@style@boxruled}{\renewcommand{\algocf@style}{boxruled}}% \newcommand{\algocf@style@tworuled}{\renewcommand{\algocf@style}{tworuled}}% +\newcommand{\algocf@style@plainruled}{\renewcommand{\algocf@style}{plainruled}}% \newcommand{\RestyleAlgo}[1]{\csname algocf@style@#1\endcsname}% \DeclareOption{plain}{\algocf@style@plain}% +\DeclareOption{plainruled}{\algocf@style@plainruled}% \DeclareOption{boxed}{\algocf@style@boxed}% \DeclareOption{ruled}{\algocf@style@ruled}% \DeclareOption{algoruled}{\algocf@style@algoruled}% @@ -926,6 +1135,8 @@ \DeclareOption{shortend}{\AtBeginDocument{\SetAlgoShortEnd}}%\SetAlgoShortEnd \DeclareOption{noend}{\AtBeginDocument{\SetAlgoNoEnd}}% \SetAlgoNoEnd % +\DeclareOption{nosemicolon}{\AtBeginDocument{\DontPrintSemicolon}}% \SetAlgoNoEnd +% % OPTION dotoc % \newboolean{algocf@dotocloa}\setboolean{algocf@dotocloa}{false}% @@ -986,10 +1197,10 @@ % \ifthenelse{\boolean{algocf@slide}}{\RequirePackage{color}}{}% % - +% \AtEndOfPackage{% \ifthenelse{\boolean{algocf@dotocloa}}{% - \renewcommand{\listofalgorithmes}{\tocfile{\listalgorithmcfname}{loa}}% + \renewcommand{\listofalgorithms}{\tocfile{\listalgorithmcfname}{loa}}% }{\relax}% }% % @@ -998,19 +1209,19 @@ \ifx\@tocextra\undefined% \RequirePackage{tocbibind}% \fi% -}% +}{\relax}% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Part %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \newcommand{\algocf@name}{algorithm2e}% -\newcommand{\algocf@date}{december 14 2009}% -\newcommand{\algocf@version}{Release 4.01}% +\newcommand{\algocf@date}{january 06 2013}% +\newcommand{\algocf@version}{Release 5.0}% \newcommand{\algocf@id}{\algocf@version\space -- \algocf@date\space --}% \typeout{********************************************************^^JPackage `\algocf@name'\space\algocf@id^^J% - algorithm2e-announce@lirmm.fr mailing list for announcement about releases^^J% - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J% subscribe by emailing sympa@lirmm.fr with 'subscribe '^^J% - - Author: Christophe Fiorio (fiorio@lirmm.fr)^^J********************************************************}% + - Author: Christophe Fiorio (cfiorio@um2.fr)^^J********************************************************}% %% %% %% @@ -1049,7 +1260,7 @@ \newskip\skipalgocfslide\skipalgocfslide=1em% \newdimen\algowidth% \newdimen\inoutsize% -\newdimen\inoutline% +\newdimen\inoutindent% \newdimen\interspacetitleruled\setlength{\interspacetitleruled}{2pt}% \newdimen\interspacealgoruled\setlength{\interspacealgoruled}{2pt}% \newdimen\interspacetitleboxruled\setlength{\interspacetitleboxruled}{2\lineskip}% @@ -1087,10 +1298,16 @@ \SetAlCapHSkip{.5\algomargin}% %% %% +\newskip\algoskipindent +\newcommand{\algocf@adjustskipindent}{% + \algoskipindent=\skiprule% + \advance\algoskipindent by \skiptext\advance\algoskipindent by 0.4pt} +\algocf@adjustskipindent% +% \newcommand{\Indentp}[1]{\advance\leftskip by #1}% -\newcommand{\Indp}{\advance\leftskip by 1em}% +\newcommand{\Indp}{\algocf@adjustskipindent\advance\leftskip by \algoskipindent} \newcommand{\Indpp}{\advance\leftskip by 0.5em}% -\newcommand{\Indm}{\advance\leftskip by -1em}% +\newcommand{\Indm}{\algocf@adjustskipindent\advance\leftskip by -\algoskipindent} \newcommand{\Indmm}{\advance\leftskip by -0.5em}% %% %% @@ -1113,6 +1330,8 @@ \sbox\algocf@nlbox{\NlSty{#1}}% \skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip\advance\skiplinenumber by-\skiptext% \advance\skiplinenumber by\algomargin\advance\skiplinenumber by.3em\advance\skiplinenumber by-\wd\algocf@nlbox% + % to handle particular case of until: printnl is after 'until' keyword has been writen, so we need to substract length of this keyword + \advance\skiplinenumber by-\algocf@skipuntil% \strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\NlSty{#1\ignorespaces}}}\ignorespaces% }% }% @@ -1139,14 +1358,14 @@ }% now we can do the line numbering \skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip% \strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\strut\NlSty{\theAlgoLine}}}\ignorespaces% -} +}% %% nlset \newcommand{\nlset}[1]{% \@ifundefined{hyper@refstepcounter}{\protected@edef\@currentlabel{#1}}{\algocf@nl@sethref{#1}}\algocf@printnl{#1}% }% % %% lnl definitions -\newcommand{\lnl}[1]{\nl\label{#1}}% +\newcommand{\lnl}[1]{\nl\label{#1}\ignorespaces}% % %% lnlset \newcommand{\lnlset}[2]{\nlset{#2}\label{#1}}% @@ -1227,6 +1446,8 @@ \newcommand{\TitleSty}[1]{#1\unskip}%\SetTitleSty{}{} \newcommand{\SetTitleSty}[2]{\renewcommand{\TitleSty}[1]{% \csname#1\endcsname{\csname#2\endcsname##1}}\unskip}% +\newcommand{\BlockMarkersSty}[1]{\KwSty{#1}}% +\newcommand{\SetBlockMarkersSty}[1]{\renewcommand{\BlockMarkersSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}% % %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1235,8 +1456,8 @@ % \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 +\newcommand{\algocf@addskiptotal}{\advance\skiptotal by 0.4pt\advance\hsize by -0.4pt\advance\hsize by -\skiplength}% 0.4 pt=width of \vrule +\newcommand{\algocf@subskiptotal}{\advance\skiptotal by -0.4pt\advance\hsize by 0.4pt\advance\hsize by \skiplength}% 0.4 pt=width of \vrule % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% @@ -1244,43 +1465,72 @@ % \skiphlne=.8ex% \newcommand{\SetVlineSkip}[1]{\skiphlne=#1}% +\newcommand{\algocf@bblock}{\BlockMarkersSty{begin}}% +\newcommand{\algocf@eblock}{\BlockMarkersSty{end}}% +\newcommand{\AlgoDisplayBlockMarkers}{\setboolean{algocf@displayblockmarkers}{true}}% +\newcommand{\AlgoDontDisplayBlockMarkers}{\setboolean{algocf@displayblockmarkers}{false}}% +\newcommand{\algocf@bblockcode}{% + \ifthenelse{\boolean{algocf@displayblockmarkers}}{\algocf@bblock\par}{\relax}% +}% +\newcommand{\algocf@eblockcode}{% + \ifthenelse{\boolean{algocf@displayblockmarkers}}{\algocf@eblock\par}{\relax}% +}% +\newcommand{\SetAlgoBlockMarkers}[2]{% + \ifArgumentEmpty{#1}{% + \renewcommand{\algocf@bblock}{\relax}% + }{% + \renewcommand{\algocf@bblock}{\BlockMarkersSty{#1}}% + }% begin marker set + \ifArgumentEmpty{#2}{% + \renewcommand{\algocf@eblock}{\relax}% + }{% + \renewcommand{\algocf@eblock}{\BlockMarkersSty{#2}}% + }% end marker set +} % -%% block with a vertical line end by a little horizontal line +%%%%%%%%% block with a vertical line end by a little horizontal line \newcommand{\algocf@Vline}[1]{% no vskip in between boxes but a strut to separate them, \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it \algocf@push{\skiprule}% move to the right before the vertical rule \hbox{\vrule% \vtop{\algocf@push{\skiptext}%move the right after the rule - \vtop{\algocf@addskiptotal\advance\hsize by -\skiplength #1}\Hlne}}\vskip\skiphlne% inside the block + \vtop{\algocf@addskiptotal #1}\Hlne}}\vskip\skiphlne% inside the block \algocf@pop{\skiprule}%\algocf@subskiptotal% restore indentation \nointerlineskip}% no vskip after % -%% block with a vertical line +%%%%%%%%% block with a vertical line \newcommand{\algocf@Vsline}[1]{% no vskip in between boxes but a strut to separate them, \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it + \algocf@bblockcode% \algocf@push{\skiprule}% move to the right before the vertical rule \hbox{\vrule% the vertical rule \vtop{\algocf@push{\skiptext}%move the right after the rule - \vtop{\algocf@addskiptotal\advance\hsize by -\skiplength #1}}}% inside the block - \algocf@pop{\skiprule}}% restore indentation + \vtop{\algocf@addskiptotal #1}}}% inside the block + \algocf@pop{\skiprule}% restore indentation + \algocf@eblockcode% +} % \newcommand{\algocf@Hlne}{\hrule height 0.4pt depth 0pt width .5em}% % -%% block without line +%%%%%%%%% block without line \newcommand{\algocf@Noline}[1]{% no vskip in between boxes but a strut to separate them, \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it + \algocf@bblockcode% \algocf@push{\skiprule}% \hbox{% \vtop{\algocf@push{\skiptext}% - \vtop{\advance\hsize by -\skiplength #1}}}% inside the block + \vtop{\algocf@addskiptotal #1}}}% inside the block \algocf@pop{\skiprule}% + \algocf@eblockcode% % \nointerlineskip% no vskip after }% +%%%%%%%%% % %% default=NoLine % -\newcommand{\algocf@group}[1]{\algocf@Noline{##1}}% group: set of instruction depending from another (ex: then part of the If) -\newcommand{\algocf@@block}[2]{\algocf@Noline{##1}\KwSty{##2}\par}% block: group with a end keyword. +\newcommand{\algocf@group}[1]{\algocf@Noline{#1}}% group: set of instruction depending from another (ex: then part of the If) +\newcommand{\algocf@@@block}[2]{#1\ifArgumentEmpty{#2}{\relax}{\KwSty{\@algocf@endoption{#2}}\strut\par}}% block: group with a end keyword. +\newcommand{\algocf@@block}[2]{\algocf@@@block{#1}{#2}}% 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 @@ -1311,18 +1561,18 @@ \algocf@setBlock}% % \newcommand{\SetAlgoNoLine}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline -\renewcommand{\algocf@@block}[2]{\algocf@Noline{##1}\KwSty{##2}\strut\par}% +\renewcommand{\algocf@@block}[2]{\algocf@@@block{\algocf@Noline{##1}}{##2}}% \renewcommand{\algocf@group}[1]{\algocf@Noline{##1}}% \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{\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{\algocf@@block}[2]{\algocf@@@block{\strut\algocf@Vsline{##1}}{##2}}% no skip after a block so garantie at least one line +\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}}%\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}% \renewcommand{\Hlne}{}}% % \newcommand{\SetNothing}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline @@ -1337,24 +1587,28 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% ``Input :'''s like command +% ``Input:'''s like command % %%% % text staying at the right of the longer keyword of KwInOut commands % (text of KwInOut commands are all vertically aligned) % -\newcommand{\algocf@newinout}{\par\parindent=\wd\algocf@inoutbox}% to put right indentation after a \\ in the KwInOut +\newcommand{\algocf@newinout}{\par\parindent=\inoutindent}% to put right indentation after a \\ in the KwInOut \newcommand{\SetKwInOut}[2]{% \sbox\algocf@inoutbox{\KwSty{#2}\algocf@typo:}% \expandafter\ifx\csname InOutSizeDefined\endcsname\relax% if first time used \newcommand\InOutSizeDefined{}\setlength{\inoutsize}{\wd\algocf@inoutbox}% + \sbox\algocf@inoutbox{\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~}\setlength{\inoutindent}{\wd\algocf@inoutbox}% \else% else keep the larger dimension - \ifdim\wd\algocf@inoutbox>\inoutsize\setlength{\inoutsize}{\wd\algocf@inoutbox}\fi% + \ifdim\wd\algocf@inoutbox>\inoutsize% + \setlength{\inoutsize}{\wd\algocf@inoutbox}% + \sbox\algocf@inoutbox{\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~}\setlength{\inoutindent}{\wd\algocf@inoutbox}% + \fi% \fi% the dimension of the box is now defined. - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \expandafter\algocf@mkcmd\csname#1\endcsname[1]{% + \algocf@newcommand{#1}[1]{% \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}% +% {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}% + {\let\\\algocf@newinout\hangindent=\inoutindent\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}% \algocf@linesnumbered% reset the numbering of the lines }}% % @@ -1371,17 +1625,15 @@ % \newcommand{\algocf@newinput}{\par\parindent=\wd\algocf@inputbox}% to put right indentation after a \\ in the KwInput \newcommand{\SetKwInput}[2]{% - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \expandafter\algocf@mkcmd\csname#1\endcsname[1]{% + \algocf@newcommand{#1}[1]{% \sbox\algocf@inputbox{\hbox{\KwSty{#2}\algocf@typo: }}% \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\everypar={\relax}}% {\let\\\algocf@newinput\hangindent=\wd\algocf@inputbox\hangafter=1\unhbox\algocf@inputbox##1\par}% \algocf@linesnumbered% reset the numbering of the lines }}% \newcommand{\SetKwData}[2]{% - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\DataSty{#2(}\ArgSty{##1}\DataSty{)}}% - \expandafter\algocf@mkcmd\csname#1\endcsname{% + \algocf@newcommand{@#1}[1]{\DataSty{#2(}\ArgSty{##1}\DataSty{)}}% + \algocf@newcommand{#1}{% \@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}% }% % @@ -1400,8 +1652,7 @@ \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]{% + \algocf@newcommand{#1}[1]{% \sbox\algocf@hangingbox{\hbox{\KwSty{#2}\algocf@typo\ }}% {\let\\\algocf@newhanging\hangindent=\wd\algocf@hangingbox\hangafter=1\unhbox\algocf@hangingbox##1\;}% }% @@ -1446,10 +1697,8 @@ \algocf@scrfill\algocf@startsidecomment\ignorespaces}% % \newcommand{\SetKwComment}[3]{% - % newcommand or renewcommand ? - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - %%% comment definition - \expandafter\algocf@mkcmd\csname algocf@#1\endcsname[1]{% + \algocf@newcommand{#1}{\@ifstar{\csname algocf@#1@star\endcsname}{\csname algocf@#1\endcsname}}% + \algocf@newcommand{algocf@#1}[1]{% \sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}% \ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\everypar={\relax}}% {\renewcommand{\algocf@endmarkcomment}{#3}% @@ -1459,49 +1708,51 @@ \algocf@linesnumbered% reset the numbering of the lines }% %%% side comment definitions - % option or not? - \expandafter\algocf@mkcmd\csname algocf@#1@star\endcsname{% - \@ifnextchar [{\csname algocf@#1@staropt\endcsname}{\csname algocf@#1@sidecomment\endcsname}% - }% - % manage option - \expandafter\def\csname algocf@#1@staropt\endcsname[##1]##2{% - \ifthenelse{\boolean{algocf@scleft}}{\setboolean{algocf@sidecomment}{true}}{\setboolean{algocf@sidecomment}{false}}% - \ifx##1h\setboolean{algocf@altsidecomment}{true}\SetSideCommentLeft\fi% - \ifx##1f\setboolean{algocf@altsidecomment}{true}\SetSideCommentRight\fi% - \ifx##1l\setboolean{algocf@altsidecomment}{false}\SetSideCommentLeft\fi% - \ifx##1r\setboolean{algocf@altsidecomment}{false}\SetSideCommentRight\fi% - \csname algocf@#1@sidecomment\endcsname{##2}% call sidecomment - \ifthenelse{\boolean{algocf@sidecomment}}{\setboolean{algocf@scleft}{true}}{\setboolean{algocf@scleft}{false}}% - \setboolean{algocf@altsidecomment}{false}% - }% - % side comment - \expandafter\algocf@mkcmd\csname algocf@#1@sidecomment\endcsname[1]{% + \algocf@newcommand{algocf@#1@star}[2][]{% + \ifArgumentEmpty{##1}\relax{% TODO: Is this even necessary, with all those \ifx's? + \ifthenelse{\boolean{algocf@scleft}}{\setboolean{algocf@sidecomment}{true}}{\setboolean{algocf@sidecomment}{false}}% + \ifx##1h\setboolean{algocf@altsidecomment}{true}\SetSideCommentLeft\fi% + \ifx##1f\setboolean{algocf@altsidecomment}{true}\SetSideCommentRight\fi% + \ifx##1l\setboolean{algocf@altsidecomment}{false}\SetSideCommentLeft\fi% + \ifx##1r\setboolean{algocf@altsidecomment}{false}\SetSideCommentRight\fi% + }% \sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}% \ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\everypar={\relax}}% {% \renewcommand{\algocf@endmarkcomment}{#3}% \let\\\algocf@endstartsidecomment% % here is the comment - %\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% + \strut\ignorespaces##2\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}}% + \ifArgumentEmpty{##1}\relax{% + \ifthenelse{\boolean{algocf@sidecomment}}{\setboolean{algocf@scleft}{true}}{\setboolean{algocf@scleft}{false}}% + \setboolean{algocf@altsidecomment}{false}% + }% + }% +}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% KwProg +% +\newcommand{\SetKwProg}[4]{% + \algocf@newcmdside{#1} 3{\KwSty{#2}\ifArgumentEmpty{#2}\relax{\ }\ArgSty{##2}\KwSty{#3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#4}}% + \algocf@newcmdside{l#1}3{\KwSty{#2} \ArgSty{##2}\KwSty{#3} ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% }% % +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Kw % \newcommand{\SetKw}[2]{% - \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% - \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}}% - }% + \algocf@newcommand{@#1}[1]{\KwSty{#2} \ArgSty{##1}} + \algocf@newcommand{#1}{\@ifnextchar\bgroup{\csname @#1\endcsname}{\KwSty{#2}\xspace}}% +}% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -1531,268 +1782,100 @@ % KwBlock % \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}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2{% \Begin(){} - \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}\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}% + \algocf@newcmdside{#1}{2} + {\KwSty{#2}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##2}{#3}\par} }% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% For Switch +% condition typo % -\newcommand{\SetKwSwitch}[8]{% #1=\Switch #2=\Case #3=\Other #4=swicth #5=case #6=do #7=otherwise #8=endsw -%%%% 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}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \Switch(){}{} - \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}\algocf@block{##2}{\@algocf@endoption{#8}}}% -% side text at the end -\expandafter\def\csname algocf@#1end\endcsname(##1){% \Switch{}{}() -}% +\newcommand{\algocf@scond}{ } +\newcommand{\algocf@econd}{ } +\newcommand{\algocf@ucond}{} +\newcommand{\SetStartEndCondition}[3]{% + \renewcommand{\algocf@scond}{#1}\renewcommand{\algocf@econd}{#2}\renewcommand{\algocf@ucond}{#3}} +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +% For Switch +% +\newcommand{\SetKwSwitch}[9]{% #1=\Switch #2=\Case #3=\Other #4=switch #5=do #6=case #7=otherwise #8=endcase #9=endsw + \algocf@newcmdside{#1}{3} + {\KwSty{#4}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#9}} %%%% 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}}% -% with side text -\expandafter\def\csname algocf@#2opt\endcsname(##1)##2##3{% \Case(){}{} - \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\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}\algocf@block{##2}{\@algocf@endoption{#8}}}% -\expandafter\algocf@mkcmd\csname algocf@u#2\endcsname[2]{% \uCase{}{} - \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}}% -% with side text -\expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \Other(){}{} - \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}\algocf@block{##1}{\@algocf@endoption{#8}}}% -\expandafter\algocf@mkcmd\csname algocf@l#3\endcsname[1]{% ldefault - \KwSty{#7} ##1}% + \algocf@newcmdside{#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@ucond\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#8}}% + \algocf@newcmdside{u#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@ucond\ifArgumentEmpty{##1}\relax{ ##1}\algocf@group{##3}}% + \algocf@newcmdside{l#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@ucond\ ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{ ##1}\strut\par}% +%%%% Other + \algocf@newcmdside{#3}{2}{\KwSty{#7}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##2}{#8}}% + \algocf@newcmdside{l#3}{2}{\KwSty{#7}\ ##2\@endalgocfline\ifArgumentEmpty{##1}\relax{ ##1}\strut\par}% }% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % If macros % -\newcommand{\SetKwIF}[8]{% #1=\If #2=\ElseIf #3=\Else #4=if #5=then #6=elseif si #7=else #8=endif +\newcommand{\SetKwIF}[8]{% #1=\If #2=\ElseIf #3=\Else #4=if #5=then #6=elseif #7=else #8=endif % % common text -\@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]{\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}}% -\@ifundefined{#3@else}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}% -\expandafter\algocf@mkcmd\csname #3@else\endcsname{\KwSty{#7}}% + \algocf@newcommand{#1@ifthen}[1]{\KwSty{#4}\algocf@scond\ArgSty{##1}\algocf@econd\KwSty{#5}}% + \algocf@newcommand{#1@endif} [1]{\algocf@block{##1}{#8}}% + \algocf@newcommand{#1@noend} [1]{\algocf@group{##1}}% + \algocf@newcommand{#1@else} [1]{\algocf@group{##1}\KwSty{#7}}% + \algocf@newcommand{#2@elseif}[1]{\KwSty{#6}\algocf@scond\ArgSty{##1}\algocf@econd\KwSty{#5}}% + \algocf@newcommand{#3@else} {\KwSty{#7}}% %%%% If then { } endif -% -\@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}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \If(){}{} - \csname #1@ifthen\endcsname{##2} ##1\csname #1@endif\endcsname{##3}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \If{}{} - \csname #1@ifthen\endcsname{##1}\csname #1@endif\endcsname{##2}}% -% + \algocf@newcmdside{#1}3{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##3}}% %%%% If then {} else {} endif -% -% side text or not? -\expandafter\def\csname e#1\endcsname{% - \@ifnextchar({\csname algocf@e#1thenopt\endcsname}{\csname algocf@e#1then\endcsname}}% -% with side text after if -\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#1thenelse\endcsname}% -% without side text after if -\expandafter\def\csname algocf@e#1then\endcsname##1##2{% \eIf() - \csname #1@ifthen\endcsname{##1}\csname #1@else\endcsname{##2}% - \csname algocf@e#1thenelse\endcsname}% -% side text after else or not ? -\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#1elseopt\endcsname(##1)##2{% - ##1\csname #1@endif\endcsname{##2}}% -% else without side text -\expandafter\algocf@mkcmd\csname algocf@e#1else\endcsname[1]{% - \csname #1@endif\endcsname{##1}}% -% + % first command to handle optional side comment of else (so just after first braces) + \algocf@newcmdside{algocf@e#1thenelse}2{\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##2}} + % the definition of if-then-else command using command above + \algocf@newcmdside{e#1}3{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@else\endcsname{##3}\csname algocf@e#1thenelse\endcsname}% + %%% leif + \algocf@newcmdside{le#1}4{\csname #1@ifthen\endcsname{##2} ##3 \csname #3@else\endcsname\ ##4\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par} %%%% If then -% -% side text or not? -\expandafter\def\csname l#1\endcsname{% lif - \@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}}% -% with side text -\expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lIf(){}{} - \csname #1@ifthen\endcsname{##2} ##3\algocf@endline\ ##1\par}% -\expandafter\def\csname algocf@u#1opt\endcsname(##1)##2##3{% \uIf(){}{} - \csname #1@ifthen\endcsname{##2} ##1\csname#1@noend\endcsname{##3}}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lIf{}{} - \csname #1@ifthen\endcsname{##1} ##2}% -\expandafter\algocf@mkcmd\csname algocf@u#1\endcsname[2]{% \uIf{}{} - \csname #1@ifthen\endcsname{##1}\csname#1@noend\endcsname{##2}}% -% + \algocf@newcmdside{l#1}3{\csname #1@ifthen\endcsname{##2} ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% + \algocf@newcmdside{u#1}3{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@noend\endcsname{##3}}% %%%% ElseIf {} endif -% -\@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}}% -% with side text -\expandafter\def\csname algocf@#2opt\endcsname(##1)##2##3{% \ElseIf(){}{} - \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}}% -% + \algocf@newcmdside{#2} 3{\csname #2@elseif\endcsname{##2}\relax\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##3}}% %%%% ElseIf -% -% side text or not? -\expandafter\def\csname l#2\endcsname{% lElseIf - \@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}}% -% with side text -\expandafter\def\csname algocf@l#2opt\endcsname(##1)##2##3{% \lElseIf(){}{} - \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}}% -% 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}}% -% + \algocf@newcmdside{l#2}3{\csname #2@elseif\endcsname{##2} ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% + \algocf@newcmdside{u#2}3{\csname #2@elseif\endcsname{##2}\relax\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@noend\endcsname{##3}}% %%%% 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}}% -% with side text -\expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \Else(){} - \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}}% -% + \algocf@newcmdside{#3} 2{\csname #3@else\endcsname\ifArgumentEmpty{##1}\relax\ ##1\csname #1@endif\endcsname{##2}}% %%%% Else -% -% side text or not? -\expandafter\def\csname l#3\endcsname{% lElse - \@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}}% -% 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@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}}% -}% + \algocf@newcmdside{l#3}2{\csname #3@else\endcsname\ ##2\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% + \algocf@newcmdside{u#3}2{\csname #3@else\endcsname \ifArgumentEmpty{##1}\relax{\ ##1\relax}\csname #1@noend\endcsname{##2}}% +}% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % For macros % \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}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \For(){}{} - \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}% -% without side text -\expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \For{}{} - \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}% + \algocf@newcmdside{#1} 3{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#4}}% + \algocf@newcmdside{l#1}3{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3} ##3\@endalgocfline\ifArgumentEmpty{##1}\relax{##1}\strut\par}% }% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Repeat macros % +\newsavebox{\algocf@untilbox}% to handle width of until keyword needed to have good skip + % for line numbers +\newskip\algocf@skipuntil \newcommand{\SetKwRepeat}[3]{% -\@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}}% -% with side text -\expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \Repeat(){}{} - \KwSty{#2} ##1\algocf@group{##3}\KwSty{#3} \ArgSty{##2}% - \@ifnextchar({\csname algocf@#1optopt\endcsname}{\@endalgoln}% -}% -\expandafter\def\csname algocf@#1optopt\endcsname(##1){% \Repeat(){}{}() - ##1\@endalgoln}% -\expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lRepeat(){}{} - \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}\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}}% + \algocf@newcmdsides{#1}{3}{% + \sbox\algocf@untilbox{\KwSty{#3}\algocf@scond}\algocf@skipuntil=\wd\algocf@untilbox% + \KwSty{#2}\ifArgumentEmpty{##1}\relax{##1}\algocf@group{##3}% + \KwSty{#3}\algocf@scond% until keyword and start condition typo + \advance\skiptotal by\algocf@skipuntil% + \ArgSty{##2}% + \advance\skiptotal by-\algocf@skipuntil% + \algocf@ucond% + \algocf@skipuntil=0pt% reset counter + }{\@endalgocfline}{\strut\par}% + \algocf@newcmdside{l#1}3{\KwSty{#2} ##3 \KwSty{#3}\algocf@scond\ArgSty{##2}\algocf@ucond\@endalgocfline\ifArgumentEmpty{##1}\relax{ ##1}\strut\par}% }% % % @@ -1841,6 +1924,7 @@ \addtolength{\hsize}{\algomargin}% }% % +\newcommand{\algocf@makecaption@plainruled}[2]{\algocf@makecaption@plain{#1}{#2}}% \newcommand{\algocf@makecaption@tworuled}[2]{\algocf@makecaption@ruled{#1}{#2}}% \newcommand{\algocf@makecaption@algoruled}[2]{\algocf@makecaption@ruled{#1}{#2}}% \newcommand{\algocf@makecaption@boxruled}[2]{\algocf@makecaption@ruled{#1}{#2}}% @@ -1854,9 +1938,10 @@ \newlength{\algotitleheightruledefault}\setlength{\algotitleheightruledefault}{0.8pt}% \newlength{\algotitleheightrule}\setlength{\algotitleheightrule}{\algotitleheightruledefault}% \newcommand{\algocf@caption@plain}{\vskip\AlCapSkip\box\algocf@capbox}% +\newcommand{\algocf@caption@plainruled}{\algocf@caption@plain}% \newcommand{\algocf@caption@boxed}{\vskip\AlCapSkip\box\algocf@capbox}% \newcommand{\algocf@caption@ruled}{\box\algocf@capbox\kern\interspacetitleruled\hrule height\algotitleheightrule depth0pt\kern\interspacealgoruled}% -\newcommand{\algocf@caption@tworuled}{\box\algocf@capbox\kern\interspacetitleruled}% +\newcommand{\algocf@caption@tworuled}{\box\algocf@capbox\hrule height0pt depth0pt\kern\interspacealgoruled}% \newcommand{\algocf@caption@algoruled}{\algocf@caption@ruled}% \newcommand{\algocf@caption@boxruled}{% \addtolength{\hsize}{-0.8pt}% @@ -1891,7 +1976,7 @@ \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 + \algocf@latexcaption{#1}[{#2}]{{#3}}% call original caption }% % % beamer define is own caption overrinding latex caption! @@ -2008,8 +2093,8 @@ \def\fps@algocf{htbp}% % default \def\ftype@algocf{10}% % float type \def\ext@algocf{\algocf@list} % loa by default, lof if figure option used -\newcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}% -\newcommand{\algocf@resetfnum}{\renewcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}}% +\newcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}% +\newcommand{\algocf@resetfnum}{\renewcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}}% \newenvironment{algocf}% % float environment for algorithms {\@float{algocf}}% {\end@float}% @@ -2063,6 +2148,9 @@ \def\@algocf@pre@boxruled{\noindent\begin{lrbox}{\algocf@algoframe}}% \def\@algocf@post@boxruled{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}% \def\@algocf@capt@boxruled{above}% +\def\@algocf@pre@plainruled{\@algocf@pre@ruled}% action to be done before printing the algo. +\def\@algocf@post@plainruled{\@algocf@post@ruled\kern\interspacealgoruled}% action to be done before printing the algo. +\def\@algocf@capt@plainruled{under}% % \newcommand{\noalgocaption}{\def\@algocf@capt@ruled{none}} % @@ -2135,6 +2223,7 @@ %%%%%%%%%%%%%%%%%%% % %% at the beginning of algocf or figure environment +\newenvironment{algomathdisplay}{\[}{\@endalgocfline\]\ifthenelse{\boolean{algocf@linesnumbered}}{\nl}{\relax}}% \newcommand{\@algocf@start}{% \@algoskip% \begin{lrbox}{\algocf@algobox}% @@ -2148,6 +2237,7 @@ \raggedright\AlFnt{}% \ifthenelse{\boolean{algocf@slide}}{\IncMargin{\skipalgocfslide}}{}% \@algoinsideskip% +% \let\@emathdisplay=\]\def\]{\algocf@endline\@emathdisplay\nl}% }% % %% at the end of algocf or figure environment @@ -2165,6 +2255,7 @@ \setlength{\hsize}{\algowidth}% \lineskip\normallineskip\setlength{\skiptotal}{\@defaultskiptotal}% \let\;=\@mathsemicolon% + \let\]=\@emathdisplay% }% % %%%%%%%%%%%%%%%%%%%% @@ -2405,6 +2496,7 @@ % french keywords % %\SetKwInOut{AlgDonnees}{Donn\'ees}\SetKwInOut{AlgRes}{R\'esultat} +\SetKwHangingKw{HDonnees}{Donnees$\rightarrow$} \SetKwInput{Donnees}{Donn\'ees}% \SetKwInput{Res}{R\'esultat}% \SetKwInput{Entree}{Entr\'ees}% @@ -2415,15 +2507,16 @@ \SetKwRepeat{Repeter}{r\'ep\'eter}{jusqu'\`a}% % \SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin si}% -\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin d'alternative}% +\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}% \SetKwFor{Pour}{pour}{faire}{fin pour}% -\SetKwFor{PourPar}{pour}{faire en parallèle}{fin pour}% +\SetKwFor{PourPar}{pour}{faire en parall\`ele}{fin pour}% \SetKwFor{PourCh}{pour chaque}{faire}{fin pour chaque}% \SetKwFor{PourTous}{pour tous les}{faire}{fin pour tous}% \SetKwFor{Tq}{tant que}{faire}{fin tq}% % % english keywords % +\SetKwHangingKw{KwHData}{Data$\rightarrow$} \SetKwInput{KwIn}{Input}% \SetKwInput{KwOut}{Output}% \SetKwInput{KwData}{Data}% @@ -2435,7 +2528,7 @@ \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}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{end switch}% \SetKwFor{For}{for}{do}{end for}% \SetKwFor{ForPar}{for}{do in parallel}{end forpar} \SetKwFor{ForEach}{foreach}{do}{end foreach}% @@ -2455,7 +2548,7 @@ \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 +\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}{Ende Unt.}%Switch \SetKwFor{Fuer}{f\"ur}{tue}{Ende f\"ur}%For \SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar \SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach @@ -2481,7 +2574,7 @@ \SetKwRepeat{Repita}{repita}{at\'{e}}% % \SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% -\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}% +\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}{fim selec}% \SetKwFor{Para}{para}{fa\c{c}a}{fim para}% \SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{fim para} \SetKwFor{ParaCada}{para cada}{fa\c{c}a}{fim para cada}% @@ -2498,15 +2591,57 @@ \SetKw{KwRitorna}{ritorna}% \SetKw{Ritorna}{ritorna}% \SetKwBlock{Inizio}{inizio}{fine}% -\SetKwRepeat{Ripeti}{ripeti}{finché}% +\SetKwRepeat{Ripeti}{ripeti}{finch\'e}% % \SetKwIF{Sea}{AltSe}{Altrimenti}{se}{allora}{altrimenti se}{allora}{fine se}% -\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{endsw}% \SetKwFor{Per}{per}{fai}{fine per}% \SetKwFor{PerPar}{per}{fai in parallelo}{fine per}% \SetKwFor{PerCiascun}{per ciascun}{fai}{fine per ciascun}% \SetKwFor{PerTutti}{per tutti i}{fai}{fine per tutti}% -\SetKwFor{Finche}{finché}{fai}{fine finché}% +\SetKwFor{Finche}{finch\'e}{fai}{fine finch\'e}% +% +% --- Spanish keywords +% +\SetKwInput{Datos}{Datos} +\SetKwInput{Resultado}{Resultado} +\SetKwInput{Entrada}{Entrada} +\SetKwInput{Salida}{Salida} +\SetKw{KwA}{a} +\SetKw{KwDevolver}{devolver} +\SetKw{Devolver}{devolver} +\SetKwBlock{Inicio}{inicio}{fin} +\SetKwIF{SSi}{EnOtroCasoSi}{EnOtroCaso}{si}{entonces}{sin\'o, si}{sin\'o}{fin si} +\SetKwSwitch{Seleccionar}{Caso}{Otro}{seleccionar}{hacer}{caso}{sin\'o}{fin caso}{fin seleccionar} +\SetKwFor{Para}{para}{hacer}{fin para} +\SetKwFor{ParaPara}{par}{hacer en paralelo}{fin para} +\SetKwFor{EnParalelo}{para}{hacer en paralelo}{fin para} +\SetKwFor{Mientras}{mientras}{hacer}{fin mientras} +\SetKwFor{ParaCada}{para cada}{hacer}{fin para cada} +\SetKwFor{ParaTodo}{para todo}{hacer}{fin para todo} +\SetKwRepeat{Repetir}{repetir}{hasta que} +% +% Croatian keywords +% +\SetKwInput{KwUlaz}{Ulaz}%KwIn +\SetKwInput{KwIzlaz}{Izlaz}%KwOut +\SetKwInput{KwPodaci}{Podaci}%KwData +\SetKwInput{KwRezultat}{Rezultat}%KwResult +\SetKw{KwDo}{do}%KwTo +\SetKw{KwVrati}{vrati}%KwRet +\SetKw{Vrati}{vrati}%Return +\SetKwBlock{Pocetak}{po\v{c}etak}{kraj}%Begin +\SetKwRepeat{Ponavljaj}{ponavljaj}{dok ne bude}%Repeat +% +\SetKwIF{Ako}{InaceAko}{Inace}{ako}{onda}{ina\v{c}e ako}{ina\v{c}e}{kraj}%gIf +\SetKwSwitch{Granaj}{Slucaj}{Inace}{granaj}{\v{c}ini}{slu\v{c}aj}{ina\v{c}e}{kraj}{kraj}%Switch +\SetKwFor{Za}{za}{\v{c}ini}{kraj}%For +\SetKwFor{ZaPar}{za}{izvr\v{s}avaj paralelno}{kraj}%ForPar +\SetKwFor{ZaSvaki}{za svaki}{\v{c}ini}{kraj}%mForEach +\SetKwFor{ZaSvaku}{za svaku}{\v{c}ini}{kraj}%fForEach +\SetKwFor{ZaSvako}{za svako}{\v{c}ini}{kraj}%nForEach +\SetKwFor{ZaSve}{za sve}{\v{c}ini}{kraj}%ForAll +\SetKwFor{Dok}{dok}{\v{c}ini}{kraj}%While % % --- End %} @@ -2527,9 +2662,9 @@ \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}% +\SetKwSwitch{Switch}{Case}{Other}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}% \SetKwFor{For}{pour}{faire}{fin pour}% -\SetKwFor{ForPar}{pour}{faire en parallèle}{fin pour}% +\SetKwFor{ForPar}{pour}{faire en parall\`ele}{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}% @@ -2546,14 +2681,14 @@ \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 +\SetKwSwitch{Switch}{Case}{Other}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}{Ende Unt.}%Switch \SetKwFor{For}{f\"ur}{tue}{Ende f\"ur}%For \SetKwFor{ForPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar \SetKwFor{ForEach}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach \SetKwFor{ForAll}{f\"ur alle}{tue}{Ende f\"ur}%ForAll \SetKwFor{While}{solange}{tue}{Ende solange}%While }{}% -\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{portugues}}{% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{portuguese}}{% \SetKwInput{KwIn}{Entrada}% \SetKwInput{KwOut}{Sa\'{i}da}% \SetKwInput{KwData}{Dados}% @@ -2565,7 +2700,7 @@ \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}% +\SetKwSwitch{Switch}{Case}{Other}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}{fim selec}% \SetKwFor{For}{para}{fa\c{c}a}{fim para}% \SetKwFor{ForPar}{para}{fa\c{c}a em paralelo}{fim para} \SetKwFor{ForEach}{para cada}{fa\c{c}a}{fim para cada}% @@ -2581,21 +2716,61 @@ \SetKw{KwRet}{ritorna}% \SetKw{Return}{ritorna}% \SetKwBlock{Begin}{inizio}{fine}% -\SetKwRepeat{Repeat}{ripeti}{finché}% +\SetKwRepeat{Repeat}{ripeti}{finch\'e}% % \SetKwIF{If}{ElseIf}{Else}{se}{allora}{altrimenti se}{allora}{fine se}% -\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}% +\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{endsw}% \SetKwFor{For}{per}{fai}{fine per}% \SetKwFor{ForPar}{per}{fai in parallelo}{fine per}% \SetKwFor{ForEach}{per ciascun}{fai}{fine per ciascun}% \SetKwFor{ForAll}{per tutti i}{fai}{fine per tutti}% -\SetKwFor{While}{finché}{fai}{fine finché}% +\SetKwFor{While}{finch\'e}{fai}{fine finch\'e}% +}{}% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{spanish}}{% +\SetKwInput{KwIn}{Entrada}% +\SetKwInput{KwOut}{Salida}% +\SetKwInput{KwData}{Datos}% +\SetKwInput{KwResult}{Resultado}% +\SetKw{KwTo}{a}% +\SetKw{KwRet}{devolver}% +\SetKw{Return}{devolver}% +\SetKwBlock{Begin}{inicio}{fin}% +\SetKwRepeat{Repeat}{repetir}{hasta que}% +% +\SetKwIF{If}{ElseIf}{Else}{si}{entonces}{sin\'o, si}{en otro caso}{fin si} +\SetKwSwitch{Switch}{Case}{Other}{seleccionar}{hacer}{caso}{sin\'o}{fin caso}{fin seleccionar} +\SetKwFor{For}{per}{fai}{fine per}% +\SetKwFor{ForPar}{par}{hacer in paralelo}{fin para}% +\SetKwFor{ForEach}{para cada}{hacer}{fin para cada} +\SetKwFor{ForAll}{para todo}{hacer}{fin para todo} +\SetKwFor{While}{mientras}{hacer}{fin mientras} +}{}% +% +\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{croatian}}{% +\SetKwInput{KwIn}{Ulaz}%KwIn +\SetKwInput{KwOut}{Izlaz}%KwOut +\SetKwInput{KwData}{Podaci}%KwData +\SetKwInput{KwResult}{Rezultat}%KwResult +\SetKw{KwTo}{do}%KwTo +\SetKw{KwRet}{vrati}%KwRet +\SetKw{Return}{vrati}%Return +\SetKwBlock{Begin}{po\v{c}etak}{kraj}%Begin +\SetKwRepeat{Repeat}{ponavljaj}{dok ne bude}%Repeat +% +\SetKwIF{If}{ElseIf}{Else}{ako}{onda}{ina\v{c}e ako}{ina\v{c}e}{kraj}%gIf +\SetKwSwitch{Switch}{Case}{Other}{granaj}{\v{c}ini}{slu\v{c}aj}{ina\v{c}e}{kraj}{kraj}%Switch +\SetKwFor{For}{za}{\v{c}ini}{kraj}%For +\SetKwFor{ForPar}{za}{izvr\v{s}avaj paralelno}{kraj}%ForPar +\SetKwFor{ForEach}{za svaki}{\v{c}ini}{kraj}%ForEach +\SetKwFor{ForAll}{za sve}{\v{c}ini}{kraj}%ForAll +\SetKwFor{While}{dok}{\v{c}ini}{kraj}%While }{}% % %%%% old commands compatibility % \ifthenelse{\boolean{algocf@oldcommands}}{% \newcommand{\SetNoLine}{\SetAlgoNoLine}% +\newcommand{\SetNoline}{\SetAlgoNoLine}% \newcommand{\SetVline}{\SetAlgoVlined}% \newcommand{\SetLine}{\SetAlgoLined}% % @@ -2619,12 +2794,18 @@ \newcommand{\restylealgo}[1]{\RestyleAlgo{#1}}% % \newcommand{\Titleofalgo}[1]{\TitleOfAlgo{#1}}% +% \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif} +\newcommand{\SetKwIf}[6]{\SetKwIF{#1}{#2#1}{#2}{#3}{#4}{#5 #1}{#5}{#6}} +% \SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{fin si}% \SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{end if}% \SetKwIF{gIf}{gElseIf}{gElse}{if}{then}{else if}{else}{end if}% \SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf \SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}% \SetKwIF{gSea}{gAltSe}{gAltrimenti}{se}{allora}{altrimenti se}{allora}{fine se}% +\SetKw{Ret}{return}% +\SetKwInput{Data}{Data}% +\SetKwInput{Result}{Result}% }{% \relax% }% -- cgit v1.2.3