algorithm2e.sty 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123
  1. % algorithm2e.sty --- style file for algorithms
  2. %% Copyright 1996-2005 Christophe Fiorio
  3. %
  4. % This program may be distributed and/or modified under the
  5. % conditions of the LaTeX Project Public License, either version 1.2
  6. % of this license or (at your option) any later version.
  7. % The latest version of this license is in
  8. % http://www.latex-project.org/lppl.txt
  9. % and version 1.2 or later is part of all distributions of LaTeX
  10. % version 1999/12/01 or later.
  11. %
  12. % This program consists of the files algorithm2e.sty and algorithm2e.tex
  13. %
  14. % Report bugs and comments to:
  15. % fiorio@lirmm.fr
  16. %
  17. % $Id: algorithm2e.sty,v 3.9 2005/10/04 12:34:52 fiorio Exp $
  18. %
  19. % PACKAGES REQUIRED:
  20. %
  21. % - float (in contrib/supported/float)
  22. % - ifthen (in base)
  23. % - xspace (in packages/tools)
  24. %
  25. %%%%%%%%%%%%%%% Release 3.9
  26. %
  27. % History:
  28. %
  29. % - October 04 2005 - revision 3.9 -
  30. % * ADD: - \setalcaphskip command which set the horizontal skip before Algorithm: in caption when
  31. % used in ruled algorithm.
  32. % * ADD: - SetAlgoInsideSkip command which allows to add an extra vertical space before and after
  33. % the core of the algorithm (ie: \SetAlgoInsideSkip{bigskip})
  34. % * CHANGE: - caption, when used with figure option, is no more controlled by algorithm2e package
  35. % and so follows the exact behaviour of figures. The drawback is that you cannot change
  36. % the typo with AlTitleFnt or CapFnt. The avantage is that if you use caption package,
  37. % it works.
  38. % * FIX: - problem with numbering line and pdflatex
  39. % * FIX: - error when algorithm2e package was used with beamer and listings together
  40. % - February 12 2005 - revision 3.8 -
  41. % * FIX: - extra line with noend option.
  42. % - February 10 2005 - revision 3.7 -
  43. % * ADD: - sidecomment: different macros allowing to put text right after code
  44. % on the same line. They are defined in the same time comment macros
  45. % are defined with a star after the macro name. By default comments
  46. % are right justified but this can be change with appropriate option
  47. % in the macro. Ex:
  48. % . default: \tcc*{side comment}
  49. % . same as previous: \tcc*[r]{side comment}
  50. % . left justify: \tcc*[l]{side comment}
  51. % . here: \tcc*[h]{side comment} don't put the end of line mark before
  52. % comment (; by default) and don't end the line.
  53. % . flushed: \tcc*[f]{side comment} same as the precedent but right
  54. % justified
  55. % * ADD: - scright OPTION (default): right justified side comments (side comments
  56. % are flushed to the righr)
  57. % * ADD: - scleft OPTION: left justified side comments (side comments are
  58. % put right after the code line)
  59. % * ADD: - \SetSideCommentLeft acts as scleft option
  60. % * ADD: - \SetSideCommentRight acts as scright option
  61. % * ADD: - block like macro side text: all macro defining a block allows now
  62. % to put text right after key words by putting text into (). Done to
  63. % be used with sidecomment macros, but all text can be used. Ex:
  64. % \eIf(\tcc*[f]{then comment}){test}{then text}(else side text){else text}
  65. % * ADD: - fillcomment OPTION (default): end mark of comment is flushed to the
  66. % right so comments fill all the width of text
  67. % * ADD: - nofillcomment OPTION: end mark of comment is put right after the
  68. % comment
  69. % * ADD: - \SetNoFillComment acts as nofillcomment option.
  70. % * ADD: - \SetFillComment acts as fillcomment option.
  71. % * ADD: - dotocloa OPTION which adds an entry in the toc for the list of
  72. % algorithms. This option load package tocbibind if not already done
  73. % and so list of figures and list of tables are also added in the toc.
  74. % If you want to control which ones of the lists will be added in the
  75. % toc, please load package tocbibind before package algorithm and give
  76. % it the options you want.
  77. % * FIX: - vertical spacing for uif macro with noend option
  78. % * FIX: - all the compatibility problems between caption and other packages
  79. % * FIX: - typographical differences between list of algorithms and other lists
  80. % when in report or book
  81. %
  82. % - January 24 2005 - revision 3.6 -
  83. % * FIX: - vertical spacing and space characters at the beginning or end of
  84. % comments.
  85. % line numbers of comments not in the nlsty.
  86. % Thanks to Arnaud Giersch for his comments and suggestions.
  87. % * FIX: - Set*Sty macro: the styles defined was not protected and was modified
  88. % by surrounding context. For example KwTo in a \For{}{} was in bold AND
  89. % italic instead of just in bold.
  90. % * FIX: - line number misplacement after \Indp
  91. %
  92. % - January 21 2005 - revision 3.5 -
  93. % * ADD: - hidden numbering of the lines. Lines are auto-numbered but numbers
  94. % are shown only on lines you specify:
  95. % * linesnumberedhidden option or \linesnumberedhidden macro activate
  96. % this functionnality.
  97. % * \showln and \showlnlabel{lab} macros make the number visible on
  98. % the line. \showlnlabel{lab} allows to set a label for this line.
  99. % Thanks to Samson de Jager who makes this suggestion and provides the
  100. % macros.
  101. % * ADD: - \AlCapFnt and \SetAlCapFnt which allow to have a different font for
  102. % caption. Works like \AlFnt and \SetAlFnt and by default is the same.
  103. % * ADD: - \AlCapSkip skip length. This vertical space is added before caption
  104. % in plain ou boxed mode. It allows to change distance between text
  105. % and caption.
  106. % * FIX: - caption compatible with IEEEtran class.
  107. % * FIX: - some vertical spacing error with \uIf macros (Thanks to Arnaud Giersch)
  108. % * FIX: - Procedure and Function: lines are also numbered like algorithms
  109. % * FIX: - CommentSty was not used for Comments
  110. %
  111. % - January 10 2005 - revision 3.4 -
  112. % * FIX: - caption compatible with new release of Beamer class.
  113. %
  114. % - June 16 2004 - revision 3.3 -
  115. % * FIX: - Hyperlink references of Hyperref package works now if compiled with pdflatex
  116. % and [naturalnames] option of hyperref package is used.
  117. % * FIX: - algorithm[H] had problem in an list environment - corrected
  118. % * FIX: - interline was not so regular in nested blocks - corrected
  119. % * ADD - \Setvlineskip macro which set the vertical skip after the little horizontal
  120. % rule which closes a block in Vlined mode. By default 0.8ex
  121. %
  122. % - June 11 2004 - revision 3.2 - AUTO NUMBERING LINES !!!
  123. % * ADD: auto numbering of the lines (the so asked and so long awaiting feature)
  124. % this feature is managed by 3 options and 3 commands:
  125. % - linesnumbered option: lines of the algo are numbered except for comments and
  126. % input/output (KwInput and KwInOut)
  127. % - commentsnumbered option: makes comments be numbered
  128. % - inoutnumbered option: makes data input/output be numbered
  129. % - \nllabel{lab} labels the line so you can cite with \ref{lab}
  130. % - \linesnumbered make the following algorithms having auto-numbered lines
  131. % - \linesnotnumbered make the following algorithms having no auto-numbered lines
  132. % * Change: algo2e option renames listofalgorithm in listofalgorithme
  133. % * FIX: new solution for compatibility with color package, more robust and not tricky.
  134. % Many thanks to David Carlisle for his advices
  135. %
  136. % - June 09 2004 - revision 3.1 -
  137. % * Change: \SetKwSwitch command defines an additionnal
  138. % macro \uCase and \Case prints end
  139. % * Change: now macros SetKw* do a renewcommand if the
  140. % keyword is already defined. So you can redefine
  141. % default definition at your own convenience or
  142. % change your definition without introducing a
  143. % new macro and changing your text.
  144. % * ADD: new macro \SetKwIF which do \SetKwIf and
  145. % \SetKwIfElseIf.The following default definition has been added:
  146. % \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}
  147. % and so you get the macros;
  148. % \If \eIf \lIf \uIf \ElseIf \uElseIf \lElseIf \Else
  149. % \uElse \lElse
  150. % * ADD: new macro \SetAlgoSkip which allow to fix the
  151. % vertical skip before and after the algorithms.
  152. % Default is smallskip, do \SetAlgoSkip{} if you
  153. % don't want an extra space or \SetAlgoSkip{medskip}
  154. % or \SetAlgoSkip{bigskip} if you want bigger space.
  155. % * ADD: macro \SetKwIf defines in addition a new macro
  156. % \uElse (depending on wat name you
  157. % have given in #2 arg).
  158. % * ADD: macro \SetKwIfElseIf defines in addition a new macro
  159. % \uElse and \ugElseIf (depending on what name you
  160. % have given in #2 and #3 arg).
  161. % * Change: baseline of algorithm is now top, so two
  162. % algorithms can be put side by side.
  163. % * FIX: Compatibility with color package solved. The problem
  164. % was due to a redefinition of standard macros by color package
  165. % This solves compatibility problem with other packages
  166. % as pstcol or colortbl.
  167. % (notified by Dirk Fressmann, Antti Tarvainen and Koby Crammer)
  168. % * Fix: extra little shift to the right with boxed style
  169. % algorithm removed (notified by P. Tanovski)
  170. % * Fix: algoln option was buggy (notified bye Jiaying Shen)
  171. % * Fix: german and portuges option didn't work due to bad
  172. % typo (notified by Martin Sievers, Thorsten Vitt
  173. % and Jeronimo Pellegrini)
  174. %
  175. % - February 13 2004 - revision 3.0 -
  176. % * Major revision which makes the package independent from
  177. % float.sty, so now
  178. % - algorithm* works better, in particular can be used in
  179. % multicols environments
  180. % - (known bug corrected)
  181. % [H] works now for all sort of environment but is
  182. % handled differently for classic environment and star
  183. % environment (algorithm, figure, procedure and
  184. % function). For star environment, H acts like for
  185. % classical figure environment, so it doesn't stay here
  186. % absolutely.
  187. % - (known bug corrected)
  188. % you can use now floatflt package with algorithm
  189. % package and even with figure option. Beware that if
  190. % you want to put an algorithm inside a floatingfigure,
  191. % it cannot be floating, so [H] is required and then
  192. % figure option should not be used, since standard
  193. % figure[H] are still floating with LaTeX.
  194. % * boxruled: a new style added. Possible now since no
  195. % style no more defined by the float package.
  196. % * nocaptionofalgo: dosen't print Algorithm #: in the
  197. % caption for algorithm in ruled or algoruled style.
  198. % note: this is just documentation of a macro which was
  199. % already in the package.
  200. % - December 14 2003 - revision 2.52 -
  201. % * output message shorter
  202. % * french keyword macro \PourTous was missing for
  203. % longend option, it has been added.
  204. % * TitleofAlgo prints Function or Procedure in
  205. % corresponding environments.
  206. %
  207. % - October 27 2003 - revision 2.51 - Revision submitted to CTAN archive
  208. % * correction of a minor which make caption in procedure
  209. % and function to be blanck with pdfscreen package
  210. % (thanks to Joel Gossens for the notification)
  211. % * add two internal definition to avoid some errors when
  212. % used with Hyperref package (Hyperref package need to
  213. % define new counter macro from existing ones, and
  214. % don't do it for algorithm2e package, so we do it)
  215. %
  216. % - October 17 2003 - revision 2.50 - first revision for CTAN archive
  217. %
  218. % * add \AlFnt and \SetAlFnt{font} macros:
  219. % \AlFnt is used at the beginning of the caption and the
  220. % body of algorithm in order to define the fonts used
  221. % for typesetting algorithms. You can use it elsewhere
  222. % you want to typeset text as algorithm. For example
  223. % you can do \SetAlFnt{\small\sf} to have algorithms
  224. % typeset in small sf font. Default is nothing so
  225. % algorithm is typeset as the text of the document.
  226. % * add \AlTitleFnt{text} and \SetAlTitleFnt{font} macros:
  227. % The {Algorithm: } in the caption is typeset with
  228. % \AlTitleFnt{Algorithm:}. You can use it to have text
  229. % typeset as {Algorithm:} of captions. Default is
  230. % textbf.
  231. % Default can be redefined by \SetAlTitleFnt{font}.
  232. % * add CommentSty typo for text comment.
  233. % * add some compatibility with hyperref package (still
  234. % an error on multiply defined refs but pdf correctly
  235. % generated)
  236. % * flush text to left in order to have correct
  237. % indentation even with class as amsart which center
  238. % all figures
  239. % * add german, portugues and czech options for title of
  240. % algorithms and typo.
  241. % * add portuguese translation of predefined keywords
  242. % * add czech translation of some predefined keywords
  243. %
  244. % - December 23 2002 - revision 2.40
  245. % * add some french keyword missing
  246. % * add function* and procedure* environment like
  247. % algorithme* environment: print in one column even
  248. % if twocolumn option is specified for the document.
  249. % * add a new macro \SetKwComment to define macro which
  250. % writes comments in the text. First argument is the
  251. % name of the macro, second is the text put before the
  252. % comment, third is the text put at the end of the
  253. % comment.Default are \tcc and \tcp
  254. % * add new options to change the way algo are numbered:
  255. % [algopart] algo are numbered within part (counter must exist)
  256. % [algochapter] algo are numbered within chapter
  257. % [algosection] algo are numbered within section
  258. %
  259. % - March 27 2002 - revision 2.39
  260. % * Gilles Geeraerts: added the \SetKwIfElseIf to manage
  261. % if (c)
  262. % i;
  263. % else if (c)
  264. % i;
  265. % ...
  266. % else
  267. % i;
  268. % end
  269. % * Also added \gIf \gElsIf \gElse.
  270. %
  271. % - January 02 2001 - revision 2.38
  272. % * bugs related to the caption in procedure and function
  273. % environment are corrected.
  274. % * bug related to option noend (extra vertical space added
  275. % after block command as If or For) is corrected.
  276. % * czech option language added (thanks to Libor Bus: l.bus@sh.cvut.cz).
  277. %
  278. % - October 16 2000 - revision 2.37
  279. % * option algo2e added: change the name of environment
  280. % algorithm into algorithm2e. So allow to use the package
  281. % with some journal style which already define an algorithm
  282. % environment.
  283. %
  284. % - September 13 2000 - revision 2.36
  285. % * option slide added: require package color
  286. % * Hack for slide class in order to have correct
  287. % margins
  288. %
  289. % - November 25 1999 - revision 2.35
  290. % * revision number match RCS number
  291. % * Thanks to David A. Bader, a new option is added:
  292. % noend: no end keywords are printed.
  293. %
  294. % - November 19 1999 - revision 2.32
  295. % * minor bug on longend option corrected.
  296. %
  297. % - August 26 1999 - revision 2.31
  298. % * add an option : figure
  299. % this option makes algorithms be figure and so are numbered
  300. % as figures, have Figure as caption and are put in
  301. % the \listoffigures
  302. %
  303. % - January 21 1999 - revision 2.3 beta
  304. % add 2 new environments: procedure and function.
  305. % These environments works like algorithm environment but:
  306. % - the ruled (or algoruled) style is imperative.
  307. % - the caption now writes Procedure name....
  308. % - the syntax of the \caption command is restricted as
  309. % follow: you MUST put a name followed by 2 braces like
  310. % this ``()''. You can put arguments inside the braces and
  311. % text after. If no argument is given, the braces will be
  312. % removed in the title.
  313. % - label now puts the name (the text before the braces in the
  314. % caption) of the procedure or function as reference (not
  315. % the number like a classic algorithm environment).
  316. % There are also two new styles : ProcNameSty and
  317. % ProcArgSty. These style are by default the same as FuncSty
  318. % and ArgSty but are used in the caption of a procedure or a
  319. % function.
  320. %
  321. % - November 28 1996 - revision 2.22
  322. % add a new macro \SetKwInParam{arg1}{arg2}{arg3}:
  323. % it defines a macro \arg1{name}{arg} which prints name in keyword
  324. % style followed byt arg surrounded by arg2 and arg3. The main
  325. % application is to a function working as \SetKwInput to be used
  326. % in the head of the algorithm. For example
  327. % \SetKwInParam{Func}{(}{)} allows
  328. % \Func{functionname}{list of arguments} which prints:
  329. % \KwSty{functioname(}list of arguments\KwSty{)}
  330. %
  331. %
  332. % - November 27 1996 - revision 2.21 :
  333. % minor bug in length of InOut boxes fixed.
  334. % add algorithm* environment.
  335. %
  336. % - July 12 1996 - revision 2.2 : \SetArg and \SetKwArg macros removed.
  337. %
  338. % \SetArg has been removed since it never has been
  339. % documented.
  340. % \SetKwArg has been removed since \SetKw can now
  341. % take an argument in order to be consistent with
  342. % \SetKwData and \SetKwFunction macros.
  343. %
  344. % - July 04 1996 - revision 2.1 : still more LaTeX2e! Minor compatibility break
  345. %
  346. % Macros use now \newcommand instead of \def, use of \setlength,
  347. % \newsavebox, ... and other LaTeX2e specific stuff.
  348. % The compatibility break:
  349. % - \SetData becomes \SetKwData to be more consistent. So the old
  350. % \SetKwData becomes \SetKwInput
  351. % - old macros \titleofalgo, \Freetitleofalgo and \freetitleofalgo
  352. % from LaTeX209 version which did print a warning message and call
  353. % \Titleofalgo in version 2.0 are now removed!
  354. %
  355. % - March 13 1996 - revision 2.0: first official major revision.
  356. %
  357. %
  358. %%%%%%%%%%%%%%
  359. %
  360. % Known bugs:
  361. % -----------
  362. % - no more known bugs... all are corrected!
  363. %
  364. %%%%%%%%%%%%%%
  365. %
  366. % Package options:
  367. % ---------------
  368. % - french, english, german, portuguese, czech : for the name of the algorithm, e.g.
  369. % - boxed, boxruled, ruled, algoruled, plain : layout of the algorithm
  370. % - algo2e : environment is algorithm2e instead of algorithms
  371. % and \listofalgorithmes instead of \listofalgorithms
  372. % - slide : to use when making slides
  373. % - noline,lined,vlined : how block are designed.
  374. % - linesnumbered : auto numbering of the algorithm's lines
  375. % - algopart,algochapter,algosection : algo numbering within part, chapter or section
  376. % - titlenumbered,titlenotnumbered : numbering of title set by \Titleofalgo
  377. % - figure : algorithms are figures, numbered as figures, and put in the list of figures.
  378. % - resetcount, noresetcount : start value of line numbers.
  379. % - algonl : line numbers preceded by algo number
  380. % - shortend, longend, noend : short or long end keyword as endif for e.g.
  381. %
  382. % defaults are; english,plain,resetcount,titlenotnumbered
  383. %
  384. %%%%%%%%%%%%%%
  385. %
  386. % Short summary
  387. % -------------
  388. %
  389. % algorithm is an environment for writing algorithm in LaTeX2e
  390. % It provide macros that allow you to create differents
  391. % sorts of key words, therefore a set of predefined key word
  392. % is gived.
  393. %
  394. % IT should be used as follows
  395. %
  396. % \begin{algorithm}
  397. % ...
  398. % ...
  399. % \end{algorithm}
  400. %
  401. %
  402. % IMPORTANT : each line MUST end with \;
  403. %
  404. % Note that if you define macros outside algorithm environment they
  405. % are avaible in all the document and particulary you can use then
  406. % inside all algorithms without re-define them.
  407. %
  408. % an example:
  409. %
  410. % \begin{algorithm}[H]
  411. % \SetLine
  412. % \AlgData{this text}
  413. % \AlgResult{how to write algorithm with \LaTeX2e }
  414. %
  415. % initialization\;
  416. % \While{not at end of this document}{
  417. % read current section\;
  418. % \eIf{understand}{
  419. % go to next section\;
  420. % current section becomes this one\;
  421. % }{
  422. % go back to the beginning of current section\;
  423. % }
  424. % }
  425. % \caption{How to write algorithm}
  426. % \end{algorithm}
  427. %
  428. %
  429. %%%%%%%%%%%%%% predefined english keywords
  430. %
  431. % \AlgData{input}
  432. % \AlgResult{output}
  433. % \KwIn{input}
  434. % \KwOut{output}
  435. % \KwData{input}
  436. % \KwResult{output}
  437. % \Ret{[value]}
  438. % \KwTo % a simple keyword
  439. % \Begin{block inside}
  440. % \If{condition}{Then block} % in a block
  441. % \uIf{condition}{Then block} % in a block unended
  442. % \Else{inside Else} % in a block
  443. % \eIf{condition}{Then Block}{Else block} % in blocks
  444. % \lIf{condition}{Else text} % on the same line
  445. % \lElse{Else text} % on the same line
  446. % \Switch{Condition}{Switch block}
  447. % \Case{a case}{case block} % in a block
  448. % \lCase{a case}{case text} % on the same line
  449. % \Other{otherwise block} % in a block
  450. % \lOther{otherwise block} % on the same line
  451. % \For{condition}{text loop} % in a block
  452. % \lFor{condition}{text} % on the same line
  453. % \ForEach{condition}{text loop} % in a block
  454. % \lForEach{condition}{text} % on the same line
  455. % \Repeat{End condition}{text loop} % in a block
  456. % \lRepeat{condition}{text} % on the same line
  457. % \While{condition}{text loop} % in a block
  458. % \lWhile{condition}{text loop} % on the same line
  459. %
  460. %
  461. %%%%%%%%%%%%%% predefined french keywords
  462. %
  463. % \AlgDonnees{input}
  464. % \AlgRes{input}
  465. % \Donnees{input}
  466. % \Res{input}
  467. % \Retour[valeur]}
  468. % \Deb{block inside}
  469. % \KwA % un mot clef simple
  470. % \Si{condition}{Bloc du Alors} % Dans un bloc
  471. % \uSi{condition}{Bloc du Alors} % Dans un bloc non termine
  472. % \eSi{condition}{Bloc du Alors}{Bloc du Sinon} % Dans un bloc
  473. % \lSi{condition}{texte du Alors} % sur la meme ligne
  474. % \lSinon{texte du Sinon} % sur la meme ligne
  475. % \Suivant{Condition}{Bloc de l'instruction}
  476. % \Cas{cas}{Bloc de ce cas} % Dans un bloc
  477. % \lCas{cas}{Bloc de ce cas} % sur la meme ligne
  478. % \Autres{Bloc de l'alternative} % Dans un bloc
  479. % \lAutres{Bloc de l'alternative} % sur la meme ligne
  480. % \Pour{condition}{texte de la boucle} % Dans un bloc
  481. % \lPour{condition}{texte} % sur la meme ligne
  482. % \PourCh{condition}{texte de la boucle} % Dans un bloc
  483. % \lPourCh{condition}{texte} % sur la meme ligne
  484. % \Repeter{End condition}{texte de la boucle} % Dans un bloc
  485. % \lRepeter{condition}{texte} % sur la meme ligne
  486. % \Tq{condition}{texte de la boucle} % Dans un bloc
  487. % \lTq{condition}{texte de la boucle} % sur la meme ligne
  488. %
  489. %
  490. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  491. %
  492. % for more complete informations you can see algorithm2e.tex
  493. %
  494. %
  495. %%%%%%%%%%%%%%%%%%%%%%%% Identification Part %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  496. %
  497. \NeedsTeXFormat{LaTeX2e}[1994/12/01]
  498. %
  499. \ProvidesPackage{algorithm2e}[2005/10/04 v3.9 algorithms environments]
  500. %
  501. %
  502. %%%%%%%%%%%%%%%%%%%%%%%%%%% Initial Code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  503. %
  504. \@makeother\*% some package redefined it as a letter (as color.sty)
  505. %
  506. % definition of commands which can be redefined in options of the package.
  507. %
  508. \newcounter{AlgoLine}
  509. \setcounter{AlgoLine}{0}
  510. %
  511. \newcommand{\listalgorithmcfname}{}
  512. \newcommand{\algorithmcfname}{}
  513. \newcommand{\algocf@typo}{}
  514. \newcommand{\@algocf@procname}{}
  515. \newcommand{\@algocf@funcname}{}
  516. \newcommand{\@algocf@titleofalgoname}{\algorithmcfname}
  517. \newcommand{\@algocf@algotitleofalgo}{%
  518. \renewcommand{\@algocf@titleofalgoname}{\algorithmcfname}}
  519. \newcommand{\@algocf@proctitleofalgo}{%
  520. \renewcommand{\@algocf@titleofalgoname}{\algocf@procname}}
  521. %
  522. \newcommand{\algocf@style}{plain}
  523. \newcommand{\@ResetCounterIfNeeded}{}
  524. \newcommand{\@titleprefix}{}
  525. %
  526. \newcommand{\algocf@numbering}[1]{\newcommand{\algocf@within}{#1}}
  527. %
  528. \newcommand{\defaultsmacros@algo}{\algocf@defaults@shortend}
  529. %
  530. \newcommand{\algocf@list}{loa}
  531. \newcommand{\algocf@float}{algocf}
  532. %
  533. \newcommand{\algocf@envname}{algorithm}
  534. \newcommand{\algocf@listofalgorithms}{listofalgorithms}
  535. %
  536. %
  537. %%%%%%%%%%%%%%%%%%%%%% Declaration of Options %%%%%%%%%%%%%%%%%%%%%%%%%%%
  538. %
  539. \RequirePackage{ifthen}
  540. %
  541. \DeclareOption{algo2e}{%
  542. \renewcommand{\algocf@envname}{algorithm2e}
  543. \renewcommand{\algocf@listofalgorithms}{listofalgorithmes}
  544. }
  545. %
  546. \newboolean{algocf@slide}\setboolean{algocf@slide}{false}
  547. \DeclareOption{slide}{%
  548. \setboolean{algocf@slide}{true}%
  549. }
  550. %
  551. \DeclareOption{figure}{
  552. \renewcommand{\algocf@list}{lof}
  553. \renewcommand{\algocf@float}{figure}
  554. }
  555. %
  556. \DeclareOption{english}{%
  557. \renewcommand{\listalgorithmcfname}{List of Algorithms}%
  558. \renewcommand{\algorithmcfname}{Algorithm}%
  559. \renewcommand{\algocf@typo}{}%
  560. \renewcommand{\@algocf@procname}{Procedure}
  561. \renewcommand{\@algocf@funcname}{Function}
  562. }
  563. %
  564. \DeclareOption{french}{%
  565. \renewcommand{\listalgorithmcfname}{Liste des Algorithmes}%
  566. \renewcommand{\algorithmcfname}{Algorithme}%
  567. \renewcommand{\algocf@typo}{\ }%
  568. \renewcommand{\@algocf@procname}{Procédure}
  569. \renewcommand{\@algocf@funcname}{Fonction}
  570. }
  571. %
  572. \DeclareOption{czech}{%
  573. \renewcommand{\listalgorithmcfname}{Seznam algoritm\v{u}}%
  574. \renewcommand{\algorithmcfname}{Algoritmus}%
  575. \renewcommand{\algocf@typo}{}%
  576. \renewcommand{\@algocf@procname}{Procedura}
  577. \renewcommand{\@algocf@funcname}{Funkce}
  578. }
  579. %
  580. \DeclareOption{german}{%
  581. \renewcommand{\listalgorithmcfname}{Liste der Algorithmen}%
  582. \renewcommand{\algorithmcfname}{Algorithmus}%
  583. \renewcommand{\algocf@typo}{\ }%
  584. \renewcommand{\@algocf@procname}{Prozedur}%
  585. \renewcommand{\@algocf@funcname}{Funktion}%
  586. }
  587. %
  588. \DeclareOption{portugues}{%
  589. \renewcommand{\listalgorithmcfname}{Lista de Algoritmos}%
  590. \renewcommand{\algorithmcfname}{Algoritmo}%
  591. \renewcommand{\algocf@typo}{}%
  592. \renewcommand{\@algocf@procname}{Procedimento}
  593. \renewcommand{\@algocf@funcname}{Fun\c{c}\~{a}o}
  594. }
  595. %
  596. % OPTIONs plain, boxed, ruled, algoruled & boxruled
  597. %
  598. \newcommand{\algocf@style@plain}{\renewcommand{\algocf@style}{plain}}
  599. \newcommand{\algocf@style@boxed}{\renewcommand{\algocf@style}{boxed}}
  600. \newcommand{\algocf@style@ruled}{\renewcommand{\algocf@style}{ruled}}
  601. \newcommand{\algocf@style@algoruled}{\renewcommand{\algocf@style}{algoruled}}
  602. \newcommand{\algocf@style@boxruled}{\renewcommand{\algocf@style}{boxruled}}
  603. \newcommand{\restylealgo}[1]{\csname algocf@style@#1\endcsname}
  604. \DeclareOption{plain}{\algocf@style@plain}
  605. \DeclareOption{boxed}{\algocf@style@boxed}
  606. \DeclareOption{ruled}{\algocf@style@ruled}
  607. \DeclareOption{algoruled}{\algocf@style@algoruled}
  608. \DeclareOption{boxruled}{\algocf@style@boxruled}
  609. %
  610. % OPTIONs algopart,algochapter & algosection
  611. %
  612. \DeclareOption{algopart}{\algocf@numbering{part}} %algo part numbered
  613. \DeclareOption{algochapter}{\algocf@numbering{chapter}} %algo chapter numbered
  614. \DeclareOption{algosection}{\algocf@numbering{section}} %algo section numbered
  615. %
  616. % OPTIONs resetcount & noresetcount
  617. %
  618. \DeclareOption{resetcount}{\renewcommand{\@ResetCounterIfNeeded}{\setcounter{AlgoLine}{0}}}
  619. \DeclareOption{noresetcount}{\renewcommand{\@ResetCounterIfNeeded}{}}
  620. %
  621. % OPTION linesnumbered
  622. %
  623. \newboolean{algocf@linesnumbered}\setboolean{algocf@linesnumbered}{false}
  624. \newcommand{\algocf@linesnumbered}{\relax}
  625. \DeclareOption{linesnumbered}{%
  626. \setboolean{algocf@linesnumbered}{true}
  627. \renewcommand{\algocf@linesnumbered}{\everypar={\nl}}
  628. }
  629. %
  630. % OPTION linesnumberedhidden
  631. %
  632. \DeclareOption{linesnumberedhidden}{%
  633. \setboolean{algocf@linesnumbered}{true}
  634. \renewcommand{\algocf@linesnumbered}{\everypar{\stepcounter{AlgoLine}}}
  635. }
  636. %
  637. % OPTION commentsnumbered inoutnumbered
  638. %
  639. \newboolean{algocf@commentsnumbered}\setboolean{algocf@commentsnumbered}{false}
  640. \DeclareOption{commentsnumbered}{\setboolean{algocf@commentsnumbered}{true}}
  641. \newboolean{algocf@inoutnumbered}\setboolean{algocf@inoutnumbered}{false}
  642. \DeclareOption{inoutnumbered}{\setboolean{algocf@inoutnumbered}{true}}
  643. %
  644. % OPTIONs titlenumbered & titlenotnumbered
  645. %
  646. \DeclareOption{titlenumbered}{%
  647. \renewcommand{\@titleprefix}{%
  648. \refstepcounter{algocf@float}%
  649. \AlTitleFnt{\@algocf@titleofalgoname\
  650. \expandafter\csname the\algocf@float\endcsname\algocf@typo : }}%
  651. }
  652. %
  653. \DeclareOption{titlenotnumbered}{\renewcommand{\@titleprefix}{%
  654. \AlTitleFnt{\@algocf@titleofalgoname\algocf@typo : }}%
  655. }
  656. %
  657. % OPTIONs lined, vlined & noline
  658. %
  659. \DeclareOption{lined}{\AtBeginDocument{\SetLine}} % \SetLine
  660. \DeclareOption{vlined}{\AtBeginDocument{\SetVline}} % \SetVline
  661. \DeclareOption{noline}{\AtBeginDocument{\SetNoline}} % \Setnoline (default)
  662. %
  663. % OPTIONs algonl
  664. % line numbered with the counter of the algorithm
  665. %
  666. \DeclareOption{algonl}{\renewcommand{\theAlgoLine}{\expandafter\csname the\algocf@float\endcsname.\arabic{AlgoLine}}}
  667. %
  668. % OPTIONs longend, shotend & noend
  669. %
  670. \DeclareOption{longend}{%
  671. \renewcommand{\defaultsmacros@algo}{\algocf@defaults@longend}}
  672. \DeclareOption{shortend}{%
  673. \renewcommand{\defaultsmacros@algo}{\algocf@defaults@shortend}}
  674. \newboolean{algocf@optnoend}\setboolean{algocf@optnoend}{false}
  675. \DeclareOption{noend}{%
  676. \setboolean{algocf@optnoend}{true}%
  677. \renewcommand{\defaultsmacros@algo}{\algocf@defaults@noend}}
  678. %
  679. % OPTION dotoc
  680. %
  681. \newboolean{algocf@dotocloa}\setboolean{algocf@dotocloa}{false}
  682. \DeclareOption{dotocloa}{%
  683. \setboolean{algocf@dotocloa}{true}
  684. }
  685. %
  686. % OPTION comments
  687. %
  688. \newboolean{algocf@optfillcomment}\setboolean{algocf@optfillcomment}{true}
  689. \DeclareOption{nofillcomment}{%
  690. \setboolean{algocf@optfillcomment}{false}%
  691. }
  692. \DeclareOption{fillcomment}{%
  693. \setboolean{algocf@optfillcomment}{true}%
  694. }
  695. %
  696. % OPTION sidecommments
  697. %
  698. \newboolean{algocf@scleft}\setboolean{algocf@scleft}{false}
  699. \DeclareOption{scleft}{%
  700. \setboolean{algocf@scleft}{true}%
  701. }
  702. \DeclareOption{sright}{% default
  703. \setboolean{algocf@scleft}{false}%
  704. }
  705. %
  706. %
  707. %%%%%%%%%%%%%%%%%%%%%%% Execution of Options %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  708. %
  709. \ExecuteOptions{english,plain,resetcount,titlenotnumbered}
  710. %
  711. \ProcessOptions
  712. %
  713. \@algocf@algotitleofalgo % fix name for \Titleofalgo to \algorithmcfname by default
  714. %
  715. %%%%%%%%%%%%%%%%%%%%%%%%%% Package Loading %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  716. %
  717. %\RequirePackage{float}[2001/11/08]
  718. %
  719. \RequirePackage{xspace}
  720. %
  721. \ifthenelse{\boolean{algocf@slide}}{\RequirePackage{color}}{}
  722. %
  723. \AtEndOfPackage{%
  724. \ifthenelse{\boolean{algocf@dotocloa}}{%
  725. \renewcommand{\listofalgorithmes}{\tocfile{\listalgorithmcfname}{loa}}%
  726. }{\relax}
  727. }
  728. % if loa in toc required, load tocbibind package if not already done.
  729. \ifthenelse{\boolean{algocf@dotocloa}}{%
  730. \ifx\@tocextra\undefined%
  731. \RequirePackage{tocbibind}
  732. \fi%
  733. }
  734. %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Part %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  735. %
  736. \newcommand{\algocf@name}{algorithm2e}
  737. \newcommand{\algocf@date}{october 04 2005}
  738. \newcommand{\algocf@version}{Release 3.9}
  739. \newcommand{\algocf@id}{\algocf@version\space -- \algocf@date\space --}
  740. \typeout{********************************************************^^JPackage `\algocf@name'\space\algocf@id^^J%
  741. - algorithm2e-announce@lirmm.fr mailing list for announcement about releases^^J%
  742. - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J%
  743. subscribe by emailing sympa@lirmm.fr with 'subscribe <list> <firstname name>'^^J%
  744. - Author: Christophe Fiorio (fiorio@lirmm.fr)^^J********************************************************}
  745. %%
  746. %%
  747. %%
  748. %%
  749. %%
  750. %%
  751. %%%% hyperref compatibility tricks: Hyperref package defines H counters from
  752. % standard counters (i.e \theHpage from \thepage) and check some particular
  753. % counters of some packages, unfortunately it doesn't do the same for
  754. % algorithm2e package but act as Hcounter was defined. To avoid errors we
  755. % defined \theHalgocf ourself
  756. %%%%
  757. % \@ifundefined{theHalgocf}{\def\theHalgocf{\thealgocf}}{}%
  758. % \@ifundefined{theHAlgoLine}{\def\theHAlgoLine{\theAlgoLine}}{}%
  759. % \@ifundefined{theHalgocf}{\def\theHalgocf{\thealgocf}}{}%
  760. % \@ifundefined{theHAlgoLine}{\def\theHAlgoLine{\thealgocf}}{}%
  761. % \@ifundefined{toclevel@algocf}{\def\toclevel@algocf{0}}{}%
  762. %%
  763. %%
  764. %%
  765. \newcommand{\@defaultskiptotal}{0.5em}%\Setnlskip{0.5em}
  766. \newskip\skiptotal\skiptotal=0.5em%\Setnlskip{0.5em}
  767. \newskip\skiprule
  768. \newskip\skiphlne
  769. \newskip\skiptext
  770. \newskip\skiplength
  771. \newskip\algomargin
  772. \newskip\skipalgocfslide\skipalgocfslide=1em
  773. \newdimen\algowidth
  774. \newdimen\inoutsize
  775. \newdimen\inoutline
  776. %
  777. \newcommand{\@algoskip}{\smallskip}%
  778. \newcommand{\SetAlgoSkip}[1]{\renewcommand{\@algoskip}{\csname#1\endcsname}}%
  779. \newcommand{\@algoinsideskip}{\relax}%
  780. \newcommand{\SetAlgoInsideSkip}[1]{\renewcommand{\@algoinsideskip}{\csname#1\endcsname}}%
  781. %
  782. \newsavebox{\algocf@inoutbox}
  783. \newsavebox{\algocf@inputbox}
  784. %%
  785. %%
  786. \newcommand{\arg@e}{}
  787. \newcommand{\arg@space}{\ }
  788. \newcommand{\BlankLine}{\vskip 1ex}
  789. %%
  790. \newcommand{\vespace}{1ex}
  791. \newcommand{\SetInd}[2]{%
  792. \skiprule=#1%
  793. \skiptext=#2%
  794. \skiplength=\skiptext\advance\skiplength by \skiprule\advance\skiplength by 0.4pt}
  795. \SetInd{0.5em}{1em}
  796. \algomargin=\leftskip\advance\algomargin by \parindent
  797. \newcommand{\incmargin}[1]{\advance\algomargin by #1}
  798. \newcommand{\decmargin}[1]{\advance\algomargin by -#1}
  799. \newcommand{\Setnlskip}[1]{%
  800. \renewcommand{\@defaultskiptotal}{#1}%
  801. \setlength{\skiptotal}{#1}}
  802. \newcommand{\setnlskip}[1]{\Setnlskip{#1}}%kept for compatibility issue
  803. %%
  804. \newskip\AlCapSkip\AlCapSkip=0ex
  805. \newskip\AlCapHSkip\AlCapSkip=0ex
  806. \newcommand{\setalcapskip}[1]{\setlength{\AlCapSkip}{#1}}
  807. \newcommand{\setalcaphskip}[1]{\setlength{\AlCapHSkip}{#1}}
  808. \setalcaphskip{.5\algomargin}
  809. %%
  810. %%
  811. \newcommand{\Indentp}[1]{\advance\leftskip by #1}
  812. \newcommand{\Indp}{\advance\leftskip by 1em}
  813. \newcommand{\Indpp}{\advance\leftskip by 0.5em}
  814. \newcommand{\Indm}{\advance\leftskip by -1em}
  815. \newcommand{\Indmm}{\advance\leftskip by -0.5em}
  816. %%
  817. %%
  818. %% Line Numbering
  819. %%
  820. %%
  821. % number line style
  822. \newcommand{\nlSty}[1]{\textnormal{\textbf{#1}}}% default definition
  823. \newcommand{\Setnlsty}[3]{\renewcommand{\nlSty}[1]{\textnormal{\csname#1\endcsname{#2##1#3}}}}
  824. %
  825. %
  826. \newcommand{\algocf@nlhlabel}[2]{%
  827. \immediate\write\@auxout{%
  828. \string\newlabel{#1}{%
  829. {#2}% current label
  830. {\thepage}% page
  831. {}% current label string
  832. % {AlgoLine\thealgocfline.\theAlgoLine}% current Href
  833. {AlgoLine\thealgocfline.\theAlgoLine}% current Href
  834. {}%
  835. }%
  836. }%
  837. }
  838. %
  839. % nl definitions
  840. %
  841. \newcommand{\nl}{%
  842. \@ifundefined{href}{% if not hyperref then do a simple refstepcounter
  843. \refstepcounter{AlgoLine}%
  844. }{% else if hyperref, do the anchor so 2 lines in two differents algorithms cannot have the same href
  845. % \stepcounter{AlgoLine}\Hy@raisedlink{\hyper@anchorstart{AlgoLine\thealgocfline.\theAlgoLine}\hyper@anchorend}%
  846. \stepcounter{AlgoLine}\Hy@raisedlink{\hyper@anchorstart{AlgoLine\thealgocfline.\theAlgoLine}\hyper@anchorend}%
  847. }% now we can do the line numbering
  848. \strut\vadjust{\kern-\dp\strutbox\vtop to \dp\strutbox{%
  849. \baselineskip\dp\strutbox\vss\llap{\scriptsize{\nlSty{\theAlgoLine}\hskip\skiptotal}}\null}}%
  850. }%
  851. \newcommand{\nllabel}[1]{%
  852. \@ifundefined{href}{\label{#1}}{\algocf@nlhlabel{#1}{\theAlgoLine}}}%
  853. %
  854. \newcommand{\enl}{;%
  855. \@ifundefined{href}{% if not hyperref then do a simple refstepcounter
  856. \refstepcounter{AlgoLine}%
  857. }{% else if hyperref, do the anchor so 2 lines in two differents algorithms cannot have the same href
  858. % \stepcounter{AlgoLine}\Hy@raisedlink{\hyper@anchorstart{AlgoLine\thealgocfline.\theAlgoLine}\hyper@anchorend}%
  859. \stepcounter{AlgoLine}\Hy@raisedlink{\hyper@anchorstart{AlgoLine\thealgocfline.\theAlgoLine}\hyper@anchorend}%
  860. }% now we can do the line numbering
  861. \hfill\rlap{%
  862. \scriptsize{\nlSty{\theAlgoLine}}}\par}
  863. \newcommand{\nlset}[1]{%
  864. \hskip 0pt\llap{%
  865. \scriptsize{\nlSty{#1}}\hskip\skiptotal}\ignorespaces}
  866. %
  867. % lnl definitions
  868. %
  869. \@ifundefined{href}{% if not hyperref
  870. \newcommand{\lnl}[1]{\nl\label{#1}\ignorespaces}%
  871. }{% else hyperref
  872. \newcommand{\lnl}[1]{\nl\algocf@nlhlabel{#1}{\theAlgoLine}\ignorespaces}%
  873. }
  874. %
  875. % nlset
  876. %
  877. \@ifundefined{href}{%
  878. \newcommand{\lnlset}[2]{\nlset{#2}\protected@edef\@currentlabel{#2}\label{#1}}%
  879. }{%else hyperref
  880. \newcommand{\lnlset}[2]{\nlset{#2}%
  881. \Hy@raisedlink{\hyper@anchorstart{AlgoLine.#2}\hyper@anchorend}\algocf@nlhlabel{#1}{#2}%
  882. \ignorespaces%
  883. }%
  884. }
  885. %
  886. % set char put at end of each line
  887. %
  888. \newcommand{\algocf@endline}{\string;}
  889. \newcommand{\SetEndCharOfAlgoLine}[1]{\renewcommand{\algocf@endline}{#1}}
  890. %
  891. % end of line definition
  892. %
  893. \newcommand{\@endalgoln}{\algocf@endline\par}% default definition: printsemicolon
  894. \newcommand{\dontprintsemicolon}{\renewcommand{\@endalgoln}{\par}}
  895. \newcommand{\printsemicolon}{\renewcommand{\@endalgoln}{\algocf@endline\par}}
  896. %
  897. % line numbering
  898. %
  899. \newcommand{\linesnumbered}{\setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\everypar={\nl}}}
  900. \newcommand{\linesnotnumbered}{%
  901. \setboolean{algocf@linesnumbered}{false}%
  902. \renewcommand{\algocf@linesnumbered}{\relax}%
  903. }
  904. %
  905. \newcommand{\linesnumberedhidden}{%
  906. \setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\everypar{\stepcounter{AlgoLine}}}}
  907. \newcommand{\showln}{\nlset{\theAlgoLine}\ignorespaces} % display the line number on this line (without labelling)
  908. \newcommand{\showlnlabel}[1]{\lnlset{#1}{\theAlgoLine}\ignorespaces} % display the line number and label this line
  909. %
  910. %%
  911. %
  912. %%
  913. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  914. %
  915. % Styling text commands
  916. %
  917. \newcommand{\AlTitleFnt}[1]{\textbf{#1}\unskip}% default definition
  918. \newcommand{\SetAlTitleFnt}[1]{\renewcommand{\AlTitleFnt}[1]{\csname#1\endcsname{##1}\unskip}}%
  919. \newcommand{\AlFnt}{\relax}% default definition
  920. \newcommand{\SetAlFnt}[1]{\renewcommand{\AlFnt}{#1}}%
  921. \newcommand{\AlCapFnt}{\AlFnt{}}% default definition
  922. \newcommand{\SetAlCapFnt}[1]{\renewcommand{\AlCapFnt}{#1}}%
  923. \newcommand{\KwSty}[1]{\textnormal{\textbf{#1}}\unskip}% default definition
  924. \newcommand{\SetKwSty}[1]{\renewcommand{\KwSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
  925. \newcommand{\ArgSty}[1]{\textnormal{\emph{#1}}\unskip}%\SetArgSty{emph}
  926. \newcommand{\SetArgSty}[1]{\renewcommand{\ArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
  927. \newcommand{\FuncSty}[1]{\textnormal{\texttt{#1}}\unskip}%\SetFuncSty{texttt}
  928. \newcommand{\SetFuncSty}[1]{\renewcommand{\FuncSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
  929. \newcommand{\DataSty}[1]{\textnormal{\textsf{#1}}\unskip}%%\SetDataSty{textsf}
  930. \newcommand{\SetDataSty}[1]{\renewcommand{\DataSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
  931. \newcommand{\CommentSty}[1]{\textnormal{\texttt{#1}}\unskip}%%\SetDataSty{texttt}
  932. \newcommand{\SetCommentSty}[1]{\renewcommand{\CommentSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
  933. \newcommand{\TitleSty}[1]{#1\unskip}%\SetTitleSty{}{}
  934. \newcommand{\SetTitleSty}[2]{\renewcommand{\TitleSty}[1]{%
  935. \csname#1\endcsname{\csname#2\endcsname##1}}\unskip}
  936. %
  937. %%
  938. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  939. %
  940. % Block basic commands
  941. %
  942. \newcommand{\al@push}[1]{\advance\skiptotal by #1\moveright #1}
  943. \newcommand{\al@pop}[1]{\advance\skiptotal by -#1}
  944. \newcommand{\al@addskiptotal}{\advance\skiptotal by 0.4pt\advance\hsize by -0.4pt} % 0.4 pt=width of \vrule
  945. \newcommand{\al@subskiptotal}{\advance\skiptotal by -0.4pt\advance\hsize by 0.4pt} % 0.4 pt=width of \vrule
  946. %
  947. \skiphlne=.8ex%
  948. \newcommand{\Setvlineskip}[1]{\skiphlne=#1}
  949. \newcommand{\V@line}[1]{% no vskip in between boxes but a strut to separate them,
  950. \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
  951. \al@push{\skiprule}% move to the right before the vertical rule
  952. \hbox{\vrule%
  953. \vtop{\al@push{\skiptext}%move the right after the rule
  954. \vtop{\al@addskiptotal\advance\hsize by -\skiplength #1}\Hlne}}\vskip\skiphlne% inside the block
  955. \al@pop{\skiprule}%\al@subskiptotal% restore indentation
  956. \nointerlineskip}% no vskip after
  957. %
  958. \newcommand{\V@sline}[1]{% no vskip in between boxes but a strut to separate them,
  959. \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
  960. \al@push{\skiprule}% move to the right before the vertical rule
  961. \hbox{\vrule% the vertical rule
  962. \vtop{\al@push{\skiptext}%move the right after the rule
  963. \vtop{\al@addskiptotal\advance\hsize by -\skiplength #1}}}% inside the block
  964. \al@pop{\skiprule}}% restore indentation
  965. %\nointerlineskip}% no vskip after
  966. %
  967. \newcommand{\H@lne}{\hrule height 0.4pt depth 0pt width .5em}
  968. %
  969. \newcommand{\No@line}[1]{% no vskip in between boxes but a strut to separate them,
  970. \strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
  971. \al@push{\skiprule}%
  972. \hbox{%
  973. \vtop{\al@push{\skiptext}%
  974. \vtop{\advance\hsize by -\skiplength #1}}}% inside the block
  975. \al@pop{\skiprule}}%
  976. %\nointerlineskip}% no vskip after
  977. %
  978. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  979. %%
  980. %% default=NoLine
  981. %
  982. \newcommand{\a@@block}[2]{\No@line{##1}\KwSty{##2}\par}
  983. \newcommand{\a@block}[2]{\a@@block{#1}{#2}} % this to be redefined as a@group in
  984. % case of noend option
  985. \newcommand{\a@group}[1]{\No@line{##1}}
  986. \newcommand{\Hlne}{}
  987. %
  988. %
  989. \newcommand{\SetNoline}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline
  990. \renewcommand{\a@@block}[2]{\No@line{##1}\KwSty{##2}\strut\par}%
  991. \renewcommand{\a@group}[1]{\No@line{##1}}
  992. \renewcommand{\Hlne}{}}
  993. %
  994. \newcommand{\SetVline}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Vline
  995. \renewcommand{\a@@block}[2]{\V@line{##1}}%
  996. \renewcommand{\a@group}[1]{\V@sline{##1}\strut\ignorespaces}
  997. \renewcommand{\Hlne}{\H@lne}}
  998. %
  999. \newcommand{\SetLine}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line
  1000. \renewcommand{\a@@block}[2]{\strut\V@sline{##1}\KwSty{##2}\strut\par}% no skip after a block so garantie at least a line
  1001. \renewcommand{\a@group}[1]{\V@sline{##1}\strut\ignorespaces}
  1002. \renewcommand{\Hlne}{}}
  1003. %
  1004. \newcommand{\SetNothing}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline
  1005. \renewcommand{\a@@block}[2]{\No@line{##1}\par}%
  1006. %\long
  1007. \renewcommand{\a@group}[1]{\No@line{##1}}
  1008. \renewcommand{\Hlne}{}}
  1009. %
  1010. %%
  1011. %%
  1012. %
  1013. %
  1014. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1015. %
  1016. % ``Input :'''s like command
  1017. %
  1018. %%%
  1019. % text staying at the right of the longer keyword of KwInOut commands
  1020. % (text of KwInOut commands are all vertically aligned)
  1021. %
  1022. \newcommand{\algocf@newinout}{\par\parindent=\wd\algocf@inoutbox}% to put right indentation after a \\ in the KwInOut
  1023. \newcommand{\SetKwInOut}[2]{%
  1024. \sbox\algocf@inoutbox{\hbox{\KwSty{#2}\algocf@typo:\ }}%
  1025. \expandafter\ifx\csname InOutSizeDefined\endcsname\relax% if first time used
  1026. \newcommand\InOutSizeDefined{}\setlength{\inoutsize}{\wd\algocf@inoutbox}%
  1027. \else% else keep the larger dimension
  1028. \ifdim\wd\algocf@inoutbox>\inoutsize\setlength{\inoutsize}{\wd\algocf@inoutbox}\fi%
  1029. \fi% the dimension of the box is now defined.
  1030. \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1031. \expandafter\algocf@mkcmd\csname#1\endcsname[1]{%
  1032. \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\everypar={\relax}}
  1033. {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\hfill:\mbox{\ }}##1\par}
  1034. \algocf@linesnumbered% reset the numbering of the lines
  1035. }}%
  1036. %
  1037. %% allow to ajust the skip size of InOut
  1038. %%
  1039. \newcommand{\ResetInOut}[1]{%
  1040. \sbox\algocf@inoutbox{\hbox{\KwSty{#1}\algocf@typo:\ }}%
  1041. \setlength{\inoutsize}{\wd\algocf@inoutbox}%
  1042. }
  1043. %
  1044. %
  1045. %%%
  1046. % text staying at the right of the keyword.
  1047. %
  1048. \newcommand{\algocf@newinput}{\par\parindent=\wd\algocf@inputbox}% to put right indentation after a \\ in the KwInput
  1049. \newcommand{\SetKwInput}[2]{%
  1050. \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1051. \expandafter\algocf@mkcmd\csname#1\endcsname[1]{%
  1052. \sbox\algocf@inputbox{\hbox{\KwSty{#2}\algocf@typo: }}%
  1053. \ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\everypar={\relax}}%
  1054. {\let\\\algocf@newinput\hangindent=\wd\algocf@inputbox\hangafter=1\unhbox\algocf@inputbox##1\par}%
  1055. \algocf@linesnumbered% reset the numbering of the lines
  1056. }}%
  1057. \newcommand{\SetKwData}[2]{%
  1058. \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1059. \expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\DataSty{#2(}\ArgSty{##1}\DataSty{)}}%
  1060. \expandafter\algocf@mkcmd\csname#1\endcsname{%
  1061. \@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}%
  1062. }
  1063. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1064. %
  1065. % Comments macros
  1066. %
  1067. %%%%
  1068. % comment in the text, first argument is the name of the macro, second is
  1069. % the text put before the comment, third is the text put at the end of the
  1070. % comment.
  1071. %
  1072. % first side comment justification
  1073. \newcommand{\SetSideCommentLeft}{\setboolean{algocf@scleft}{true}}
  1074. \newcommand{\SetSideCommentRight}{\setboolean{algocf@scleft}{false}}
  1075. \newcommand{\SetNoFillComment}{\setboolean{algocf@optfillcomment}{false}}
  1076. \newcommand{\SetFillComment}{\setboolean{algocf@optfillcomment}{true}}
  1077. %
  1078. % next comment and side comment
  1079. %
  1080. \newcommand{\algocf@endmarkcomment}{\relax}%
  1081. \newcommand{\algocf@fillcomment}{%
  1082. \ifthenelse{\boolean{algocf@optfillcomment}}{\hfill}{\relax}}%
  1083. %
  1084. \newcommand{\algocf@startcomment}{%
  1085. \hangindent=\wd\algocf@inputbox\hangafter=1\usebox\algocf@inputbox}%
  1086. \newcommand{\algocf@endcomment}{\algocf@fillcomment\algocf@endmarkcomment\ignorespaces\par}%
  1087. \newcommand{\algocf@endstartcomment}{\algocf@endcomment\algocf@startcomment\ignorespaces}%
  1088. %
  1089. \newboolean{algocf@sidecomment}%
  1090. \newboolean{algocf@altsidecomment}\setboolean{algocf@altsidecomment}{false}%
  1091. \newcommand{\algocf@scpar}{\ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\par}}%
  1092. \newcommand{\algocf@sclfill}{\ifthenelse{\boolean{algocf@scleft}}{\algocf@fillcomment}{\relax}}%
  1093. \newcommand{\algocf@scrfill}{\ifthenelse{\boolean{algocf@scleft}}{\relax}{\hfill}}
  1094. \newcommand{\algocf@startsidecomment}{\usebox\algocf@inputbox}%
  1095. \newcommand{\algocf@endsidecomment}{\algocf@endmarkcomment\algocf@scpar}%
  1096. \newcommand{\algocf@endstartsidecomment}{%
  1097. \algocf@sclfill\algocf@endsidecomment%
  1098. \algocf@scrfill\algocf@startsidecomment\ignorespaces}%
  1099. %
  1100. \newcommand{\SetKwComment}[3]{%
  1101. % newcommand or renewcommand ?
  1102. \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1103. %%% comment definition
  1104. \expandafter\algocf@mkcmd\csname algocf@#1\endcsname[1]{%
  1105. \sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}%
  1106. \ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\everypar={\relax}}%
  1107. {\renewcommand{\algocf@endmarkcomment}{#3}%
  1108. \let\\\algocf@endstartcomment%
  1109. \algocf@startcomment\CommentSty{%
  1110. \strut\ignorespaces##1\strut\algocf@fillcomment#3}\par}%
  1111. \algocf@linesnumbered% reset the numbering of the lines
  1112. }%
  1113. %%% side comment definitions
  1114. % option or not?
  1115. \expandafter\algocf@mkcmd\csname algocf@#1@star\endcsname{%
  1116. \@ifnextchar [{\csname algocf@#1@staropt\endcsname}{\csname algocf@#1@sidecomment\endcsname}%
  1117. }%
  1118. % manage option
  1119. \expandafter\def\csname algocf@#1@staropt\endcsname[##1]##2{%
  1120. \ifthenelse{\boolean{algocf@scleft}}{\setboolean{algocf@sidecomment}{true}}{\setboolean{algocf@sidecomment}{false}}%
  1121. \ifx##1h\setboolean{algocf@altsidecomment}{true}\SetSideCommentLeft\fi%
  1122. \ifx##1f\setboolean{algocf@altsidecomment}{true}\SetSideCommentRight\fi%
  1123. \ifx##1l\setboolean{algocf@altsidecomment}{false}\SetSideCommentLeft\fi%
  1124. \ifx##1r\setboolean{algocf@altsidecomment}{false}\SetSideCommentRight\fi%
  1125. \csname algocf@#1@sidecomment\endcsname{##2}% call sidecomment
  1126. \ifthenelse{\boolean{algocf@sidecomment}}{\setboolean{algocf@scleft}{true}}{\setboolean{algocf@scleft}{false}}%
  1127. \setboolean{algocf@altsidecomment}{false}%
  1128. }%
  1129. % side comment
  1130. \expandafter\algocf@mkcmd\csname algocf@#1@sidecomment\endcsname[1]{%
  1131. \sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}%
  1132. \ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\everypar={\relax}}%
  1133. {%
  1134. \renewcommand{\algocf@endmarkcomment}{#3}%
  1135. \let\\\algocf@endstartsidecomment%
  1136. % here is the comment
  1137. \ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\algocf@endline\ }%
  1138. \algocf@scrfill\algocf@startsidecomment\CommentSty{%
  1139. \strut\ignorespaces##1\strut\algocf@sclfill#3}\algocf@scpar%
  1140. }%
  1141. \algocf@linesnumbered% reset the numbering of the lines
  1142. }
  1143. \expandafter\algocf@mkcmd\csname#1\endcsname{\@ifstar{\csname algocf@#1@star\endcsname}{\csname algocf@#1\endcsname}}
  1144. }%
  1145. %
  1146. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1147. %
  1148. % Kw
  1149. %
  1150. \newcommand{\SetKw}[2]{%
  1151. \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1152. \expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\KwSty{#2} \ArgSty{##1}}%
  1153. \expandafter\algocf@mkcmd\csname#1\endcsname{%
  1154. \@ifnextchar\bgroup{\csname @#1\endcsname}{\KwSty{#2}\xspace}}%
  1155. }
  1156. %
  1157. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1158. %
  1159. % KwFunction
  1160. %
  1161. \newcommand{\SetKwFunction}[2]{%
  1162. \@ifundefined{#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1163. \expandafter\algocf@mkcmd\csname @#1\endcsname[1]{\FuncSty{#2(}\ArgSty{##1}\FuncSty{)}}%
  1164. \expandafter\algocf@mkcmd\csname#1\endcsname{%
  1165. \@ifnextchar\bgroup{\csname @#1\endcsname}{\FuncSty{#2}\xspace}}%
  1166. }
  1167. %
  1168. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1169. %
  1170. % KwBlock
  1171. %
  1172. \newcommand{\SetKwBlock}[3]{%
  1173. \@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1174. % side text or not?
  1175. \expandafter\def\csname#1\endcsname{ %Begin
  1176. \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
  1177. % with side text
  1178. \expandafter\def\csname algocf@#1opt\endcsname(##1)##2{% \Begin(){}
  1179. \KwSty{#2} ##1\a@group{##2}\KwSty{#3}%
  1180. \@ifnextchar({\csname algocf@#1end\endcsname}{\par}}%
  1181. % without side text at the beginning
  1182. \expandafter\algocf@mkcmd\csname algocf@#1\endcsname[1]{% \Begin{}
  1183. \KwSty{#2}\a@group{##1}\KwSty{#3}\@ifnextchar({\csname algocf@#1end\endcsname}{\par}}%
  1184. % side text at the end
  1185. \expandafter\def\csname algocf@#1end\endcsname(##1){% \Begin{}
  1186. \ ##1\par}%
  1187. }
  1188. %
  1189. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1190. %
  1191. % For Switch
  1192. %
  1193. \newcommand{\SetKwSwitch}[8]{% #1=\Switch #2=\Case #3=\Other #4=swicth #5=case #6=do #7=otherwise #8=endsw
  1194. %%%% Switch
  1195. \@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1196. % side text or not?
  1197. \expandafter\def\csname#1\endcsname{ %Switch
  1198. \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
  1199. % with side text
  1200. \expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \Switch(){}{}
  1201. \KwSty{#4} \ArgSty{##2} \KwSty{#5} ##1\a@block{##3}{#8}}%
  1202. % without side text
  1203. \expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \Switch{}{}
  1204. \KwSty{#4} \ArgSty{##1} \KwSty{#5}\a@block{##2}{#8}}%
  1205. % side text at the end
  1206. \expandafter\def\csname algocf@#1end\endcsname(##1){% \Switch{}{}()
  1207. }
  1208. %%%% Case
  1209. \@ifundefined{algocf@#2}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1210. % side text or not?
  1211. \expandafter\def\csname#2\endcsname{ %Case
  1212. \@ifnextchar({\csname algocf@#2opt\endcsname}{\csname algocf@#2\endcsname}}
  1213. \expandafter\def\csname u#2\endcsname{ %uCase
  1214. \@ifnextchar({\csname algocf@u#2opt\endcsname}{\csname algocf@u#2\endcsname}}
  1215. \expandafter\def\csname l#2\endcsname{ %lCase
  1216. \@ifnextchar({\csname algocf@l#2opt\endcsname}{\csname algocf@l#2\endcsname}}
  1217. % with side text
  1218. \expandafter\def\csname algocf@#2opt\endcsname(##1)##2##3{% \Case(){}{}
  1219. \KwSty{#6} \ArgSty{##2} ##1\a@block{##3}{#8}}%
  1220. \expandafter\def\csname algocf@u#2opt\endcsname(##1)##2##3{% \uCase(){}{}
  1221. \KwSty{#6} \ArgSty{##2} ##1\a@group{##3}}%
  1222. \expandafter\def\csname algocf@l#2opt\endcsname(##1)##2##3{% \lCase(){}{}
  1223. \KwSty{#6} \ArgSty{##2} ##3\algocf@endline\ ##1\par}%
  1224. % without side text
  1225. \expandafter\algocf@mkcmd\csname algocf@#2\endcsname[2]{% \Case{}{}
  1226. \KwSty{#6} \ArgSty{##1}\a@block{##2}{#8}}%
  1227. \expandafter\algocf@mkcmd\csname algocf@u#2\endcsname[2]{% \uCase{}{}
  1228. \KwSty{#6} \ArgSty{##1}\a@group{##2}}%
  1229. \expandafter\algocf@mkcmd\csname algocf@l#2\endcsname[2]{% \lCase{}{}
  1230. \KwSty{#6} \ArgSty{##1} ##2}%
  1231. %%%% Other
  1232. \@ifundefined{algocf@#3}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1233. % side text or not?
  1234. \expandafter\def\csname#3\endcsname{ %Other
  1235. \@ifnextchar({\csname algocf@#3opt\endcsname}{\csname algocf@#3\endcsname}}
  1236. \expandafter\def\csname l#3\endcsname{ %Other
  1237. \@ifnextchar({\csname algocf@l#3opt\endcsname}{\csname algocf@l#3\endcsname}}
  1238. % with side text
  1239. \expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \Other(){}{}
  1240. \KwSty{#7} ##1\a@block{##2}{#8}}%
  1241. \expandafter\def\csname algocf@l#3opt\endcsname(##1)##2{% \Other(){}{}
  1242. \KwSty{#7} ##2\algocf@endline\ ##1\par}%
  1243. % without side text
  1244. \expandafter\algocf@mkcmd\csname algocf@#3\endcsname[1]{% default
  1245. \KwSty{#7}\a@block{##1}{#8}}%
  1246. \expandafter\algocf@mkcmd\csname algocf@l#3\endcsname[1]{% ldefault
  1247. \KwSty{#7} ##1}%
  1248. }
  1249. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1250. %
  1251. % If macros
  1252. %
  1253. \newcommand{\SetKwIF}[8]{% #1=\If #2=\ElseIf #3=\Else #4=if #5=then #6=elseif si #7=else #8=endif
  1254. %
  1255. % common text
  1256. \@ifundefined{#1@ifthen}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1257. \expandafter\algocf@mkcmd\csname #1@ifthen\endcsname[1]{%
  1258. \KwSty{#4} \ArgSty{##1} \KwSty{#5}}%
  1259. \expandafter\algocf@mkcmd\csname #1@endif\endcsname[1]{\a@block{##1}{#8}}%
  1260. \expandafter\algocf@mkcmd\csname #1@noend\endcsname[1]{\a@group{##1}}%
  1261. \expandafter\algocf@mkcmd\csname #1@else\endcsname[1]{\a@group{##1}\KwSty{#7}}%
  1262. \@ifundefined{#2@elseif}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1263. \expandafter\algocf@mkcmd\csname #2@elseif\endcsname[1]{%
  1264. \KwSty{#6} \ArgSty{##1} \KwSty{#5}}%
  1265. \@ifundefined{#3@else}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1266. \expandafter\algocf@mkcmd\csname #3@else\endcsname{\KwSty{#7}}%
  1267. %%%% If then { } endif
  1268. %
  1269. \@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1270. % side text or not?
  1271. \expandafter\def\csname#1\endcsname{%
  1272. \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
  1273. % with side text
  1274. \expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \If(){}{}
  1275. \csname #1@ifthen\endcsname{##2} ##1\csname #1@endif\endcsname{##3}}%
  1276. % without side text
  1277. \expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \If{}{}
  1278. \csname #1@ifthen\endcsname{##1}\csname #1@endif\endcsname{##2}}%
  1279. %
  1280. %%%% If then {} else {} endif
  1281. %
  1282. % side text or not?
  1283. \expandafter\def\csname e#1\endcsname{%
  1284. \@ifnextchar({\csname algocf@e#1opt\endcsname}{\csname algocf@e#1optif\endcsname}}
  1285. % with side text after if
  1286. \expandafter\def\csname algocf@e#1opt\endcsname(##1)##2##3{% \eIf()
  1287. \csname #1@ifthen\endcsname{##2} ##1\csname #1@else\endcsname{##3}%
  1288. \csname algocf@e#1opte\endcsname}
  1289. % without side text after if
  1290. \expandafter\def\csname algocf@e#1optif\endcsname##1##2{% \eIf()
  1291. \csname #1@ifthen\endcsname{##1}\csname #1@else\endcsname{##2}%
  1292. \csname algocf@e#1opte\endcsname}%
  1293. % side text after else or not ?
  1294. \expandafter\def\csname algocf@e#1opte\endcsname{%
  1295. \@ifnextchar({\csname algocf@e#1optopt\endcsname}{\csname algocf@e#1\endcsname}}
  1296. % else with a side text
  1297. \expandafter\def\csname algocf@e#1optopt\endcsname(##1)##2{%
  1298. ##1\csname #1@endif\endcsname{##2}}
  1299. % else without side text
  1300. \expandafter\algocf@mkcmd\csname algocf@e#1\endcsname[1]{%
  1301. \csname #1@endif\endcsname{##1}}
  1302. %
  1303. %%%% If then
  1304. %
  1305. % side text or not?
  1306. \expandafter\def\csname l#1\endcsname{% lif
  1307. \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}
  1308. \expandafter\def\csname u#1\endcsname{% uif
  1309. \@ifnextchar({\csname algocf@u#1opt\endcsname}{\csname algocf@u#1\endcsname}}
  1310. % with side text
  1311. \expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lIf(){}{}
  1312. \csname #1@ifthen\endcsname{##2} ##3\algocf@endline\ ##1\par}%
  1313. \expandafter\def\csname algocf@u#1opt\endcsname(##1)##2##3{% \uIf(){}{}
  1314. \csname #1@ifthen\endcsname{##2} ##1\csname#1@noend\endcsname{##3}}%
  1315. % without side text
  1316. \expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lIf{}{}
  1317. \csname #1@ifthen\endcsname{##1} ##2}%
  1318. \expandafter\algocf@mkcmd\csname algocf@u#1\endcsname[2]{% \uIf{}{}
  1319. \csname #1@ifthen\endcsname{##1}\csname#1@noend\endcsname{##2}}%
  1320. %
  1321. %%%% ElseIf {} endif
  1322. %
  1323. \@ifundefined{algocf@#2}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1324. % side text or not?
  1325. \expandafter\def\csname#2\endcsname{% ElseIf
  1326. \@ifnextchar({\csname algocf@#2opt\endcsname}{\csname algocf@#2\endcsname}}
  1327. % with side text
  1328. \expandafter\def\csname algocf@#2opt\endcsname(##1)##2##3{% \ElseIf(){}{}
  1329. \csname #2@elseif\endcsname{##2} ##1\csname #1@endif\endcsname{##3}}
  1330. % without side text
  1331. \expandafter\algocf@mkcmd\csname algocf@#2\endcsname[2]{% \ElseIf{}{}
  1332. \csname #2@elseif\endcsname{##1}\csname #1@endif\endcsname{##2}}
  1333. %
  1334. %%%% ElseIf
  1335. %
  1336. % side text or not?
  1337. \expandafter\def\csname l#2\endcsname{% lElseIf
  1338. \@ifnextchar({\csname algocf@l#2opt\endcsname}{\csname algocf@l#2\endcsname}}
  1339. \expandafter\def\csname u#2\endcsname{% uElseIf
  1340. \@ifnextchar({\csname algocf@u#2opt\endcsname}{\csname algocf@u#2\endcsname}}
  1341. % with side text
  1342. \expandafter\def\csname algocf@l#2opt\endcsname(##1)##2##3{% \lElseIf(){}{}
  1343. \csname #2@elseif\endcsname{##2} ##3\algocf@endline\ ##1\par}
  1344. \expandafter\def\csname algocf@u#2opt\endcsname(##1)##2##3{% \uElseIf(){}{}
  1345. \csname #2@elseif\endcsname{##2} ##1\csname #1@noend\endcsname{##3}}
  1346. % without side text
  1347. \expandafter\algocf@mkcmd\csname algocf@l#2\endcsname[2]{% \lElseIf{}{}
  1348. \csname #2@elseif\endcsname{##1} ##2}%
  1349. \expandafter\algocf@mkcmd\csname algocf@u#2\endcsname[2]{% \uElseIf{}{}
  1350. \csname #2@elseif\endcsname{##1}\csname #1@noend\endcsname{##2}}
  1351. %
  1352. %%%% Else {} endif
  1353. %
  1354. \@ifundefined{algocf@#3}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1355. % side text or not?
  1356. \expandafter\def\csname#3\endcsname{% Else
  1357. \@ifnextchar({\csname algocf@#3opt\endcsname}{\csname algocf@#3\endcsname}}
  1358. % with side text
  1359. \expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \Else(){}
  1360. \csname #3@else\endcsname\ ##1\csname #1@endif\endcsname{##2}}
  1361. % without side text
  1362. \expandafter\algocf@mkcmd\csname algocf@#3\endcsname[1]{% \Else{}
  1363. \csname #3@else\endcsname\csname #1@endif\endcsname{##1}}%
  1364. %
  1365. %%%% Else
  1366. %
  1367. % side text or not?
  1368. \expandafter\def\csname l#3\endcsname{% lElse
  1369. \@ifnextchar({\csname algocf@l#3opt\endcsname}{\csname algocf@l#3\endcsname}}
  1370. \expandafter\def\csname u#3\endcsname{% uElse
  1371. \@ifnextchar({\csname algocf@u#3opt\endcsname}{\csname algocf@u#3\endcsname}}
  1372. % with side text
  1373. \expandafter\def\csname algocf@l#3opt\endcsname(##1)##2{% \lElse(){}
  1374. \csname #3@else\endcsname\ ##2\algocf@endline\ ##1\par}
  1375. \expandafter\def\csname algocf@#3opt\endcsname(##1)##2{% \uElse(){}
  1376. \csname #3@else\endcsname\ ##1\csname #1@noend\endcsname{##2}}
  1377. % without side text
  1378. \expandafter\algocf@mkcmd\csname algocf@l#3\endcsname[1]{% \lElse{}
  1379. \csname #3@else\endcsname\ ##1}%
  1380. \expandafter\algocf@mkcmd\csname algocf@u#3\endcsname[1]{% \uElse{}
  1381. \csname #3@else\endcsname\csname #1@noend\endcsname{##1}}%
  1382. }
  1383. %
  1384. % old for backward compatibility
  1385. \newcommand{\SetKwIf}[6]{%
  1386. \SetKwIF{#1}{cf@dumb}{#2}{#3}{#4}{cf@dumb}{#5}{#6}%
  1387. \typeout{**** WARNING: SetKwIf deprecated: use SetKwIF instead*****^^J}%
  1388. }%
  1389. \newcommand{\SetKwIfElseIf}[8]{%
  1390. \SetKwIF{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
  1391. \typeout{**** WARNING: SetKwIfElseIf deprecated: use SetKwIF instead*****^^J}%
  1392. }%
  1393. %
  1394. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1395. %
  1396. % For macros
  1397. %
  1398. \newcommand{\SetKwFor}[4]{%
  1399. \@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1400. % side text or not?
  1401. \expandafter\def\csname#1\endcsname{ %For
  1402. \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
  1403. \expandafter\def\csname l#1\endcsname{ %For
  1404. \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}
  1405. % with side text
  1406. \expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \For(){}{}
  1407. \KwSty{#2} \ArgSty{##2} \KwSty{#3} ##1\a@block{##3}{#4}}%
  1408. \expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lFor(){}{}
  1409. \KwSty{#2} \ArgSty{##2} \KwSty{#3} ##3\algocf@endline\ ##1\par}
  1410. % without side text
  1411. \expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \For{}{}
  1412. \KwSty{#2} \ArgSty{##1} \KwSty{#3}\a@block{##2}{#4}}%
  1413. \expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lFor{}{}
  1414. \KwSty{#2} \ArgSty{##1} \KwSty{#3} ##2}%
  1415. }
  1416. %
  1417. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1418. %
  1419. % Repeat macros
  1420. %
  1421. \newcommand{\SetKwRepeat}[3]{%
  1422. \@ifundefined{algocf@#1}{\let\algocf@mkcmd=\newcommand}{\let\algocf@mkcmd=\renewcommand}%
  1423. % side text or not?
  1424. \expandafter\def\csname#1\endcsname{ %Repeat
  1425. \@ifnextchar({\csname algocf@#1opt\endcsname}{\csname algocf@#1\endcsname}}
  1426. \expandafter\def\csname l#1\endcsname{ %lRepeat
  1427. \@ifnextchar({\csname algocf@l#1opt\endcsname}{\csname algocf@l#1\endcsname}}
  1428. % with side text
  1429. \expandafter\def\csname algocf@#1opt\endcsname(##1)##2##3{% \Repeat(){}{}
  1430. \KwSty{#2} ##1\a@group{##3}\KwSty{#3} \ArgSty{##2}%
  1431. \@ifnextchar({\csname algocf@#1optopt\endcsname}{\@endalgoln}%
  1432. }%
  1433. \expandafter\def\csname algocf@#1optopt\endcsname(##1){% \Repeat(){}{}()
  1434. ##1\@endalgoln}%
  1435. \expandafter\def\csname algocf@l#1opt\endcsname(##1)##2##3{% \lRepeat(){}{}
  1436. \KwSty{#2} ##3 \KwSty{#3} \ArgSty{##2}\algocf@endline\ ##1\par}%
  1437. % without side text
  1438. \expandafter\algocf@mkcmd\csname algocf@#1\endcsname[2]{% \Repeat{}{}
  1439. \KwSty{#2}\a@group{##2}\KwSty{#3} \ArgSty{##1}
  1440. \@ifnextchar({\csname algocf@#1optopt\endcsname}{\@endalgoln}%
  1441. }%
  1442. \expandafter\algocf@mkcmd\csname algocf@l#1\endcsname[2]{% \lRepeat{}{}
  1443. \KwSty{#2} ##2 \KwSty{#3} \ArgSty{##1}}%
  1444. }
  1445. %
  1446. %
  1447. %
  1448. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1449. %%%%%%%%%%%%%%%%%%%% Environments definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1450. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1451. %
  1452. %%
  1453. %% Caption management
  1454. %%
  1455. % for the following macros:
  1456. % #1 is given by caption and is equal to fnum@algocf
  1457. % #2 is the text given in argument by the user in the \caption macro
  1458. %
  1459. %%%%% text of caption
  1460. \newcommand{\algocf@captiontext}[2]{#1\algocf@typo: \AlCapFnt{}#2} % text of caption
  1461. %
  1462. %%%%% default caption of algorithm: used if no specific style caption is defined
  1463. \newcommand{\algocf@makecaption}[2]{%
  1464. \addtolength{\hsize}{\algomargin}%
  1465. \sbox\@tempboxa{\algocf@captiontext{#1}{#2}}%
  1466. \ifdim\wd\@tempboxa >\hsize% % if caption is longer than a line
  1467. \hskip .5\algomargin%
  1468. \parbox[t]{\hsize}{\algocf@captiontext{#1}{#2}}% then caption is not centered
  1469. \else%
  1470. \global\@minipagefalse%
  1471. \hbox to\hsize{\hfil\box\@tempboxa\hfil}% else caption is centered
  1472. \fi%
  1473. \addtolength{\hsize}{-\algomargin}%
  1474. }
  1475. %
  1476. \newsavebox\algocf@capbox
  1477. \newcommand{\algocf@makecaption@plain}[2]{%
  1478. \global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}}%
  1479. \newcommand{\algocf@makecaption@boxed}[2]{%
  1480. \addtolength{\hsize}{-\algomargin}%
  1481. \global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}
  1482. \addtolength{\hsize}{\algomargin}%
  1483. }%
  1484. %
  1485. \newcommand{\algocf@makecaption@algoruled}[2]{\algocf@makecaption@ruled{#1}{#2}}%
  1486. \newcommand{\algocf@makecaption@boxruled}[2]{\algocf@makecaption@ruled{#1}{#2}}%
  1487. \newcommand{\algocf@makecaption@ruled}[2]{%
  1488. \global\sbox\algocf@capbox{\hskip\AlCapHSkip% .5\algomargin%
  1489. \parbox[t]{\hsize}{\algocf@captiontext{#1}{#2}}}% then caption is not centered
  1490. }
  1491. %
  1492. \newcommand{\algocf@caption@plain}{\vskip\AlCapSkip\box\algocf@capbox}%
  1493. \newcommand{\algocf@caption@boxed}{\vskip\AlCapSkip\box\algocf@capbox}%
  1494. \newcommand{\algocf@caption@ruled}{\box\algocf@capbox\kern2pt\hrule height.8pt depth0pt\kern2pt}%
  1495. \newcommand{\algocf@caption@algoruled}{\algocf@caption@ruled}%
  1496. \newcommand{\algocf@caption@boxruled}{%
  1497. \addtolength{\hsize}{-0.8pt}%
  1498. \hbox to\hsize{%
  1499. \vrule%\hskip-0.35pt%
  1500. \vbox{%
  1501. \hrule\vskip2\lineskip%
  1502. \hbox to\hsize{\unhbox\algocf@capbox\hfill}\vskip2\lineskip%
  1503. }%
  1504. %\hskip-0.35pt%
  1505. \vrule%
  1506. }\vskip-2\lineskip\nointerlineskip%
  1507. \addtolength{\hsize}{0.8pt}%
  1508. }
  1509. %
  1510. %
  1511. %%%% set caption for the environment
  1512. % beamer define is own caption overrinding latex caption!
  1513. % as we need it, we have put here the original definition
  1514. \long\def\algocf@latexcaption#1[#2]#3{% original definition of caption
  1515. \par
  1516. \addcontentsline{\csname ext@#1\endcsname}{#1}%
  1517. {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  1518. \begingroup
  1519. \@parboxrestore
  1520. \if@minipage
  1521. \@setminipage
  1522. \fi
  1523. \normalsize
  1524. \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  1525. \endgroup%
  1526. }
  1527. \ifx\beamer@makecaption\undefined%
  1528. \else% beamer detected
  1529. \ifx\@makecaption\undefined%
  1530. \newcommand{\@makecaption}[2]{\relax}%
  1531. \fi%
  1532. \fi
  1533. %
  1534. % more and more packages redefine \@caption instead of just \@makecaption which makes algorithm2e
  1535. % caption not works since based on standard \@caption. So we force the definition of \@caption to be
  1536. % the standard one (the one from LaTeX) inside algorithm environment.
  1537. %
  1538. \newcommand{\algocf@setcaption}{%
  1539. \let\algocf@savecaption=\@caption%
  1540. \let\@caption=\algocf@latexcaption%
  1541. \let\algocf@oldmakecaption=\@makecaption%
  1542. \renewcommand{\@makecaption}[2]{%
  1543. \expandafter\csname algocf@makecaption@\algocf@style\endcsname{##1}{##2}}%
  1544. }
  1545. %
  1546. %%%%% reset caption
  1547. %
  1548. % since we have force the LaTeX caption for algorithm environment, we must go back to the caption
  1549. % used in the text.
  1550. \newcommand{\algocf@resetcaption}{%
  1551. \let\@caption=\algocf@savecaption%
  1552. \let\@makecaption=\algocf@oldmakecaption%
  1553. }
  1554. %
  1555. %%%%% nocaptionofalgo and restorecaptionofalgo --
  1556. \newcommand{\nocaptionofalgo}{%
  1557. \let\@old@algocf@captiontext=\algocf@captiontext%
  1558. \renewcommand{\algocf@captiontext}[2]{\AlCapFnt{}##2}%
  1559. }
  1560. \newcommand{\restorecaptionofalgo}{%
  1561. \let\algocf@captiontext=\@old@algocf@captiontext%
  1562. }
  1563. %
  1564. % ---------------------- algocf environment
  1565. %
  1566. \newcounter{algocfline} % new counter to make lines numbers be internally
  1567. \setcounter{algocfline}{0} % different in different algorithms
  1568. %
  1569. \expandafter\ifx\csname algocf@within\endcsname\relax% if \algocf@within doesn't exist
  1570. \newcounter{algocf} % just define a new counter
  1571. \renewcommand\thealgocf{\@arabic\c@algocf} % and the way it is printed
  1572. \else% else
  1573. \newcounter{algocf}[\algocf@within] % counter is numbered within \algocf@within
  1574. \renewcommand\thealgocf{\csname the\algocf@within\endcsname.\@arabic\c@algocf}
  1575. \fi
  1576. %
  1577. \def\fps@algocf{htbp} % default
  1578. \def\ftype@algocf{10} % float type
  1579. \def\ext@algocf{\algocf@list} % loa by default, lof if figure option used
  1580. \def\fnum@algocf{{\AlCapFnt\AlTitleFnt{\algorithmcfname\nobreakspace\thealgocf}}}
  1581. \newenvironment{algocf}% % float environment for algorithms
  1582. {\@float{algocf}}%
  1583. {\end@float}
  1584. \newenvironment{algocf*}% % float* environment for algorithms
  1585. {\@dblfloat{algocf}}
  1586. {\end@dblfloat}
  1587. \ifx\l@chapter\undefined%
  1588. \newcommand\listofalgocfs{ % list of algorithms
  1589. \section*{\listalgorithmcfname}%
  1590. \@mkboth{\MakeUppercase\listalgorithmcfname}%
  1591. {\MakeUppercase\listalgorithmcfname}%
  1592. \@starttoc{loa}%
  1593. }
  1594. \else%
  1595. \newcommand\listofalgocfs{%
  1596. \if@twocolumn
  1597. \@restonecoltrue\onecolumn
  1598. \else
  1599. \@restonecolfalse
  1600. \fi
  1601. \chapter*{\listalgorithmcfname}%
  1602. \@mkboth{\MakeUppercase\listalgorithmcfname}%
  1603. {\MakeUppercase\listalgorithmcfname}%
  1604. \@starttoc{loa}%
  1605. \if@restonecol\twocolumn\fi
  1606. }
  1607. \fi
  1608. \newcommand*\l@algocf{\@dottedtocline{1}{1em}{2.3em}}% line of the list
  1609. %
  1610. % ---------------------- algorithm environment
  1611. %
  1612. %%%%%%%
  1613. %%
  1614. %% Algorithm environment definition
  1615. %%
  1616. %%%%%%%
  1617. %%
  1618. %
  1619. \newsavebox\algocf@algoframe
  1620. \def\@algocf@pre@plain{\relax}% action to be done before printing the algo.
  1621. \def\@algocf@post@plain{\relax}% action to be done after printing the algo.
  1622. \def\@algocf@capt@plain{bottom}% where the caption should be localized.
  1623. \def\@algocf@pre@boxed{\noindent\begin{lrbox}{\algocf@algoframe}}
  1624. \def\@algocf@post@boxed{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}%
  1625. \def\@algocf@capt@boxed{under}%
  1626. \def\@algocf@pre@ruled{\hrule height.8pt depth0pt\kern2pt}%
  1627. \def\@algocf@post@ruled{\kern2pt\hrule\relax}%
  1628. \def\@algocf@capt@ruled{top}%
  1629. \def\@algocf@pre@algoruled{\hrule height.8pt depth0pt\kern2pt}%
  1630. \def\@algocf@post@algoruled{\kern2pt\hrule\relax}%
  1631. \def\@algocf@capt@algoruled{top}%
  1632. \def\@algocf@pre@boxruled{\noindent\begin{lrbox}{\algocf@algoframe}}%
  1633. \def\@algocf@post@boxruled{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}%
  1634. \def\@algocf@capt@boxruled{above}%
  1635. %
  1636. %% before algocf or figure environment
  1637. \newcommand{\@algocf@init@caption}{%
  1638. \@algocf@algotitleofalgo% fix name for \Titleofalgo to \algorithmcfname
  1639. \algocf@setcaption% set caption to our caption style
  1640. }%
  1641. \newcommand{\@algocf@init}{%
  1642. \refstepcounter{algocfline}%
  1643. \ifthenelse{\boolean{algocf@optnoend}}{%
  1644. \renewcommand{\a@block}[2]{\a@group{##1}}%
  1645. }{%
  1646. \renewcommand{\a@block}[2]{\a@@block{##1}{##2}}%
  1647. }%
  1648. }
  1649. %% after the end of algocf or figure environment
  1650. \newcommand{\@algocf@term@caption}{%
  1651. \algocf@resetcaption% restore original caption
  1652. }%
  1653. \newcommand{\@algocf@term}{%
  1654. \setboolean{algocf@algoH}{false}% no H by default
  1655. \ifthenelse{\boolean{algocf@optnoend}}{%
  1656. \renewcommand{\a@block}[2]{\a@@block{##1}{##2}}
  1657. }{%
  1658. \renewcommand{\a@block}[2]{\a@group{##1}}%
  1659. }%
  1660. }
  1661. %
  1662. %%%%%%%%%%%%%%%%%
  1663. %% makethealgo: macro which print effectively the algo in its box
  1664. %%
  1665. \newsavebox\algocf@algobox
  1666. \newcommand{\algocf@makethealgo}{%
  1667. \vtop{%
  1668. % place caption above if needed bye the style
  1669. \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{above}}%
  1670. {\csname algocf@caption@\algocf@style\endcsname}{}%
  1671. %
  1672. % precommand according to the style
  1673. \csname @algocf@pre@\algocf@style\endcsname%
  1674. % place caption at top if needed bye the style
  1675. \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{top}}%
  1676. {\csname algocf@caption@\algocf@style\endcsname}{}%
  1677. %
  1678. \box\algocf@algobox% the algo
  1679. % place caption at bottom if needed bye the style
  1680. \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{bottom}}%
  1681. {\csname algocf@caption@\algocf@style\endcsname}{}%
  1682. % postcommand according to the style
  1683. \csname @algocf@post@\algocf@style\endcsname%
  1684. % place caption under if needed bye the style
  1685. \ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{under}}
  1686. {\csname algocf@caption@\algocf@style\endcsname}{}%
  1687. }%
  1688. }
  1689. %%%%%%%%%%%%%%%%%%%
  1690. %
  1691. %% at the beginning of algocf or figure environment
  1692. \newcommand{\@algocf@start}{%
  1693. \@algoskip%
  1694. \begin{lrbox}{\algocf@algobox}%
  1695. \setlength{\algowidth}{\hsize}%
  1696. \vbox\bgroup% save all the algo in a box
  1697. \hbox to\algowidth\bgroup\hbox to \algomargin{\hfill}\vtop\bgroup%
  1698. \ifthenelse{\boolean{algocf@slide}}{\parskip 0.5ex\color{black}}{}%
  1699. % initialization
  1700. \addtolength{\hsize}{-1.5\algomargin}%
  1701. \let\@mathsemicolon=\;\def\;{\ifmmode\@mathsemicolon\else\@endalgoln\fi}%
  1702. \raggedright\AlFnt{}%
  1703. \ifthenelse{\boolean{algocf@slide}}{\incmargin{\skipalgocfslide}}{}%
  1704. \@algoinsideskip%
  1705. %
  1706. }
  1707. %
  1708. %% at the end of algocf or figure environment
  1709. \newcommand{\@algocf@finish}{%
  1710. \@algoinsideskip%
  1711. \egroup%end of vtop which contain all the text
  1712. \egroup%end of hbox wich contains [margin][vtop]
  1713. \ifthenelse{\boolean{algocf@slide}}{\decmargin{\skipalgocfslide}}{}%
  1714. %
  1715. \egroup%end of main vbox
  1716. \end{lrbox}%
  1717. %\egroup% end of algo box
  1718. \algocf@makethealgo% print the algo
  1719. \@algoskip%
  1720. % restore dimension and macros
  1721. \setlength{\hsize}{\algowidth}%
  1722. \lineskip\normallineskip\setlength{\skiptotal}{\@defaultskiptotal}%
  1723. \let\;=\@mathsemicolon%
  1724. %
  1725. }
  1726. %%%%%%%%%%%%%%%%%%%%
  1727. %% basic definition of the environment algorithm
  1728. %%
  1729. \newboolean{algocf@algoH}\setboolean{algocf@algoH}{false}
  1730. \newenvironment{algocf@Here}{\noindent%
  1731. \def\@captype{algocf}% if not defined, caption exit with an error
  1732. % \hbox\bgroup%
  1733. \begin{minipage}{\hsize}
  1734. }{%
  1735. \end{minipage}
  1736. % \egroup%
  1737. }%
  1738. \newenvironment{\algocf@envname}[1][htbp]{%
  1739. \@algocf@init%
  1740. \ifthenelse{\equal{\algocf@float}{figure}}%
  1741. {\begin{figure}[#1]}%
  1742. {\@algocf@init@caption\ifthenelse{\equal{#1}{H}}%
  1743. {\setboolean{algocf@algoH}{true}\begin{algocf@Here}}%
  1744. {\begin{algocf}[#1]}%
  1745. }%
  1746. \@algocf@start%
  1747. \@ResetCounterIfNeeded%
  1748. \algocf@linesnumbered%
  1749. }{%
  1750. \@algocf@finish%
  1751. \ifthenelse{\equal{\algocf@float}{figure}}%
  1752. {\end{figure}}%
  1753. {\@algocf@term@caption\ifthenelse{\boolean{algocf@algoH}}%
  1754. {\end{algocf@Here}}%
  1755. {\end{algocf}}%
  1756. }%
  1757. \@algocf@term
  1758. }
  1759. %%%
  1760. %%% algorithm*
  1761. %%%
  1762. \newenvironment{\algocf@envname*}[1][htbp]{%
  1763. \@algocf@init%
  1764. \ifthenelse{\equal{\algocf@float}{figure}}%
  1765. {\begin{figure*}[#1]}%
  1766. {\begin{algocf*}[#1]}%
  1767. \@algocf@start%
  1768. \@ResetCounterIfNeeded%
  1769. \algocf@linesnumbered%
  1770. }{
  1771. \@algocf@finish%
  1772. \ifthenelse{\equal{\algocf@float}{figure}}%
  1773. {\end{figure*}}%
  1774. {\end{algocf*}}%
  1775. \@algocf@term%
  1776. }
  1777. %
  1778. %%%%%%%%%%%%%%%%%%%%%%%
  1779. %%%
  1780. %
  1781. \expandafter\newcommand\csname\algocf@listofalgorithms\endcsname{%
  1782. \ifthenelse{\equal{\algocf@float}{figure}}{\listoffigures}{\listofalgocfs}
  1783. }
  1784. %%%
  1785. %%%
  1786. %
  1787. % ---------------------- procedure and function environments
  1788. %
  1789. %
  1790. % -- new style (used in particular in the caption of function and procedure environments)
  1791. %
  1792. \newcommand{\ProcNameSty}[1]{\FuncSty{#1}}%
  1793. \newcommand{\SetProcNameSty}[1]{\renewcommand{\ProcNameSty}[1]{\textnormal{\csname#1\endcsname{##1}}}}
  1794. \newcommand{\ProcArgSty}[1]{\ArgSty{#1}}%
  1795. \newcommand{\SetProcArgSty}[1]{\renewcommand{\ProcArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}}}
  1796. % three macros to extract parts of the caption
  1797. \gdef\algocf@captname#1(#2)#3@{#1} % keep characters before the first brace
  1798. \gdef\algocf@captparam#1(#2)#3@{#2} % keep character in between the braces
  1799. \gdef\algocf@captother#1(#2)#3@{#3} % keep character after the braces
  1800. %
  1801. %%% Text of caption for Procedure or Function
  1802. \newcommand{\algocf@captionproctext}[2]{%
  1803. {\AlCapFnt{}\AlTitleFnt{\algocf@procname} %
  1804. \ProcNameSty{\algocf@captname #2@}% Name of the procedure in ProcName Style.
  1805. \ifthenelse{\equal{\algocf@captparam #2@}{\arg@e}}{}% if no argument, write nothing
  1806. {% else put arguments in ProcArgSty:
  1807. \ProcNameSty{(}\ProcArgSty{\algocf@captparam #2@}\ProcNameSty{)}%
  1808. }% endif
  1809. \algocf@captother #2@%
  1810. }
  1811. }
  1812. %%%% set caption for the environment
  1813. % unfortunately, makecaption is called with \ignorespace #3 so
  1814. % we can't do the @currentlabel definition inside \algocf@captionproctext
  1815. \long\def\algocf@caption@proc#1[#2]#3{%
  1816. \gdef\@currentlabel{\algocf@captname #3@}%
  1817. \algocf@old@caption{#1}[\algocf@procname\nobreakspace #2]{\ #3}%
  1818. }%
  1819. \newcommand{\algocf@setcaptionproc}{%
  1820. \let\algocf@oldcaptiontext=\algocf@captiontext%
  1821. \renewcommand{\algocf@captiontext}[2]{%
  1822. \algocf@captionproctext{##1}{##2}}%
  1823. \let\algocf@old@caption=\@caption%
  1824. \let\@caption=\algocf@caption@proc%
  1825. }
  1826. %%%%% reset caption
  1827. \newcommand{\algocf@resetcaptionproc}{%
  1828. \let\algocf@captiontext=\algocf@oldcaptiontext%
  1829. \let\@caption=\algocf@old@caption%
  1830. }
  1831. %
  1832. %
  1833. %%%%% algocf@proc is the generic environment for procedure and function environment.
  1834. %
  1835. \newboolean{algocf@procstar}\setboolean{algocf@procstar}{false}
  1836. \newenvironment{algocf@proc}[1][htbp]{%
  1837. \@algocf@proctitleofalgo% set Titleofalgo to Procedure: or Function:
  1838. % accordingly to the environment
  1839. \let\old@thealgocf=\thealgocf%\renewcommand{\thealgocf}{--}%
  1840. \algocf@setcaptionproc% set the text of caption to proc
  1841. \algocf@setcaption% set caption to our caption style
  1842. \refstepcounter{algocfline}%
  1843. \ifthenelse{\equal{\algocf@float}{figure}}{%
  1844. \ifthenelse{\boolean{algocf@procstar}}{\begin{figure*}[#1]}{\begin{figure}[#1]}%
  1845. }{%
  1846. \ifthenelse{\boolean{algocf@procstar}}%
  1847. {\begin{algocf*}[#1]}%
  1848. {\ifthenelse{\equal{#1}{H}}%
  1849. {\setboolean{algocf@algoH}{true}\begin{algocf@Here}}%
  1850. {\begin{algocf}[#1]}%
  1851. }%
  1852. }%
  1853. \@algocf@start%
  1854. \@ResetCounterIfNeeded%
  1855. \algocf@linesnumbered%
  1856. }{%
  1857. \@algocf@finish%
  1858. \ifthenelse{\equal{\algocf@float}{figure}}{%
  1859. \ifthenelse{\boolean{algocf@procstar}}{\end{figure*}}{\end{figure}}%
  1860. }{%
  1861. \ifthenelse{\boolean{algocf@procstar}}
  1862. {\end{algocf*}}
  1863. {\ifthenelse{\boolean{algocf@algoH}}
  1864. {\end{algocf@Here}}%
  1865. {\end{algocf}}%
  1866. }%
  1867. }%
  1868. \let\thealgocf=\old@thealgocf%
  1869. \@algocf@term% restore original caption and H boolean
  1870. \algocf@resetcaptionproc%
  1871. }
  1872. %
  1873. % -- procedure and function environments are defined from algocf@proc environment
  1874. %
  1875. \newenvironment{procedure}[1][htbp]%
  1876. {\setboolean{algocf@procstar}{false}%
  1877. \newcommand{\algocf@procname}{\@algocf@procname}\begin{algocf@proc}[#1]}%
  1878. {\end{algocf@proc}}
  1879. \newenvironment{function}[1][htbp]%
  1880. {\setboolean{algocf@procstar}{false}%
  1881. \newcommand{\algocf@procname}{\@algocf@funcname}\begin{algocf@proc}[#1]}%
  1882. {\end{algocf@proc}}
  1883. %
  1884. \newenvironment{procedure*}[1][htbp]%
  1885. {\setboolean{algocf@procstar}{true}%
  1886. \newcommand{\algocf@procname}{\@algocf@procname}\begin{algocf@proc}[#1]}%
  1887. {\end{algocf@proc}}
  1888. \newenvironment{function*}[1][htbp]%
  1889. {\setboolean{algocf@procstar}{true}%
  1890. \newcommand{\algocf@procname}{\@algocf@funcname}\begin{algocf@proc}[#1]}%
  1891. {\end{algocf@proc}}
  1892. %
  1893. %
  1894. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1895. %
  1896. %
  1897. \newcommand{\Titleofalgo}[1]{\@titleprefix\TitleSty{#1}\par\smallskip}
  1898. %
  1899. %
  1900. % ------------------------- Default Definitions
  1901. %
  1902. %%
  1903. %%
  1904. %
  1905. \newcommand{\algocf@defaults@common}{
  1906. %\SetKwInOut{AlgDonnees}{Donn\'ees}\SetKwInOut{AlgRes}{R\'esultat}
  1907. \SetKwInput{Donnees}{Donn\'ees}%
  1908. \SetKwInput{Res}{R\'esultat}%
  1909. \SetKwInput{Entree}{Entr\'ees}%
  1910. \SetKwInput{Sortie}{Sorties}%
  1911. \SetKw{KwA}{\`a}%
  1912. \SetKw{Retour}{retourner}%
  1913. \SetKwBlock{Deb}{d\'ebut}{fin}%
  1914. \SetKwRepeat{Repeter}{r\'ep\'eter}{jusqu'\`a}%
  1915. %
  1916. \SetKwComment{tcc}{/* }{ */}
  1917. \SetKwComment{tcp}{// }{}
  1918. %
  1919. %\SetKwInOut{AlgData}{Data}\SetKwInOut{AlgResult}{Result}
  1920. \SetKwInput{KwIn}{Input}%
  1921. \SetKwInput{KwOut}{Output}%
  1922. \SetKwInput{KwData}{Data}%
  1923. \SetKwInput{KwResult}{Result}%
  1924. \SetKw{KwTo}{to}
  1925. \SetKw{KwRet}{return}%
  1926. \SetKw{Return}{return}%
  1927. \SetKwBlock{Begin}{begin}{end}%
  1928. \SetKwRepeat{Repeat}{repeat}{until}%
  1929. %
  1930. % --- German keywords
  1931. %
  1932. % \SetKwInOut{AlgDaten}{Daten}%AlgData
  1933. % \SetKwInOut{AlgErgebnis}{Ergebnis}%AlgResult
  1934. \SetKwInput{Ein}{Eingabe}%KwIn
  1935. \SetKwInput{Aus}{Ausgabe}%KwOut
  1936. \SetKwInput{Daten}{Daten}%KwData
  1937. \SetKwInput{Ergebnis}{Ergebnis}%KwResult
  1938. \SetKw{Bis}{bis}%KwTo
  1939. \SetKw{KwZurueck}{zur\"uck}%KwRet
  1940. \SetKw{Zurueck}{zur\"uck}%Return
  1941. \SetKwBlock{Beginn}{Beginn}{Ende}%Begin
  1942. \SetKwRepeat{Wiederh}{wiederhole}{bis}%Repeat
  1943. %
  1944. % --- Czech keywords
  1945. %
  1946. % \SetKwInOut{AlgVst}{Vstup}\SetKwInOut{AlgVyst}{V\'{y}stup}
  1947. \SetKwInput{Vst}{Vstup}%
  1948. \SetKwInput{Vyst}{V\'{y}stup}%
  1949. \SetKwInput{Vysl}{V\'{y}sledek}%
  1950. %
  1951. % --- Portuguese keywords
  1952. %
  1953. % \SetKwInOut{AlgDados}{Dados}\SetKwInOut{AlgResultado}{Result.}
  1954. \SetKwInput{Entrada}{Entrada}%
  1955. \SetKwInput{Saida}{Sa\'{i}da}%
  1956. \SetKwInput{Dados}{Dados}%
  1957. \SetKwInput{Resultado}{Resultado}%
  1958. \SetKw{Ate}{at\'{e}}
  1959. \SetKw{KwRetorna}{retorna}%
  1960. \SetKw{Retorna}{retorna}%
  1961. \SetKwBlock{Inicio}{in\'{i}cio}{fim}%
  1962. \SetKwRepeat{Repita}{repita}{at\'{e}}%
  1963. % --- End
  1964. }
  1965. %
  1966. %
  1967. \newcommand{\algocf@defaults@longend}{%
  1968. \algocf@defaults@common
  1969. \SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{finsi}%
  1970. \SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{finsi}%
  1971. \SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin d'alternative}%
  1972. \SetKwFor{Pour}{pour}{faire}{finpour}%
  1973. \SetKwFor{PourPar}{pour}{faire en parallèle}{finpour}%
  1974. \SetKwFor{PourCh}{pour chaque}{faire}{finprch}%
  1975. \SetKwFor{PourTous}{pour tous les}{faire}{finprts}%
  1976. \SetKwFor{Tq}{tant que}{faire}{fintq}%
  1977. %
  1978. \SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{endif}%
  1979. \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}%
  1980. \SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endsw}%
  1981. \SetKwFor{For}{for}{do}{endfor}%
  1982. \SetKwFor{ForPar}{for}{do in parallel}{endfpar}
  1983. \SetKwFor{ForEach}{foreach}{do}{endfch}%
  1984. \SetKwFor{ForAll}{forall the}{do}{endfall}%
  1985. \SetKwFor{While}{while}{do}{endw}%
  1986. %
  1987. % --- German for longend
  1988. %
  1989. \SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende-wenn}%gIf
  1990. \SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende-wenn}%gIf
  1991. \SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende-Unt.}%Switch
  1992. \SetKwFor{Fuer}{f\"ur}{tue}{Ende-f\"ur}%For
  1993. \SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende-gleichzeitig}%ForPar
  1994. \SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende-f\"ur}%ForEach
  1995. \SetKwFor{FuerAlle}{f\"ur alle}{tue}{Ende-f\"ur}%ForAll
  1996. \SetKwFor{Solange}{solange}{tue}{Ende-solange}%While
  1997. %
  1998. % --- Portuguese
  1999. %
  2000. \SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
  2001. \SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
  2002. \SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}%
  2003. \SetKwFor{Para}{para}{fa\c{c}a}{fim para}%
  2004. \SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{fim para}
  2005. \SetKwFor{ParaCada}{para cada}{fa\c{c}a}{fim para cada}%
  2006. \SetKwFor{ParaTodo}{para todo}{fa\c{c}a}{fim para todo}%
  2007. \SetKwFor{Enqto}{enquanto}{fa\c{c}a}{fim enqto}%
  2008. }
  2009. %
  2010. %
  2011. \newcommand{\algocf@defaults@shortend}{%
  2012. \algocf@defaults@common
  2013. \SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{fin}%
  2014. \SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin}%
  2015. \SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin}%
  2016. \SetKwFor{Pour}{pour}{faire}{fin}%
  2017. \SetKwFor{PourPar}{pour}{faire en parallèle}{fin}%
  2018. \SetKwFor{PourCh}{pour chaque}{faire}{fin}%
  2019. \SetKwFor{PourTous}{pour tous les}{faire}{fin}%
  2020. \SetKwFor{Tq}{tant que}{faire}{fin}%
  2021. %
  2022. %
  2023. \SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{end}%
  2024. \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end}%
  2025. \SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end}%
  2026. \SetKwFor{For}{for}{do}{end}%
  2027. \SetKwFor{ForPar}{for}{do in parallel}{end}
  2028. \SetKwFor{ForEach}{foreach}{do}{end}%
  2029. \SetKwFor{ForAll}{forall}{do}{end}%
  2030. \SetKwFor{While}{while}{do}{end}%
  2031. %
  2032. % --- German for shortend
  2033. %
  2034. \SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende}%gIf
  2035. \SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende}%gIf
  2036. \SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{}%Switch
  2037. \SetKwFor{Fuer}{f\"ur}{tue}{Ende}%For
  2038. \SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende}%ForPar
  2039. \SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende}%ForEach
  2040. \SetKwFor{FuerAlle}{f\"ur alle}{tue}{Ende}%ForAll
  2041. \SetKwFor{Solange}{solange}{tue}{Ende}%While
  2042. %
  2043. % --- Portuguese
  2044. %
  2045. \SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim}%
  2046. \SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim}%
  2047. \SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim}%
  2048. \SetKwFor{Para}{para}{fa\c{c}a}{fim}%
  2049. \SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{fim}
  2050. \SetKwFor{ParaCada}{para cada}{fa\c{c}a}{fim}%
  2051. \SetKwFor{ParaTodo}{para todo}{fa\c{c}a}{fim}%
  2052. \SetKwFor{Enqto}{enquanto}{fa\c{c}a}{fim}%
  2053. }
  2054. %
  2055. %
  2056. \newcommand{\algocf@defaults@noend}{%
  2057. \renewcommand{\a@block}[2]{\a@group{##1}}
  2058. \algocf@defaults@common
  2059. \SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{}%
  2060. \SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{}%
  2061. \SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas où}{autres cas}{}%
  2062. \SetKwFor{Pour}{pour}{faire}{}%
  2063. \SetKwFor{PourPar}{pour}{faire en parallèle}{}%
  2064. \SetKwFor{PourCh}{pour chaque}{faire}{}%
  2065. \SetKwFor{PourTous}{pour tous les}{faire}{}%
  2066. \SetKwFor{Tq}{tant que}{faire}{}%
  2067. %
  2068. \SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{}%
  2069. \SetKwIF{If}{ElsIf}{Else}{if}{then}{else if}{else}{}%
  2070. \SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{}%
  2071. \SetKwFor{For}{for}{do}{}%
  2072. \SetKwFor{ForPar}{for}{do in parallel}{}
  2073. \SetKwFor{ForEach}{foreach}{do}{}%
  2074. \SetKwFor{ForAll}{forall}{do}{}%
  2075. \SetKwFor{While}{while}{do}{}%
  2076. % --- German for noend
  2077. \SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{}%gIf
  2078. \SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{}%gIf
  2079. \SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{}%Switch
  2080. \SetKwFor{Fuer}{f\"ur}{tue}{}%For
  2081. \SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{}%ForPar
  2082. \SetKwFor{FuerJedes}{f\"ur jedes}{tue}{}%ForEach
  2083. \SetKwFor{FuerAlle}{f\"ur alle}{tue}{}%ForAll
  2084. \SetKwFor{Solange}{solange}{tue}{}%While
  2085. % --- Portuguese
  2086. \SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{}%
  2087. \SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{}%
  2088. \SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{}%
  2089. \SetKwFor{Para}{para}{fa\c{c}a}{}%
  2090. \SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{}
  2091. \SetKwFor{ParaCada}{para cada}{fa\c{c}a}{}%
  2092. \SetKwFor{ParaTodo}{para todo}{fa\c{c}a}{}%
  2093. \SetKwFor{Enqto}{enquanto}{fa\c{c}a}{}%
  2094. }
  2095. %
  2096. %%
  2097. %%
  2098. %%
  2099. %
  2100. % default macros are:
  2101. \defaultsmacros@algo
  2102. \SetNoline
  2103. %
  2104. %
  2105. %
  2106. %%
  2107. %%%
  2108. %%%% END