1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
|
% algorithm2e.sty --- style file for algorithms
% almost everything can be customized by users. See the document for more explanations
%% Copyright 1996-2017 Christophe Fiorio
%
% This work may be distributed and/or modified under the conditions of the LaTeX Project
% Public License, either version 1.3 of this license or (at your option) any later version.
% The latest version of this license is in http://www.latex-project.org/lppl.txt and
% version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is M. Christophe Fiorio
%
% This work consists of the files algorithm2e.sty and algorithm2e.tex
% and the associated example files algorithm2e_exAlgoDisjdecomp.tex,
% algorithm2e_exIR.tex, algorithm2e_ex01.tex, algorithm2e_exProg.tex,
% algorithm2e_ex02.tex, algorithm2e_exfor.tex, algorithm2e_ex03.tex,
% algorithm2e_exgeneric.tex, algorithm2e_ex04.tex, algorithm2e_exgeneric2.tex,
% algorithm2e_ex05.tex, algorithm2e_exnlsty.tex, algorithm2e_ex06.tex,
% algorithm2e_exrepeat.tex, algorithm2e_ex07.tex, algorithm2e_exswitch.tex
%
% Report bugs and comments to:
% - algorithm2e-announce@lirmm.fr mailing list for announcement about releases^^J%
% - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J%
% subscribe by emailing sympa@lirmm.fr with 'subscribe <list> <firstname name>'^^J%
%
% $Id: algorithm2e.sty,v 5.2 2017/07/18 15:26:26 fioriochristophe Exp $
%
% PACKAGES REQUIRED:
%
% - float (in contrib/supported/float)
% - ifthen (in base)
% - xspace (in packages/tools)
% - relsize (in contrib/misc/relsize.sty)
%
%%%%%%%%%%%%%%% Release 5.2
%
% Package options:
% ---------------
% - oldcommands : to use old command names
% - french, english, german, ngerman
% portuguese, czech, italiano,
% slovak, croatian, spanish : for the name of the algorithm and some keyword code
% - onelanguage : to simply switch keyword from one language to another without changing
% keyword commands
% - boxed, boxruled, ruled, tworuled,
% algoruled, plain : layout of the algorithm
% - algo2e : environment is algorithm2e instead of algorithms and \listofalgorithmes
% instead of \listofalgorithms
% - slide : to use when making slides
% - noline,lined,vlined : how block are designed.
% - shortend, longend, noend : short or long end keyword as endif for e.g.
% - linesnumbered : auto numbering of the algorithm's lines
% - linesnumberedhidden : to hide autonumbered lines (show number on a line with \ShowLn
% - commentsnumbered, inoutnumbered : to autonumber comments and inout keywords (by defaut not numbered)
% - rightnl : to have line number on the right instead of on the left as default
% - algonl : line numbers preceded by algo number
% - scright, scleft : right or left justified side comments
% - fillcomment, nofillcomment : end mark of comment is flushed to the right so comments fill the line
% - dotocloa : add an entry in the toc for list of algorithms (require tocbibind package)
% - endfloat : add algoendfloat environment pushing algorithm so written to the end of document
% - resetcount, noresetcount : start value of line numbers.
% - algopart,algochapter,algosection : algo numbering within part, chapter or section
% - titlenumbered,titlenotnumbered : numbering of title set by \Titleofalgo
% - figure : algorithms are figures, numbered as figures, and put in the list of figures.
% - procnumbered : procedure or function are numbered as algorithm
% - nokwfunc : procedure or function name doens't become a command
% - norelsize : don't use relsize package (useful if it breaks the compatibily)
% - displayblockmarkers : display begin, end keywords at start of each block
%
% defaults are; english,plain,resetcount,titlenotnumbered
%
%%%%%%%%%%%%%%
%
% Short summary
% -------------
%
% algorithm is an environment for writing algorithm in LaTeX2e.
% Almost all is customizable. You can add keywords, change style, change the layout, ...
% It provide macros that allow you to create differents sorts of key words, therefore a set of predefined key
% word is gived.
%
% IT should be used as follows
%
% \begin{algorithm}
% ...
% ...
% \end{algorithm}
%
%
% IMPORTANT : each line MUST end with \;
%
% Note that if you define macros outside algorithm environment they
% are avaible in all the document and particulary you can use then
% inside all algorithms without re-define them.
%
% an example:
%
% \begin{algorithm}
% \SetAlgoLined
% \KwIn{this text}
% \KwOut{how to write algorithm with \LaTeX2e }
%
% initialization\;
% \While{not at end of this document}{
% read current section\;
% \eIf{understand}{
% go to next section\;
% current section becomes this one\;
% }{
% go back to the beginning of current section\;
% }
% }
% \caption{How to write algorithm}
% \end{algorithm}
%
%
%%%%%%%%%%%%%% predefined keywords
%
% \KwIn{input}
% \KwOut{output}
% \KwData{input}
% \KwResult{output}
% \KwTo % a simple keyword
% \KwFrom % a simple keyword
% \KwRet{[value]}
% \Return{[value]}
% \Begin{block inside}
% \eIf{condition}{Then Block}{Else block} % in blocks
% \If{condition}{Then block} % in a block
% \uIf{condition}{Then block} % in a block unended
% \lIf{condition}{Else text} % on the same line
% \Else{inside Else} % in a block
% \lElse{Else text} % on the same line
% \uElse{Else text} % in a block unended
% \ElseIf{inside Elseif} % in a block
% \lElseIf{Elseif text} % on the same line
% \uElseIf{Elseif text} % in a block unended
% \Switch{Condition}{Switch block}
% \Case{a case}{case block} % in a block
% \lCase{a case}{case text} % on the same line
% \Other{otherwise block} % in a block
% \lOther{otherwise block} % on the same line
% \For{condition}{text loop} % in a block
% \lFor{condition}{text} % on the same line
% \ForEach{condition}{text loop} % in a block
% \lForEach{condition}{text} % on the same line
% \ForPar{condition}{text loop} % in a block
% \lForPar{condition}{text} % on the same line
% \While{condition}{text loop} % in a block
% \lWhile{condition}{text loop} % on the same line
% \Repeat{End condition}{text loop} % in a block
% \lRepeat{condition}{text} % on the same line
%
%%%%%%%%%%%%%%
%
% History:
%
% - July 18 2017 - revision 5.2
% * FIX: There was an overfull box 0.8pt with boxruled algorithm. This is fixed.
% * FIX: problem when mixing caption package and figure option. This bug was partially corrected
% in 5.0 for one side document but with false indentation and not working for two side
% document. This is now fully fixed.
% * FIX: misaligned lines numbers with noline option
% * FIX: Fix croation keywords thanks to Ivan Kolan
% * FIX: there was an overfull hbox of 8.5pt when using [H] and ruled caption. This is fixed.
% * FIX: \SetCustomAlgoRuledWidth only changed midrule. This is fixed, it changes all the rules
% - October 19 2015 - revision 5.1
% * CHANGE/ADD: l commands (the ones as \lIf) can now be used with a
% star. If done, no end of line are done, so you can enclose
% l command into another one. For example, you can write:
% \lForEach{$i$}{\lIf*{foo}{bar}}.
% Note that when you use a star, side comments are not allowed.
% * CHANGE/ADD: Now you can have a side comment at end of macros which
% have a block. For example you can do :
% \Begin(\tcc*[h]{side comment for begin}{text}(\tcc*[h]{side comment after end})
% Note: there are some side effects for some commands:
% \SetKwProg : macro defined thanks to \SetKwProg are allowed
% to have no end marker. In this case,
% beware to end side comment, this can
% do weird output (but no error)
% * CHANGE: \SetKwSwitch defines also an \uOther command which was not
% the case until this release.
% * CHANGE: \SetStartEndCondition{typo1}{typo2}{typo3} defined two end
% conditions (type2 and typo3) : typo3 is no more used for
% case condition as typo2 is used which is more consistent
% since there is a condition followed by a keyword as for
% if-then or other command that are defined using typo2.
% * CHANGE: keywords was not language dependant to allow to use multiple
% languages in the same document, but some keywords in
% different language were having the same keyword that lead
% last one declared to replace first one and so you could have some
% spanish keywords printed as you were in portuguese. So
% this behavior is changed from now:
% - localized keywords are defined if according language
% option is defined ;
% - if you want to keep old behaviour and use localized
% keywords without using language option (keep old
% behavior), you can use languagekw option
% (e.g. frenchkw, germankw, ...). Note that you can use
% multiple languagekw options at the same time, in
% contrary of language option. Note also that if you use
% multiple languagekw options, you can get back the same
% problem as previously when keywords was not language
% dependant.
% * ADD: new typo styles:
% - Arguments of functions have now their own style. By
% default, FuncArgSty is the same as ArgSty.
% - Name of KwProg have now their own sty (they used ArgSty
% previously). By default, ProgSty is still ArgSty.
% As usual, \SetFuncArgSty{}, FuncArgSty{} and
% \SetProgSty{}, ProgSty{} are macros to set and use these
% typo styles.
% * ADD: Options to manage algorithm hangindent
% Until this revision, long statement acts as classical text and
% continue on next line starting from the same point. This makes
% difficult to notice that the new lines of text is not a new
% statement. Now, hangindent is managed and when a long
% statement continue on next lines, lines, except the first,
% are indented.
% Option: noalgohanging
% By default, long statement are indented on subsequent
% lines; with this option you get old behavior and lines are
% no more indented
% Option: hangingcomment
% Comment that are alone on a line (not side comment) are
% not driven by algo hanging: subsequent lines of long
% comments are indented according to width of start comment
% marker. With this option, comment are indented like normal
% statement.
% Option: hanginginout
% As for comment, by default, in/out keywords and input
% keywords (defined by \SetKwInOut or \SetKwInput) are not
% indented by algorithm hangindent. They are indented
% according to width of input keyword. If you want that these
% keywords acts like normal statement, use this option.
% \SetAlgoHangIndent{length}
% This macro allows you to set your own indent length. By
% default, \SetAlgoHangIndent{0.5em}
% * ADD: Group markers.
% This option is related to block markers of release 5.0. Some
% have ask to put also block markers for single line
% command. This new feature has been implemented to do this.
% So, you can now ask package to put begin and end keywords
% automatically at start and end of single line command (see
% example in documentation).
% These new group markers macros are:
% - \AlgoDisplayGroupMarkers and \AlgoDontDisplayGroupMarkers
% Note that a new option has also been added: displaygroupmarkers
% * ADD: \SetCustomAlgoRuledWidth{length}
% set a custom ruled width of ruled and algoruled options ;
% note that by the moment you use this macro, rules will have
% this fixed length: this can cause strange behavior in
% multicolumn mode or other layout that change the line
% width.
% * ADD: turkish language option
% * FIX: a spurious whitespace which results in a spurious indent in the
% user's text right after the end of the algorithm environment
% was introduced in release 5.0. This is fixed now thanks to
% Alexander Malkis.
% * FIX: there was a problem with margins in caption when option figure
% was use with caption package. This is fixed.
% * FIX: when changing font size in caption with, interline skip stayed
% unchanged and so with a small font was to large. This is fixed.
% * FIX: in contrary of that is written in the documentation, ':' what
% not in KwSty typo for KwIn and KwOut command. This is fixed.
% * FIX: strange behaviour with label and lines numbered: @currentlabel
% was updated according to algo line number not in all
% situation. For e.g, with hyperref package, always updated ;
% with \nlset also updated, but with \nl or linesnumbered
% option, not updated. This "feature" causes different output
% with \label command according to options used which is not
% that one want. This is solved now, and @currentlabel is
% always updated so \label command works always is the same way.
% * FIX: some czech keywords
% * FIX: some spanish keywords
% * FIX: some croatian keywords
% * FIX: krantz class changes definition of chapter and get one more
% option that classical classes as book.cls or report.cls and
% broke fix for hyperref on chapter definition. This is now
% fixed and algorithm detects use of krantz class and use then
% a definition of chapter working with krantz class.
% * FIX: an issue with internal macro which causes ([Q]) use as argument
% of some environment to be misprinted (thanks to Martin Schröder).
% * FIX: mispelled name of hyperrefcounter inside internal macro.
%
% - January 06 2013 - revision 5.0
% * CHANGE: SetKwSwitch takes now 9 args: 9th arg is the same as
% previous 8th arg ('end of switch' keyword). New 8th arg is
% 'end of case' keyword. This is due to change of release
% 3.2 which introduce end after case block... as I never
% test with longend option, I never see that the 'end
% switch' used for case was not good.
% * CHANGE: when no end keyword is defined in a block macro, then
% algorithm2e does no more try to print it. So even with lined or noline
% option, no empty line is printed (before: a blank end was
% printed, so a blank line appeared)
% * Internal Change: add some internal function to improve readibility
% (thanks to Philip K. F. H\ölzenspies)
% * ADD: Block markers.
% You can now ask package to put begin and end keywords automatically at begin
% and end of blocks, it means each group of commands shifted and enclosed in
% braces.
% This is tricky to use but, combined with \SetStartEndCondition and
% redefinition of keywords, you should be abble to simulate any syntax. See
% examples in documentation where a generic example is derived in pseudo-code,
% python and C by keeping code and changing only style using block markers
% macros, \SetStartEndCondition and some redefinition of keywords.
% These new block markers macros are:
% - \AlgoDisplayBlockMarkers and \AlgoDontDisplayBlockMarkers
% - \SetAlgoBlockMarkers{begin marker}{end marker}
% - \BlockMarkersSty{text} and \SetBlockMarkersSty
% Note that a new option has also been added: displayblockmarkers
% * ADD: \leIf macro automatically defined by \SetKwIF: allow to define
% an if-then-else on a single line.
% * ADD: new macro \SetStartEndCondition{typo1}{typo2}{typo3} which
% sets typo around condition in For, If, Switch, Case and
% Repeat macros. First two are used around For, If, Swith
% conditions, First and third are used for Case and Repeat
% condition where condition ends the line. Default definition
% is \SetStartEndCondition{ }{ }{}.
% A common alternative is \SetStartEndCondition{ (}{) }{)}
% Can also be used to remove space around condition, for
% example if you want python style commands:
% \SetStartEndCondition{ }{}{} and \SetKwFor{For}{for}{:}{}
% * ADD: new environment algomathdisplay which allow display math (like inside \[ \] or $$ $$)
% handling end line and line number
% * ADD: new command \SetKwProg{Env}{Title}{is}{end} which defines a macro
% \Env{args}{text}. Env is a block with 'Title' (in \CapSty) at the beginning
% followed by args followed by 'is' then 'text' is put below inside a block ended
% by 'end'. If no 'end' is specified, nothing is written (no
% blank line is inserted). Useful to typeset function or prog for example:
% \SetKwProg{Fn}{Function}{ is}{end} makes \Fn{afunc(i: int) : int}{return 0\;}
% writes:
% Function afunc(i: int) : int is
% | return 0;
% end
% or \SetKwProg{Def}{def}{:}{} makes \Def{afunc(i: int)}{return 0\;} writes:
% def afunc(i: int):
% | return 0
% Tip: combine it with \SetKwFunction to write recursive function algorithm. With
% example above, you could define \SetKwFunction{\Afunc}{afunc} and then write:
% \Def{\Afunc{i:int}{\eIf{i>0}{\KwRet \Afunc{i-1}}{\KwRet 0\;}} that writes:
% def afunc(i: int):
% | if(i>0):
% | return afunc(i-1)
% | else:
% | return 0
% with appropriate typo.
% * ADD: option croatian: croatian keywords (thanks to Ivan Kohan and
% Yvan Gavran)
% * ADD: option ngerman: same as german option but so can be used with global option ngerman
% of babel
% * ADD: option spanish: Spanish support (thanks to Mario Abarca)
% * ADD: unterminated block: useful to add part separator that doesn't necessary need an end
% keyword.
% Designed on the pattern of unterminated if (see \uIf macro) allowing to
% add a block that is not terminated by a keyword. Such block are defined in the same
% time as a block is defined by adding a macro beginning with u. So, for example,
% predefined \SetKwBlock{Begin}{begin}{end} defines now two commands:
% - \Begin{} as previously which print a begin - end block
% - \uBegin{} that defines a begin only block
% * FIX: problem when numbering line inside until condition of
% \SetKwRepeat macro: line number was not correctly aligned.
% * FIX: dotocloa option which was broken
% * FIX: uIf and uCase didn't have same behavior when used with
% noline, vlined or lined option. This is fixed. Side effect: no empty
% line after an uIf or uCase when used with options lined or vlined
% * FIX: a bug with Repeat Until command when use with side comment on Until
% * FIX: a bug with side text -- text put into () -- of command macro (SetKwIf and so on)
% which was always setting a ';' even after a \DontPrintSemicolon
% * FIX: a bug with hyperref and chapter definition (thanks to Hubert Meier)
% * FIX: bugs with l macro and side comment
% * FIX: revision number
% * FIX: fix non ascii character (utf8 not yet recognized by all latex engine)
% * FIX: fnum@algocf had an useless parameter which sometimes broke expansion and output an error
% * FIX: works now with multicol package
%
% - december 14 2009 - revision 4.1
% * ADD: new command \SetKwHangingKw{Name}{text} (hanging indent with keyword): This creates a
% hanging indent much like \texttt{SetKwInput}, except that it removes the trailing `:'
% and does not reset numbering (thanks to Nathan Tallent)
%
% - november 17 2009 - revision 4.00 -
%
% * CHANGE: IMPORTANT: some commands have been renamed to have consistent naming (CamlCase
% syntax) and old commands are no more available. If you doesn't want to change
% your mind or use old latex files, you can use oldcommands option to enable old
% commands back.
% text. Here are these commands:
% - \SetNoLine becomes \SetAlgoNoLine
% - \SetVline becomes \SetAlgoVlined
% - \Setvlineskip becomes \SetVlineSkip
% - \SetLine becomes \SetAlgoLined
% - \dontprintsemicolon becomes \DontPrintSemicolon
% - \printsemicolon becomes \PrintSemicolon
% - \incmargin becomes \IncMargin
% - \decmargin becomes \DecMargin
% - \setnlskip becomes \SetNlSkip
% - \Setnlskip becomes \SetNlSkip
% - \setalcapskip becomes \SetAlCapSkip
% - \setalcaphskip becomes \SetAlCapHSkip
% - \nlSty becomes \NlSty
% - \Setnlsty becomes \SetNlSty
% - \linesnumbered becomes \LinesNumbered
% - \linesnotnumbered becomes \LinesNotNumbered
% - \linesnumberedhidden becomes \LinesNumberedHidden
% - \showln becomes \ShowLn
% - \showlnlabel becomes \ShowLnLabel
% - \nocaptionofalgo becomes \NoCaptionOfAlgo
% - \restorecaptionofalgo becomes \RestoreCaptionOfAlgo
% - \restylealgo becomes \RestyleAlgo
% - gIf macros and so on do no more exist
% * NEW: - Compatibily with other packages improven by changing name of internal
% macros. Algorithm2e can now be used with arabtex for example, if this last is
% loaded after algorithm2e package.
% * ADD: - OPTION endfloat: endfloat packages doesn't allow float environment inside other
% environment. So using it with figure option of algorithm2e makes error. This
% option enables a new environment algoendfloat to be used instead of algorithm
% environment that put algorithm at the end. algoendfloat environment make
% algorithm acting as endfloat figures. This option requires endfloat packages.
% * ADD: - OPTION norelsize: starting from this release (v4.00), algorithm2e package uses
% relsize package in order to get relative size for lines numbers; but it seems
% that some rare classes (such as inform1.cls) are not compatible with relsize; to
% have algorithm2e working, this option makes algorithm2e not to load relsize
% package and go back to previous definition by using \scriptsize font for lines
% numbers.
% * ADD: - OPTION onelanguage: allow, if using standard keywords listed below, to switch
% from one language to another without changing keywords by using appropriate
% language option:
% . KwIn, KwOut, KwData, KwResult
% . KwTo KwFrom
% . KwRet, Return
% . Begin
% . Repeat
% . If, ElseIf, Else
% . Switch, Case, Other
% . For, ForPar, ForEach, ForAll, While
% .
% * ADD: - OPTION rightnl: put lines numbers to the right of the algorithm instead of left.
% * ADD: new commands \setRightLinesNumbers and \setLeftLinesNumbers which sets the lines
% numbers to the right or to the left of the algorithm.
% * ADD: - new kind of keywords: KwArray used to define arrays:
% \SetKwArray{Kw}{array} defines an array keywords Kw called array and printed in
% DataSty style when call with \Kw. It can be used with one argument which
% denotes the element index: \Kw{n} prints array[n] with array in DataSty and n in
% ArgSty.
% * ADD/FIX: rules of ruled, algoruled, tworuled styles used rules of different sizes! This
% is now fixed. Moreover size of the rules is now controlled by a length and so
% can be customized by the user.
% \algoheightrule is the height of the rules and can be changed via \setlength
% \algoheightruledefault is the default height of he rules (0.8pt)
% \algotitleheightrule is the height of the rule that comes just after the
% caption in ruled and algoruled style; it can be changed via \setlength
% \algotitleheightruledefault is the default height of this rules (0.8pt)
% Thanks to Philippe Dumas who reports the bug and make the suggestion.
% * ADD: - \SetAlgoCaptionSeparator which sets the separator between Algorithm 1 and the
% title. By default it's ':' and caption looks like "Algorithm 2: title" but now
% you can change it by using for example \SetAlgoCaptionSeparator{.} which will
% give "Algorithm 3. title"
% * ADD: - \SetAlgoLongEnd and \SetAlgoShortEnd and \SetAlgoNoEnd commands which act as
% corresponding package options
% * ADD: - OPTIONS italiano and slovak as new language (thanks to Roberto Posenato and
% Miroslav Binas)
% * CHANGE: - Fnt and Sty macro to have consistent use and naming (see below)
% * ADD: - \AlCapSty, \AlCapNameSty, \AlCapFnt, \AlCapNameFnt, \ProcSty, \ProcFnt,
% \ProcNameSty, \ProcNameFnt, \ProcArgSty, ProcArgFnt and corresponding "set macro"
% \SetAlCapSty, \SetAlCapNameSty, \SetAlCapFnt, \SetAlCapNameFnt, \SetProcSty,
% \SetProcFnt, \SetProcNameSty, \SetProcNameFnt, \SetProcArgSty, \SetProcArgFnt which
% control the way caption is printed. Sty macro use command taking one parameter as
% argument, Fnt macros use directly command. In Fact caption is printed as follow:
% \AlCapSty{\AlCapFnt Algorithm 1:}\AlCapNameSty{\AlCapNameFnt my algorithm}
% By default, \AlCapSty is textbf and \AlCapFnt is nothing. \AlCapNameSty keep text
% as it is, and \AlCapNameFnt do nothing also.
% You can redefine \AlCapFnt and \AlCapNameFnt by giving macro to \Set commands. For
% example, you can do \SetAlCapFnt{\large} to see Algorithm printed in \large font.
% You can redefine \AlCapSty, \AlCapFnt, \AlCapNameSty and \AlCapNameFnt with the
% corresponding \Set command. For the Sty commands, you have to give in parameter
% name of a macro (whithout \) which takes one argument. For example,
% \SetAlCapFnt{textbf} defines the default behaviour. If you want to do more
% complicated thing, you should define your own macro and give it to \SetAlCapFnt or
% \SetAlCapNameFnt. Here are two examples:
% - \newcommand{\mycapsty}[1]{\tiny #1}\SetAlCapNameSty{mycapsty}
% - \newcommand{\mycapsty}[1]{\textsl{\small #1}}\SetAlCapNameSty{mycapsty}
% Or you can combine the two, for the last example you can also do:
% \SetAlCapNameSty{textsl}\SetAlCapNameFnt{\small}
% Thanks to Jan Stilhammer who gives me the idea of \AlCapNameFnt.
% * CHANGE \AlTitleFnt to match definition of all other Fnt macros and add a \AlTitleSty
% macro (see below) . Now you set \AlTitleFnt by calling \SetAlTitleFnt with
% directly a macro without parameter in argument:
% Example: \SetAlTitleFnt{\small} to set title in small font.
% * ADD: - \AlTitleSty and \SetAlTitleSty commands to set a style for title. These commands
% are defined from a macro taking the text in argument, as \textbf for example.
% To set the TitleSty you have to give name of the macro (without the '\')
% to \SetAlTitleSty. For example \SetAlTitleSty{textbf} to set \textbf style.
% * ADD: - new command \SetAlgorithmName{algorithmname}{list of algorithms name} which
% redefines name of the algorithms and the sentence list of algorithms. Second
% argument is the name that \autoref, from hyperref package, will use. Example:
% \SetAlgorithmName{Protocol}{List of protocols} if you prefer protocol than
% algorithm.
% * ADD: - new \SetAlgoRefName{QXY} which change the default ref (number of the algorithm) by
% the name given in parameter (QXY in the example).
% * ADD: - new command \SetAlgoRefRelativeSize{-2} which sets the output size of refs, defined
% by \SetAlgoRefName, used in list of algorithms.
% * ADD: - two dimensions to control the layout of caption in ruled, algoruled and boxruled
% algorithms:
% - interspacetitleruled (2pt by defaut) which controls the vertical space between
% rules and title in ruled and algoruled algorithms.
% - interspaceboxruled (2\lineskip by default) which controls the vertical space
% between rules and title in boxruled algorithms.
% These two dimensions can be changed by using \setlength command.
% * ADD: - With the fix (see below) of procedure and function environments, a new feature has
% been added: the name of the procedure or function set in caption is automatically
% defined as a KwFunction and so can be used as a macro. For example, if inside a
% procedure environment you set \caption{myproc()}, you can use \myproc macro in you
% main text. Beware that the macro is only defined after the \caption!
% * ADD: - OPTION nokwfunc to unable the new feature described above in function and
% procedure environment. Useful if you use name of procedure or function that cannot
% be a command name as a math display for example.
% * ADD: - \SetAlgoNlRelativeSize{number} command which sets the relative size of line
% numbers. By default, line numbers are two size smaller than algorithm text. Use
% this macro to change this behavior. For example, \SetAlgoNlRelativeSize{0} sets it
% to the same size, \SetAlgoNlRelativeSize{-1} to one size smaller and
% \SetAlgoNlRelativeSize{1} to one size bigger
% * ADD: - \SetAlgoProcName{aname} command which sets the name of Procedure printed by
% procedure environment (the environment prints Procedure by default). Second
% argument is the name that \autoref, from hyperref package, will use.
% * ADD: - \SetAlgoFuncName{aname} command which sets the name of Function printed by
% procedure environment (the environment prints Function by default). Second
% argument is the name that \autoref, from hyperref package, will use.
% * ADD: - \SetAlgoCaptionLayout{style} command which sets style of the caption; style must
% be the name of a macro taking one argument (the text of the caption). Examples
% below show how to use it:
% . \SetAlgoCaptionLayout{centerline} to have centered caption
% . \SetAlgoCaptionLayout{textbf} to have bold caption
% If you want to apply two styles in the same time, such as centered bold, you have
% to define you own macro and then use \SetAlgoCaptionLayout with its name.
% * ADD: - OPTION procnumbered: which makes the procedure and function to be numbered as
% algorithm
% * ADD: - OPTIONS tworuled and boxruled
% these are two new layouts: tworuled acts like ruled but doesn't put a line after
% caption ; boxruled surround algorithm by a box, puts caption above and add a line
% after caption.
% * REMOVE: - SetKwInParam has been deleted since not useful itself because of different
% macros which can do the same in a better and a more consistent way as
% SetKwFunction or SetKw.
% * FIX: - line number is now correctly vertically aligned with math display.
% * FIX: - references with hyperref. No more same identifier or missing name error. BUT now
% you must NOT use naturalnames option of hyperref packages if you do PdfLaTeX
% * FIX: - autoref with hyperref package (thanks to Jörg Sommer who notices the problem).
% * FIX: - titlenumbered was not working! fixed.
% * FIX: - Else(){} acted like uElse. Corrected.
% * FIX: - noend management: when a block was inside another and end of block was following
% each other, a blank line was added: it's now corrected.
% * FIX: - Function and Procedure environment was no more working as defined originally: the
% label was no more name of the procedure, it acts always as if procumbered option
% has been used.
% * FIX: - line numbers had a fixed size which can be bigger than algorithm text accordingly
% to \AlFnt set (see also new command \SetAlgoNlRelativeSize above)
% * FIX: - semicolon in comments when dontprintsemicolon is used.
% * FIX: - listofalgorithms adds a vertical space before first algo of a chapter as for
% listoffigures or listoftables
% * FIX: - listofalgorithms with twocolumns mode and some classes which don't allow onecolumn
% and so don't define \if@restonecol as prescribed in LaTeX (sig-alternate for
% example)
% * FIX: - algorithm2e now works with elsart cls and some more classes.
% * FIX: - blocks defined by SetKwBlock act now as other blocks (if for instance) and don't
% write end in vlined mode, instead they print a small horizontal line as required
% by the option.
% * FIX: - underfull hbox warning at each end of algorithm environment removed.
%
% * INTERNAL CHANGE: - short end keyword are deduce from long end keyword by keeping the
% first one. Allows to avoid double definition.
% * INTERNAL CHANGE: - procedure, function and algorithm are now resolved by the same
% environment to avoid code duplication.
%
% - October 04 2005 - revision 3.9 -
% * ADD: - \setalcaphskip command which sets the horizontal skip before Algorithm: in caption
% when used in ruled algorithm.
% * ADD: - \SetAlgoInsideSkip command which allows to add an extra vertical space before and
% after the core of the algorithm (ie: \SetAlgoInsideSkip{bigskip})
% * CHANGE: - caption, when used with figure option, is no more controlled by algorithm2e
% package and so follows the exact behaviour of figures. The drawback is that you
% cannot change the typo with AlTitleFnt or CapFnt. The avantage is that if you
% use caption package, it works.
% * FIX: - problem with numbering line and pdflatex
% * FIX: - error when algorithm2e package was used with beamer and listings together
% - February 12 2005 - revision 3.8 -
% * FIX: - extra line with noend option.
% - February 10 2005 - revision 3.7 -
% * ADD: - sidecomment: different macros allowing to put text right after code on the same
% line. They are defined in the same time comment macros are defined with a star
% after the macro name. By default comments are right justified but this can be
% change with appropriate option in the macro. Ex:
% . default: \tcc*{side comment}
% . same as previous: \tcc*[r]{side comment}
% . left justify: \tcc*[l]{side comment}
% . here: \tcc*[h]{side comment} don't put the end of line mark before
% comment (; by default) and don't end the line.
% . flushed: \tcc*[f]{side comment} same as the precedent but right
% justified
% * ADD: - OPTION scright (default): right justified side comments (side comments
% are flushed to the righr)
% * ADD: - OPTION scleft: left justified side comments (side comments are put right after the
% code line)
% * ADD: - \SetSideCommentLeft acts as scleft option
% * ADD: - \SetSideCommentRight acts as scright option
% * ADD: - block like macro side text: all macro defining a block allows now to put text right
% after key words by putting text into (). Done to be used with sidecomment macros,
% but all text can be used.
% Ex: \eIf(\tcc*[f]{then comment}){test}{then text}(else side text){else text}
% * ADD: - OPTION fillcomment (default): end mark of comment is flushed to the right so
% comments fill all the width of text.
% * ADD: - OPTION nofillcomment: end mark of comment is put right after the comment.
% * ADD: - \SetNoFillComment acts as nofillcomment option.
% * ADD: - \SetFillComment acts as fillcomment option.
% * ADD: - OPTION dotocloa: which adds an entry in the toc for the list of algorithms. This
% option load package tocbibind if not already done and so list of figures and list
% of tables are also added in the toc. If you want to control which ones of the lists
% will be added in the toc, please load package tocbibind before package algorithm
% and give it the options you want.
% * FIX: - vertical spacing for uif macro with noend option
% * FIX: - all the compatibility problems between caption and other packages
% * FIX: - typographical differences between list of algorithms and other lists when in
% report or book
%
% - January 24 2005 - revision 3.6 -
% * FIX: - vertical spacing and space characters at the beginning or end of comments.
% line numbers of comments not in the NlSty.
% Thanks to Arnaud Giersch for his comments and suggestions.
% * FIX: - Set*Sty macro: the styles defined was not protected and was modified by surrounding
% context. For example KwTo in a \For{}{} was in bold AND italic instead of just in
% bold.
% * FIX: - line number misplacement after \Indp
%
% - January 21 2005 - revision 3.5 -
% * ADD: - hidden numbering of the lines. Lines are auto-numbered but numbers are shown only
% on lines you specify:
% * linesnumberedhidden option or \LinesNumberedHidden macro activate this
% functionnality.
% * \ShowLn and \ShowLnLabel{lab} macros make the number visible on the
% line. \ShowLnLabel{lab} allows to set a label for this line.
% Thanks to Samson de Jager who makes this suggestion and provides the macros.
% * ADD: - \AlCapFnt and \SetAlCapFnt which allow to have a different font for
% caption. Works like \AlFnt and \SetAlFnt and by default is the same.
% * ADD: - \AlCapSkip skip length. This vertical space is added before caption in plain ou
% boxed mode. It allows to change distance between text and caption.
% * FIX: - caption compatible with IEEEtran class.
% * FIX: - some vertical spacing error with \uIf macros (Thanks to Arnaud Giersch)
% * FIX: - Procedure and Function: lines are also numbered like algorithms
% * FIX: - CommentSty was not used for Comments
%
% - January 10 2005 - revision 3.4 -
% * FIX: - caption compatible with new release of Beamer class.
%
% - June 16 2004 - revision 3.3 -
% * FIX: - Hyperlink references of Hyperref package works now if compiled with pdflatex
% and [naturalnames] option of hyperref package is used.
% * FIX: - algorithm[H] had problem in an list environment - corrected
% * FIX: - interline was not so regular in nested blocks - corrected
% * ADD - \SetVlineSkip macro which sets the vertical skip after the little horizontal
% rule which closes a block in Vlined mode. By default 0.8ex
%
% - June 11 2004 - revision 3.2 - AUTO NUMBERING LINES !!!
% * ADD: auto numbering of the lines (the so asked and so long awaiting feature)
% this feature is managed by 3 options and 3 commands:
% - linesnumbered option: lines of the algo are numbered except for comments and
% input/output (KwInput and KwInOut)
% - commentsnumbered option: makes comments be numbered
% - inoutnumbered option: makes data input/output be numbered
% - \nllabel{lab} labels the line so you can cite with \ref{lab}
% - \LinesNumbered make the following algorithms having auto-numbered lines
% - \linesnotnumbered make the following algorithms having no auto-numbered lines
% * Change: algo2e option renames listofalgorithms in listofalgorithmes
% * FIX: new solution for compatibility with color package, more robust and not tricky.
% Many thanks to David Carlisle for his advices
%
% - June 09 2004 - revision 3.1 -
% * Change: \SetKwSwitch command defines an additionnal macro \uCase and \Case prints end
% * Change: now macros SetKw* do a renewcommand if the keyword is already defined. So you can
% redefine default definition at your own convenience or change your definition
% without introducing a new macro and changing your text.
% * ADD: new macro \SetKwIF which do \SetKwIf and
% \SetKwIfElseIf.The following default definition has been added:
% \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}
% and so you get the macros;
% \If \eIf \lIf \uIf \ElseIf \uElseIf \lElseIf \Else \uElse \lElse
% * ADD: new macro \SetAlgoSkip which allow to fix the vertical skip before and after the
% algorithms. Default is smallskip, do \SetAlgoSkip{} if you don't want an extra space
% or \SetAlgoSkip{medskip} or \SetAlgoSkip{bigskip} if you want bigger space.
% * ADD: macro \SetKwIf defines in addition a new macro \uElse (depending on wat name you
% have given in #2 arg).
% * ADD: macro \SetKwIfElseIf defines in addition a new macro \uElse and \ugElseIf (depending
% on what name you have given in #2 and #3 arg).
% * Change: baseline of algorithm is now top, so two algorithms can be put side by side.
% * FIX: Compatibility with color package solved. The problem was due to a redefinition of
% standard macros by color package. This solves compatibility problem with other
% packages as pstcol or colortbl. (notified by Dirk Fressmann, Antti Tarvainen and Koby
% Crammer)
% * Fix: extra little shift to the right with boxed style algorithm removed (notified by
% P. Tanovski)
% * Fix: algoln option was buggy (notified bye Jiaying Shen)
% * Fix: german and portuges option didn't work due to bad typo (notified by Martin Sievers,
% Thorsten Vitt and Jeronimo Pellegrini)
%
% - February 13 2004 - revision 3.0 -
% * Major revision which makes the package independent from float.sty, so now
% - algorithm* works better, in particular can be used in multicols environments
% - (known bug corrected)
% [H] works now for all sort of environment but is handled differently for classic
% environment and star environment (algorithm, figure, procedure and function). For star
% environment, H acts like for classical figure environment, so it doesn't stay here
% absolutely.
% - (known bug corrected)
% you can use now floatflt package with algorithm package and even with figure
% option. Beware that if you want to put an algorithm inside a floatingfigure, it cannot
% be floating, so [H] is required and then figure option should not be used, since
% standard figure[H] are still floating with LaTeX.
% * boxruled: a new style added. Possible now since no style no more defined by the float
% package.
% * nocaptionofalgo: dosen't print Algorithm #: in the caption for algorithm in ruled or
% algoruled style.
% note: this is just documentation of a macro which was already in the package.
% - December 14 2003 - revision 2.52 -
% * output message shorter
% * French keyword macro \PourTous was missing for longend option, it has been added.
% * TitleofAlgo prints Function or Procedure in corresponding environments.
%
% - October 27 2003 - revision 2.51 - Revision submitted to CTAN archive
% * correction of a minor which make caption in procedure
% and function to be blanck with pdfscreen package
% (thanks to Joel Gossens for the notification)
% * add two internal definition to avoid some errors when
% used with Hyperref package (Hyperref package need to
% define new counter macro from existing ones, and
% don't do it for algorithm2e package, so we do it)
%
% - October 17 2003 - revision 2.50 - first revision for CTAN archive
% * add \AlFnt and \SetAlFnt{font} macros: \AlFnt is used at the beginning of the caption and
% the body of algorithm in order to define the fonts used for typesetting algorithms. You
% can use it elsewhere you want to typeset text as algorithm. For example you can do
% \SetAlFnt{\small\sf} to have algorithms typeset in small sf font. Default is nothing so
% algorithm is typeset as the text of the document.
% * add \AlTitleFnt{text} and \SetAlTitleFnt{font} macros: The {Algorithm: } in the caption is
% typeset with \AlTitleFnt{Algorithm:}. You can use it to have text typeset as {Algorithm:}
% of captions. Default is textbf. Default can be redefined by \SetAlTitleFnt{font}, for
% example you can do \SetAlTitleFnt{emph}
% * add CommentSty typo for text comment.
% * add some compatibility with hyperref package (still an error on multiply defined refs but
% pdf correctly generated)
% * flush text to left in order to have correct indentation even with class as amsart which
% center all figures
% * add german, portuguese and czech options for title of algorithms and typo.
% * add portuguese translation of predefined keywords * add czech translation of some
% predefined keywords
%
% - December 23 2002 - revision 2.40
% * add some French keyword missing
% * add function* and procedure* environment like algorithme* environment: print in one column
% even if twocolumn option is specified for the document.
% * add a new macro \SetKwComment to define macro which writes comments in the text. First
% argument is the name of the macro, second is the text put before the comment, third is the
% text put at the end of the comment.Default are \tcc and \tcp
% * add new options to change the way algo are numbered:
% [algopart] algo are numbered within part (counter must exist)
% [algochapter] algo are numbered within chapter
% [algosection] algo are numbered within section
%
% - March 27 2002 - revision 2.39
% * Gilles Geeraerts: added the \SetKwIfElseIf to manage
% if (c)
% i;
% else if (c)
% i;
% ...
% else
% i;
% end
% * Also added \gIf \gElseIf \gElse.
%
% - January 02 2001 - revision 2.38
% * bugs related to the caption in procedure and function
% environment are corrected.
% * bug related to option noend (extra vertical space added
% after block command as If or For) is corrected.
% * czech option language added (thanks to Libor Bus: l.bus@sh.cvut.cz).
%
% - October 16 2000 - revision 2.37
% * option algo2e added: change the name of environment
% algorithm into algorithm2e. So allow to use the package
% with some journal style which already define an algorithm
% environment.
%
% - September 13 2000 - revision 2.36
% * option slide added: require package color
% * Hack for slide class in order to have correct
% margins
%
% - November 25 1999 - revision 2.35
% * revision number match RCS number
% * Thanks to David A. Bader, a new option is added:
% noend: no end keywords are printed.
%
% - November 19 1999 - revision 2.32
% * minor bug on longend option corrected.
%
% - August 26 1999 - revision 2.31
% * add an option: figure
% this option makes algorithms be figure and so are numbered
% as figures, have Figure as caption and are put in
% the \listoffigures
%
% - January 21 1999 - revision 2.3 beta
% add 2 new environments: procedure and function.
% These environments works like algorithm environment but:
% - the ruled (or algoruled) style is imperative.
% - the caption now writes Procedure name....
% - the syntax of the \caption command is restricted as
% follow: you MUST put a name followed by 2 braces like
% this ``()''. You can put arguments inside the braces and
% text after. If no argument is given, the braces will be
% removed in the title.
% - label now puts the name (the text before the braces in the
% caption) of the procedure or function as reference (not
% the number like a classic algorithm environment).
% There are also two new styles: ProcNameSty and
% ProcArgSty. These style are by default the same as FuncSty
% and ArgSty but are used in the caption of a procedure or a
% function.
%
% - November 28 1996 - revision 2.22
% add a new macro \SetKwInParam{arg1}{arg2}{arg3}:
% it defines a macro \arg1{name}{arg} which prints name in keyword
% style followed byt arg surrounded by arg2 and arg3. The main
% application is to a function working as \SetKwInput to be used
% in the head of the algorithm. For example
% \SetKwInParam{Func}{(}{)} allows
% \Func{functionname}{list of arguments} which prints:
% \KwSty{functioname(}list of arguments\KwSty{)}
%
%
% - November 27 1996 - revision 2.21:
% minor bug in length of InOut boxes fixed.
% add algorithm* environment.
%
% - July 12 1996 - revision 2.2: \SetArg and \SetKwArg macros removed.
%
% \SetArg has been removed since it never has been
% documented.
% \SetKwArg has been removed since \SetKw can now
% take an argument in order to be consistent with
% \SetKwData and \SetKwFunction macros.
%
% - July 04 1996 - revision 2.1: still more LaTeX2e! Minor compatibility break
%
% Macros use now \newcommand instead of \def, use of \setlength,
% \newsavebox, ... and other LaTeX2e specific stuff.
% The compatibility break:
% - \SetData becomes \SetKwData to be more consistent. So the old
% \SetKwData becomes \SetKwInput
% - old macros \titleofalgo, \Freetitleofalgo and \freetitleofalgo
% from LaTeX209 version which did print a warning message and call
% \Titleofalgo in version 2.0 are now removed!
%
% - March 13 1996 - revision 2.0: first official major revision.
%
%
%%%%%%%%%%%%%%
%
% Known bugs:
% -----------
% - horizontal spacing (indent) doesn't work with revtex4 class.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% for more complete informations you can see algorithm2e.tex
%
%
%%%%%%%%%%%%%%%%%%%%%%%% Identification Part %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
%
\ProvidesPackage{algorithm2e}[2017/07/18 v5.2 algorithms environments]
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%% Initial Code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\@makeother\*% some package redefined it as a letter (as color.sty)
\def\@firstword#1 #2\@nil{#1}% an useful fonction
%%%%%%% Utilities:
% \ifArgumentEmpty<c><t><e> ; if c is empty, i.e. {}, then t, else e.
% Function used internally, but may as well expose it to the user; it's useful
\begingroup
\catcode`\Q=3
\catcode`\T=3
\long\gdef\ALGOCF@argemptyaux#1#2Q#3#4#5T{#4}
\long\gdef\ifArgumentEmpty#1{%
\begingroup\long\edef\@tempa{\endgroup
\ALGOCF@argemptyaux#1QQ{\noexpand\@secondoftwo}{\noexpand\@firstoftwo}T%
}\@tempa
}
\endgroup
% \long\def\ifArgumentEmpty#1{\bgroup
% \catcode`\Q=3
% \catcode`\T=3
% \long\def\@tempa##1##2Q##3##4##5T{##4}%
% \xdef\@tempa{\@tempa#1QQ{\noexpand\@secondoftwo}{\noexpand\@firstoftwo}T}%
% \egroup\@tempa}
%%%%%%%%%%%
%
% \algocf@longdef -> shorthand to reduce
% \expandafter\long\expandafter\def
% to
% \expandafter\algocf@longdef
% may look insignificant, but reads that much better ;)
\def\algocf@longdef{\long\def}
%
% \algocf@newcommand (and helper \algocf@new@command) behaves like LaTeX's newcommand,
% with two differences:
% - the argument is not "\<name>", but rather "<name>"; i.e. one level of indirection
% - if the command exists already, then \renewcommand, rather than \newcommand
\def\algocf@newcommand#1{\expandafter\algocf@new@command\csname#1\endcsname}
\def\algocf@new@command#1{%
\begingroup \escapechar\m@ne\xdef\@gtempa{{\string#1}}\endgroup
\expandafter\@ifundefined\@gtempa\newcommand\renewcommand#1}%
%
% \algocf@newcmdside<name><arity><body>
% The largest time-saver; many commands we define have the pattern:
% \<name>(<side_text>)<argX><argY>...
% where "(<side_text>)" is optional. By defining them with this function,
% the arguments are parsed and renumbered, i.e. the body works as if the
% command was:
% \<name><side_text><argX><argY>...
% and can use \ifArgumentEmpty to see whether its #1 exists (default case
% for the side text is (), so there's no difference between calling
% \foo{bar}
% or
% \foo(){bar}
% Technically this is new behaviour, but it shouldn't really occur...
\algocf@longdef\algocf@newcmdside#1#2#3{%
\expandafter\def\csname#1\endcsname{%
\@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}%
}%
\expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1){\csname algocf@#1main\endcsname{##1}}%
\algocf@newcommand{algocf@#1main}[#2]{#3}%
}
%
% a serie of newcmdside macro for block that allows a comment after the end
% \<name>(<side_text>)<argX><argY>...(<side_text>)%
%
% 1. kind of begin-end : for command with only one block as begin-end
\algocf@longdef\algocf@newcmdside@kobe#1#2{% <name of cmd><body of cmd>
% command starts by checking for side comment at beginning
\expandafter\def\csname#1\endcsname{%
\@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}%
}%
% next we strip comment and include it in cmd that get body and check last side comment
\expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1)##2{\csname algocf@#1checkcomfol\endcsname{##1}{##2}}%
% now check for last side comment; args are : <first side com (could be empty)>, <body of cmd>
\expandafter\algocf@longdef\csname algocf@#1checkcomfol\endcsname##1##2{\@ifnextchar({\csname algocf@#1withendcom\endcsname{##1}{##2}}{\csname algocf@#1noendcom\endcsname{##1}{##2}}}% call macro that manages end of command, with or without last side comment
% finally manage end of macro... with end side comment...
\expandafter\algocf@longdef\csname algocf@#1withendcom\endcsname##1##2(##3){%
\csname algocf@#1main\endcsname{##1}{##2}{##3}}%
% ... or without end side comment
\expandafter\algocf@longdef\csname algocf@#1noendcom\endcsname##1##2{%
\csname algocf@#1main\endcsname{##1}{##2}{}}%
\algocf@newcommand{algocf@#1main}[3]{#2}%
}%
%
% 2. kind of if-else : for command with two blocks as if-then-else
\algocf@longdef\algocf@newcmdside@koif#1#2{% <name of cmd><body of cmd>
% command starts by checking for side comment at beginning
\expandafter\def\csname#1\endcsname{%
\@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}%
}%
% next we strip comment and include it in cmd that get body and check last side comment
\expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1)##2##3{\csname algocf@#1checkcomfol\endcsname{##1}{##2}{##3}}%
% now check for last side comment; args are : <1st side com>, <1st body of cmd>, <2nd body of cmd>
\expandafter\algocf@longdef\csname algocf@#1checkcomfol\endcsname##1##2##3{\@ifnextchar({\csname algocf@#1withendcom\endcsname{##1}{##2}{##3}}{\csname algocf@#1noendcom\endcsname{##1}{##2}{##3}}}% call macro that manages end of command, with or without last side comment
% finally manage end of macro... with end side comment...
\expandafter\algocf@longdef\csname algocf@#1withendcom\endcsname##1##2##3(##4){%
\csname algocf@#1main\endcsname{##1}{##2}{##3}{##4}}%
% ... or without end side comment
\expandafter\algocf@longdef\csname algocf@#1noendcom\endcsname##1##2##3{%
\csname algocf@#1main\endcsname{##1}{##2}{##3}{}}%
\algocf@newcommand{algocf@#1main}[4]{#2}%
}%
%
% \algocf@newcmdsides<name><arity><body><tail><closing>
% Like the command above, but with an optional side text at the end
% of the command as well, i.e.:
% \<name>(<side_text>)<argX><argY>(<end_text>)
% It may be a bit confusing that <arity> doesn't count <end_text>,
% but since it is for internal use, the naming can be a little more
% fuzzy. This function behaves as if:
% <body'> = <body><if end_text: tail{end_text}><closing>
\algocf@longdef\algocf@newcmdsides#1#2#3#4#5{%
\expandafter\def\csname#1\endcsname{%
\@ifnextchar({\csname algocf@#1strip\endcsname}{\csname algocf@#1strip\endcsname()}%
}%
\expandafter\algocf@longdef\csname algocf@#1strip\endcsname(##1){\csname algocf@#1main\endcsname{##1}}%
\algocf@newcommand{algocf@#1main}[#2]{#3\@ifnextchar({\csname algocf@#1end\endcsname}{#4#5}}%
\expandafter\algocf@longdef\csname algocf@#1end\endcsname(##1){#4{##1}\strut\par}%
}%
%
% definition of commands which can be redefined in options of the package.
%
\newcounter{AlgoLine}%
\setcounter{AlgoLine}{0}%
%
\newcommand{\algocf@algocfref}{\relax}%
\newcommand{\listalgorithmcfname}{}%
\newcommand{\algorithmcfname}{}%
\@ifundefined{algorithmautorefname}{\newcommand{\algorithmautorefname}{algorithm}}{\renewcommand{\algorithmautorefname}{algorithm}}%
\newcommand{\algorithmcflinename}{}%
\newcommand{\algocf@typo}{}%
\newcommand{\@algocf@procname}{}\newcommand{\procedureautorefname}{}%
\newcommand{\SetAlgoProcName}[2]{\renewcommand{\@algocf@procname}{#1}\renewcommand{\procedureautorefname}{#2}}%
\newcommand{\@algocf@funcname}{}\newcommand{\functionautorefname}{}%
\newcommand{\SetAlgoFuncName}[2]{\renewcommand{\@algocf@funcname}{#1}\renewcommand{\functionautorefname}{#2}}%
\newcommand{\@algocf@titleofalgoname}{\algorithmcfname}%
\newcommand{\@algocf@algotitleofalgo}{%
\renewcommand{\@algocf@titleofalgoname}{\algorithmcfname}}%
\newcommand{\@algocf@proctitleofalgo}{%
\renewcommand{\@algocf@titleofalgoname}{\algocf@procname}}%
%
\newcommand{\algocf@style}{plain}%
\newcommand{\@ResetCounterIfNeeded}{}%
\newcommand{\@titleprefix}{}%
%
\newcommand{\algocf@numbering}[1]{\newcommand{\algocf@within}{#1}}%
%
\newcommand{\defaultsmacros@algo}{\algocf@defaults@shortend}%
%
\newcommand{\algocf@list}{loa}%
\newcommand{\algocf@float}{algocf}%
%
\newcommand{\algocf@envname}{algorithm}%
\newcommand{\algocf@listofalgorithms}{listofalgorithms}%
%
%
%% redefine chapter so that it adds a vspace in the loa as the original does for lof and lot
% \let\algocf@original@chapter=\chapter%
% \def\chapter{\expandafter\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}%
%
% bug correction with hyperref submitted by Hubert Meier
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname @chapter\endcsname\relax\else
% \let\algocf@original@chapter=\chapter%
% \def\chapter{\addtocontents{loa}{\protect\addvspace{10\p@}}\algocf@original@chapter}%
\let\algocf@original@chapter=\@chapter%
\@ifclassloaded{krantz}{%
\def\@chapter[#1][#2]#3{\algocf@original@chapter[#1][#2]{#3}\addtocontents{loa}{\protect\addvspace{10\p@}}}%
}{%
\def\@chapter[#1]#2{\algocf@original@chapter[#1]{#2}\addtocontents{loa}{\protect\addvspace{10\p@}}}%
}%
\fi
%
%% if@restonecol is defined in article and book but some other classes don't define it and we need it, so we do
\ifx\if@restonecol\relax\else\newif\if@restonecol\fi%
%
%
%%%%%%%%%%%%%%%%%%%%%% Declaration of Options %%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\RequirePackage{ifthen}%
%
\newboolean{algocf@displayblockmarkers}\setboolean{algocf@displayblockmarkers}{false}%
\DeclareOption{displayblockmarkers}{%
\setboolean{algocf@displayblockmarkers}{true}%
}%
\newboolean{algocf@displaygroupmarkers}\setboolean{algocf@displaygroupmarkers}{false}
\DeclareOption{displaygroupmarkers}{%
\setboolean{algocf@displaygroupmarkers}{true}%
}%
%
\newboolean{algocf@nokwfunc}\setboolean{algocf@nokwfunc}{false}%
\DeclareOption{nokwfunc}{%
\setboolean{algocf@nokwfunc}{true}%
}%
%
\newboolean{algocf@oldcommands}\setboolean{algocf@oldcommands}{false}%
\DeclareOption{oldcommands}{%
\setboolean{algocf@oldcommands}{true}%
}%
%
\newboolean{algocf@leftlinenumber}\setboolean{algocf@leftlinenumber}{true}%
\newcommand{\setLeftLinesNumbers}{\setboolean{algocf@leftlinenumber}{true}}%
\newcommand{\setRightLinesNumbers}{\setboolean{algocf@leftlinenumber}{false}}%
\DeclareOption{rightnl}{%
\setRightLinesNumbers%
}%
%
\newboolean{algocf@endfloat}\setboolean{algocf@endfloat}{false}%
\DeclareOption{endfloat}{%
\setboolean{algocf@endfloat}{true}%
\newcounter{postalgo}\setcounter{postalgo}{0}%
}%
%
\newboolean{algocf@procnumbered}\setboolean{algocf@procnumbered}{false}%
\DeclareOption{procnumbered}{%
\setboolean{algocf@procnumbered}{true}%
}%
%
\DeclareOption{algo2e}{%
\renewcommand{\algocf@envname}{algorithm2e}%
\renewcommand{\algocf@listofalgorithms}{listofalgorithmes}%
}%
%
\newboolean{algocf@slide}\setboolean{algocf@slide}{false}%
\DeclareOption{slide}{%
\setboolean{algocf@slide}{true}%
}%
%
\newboolean{algocf@figurecaption}\setboolean{algocf@figurecaption}{false}%
\DeclareOption{figure}{%
\renewcommand{\algocf@list}{lof}%
\renewcommand{\algocf@float}{figure}%
\AtBeginDocument{\@ifpackageloaded{caption}{\setboolean{algocf@figurecaption}{true}}{}}%
}%
%
\newboolean{algocf@optonelanguage}\setboolean{algocf@optonelanguage}{false}%
\DeclareOption{onelanguage}{\setboolean{algocf@optonelanguage}{true}}%
%
\newcommand{\algocf@languagechoosen}{english}%
\newboolean{algocf@localkw@english}\setboolean{algocf@localkw@english}{true}%
\DeclareOption{englishkw}{%
\setboolean{algocf@localkw@english}{true}%
}%
%
\DeclareOption{english}{%
\renewcommand{\listalgorithmcfname}{List of Algorithms}%
\renewcommand{\algorithmcfname}{Algorithm}%
\renewcommand{\algorithmautorefname}{algorithm}%
\renewcommand{\algorithmcflinename}{line}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedure}%
\renewcommand{\@algocf@funcname}{Function}%
\renewcommand{\procedureautorefname}{procedure}%
\renewcommand{\functionautorefname}{function}%
\renewcommand{\algocf@languagechoosen}{english}%
}%
%
%----
\newboolean{algocf@localkw@french}\setboolean{algocf@localkw@french}{false}%
\DeclareOption{frenchkw}{%
\setboolean{algocf@localkw@french}{true}%
}%
%
\DeclareOption{french}{%
\renewcommand{\listalgorithmcfname}{Liste des Algorithmes}%
\renewcommand{\algorithmcfname}{Algorithme}%
\renewcommand{\algorithmautorefname}{algorithme}%
\renewcommand{\algorithmcflinename}{ligne}%
\renewcommand{\algocf@typo}{\ }%
\renewcommand{\@algocf@procname}{Proc\'edure}%
\renewcommand{\@algocf@funcname}{Fonction}%
\renewcommand{\procedureautorefname}{proc\'edure}%
\renewcommand{\functionautorefname}{fonction}%
\renewcommand{\algocf@languagechoosen}{french}%
}%
%
%----
\newboolean{algocf@localkw@czech}\setboolean{algocf@localkw@czech}{false}%
\DeclareOption{czechkw}{%
\setboolean{algocf@localkw@czech}{true}%
}%
%
\DeclareOption{czech}{%
\renewcommand{\listalgorithmcfname}{Seznam algoritm\r{u}}%
\renewcommand{\algorithmcfname}{Algoritmus}%
\renewcommand{\algorithmautorefname}{\algorithmcfname}%
\renewcommand{\algorithmcflinename}{Radek}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedura}%
\renewcommand{\@algocf@funcname}{Funkce}%
\renewcommand{\procedureautorefname}{\@algocf@procname}%
\renewcommand{\functionautorefname}{\@algocf@funcname}%
\renewcommand{\algocf@languagechoosen}{czech}%
}%
%
%----
\newboolean{algocf@localkw@german}\setboolean{algocf@localkw@german}{false}%
\DeclareOption{germankw}{%
\setboolean{algocf@localkw@german}{true}%
}%
%
\DeclareOption{german}{%
\renewcommand{\listalgorithmcfname}{Liste der Algorithmen}%
\renewcommand{\algorithmcfname}{Algorithmus}%
\renewcommand{\algorithmautorefname}{\algorithmcfname}%
\renewcommand{\algorithmcflinename}{Zeile}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Prozedur}%
\renewcommand{\@algocf@funcname}{Funktion}%
\renewcommand{\procedureautorefname}{\@algocf@procname}%
\renewcommand{\functionautorefname}{\@algocf@funcname}%
\renewcommand{\algocf@languagechoosen}{german}%
}%
%
%----
\DeclareOption{ngermankw}{%
\setboolean{algocf@localkw@german}{true}%
}%
%
\DeclareOption{ngerman}{%
\renewcommand{\listalgorithmcfname}{Liste der Algorithmen}%
\renewcommand{\algorithmcfname}{Algorithmus}%
\renewcommand{\algorithmautorefname}{\algorithmcfname}%
\renewcommand{\algorithmcflinename}{Zeile}%
\renewcommand{\algocf@typo}{\ }%
\renewcommand{\@algocf@procname}{Prozedur}%
\renewcommand{\@algocf@funcname}{Funktion}%
\renewcommand{\procedureautorefname}{\@algocf@procname}%
\renewcommand{\functionautorefname}{\@algocf@funcname}%
\renewcommand{\algocf@languagechoosen}{german}%
}%
%
%----
\newboolean{algocf@localkw@portuguese}\setboolean{algocf@localkw@portuguese}{false}%
\DeclareOption{portuguesekw}{%
\setboolean{algocf@localkw@portuguese}{true}%
}%
%
\DeclareOption{portuguese}{%
\renewcommand{\listalgorithmcfname}{Lista de Algoritmos}%
\renewcommand{\algorithmcfname}{Algoritmo}%
\renewcommand{\algorithmautorefname}{algoritmo}%
\renewcommand{\algorithmcflinename}{linha}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedimento}%
\renewcommand{\@algocf@funcname}{Fun\c{c}\~{a}o}%
\renewcommand{\procedureautorefname}{procedimento}%
\renewcommand{\functionautorefname}{fun\c{c}\~{a}o}%
\renewcommand{\algocf@languagechoosen}{portuguese}%
}%
%
%----
\newboolean{algocf@localkw@italiano}\setboolean{algocf@localkw@italiano}{false}%
\DeclareOption{italianokw}{%
\setboolean{algocf@localkw@italiano}{true}%
}%
%
\DeclareOption{italiano}{%
\renewcommand{\listalgorithmcfname}{Elenco degli algoritmi}%
\renewcommand{\algorithmcfname}{Algoritmo}%
\renewcommand{\algorithmautorefname}{algoritmo}%
\renewcommand{\algorithmcflinename}{riga}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedura}%
\renewcommand{\@algocf@funcname}{Funzione}%
\renewcommand{\procedureautorefname}{procedura}%
\renewcommand{\functionautorefname}{funzione}%
\renewcommand{\algocf@languagechoosen}{italiano}%
}%
%----
\newboolean{algocf@localkw@spanish}\setboolean{algocf@localkw@spanish}{false}%
\DeclareOption{spanishkw}{%
\setboolean{algocf@localkw@spanish}{true}%
}%
%
\DeclareOption{spanish}{%
\renewcommand{\listalgorithmcfname}{\'Indice de algoritmos}%
\renewcommand{\algorithmcfname}{Algoritmo}%
\renewcommand{\algorithmautorefname}{algoritmo}%
\renewcommand{\algorithmcflinename}{l\'inea}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedimiento}%
\renewcommand{\@algocf@funcname}{Funci\'on}%
\renewcommand{\procedureautorefname}{procedimiento}%
\renewcommand{\functionautorefname}{funci\'on}%
\renewcommand{\algocf@languagechoosen}{spanish}%
}%
%----
\newboolean{algocf@localkw@slovak}\setboolean{algocf@localkw@slovak}{false}%
\DeclareOption{slovakkw}{%
\setboolean{algocf@localkw@slovak}{true}%
}%
%
\DeclareOption{slovak}{%
\renewcommand{\listalgorithmcfname}{Zoznam algoritmov}%
\renewcommand{\algorithmcfname}{Algoritmus}%
\renewcommand{\algorithmautorefname}{\algorithmcfname}%
\renewcommand{\algorithmcflinename}{Radek}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Proced\'{u}ra}%
\renewcommand{\@algocf@funcname}{Funkcia}%
\renewcommand{\procedureautorefname}{\@algocf@procname}%
\renewcommand{\functionautorefname}{\@algocf@funcname}%
\renewcommand{\algocf@languagechoosen}{slovak}%
}%
%
%----
\newboolean{algocf@localkw@croatian}\setboolean{algocf@localkw@croatian}{false}%
\DeclareOption{croatiankw}{%
\setboolean{algocf@localkw@croatian}{true}%
}%
%
\DeclareOption{croatian}{%
\renewcommand{\listalgorithmcfname}{Popis algoritama}%
\renewcommand{\algorithmcfname}{Algoritam}%
\renewcommand{\algorithmautorefname}{\algorithmcfname}%
\renewcommand{\algorithmcflinename}{redak}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedura}%
\renewcommand{\@algocf@funcname}{Funkcija}%
\renewcommand{\procedureautorefname}{\@algocf@procname}%
\renewcommand{\functionautorefname}{\@algocf@funcname}%
\renewcommand{\algocf@languagechoosen}{croatian}%
}%
%%% adding 'turkish' option customization
%
%----
\newboolean{algocf@localkw@turkish}\setboolean{algocf@localkw@turkish}{false}%
\DeclareOption{turkishkw}{%
\setboolean{algocf@localkw@turkish}{true}%
}%
\DeclareOption{turkish}{%
\renewcommand{\listalgorithmcfname}{Algoritma Listesi}%
\renewcommand{\algorithmcfname}{Algoritma}%
\renewcommand{\algorithmautorefname}{algoritma}%
\renewcommand{\algorithmcflinename}{\c{c}izgi}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Prosed\"ur}%
\renewcommand{\@algocf@funcname}{Fonksiyon}%
\renewcommand{\procedureautorefname}{prosed\"ur}%
\renewcommand{\functionautorefname}{fonksiyon}%
\renewcommand{\algocf@languagechoosen}{turkish}%
}%
%
% OPTIONs plain, boxed, ruled, algoruled & boxruled
%
\newcommand{\algocf@style@plain}{\renewcommand{\algocf@style}{plain}}%
\newcommand{\algocf@style@boxed}{\renewcommand{\algocf@style}{boxed}}%
\newcommand{\algocf@style@ruled}{\renewcommand{\algocf@style}{ruled}}%
\newcommand{\algocf@style@algoruled}{\renewcommand{\algocf@style}{algoruled}}%
\newcommand{\algocf@style@boxruled}{\renewcommand{\algocf@style}{boxruled}}%
\newcommand{\algocf@style@tworuled}{\renewcommand{\algocf@style}{tworuled}}%
\newcommand{\algocf@style@plainruled}{\renewcommand{\algocf@style}{plainruled}}%
\newcommand{\RestyleAlgo}[1]{\csname algocf@style@#1\endcsname}%
\DeclareOption{plain}{\algocf@style@plain}%
\DeclareOption{plainruled}{\algocf@style@plainruled}%
\DeclareOption{boxed}{\algocf@style@boxed}%
\DeclareOption{ruled}{\algocf@style@ruled}%
\DeclareOption{algoruled}{\algocf@style@algoruled}%
\DeclareOption{boxruled}{\algocf@style@boxruled}%
\DeclareOption{tworuled}{\algocf@style@tworuled}%
%
% OPTIONs algopart,algochapter & algosection
%
\DeclareOption{algopart}{\algocf@numbering{part}}% %algo part numbered
\DeclareOption{algochapter}{\algocf@numbering{chapter}}% %algo chapter numbered
\DeclareOption{algosection}{\algocf@numbering{section}}% %algo section numbered
%
% OPTIONs resetcount & noresetcount
%
\DeclareOption{resetcount}{\renewcommand{\@ResetCounterIfNeeded}{\setcounter{AlgoLine}{0}}}%
\DeclareOption{noresetcount}{\renewcommand{\@ResetCounterIfNeeded}{}}%
%
% OPTIONs algorithm hanging for long lines
%
\newlength{\algocf@hangindent}\setlength{\algocf@hangindent}{.5em}
\newcommand{\SetAlgoHangIndent}[1]{\setlength{\algocf@hangindent}{#1}}
%
\newboolean{algocf@hanging}\setboolean{algocf@hanging}{true}% hanging is handle by default
\newboolean{algocf@hanginginout}\setboolean{algocf@hanginginout}{false}% inout are managed as previously: hanging set by inout keywords
\newboolean{algocf@hangingcomment}\setboolean{algocf@hangingcomment}{false}% comment that are not side comment are indented accordingly to comment mark, not as normal text
\newcommand{\algocf@everyparnl}{\relax}%
\newcommand{\algocf@everyparhanging}{\hangafter=1\hangindent=\algocf@hangindent\relax}%
\newcommand{\algocf@everypar}{\algocf@everyparnl\algocf@everyparhanging}%
\newcommand{\algocf@seteverypar}{%
\ifthenelse{\boolean{algocf@hanging}}{\everypar{\algocf@everypar}}{\relax}%
}%
%
\newcommand{\algocf@seteveryparnl}[1]{\renewcommand{\algocf@everyparnl}{#1}\everypar{\algocf@everypar}}%
\newcommand{\algocf@seteveryparhanging}[1]{%
\let\algocf@oldeveryparhanging=\algocf@everyparhanging%
\renewcommand{\algocf@everyparhanging}{#1}\everypar{\algocf@everypar}%
}%
\newcommand{\algocf@reseteveryparhanging}{%
\let\algocf@everyparhanging=\algocf@oldeveryparhanging%
\everypar{\algocf@everypar}%
}%
\DeclareOption{hanginginout}{\setboolean{algocf@hanginginout}{true}}%
\DeclareOption{hangingcomment}{\setboolean{algocf@hangingcomment}{true}}%
\DeclareOption{noalgohanging}{%
\setboolean{algocf@hanginginout}{false}%
\setboolean{algocf@hangingcomment}{false}%
\setboolean{algocf@hanging}{false}%
}%
%\newcommand{
%
%
% OPTION linesnumbered
%
\newboolean{algocf@linesnumbered}\setboolean{algocf@linesnumbered}{false}%
\newcommand{\algocf@linesnumbered}{\relax}%
\DeclareOption{linesnumbered}{%
\setboolean{algocf@linesnumbered}{true}%
\renewcommand{\algocf@linesnumbered}{\algocf@seteveryparnl{\nl}}%
}%
%
% OPTION linesnumberedhidden
%
\DeclareOption{linesnumberedhidden}{%
\setboolean{algocf@linesnumbered}{true}%
\renewcommand{\algocf@linesnumbered}{\algocf@seteveryparnl{\stepcounter{AlgoLine}}}%
}%
%
% OPTION commentsnumbered inoutnumbered
%
\newboolean{algocf@commentsnumbered}\setboolean{algocf@commentsnumbered}{false}%
\DeclareOption{commentsnumbered}{\setboolean{algocf@commentsnumbered}{true}}%
\newboolean{algocf@inoutnumbered}\setboolean{algocf@inoutnumbered}{false}%
\DeclareOption{inoutnumbered}{\setboolean{algocf@inoutnumbered}{true}}%
%
% OPTIONs titlenumbered & titlenotnumbered
%
\DeclareOption{titlenumbered}{%
\renewcommand{\@titleprefix}{%
\refstepcounter{\algocf@float}%
\AlTitleSty{\AlTitleFnt\@algocf@titleofalgoname\ \expandafter\csname the\algocf@float\endcsname\algocf@typo: }%
}%
}%
%
\DeclareOption{titlenotnumbered}{\renewcommand{\@titleprefix}{%
\AlTitleSty{\AlTitleFnt\@algocf@titleofalgoname\algocf@typo: }}%
}%
%
% OPTIONs algonl
% line numbered with the counter of the algorithm
%
\DeclareOption{algonl}{\renewcommand{\theAlgoLine}{\expandafter\csname the\algocf@float\endcsname.\arabic{AlgoLine}}}%
%
% OPTIONs lined, vlined & noline
%
\DeclareOption{lined}{\AtBeginDocument{\SetAlgoLined}}% \SetAlgoLined (default)
\DeclareOption{vlined}{\AtBeginDocument{\SetAlgoVlined}}% \SetAlgoVlined
\DeclareOption{noline}{\AtBeginDocument{\SetAlgoNoLine}}%\SetAlgoNoLine
%
% OPTIONs longend, shotend & noend
%
\DeclareOption{longend}{\AtBeginDocument{\SetAlgoLongEnd}}% \SetAlgoLongEnd
\DeclareOption{shortend}{\AtBeginDocument{\SetAlgoShortEnd}}%\SetAlgoShortEnd
\DeclareOption{noend}{\AtBeginDocument{\SetAlgoNoEnd}}% \SetAlgoNoEnd
%
\DeclareOption{nosemicolon}{\AtBeginDocument{\DontPrintSemicolon}}% \SetAlgoNoEnd
%
% OPTION dotoc
%
\newboolean{algocf@dotocloa}\setboolean{algocf@dotocloa}{false}%
\DeclareOption{dotocloa}{%
\setboolean{algocf@dotocloa}{true}%
}
%
% OPTION comments
%
\newboolean{algocf@optfillcomment}\setboolean{algocf@optfillcomment}{true}%
\DeclareOption{nofillcomment}{%
\setboolean{algocf@optfillcomment}{false}%
}%
\DeclareOption{fillcomment}{%
\setboolean{algocf@optfillcomment}{true}%
}%
%
% OPTION sidecommments
%
\newboolean{algocf@scleft}\setboolean{algocf@scleft}{false}%
\DeclareOption{scleft}{%
\setboolean{algocf@scleft}{true}%
}%
\DeclareOption{sright}{% default
\setboolean{algocf@scleft}{false}%
}%
%
% OPTION norelsize
%
\newboolean{algocf@norelsize}\setboolean{algocf@norelsize}{false}%
\DeclareOption{norelsize}{%
\setboolean{algocf@norelsize}{true}%
}%
%
%
%%%%%%%%%%%%%%%%%%%%%%% Execution of Options %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\ExecuteOptions{english,plain,resetcount,titlenotnumbered,lined,shortend}%
%
\ProcessOptions%
%
\@algocf@algotitleofalgo% fix name for \TitleOfAlgo to \algorithmcfname by default
%
%%%%%%%%%%%%%%%%%%%%%%%%%% Package Loading %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
\RequirePackage{ifoddpage}%
\RequirePackage{xspace}%
%
\ifthenelse{\boolean{algocf@endfloat}}{%
\RequirePackage{endfloat}%
}{\relax}%
%
\ifthenelse{\boolean{algocf@norelsize}}{%
\newcommand{\relsize}[1]{\scriptsize}%
}{%
\RequirePackage{relsize}%
}%
%
\ifthenelse{\boolean{algocf@slide}}{\RequirePackage{color}}{}%
%
%
\AtEndOfPackage{%
\ifthenelse{\boolean{algocf@dotocloa}}{%
\renewcommand{\listofalgorithms}{\tocfile{\listalgorithmcfname}{loa}}%
}{\relax}%
}%
%
% if loa in toc required, load tocbibind package if not already done.
\ifthenelse{\boolean{algocf@dotocloa}}{%
\ifx\@tocextra\undefined%
\RequirePackage{tocbibind}%
\fi%
}{\relax}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Part %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\newcommand{\algocf@name}{algorithm2e}%
\newcommand{\algocf@date}{July 18 2017}%
\newcommand{\algocf@version}{Release 5.2}%
\newcommand{\algocf@id}{\algocf@version\space -- \algocf@date\space --}%
% \typeout{********************************************************^^JPackage `\algocf@name'\space\algocf@id^^J%
% - algorithm2e-announce@lirmm.fr mailing list for announcement about releases^^J%
% - algorithm2e-discussion@lirmm.fr mailing list for discussion about package^^J%
% subscribe by emailing sympa@lirmm.fr with 'subscribe <list> <firstname name>'^^J%
% - Author: Christophe Fiorio (christophe.fiorio@umontpellier.fr)^^J********************************************************}%
%%
%%
%%
%%
%%
%%
%%%% hyperref compatibility tricks: Hyperref package defines H counters from
% standard counters (i.e \theHpage from \thepage) and check some particular
% counters of some packages, unfortunately it doesn't do the same for
% algorithm2e package but act as Hcounter was defined. To avoid errors we
% defined \theHalgocf ourself
%%%%
%
\@ifundefined{theHalgocf}{\def\theHalgocf{\thealgocf}}{}%
\@ifundefined{theHAlgoLine}{\def\theHAlgoLine{\theAlgoLine}}{}%
\@ifundefined{theHalgocfproc}{\def\theHalgocfproc{0}}{}%
\@ifundefined{theHalgocffunc}{\def\theHalgocffunc{0}}{}%
\@ifundefined{toclevel@algocf}{\def\toclevel@algocf{0}}{}%
%
% autoref from hyperref needs an autorefname, so we give it.
\def\AlgoLineautorefname{\algorithmcflinename}%
\def\algocfautorefname{\algorithmautorefname}%
\def\algocfprocautorefname{\procedureautorefname}%
\def\algocffuncautorefname{\functionautorefname}%
%%
%%
%%
\newcommand{\@defaultskiptotal}{0.5em}%
\newskip\skiptotal\skiptotal=0.5em%
\newskip\skiplinenumber\skiplinenumber=\hsize\advance\skiplinenumber by-\skiptotal%
\newskip\skiprule%
\newskip\skiphlne%
\newskip\skiptext%
\newskip\skiplength%
\newskip\algomargin%
\newskip\skipalgocfslide\skipalgocfslide=1em%
\newdimen\algowidth%
\newdimen\inoutsize%
\newdimen\inoutindent%
\newdimen\interspacetitleruled\setlength{\interspacetitleruled}{2pt}%
\newdimen\interspacealgoruled\setlength{\interspacealgoruled}{2pt}%
\newdimen\interspacetitleboxruled\setlength{\interspacetitleboxruled}{2\lineskip}%
%
\newcommand{\@algoskip}{\smallskip}%
\newcommand{\SetAlgoSkip}[1]{\renewcommand{\@algoskip}{\csname#1\endcsname}}%
\newcommand{\@algoinsideskip}{\relax}%
\newcommand{\SetAlgoInsideSkip}[1]{\renewcommand{\@algoinsideskip}{\csname#1\endcsname}}%
%
% ruledwidth
%
\newlength{\algocf@ruledwidth}\setlength{\algocf@ruledwidth}{\linewidth}%
\newboolean{algocf@customruledwidth}\setboolean{algocf@customruledwidth}{false}%
\newcommand{\SetCustomAlgoRuledWidth}[1]{%
\setboolean{algocf@customruledwidth}{true}%
\ifthenelse{\boolean{algocf@customruledwidth}}{\setlength{\algocf@ruledwidth}{#1}}{\relax}%
}%
%
\newsavebox{\algocf@inoutbox}%
\newsavebox{\algocf@inputbox}%
%%
%%
\newcommand{\arg@e}{}%
\newcommand{\arg@space}{\ }%
\newcommand{\BlankLine}{\vskip 1ex}%
%%
\newcommand{\vespace}{1ex}%
\newcommand{\SetInd}[2]{%
\skiprule=#1%
\skiptext=#2%
\skiplength=\skiptext\advance\skiplength by \skiprule\advance\skiplength by 0.4pt}%
\SetInd{0.5em}{1em}
\algomargin=\leftskip\advance\algomargin by \parindent%
\newcommand{\IncMargin}[1]{\advance\algomargin by #1}%
\newcommand{\DecMargin}[1]{\advance\algomargin by -#1}%
\newcommand{\SetNlSkip}[1]{%
\renewcommand{\@defaultskiptotal}{#1}%
\setlength{\skiptotal}{#1}}%
%%
\newskip\AlCapSkip\AlCapSkip=0ex%
\newskip\AlCapHSkip\AlCapSkip=0ex%
\newcommand{\SetAlCapSkip}[1]{\setlength{\AlCapSkip}{#1}}%
\newcommand{\SetAlCapHSkip}[1]{\setlength{\AlCapHSkip}{#1}}%
\SetAlCapHSkip{.5\algomargin}%
%%
%%
\newskip\algoskipindent
\newcommand{\algocf@adjustskipindent}{%
\algoskipindent=\skiprule%
\advance\algoskipindent by \skiptext\advance\algoskipindent by 0.4pt}
\algocf@adjustskipindent%
%
\newcommand{\Indentp}[1]{\advance\leftskip by #1}%
\newcommand{\Indp}{\algocf@adjustskipindent\advance\leftskip by \algoskipindent}
\newcommand{\Indpp}{\advance\leftskip by 0.5em}%
\newcommand{\Indm}{\algocf@adjustskipindent\advance\leftskip by -\algoskipindent}
\newcommand{\Indmm}{\advance\leftskip by -0.5em}%
%
%%
%%
%% Line Numbering
%%
%%
% number line style
\newcommand{\algocf@nlrelsize}{-2}\newcommand{\SetAlgoNlRelativeSize}[1]{\renewcommand{\algocf@nlrelsize}{#1}}%
\newcommand{\NlSty}[1]{\textnormal{\textbf{\relsize{\algocf@nlrelsize}#1}}}% default definition
\newcommand{\SetNlSty}[3]{\renewcommand{\NlSty}[1]{\textnormal{\csname#1\endcsname{\relsize{\algocf@nlrelsize}#2##1#3}}}}%
%
% nl definitions
%
\newsavebox{\algocf@nlbox}%
\newcommand{\algocf@printnl}[1]{%
\ifthenelse{\boolean{algocf@leftlinenumber}}{%
\skiplinenumber=\skiptotal\advance\skiplinenumber by\leftskip%
\strut\raisebox{0pt}{\llap{\NlSty{#1}\kern\skiplinenumber}}\ignorespaces%
}{%
\sbox\algocf@nlbox{\NlSty{#1}}%
\skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip\advance\skiplinenumber by-\skiptext%
\advance\skiplinenumber by\algomargin\advance\skiplinenumber by.3em\advance\skiplinenumber by-\wd\algocf@nlbox%
% to handle particular case of until: printnl is after 'until' keyword has been writen, so we need to substract length of this keyword
\advance\skiplinenumber by-\algocf@skipuntil%
\strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\NlSty{#1\ignorespaces}}}\ignorespaces%
}%
}%
\newcommand{\algocf@nl@sethref}[1]{%
\renewcommand{\theHAlgoLine}{\thealgocfproc.#1}%
\hyper@refstepcounter{AlgoLine}\gdef\@currentlabel{#1}%
}%
\newcommand{\nl}{%
\@ifundefined{hyper@refstepcounter}{% if not hyperref then do a simple refstepcounter
\refstepcounter{AlgoLine}\gdef\@currentlabel{\theAlgoLine}%
}{% else if hyperref, do the anchor so 2 lines in two differents algorithms cannot have the same href
\stepcounter{AlgoLine}\algocf@nl@sethref{\theAlgoLine}%
}% now we can do the line numbering
\algocf@printnl{\theAlgoLine}%
}%
%
\newcommand{\nllabel}[1]{\label{#1}}%
%
\newcommand{\enl}{%
\@ifundefined{hyper@refstepcounter}{% if not hyperref then do a simple refstepcounter
\refstepcounter{AlgoLine}\gdef\@currentlabel{\theAlgoLine}%
}{% else if hyperref, do the anchor so 2 lines in two differents algorithms cannot have the same href
\stepcounter{AlgoLine}\algocf@nl@sethref{\theAlgoLine}%
}% now we can do the line numbering
\skiplinenumber=\hsize\advance\skiplinenumber by-\leftskip%
\strut\raisebox{0pt}{\rlap{\kern\skiplinenumber\strut\NlSty{\theAlgoLine}}}\ignorespaces%
}%
%% nlset
\newcommand{\nlset}[1]{%
\@ifundefined{hyper@refstepcounter}{\protected@edef\@currentlabel{#1}}{\algocf@nl@sethref{#1}}\algocf@printnl{#1}%
}%
%
%% lnl definitions
\newcommand{\lnl}[1]{\nl\label{#1}\ignorespaces}%
%
%% lnlset
\newcommand{\lnlset}[2]{\nlset{#2}\label{#1}}%
%
% set char put at end of each line
%
\newcommand{\algocf@endline}{\string;}
\newcommand{\SetEndCharOfAlgoLine}[1]{\renewcommand{\algocf@endline}{#1}}
%
% end of line definition
%
\newcommand{\@endalgocfline}{\algocf@endline}% default definition: printsemicolon
\newcommand{\DontPrintSemicolon}{\renewcommand{\@endalgocfline}{\relax}}%
\newcommand{\PrintSemicolon}{\renewcommand{\@endalgocfline}{\algocf@endline}}%
\newcommand{\@endalgoln}{\@endalgocfline\hfill\strut\par}%
%
% line numbering
%
\newcommand{\LinesNumbered}{\setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\algocf@seteveryparnl{\nl}}}%
\newcommand{\LinesNotNumbered}{%
\setboolean{algocf@linesnumbered}{false}%
\renewcommand{\algocf@linesnumbered}{\relax}%
}%
%
\newcommand{\LinesNumberedHidden}{%
\setboolean{algocf@linesnumbered}{true}\renewcommand{\algocf@linesnumbered}{\algocf@seteveryparnl{\stepcounter{AlgoLine}}}}%
\newcommand{\ShowLn}{\nlset{\theAlgoLine}\ignorespaces}% display the line number on this line (without labelling)
\newcommand{\ShowLnLabel}[1]{\lnlset{#1}{\theAlgoLine}\ignorespaces}% display the line number and label this line
%
%%
%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Styling text commands
%
\newcommand{\AlFnt}{\relax}% default definition
\newcommand{\SetAlFnt}[1]{\renewcommand{\AlFnt}{#1}}%
\newcommand{\AlTitleFnt}{\relax}% default definition
\newcommand{\SetAlTitleFnt}[1]{\renewcommand{\AlTitleFnt}{#1}}%
%
\newcommand{\AlCapFnt}{\relax}% default definition
\newcommand{\SetAlCapFnt}[1]{\renewcommand{\AlCapFnt}{#1}}%
\newcommand{\AlCapNameFnt}{\relax}% default definition
\newcommand{\SetAlCapNameFnt}[1]{\renewcommand{\AlCapNameFnt}{#1}}%
%
\newcommand{\ProcFnt}{\relax}% default definition
\newcommand{\SetProcFnt}[1]{\renewcommand{\ProcFnt}{#1}}%
\newcommand{\ProcNameFnt}{\relax}% default definition
\newcommand{\SetProcNameFnt}[1]{\renewcommand{\ProcNameFnt}{#1}}%
\newcommand{\ProcArgFnt}{\relax}% default definition
\newcommand{\SetProcArgFnt}[1]{\renewcommand{\ProcArgFnt}{#1}}%
%
\newcommand{\AlTitleSty}[1]{\textbf{#1}\unskip}% default definition
\newcommand{\SetAlTitleSty}[1]{\renewcommand{\AlTitleSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\AlCapSty}[1]{\textnormal{\textbf{#1}}\unskip}% default definition
\newcommand{\SetAlCapSty}[1]{\renewcommand{\AlCapSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\AlCapNameSty}[1]{\textnormal{#1}\unskip}% default definition
\newcommand{\SetAlCapNameSty}[1]{\renewcommand{\AlCapNameSty}[1]{\textnormal{\csname #1\endcsname{##1}}\unskip}}%
%
\newcommand{\ProcSty}[1]{\AlCapSty{#1}}%
\newcommand{\SetProcSty}[1]{\renewcommand{\ProcSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\ProcNameSty}[1]{\AlCapNameSty{#1}}%
\newcommand{\SetProcNameSty}[1]{\renewcommand{\ProcNameSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\ProcArgSty}[1]{\AlCapNameSty{#1}}%
\newcommand{\SetProcArgSty}[1]{\renewcommand{\ProcArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
%
\newcommand{\KwSty}[1]{\textnormal{\textbf{#1}}\unskip}% default definition
\newcommand{\SetKwSty}[1]{\renewcommand{\KwSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\ArgSty}[1]{\textnormal{\emph{#1}}\unskip}%\SetArgSty{emph}
\newcommand{\SetArgSty}[1]{\renewcommand{\ArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\FuncArgSty}[1]{\textnormal{\emph{#1}}\unskip}%\SetFuncArgSty{emph}
\newcommand{\SetFuncArgSty}[1]{\renewcommand{\FuncArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\FuncSty}[1]{\textnormal{\texttt{#1}}\unskip}%\SetFuncSty{texttt}
\newcommand{\SetFuncSty}[1]{\renewcommand{\FuncSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\ProgSty}[1]{\textnormal{\emph{#1}}\unskip}%\SetProgSty{emphg}
\newcommand{\SetProgSty}[1]{\renewcommand{\ArgSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\DataSty}[1]{\textnormal{\textsf{#1}}\unskip}%%\SetDataSty{textsf}
\newcommand{\SetDataSty}[1]{\renewcommand{\DataSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\CommentSty}[1]{\textnormal{\texttt{#1}}\unskip}%%\SetDataSty{texttt}
\newcommand{\SetCommentSty}[1]{\renewcommand{\CommentSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
\newcommand{\TitleSty}[1]{#1\unskip}%\SetTitleSty{}{}
\newcommand{\SetTitleSty}[2]{\renewcommand{\TitleSty}[1]{%
\csname#1\endcsname{\csname#2\endcsname##1}}\unskip}%
\newcommand{\BlockMarkersSty}[1]{\KwSty{#1}}%
\newcommand{\SetBlockMarkersSty}[1]{\renewcommand{\BlockMarkersSty}[1]{\textnormal{\csname#1\endcsname{##1}}\unskip}}%
%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Block basic commands
%
\newcommand{\algocf@push}[1]{\advance\skiptotal by #1\moveright #1}%
\newcommand{\algocf@pop}[1]{\advance\skiptotal by -#1}%
\newcommand{\algocf@addskiptotal}{%
\advance\hsize by -\skiplength%
}% \skiplength=skiptext+0.4 pt that is the width of \vrule
\newcommand{\algocf@subskiptotal}{%
\advance\hsize by \skiplength%
}% \skiplength=skiptext+0.4 pt that is the width of \vrule
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% group of instructions definition
%
\skiphlne=.8ex%
\newcommand{\SetVlineSkip}[1]{\skiphlne=#1}%
\newcommand{\algocf@bblock}{\BlockMarkersSty{begin}}%
\newcommand{\algocf@eblock}{\BlockMarkersSty{end}}%
\newcommand{\AlgoDisplayBlockMarkers}{\setboolean{algocf@displayblockmarkers}{true}}%
\newcommand{\AlgoDontDisplayBlockMarkers}{\setboolean{algocf@displayblockmarkers}{false}}%
\newcommand{\AlgoDisplayGroupMarkers}{\setboolean{algocf@displaygroupmarkers}{true}}%
\newcommand{\AlgoDontDisplayGroupMarkers}{\setboolean{algocf@displaygroupmarkers}{false}}%
\newcommand{\algocf@bblockcode}{%
\ifthenelse{\boolean{algocf@displayblockmarkers}}{\algocf@bblock\par}{\relax}%
}%
\newcommand{\algocf@eblockcode}{%
\ifthenelse{\boolean{algocf@displayblockmarkers}}{\algocf@eblock\par}{\relax}%
}%
\newcommand{\algocf@bgroupcode}{%
\ifthenelse{\boolean{algocf@displaygroupmarkers}}{\algocf@bblock}{\relax}%
}%
\newcommand{\algocf@egroupcode}{%
\ifthenelse{\boolean{algocf@displaygroupmarkers}}{\algocf@eblock}{\relax}%
}%
\newcommand{\SetAlgoBlockMarkers}[2]{%
\ifArgumentEmpty{#1}{%
\renewcommand{\algocf@bblock}{\relax}%
}{%
\renewcommand{\algocf@bblock}{\BlockMarkersSty{#1}}%
}% begin marker set
\ifArgumentEmpty{#2}{%
\renewcommand{\algocf@eblock}{\relax}%
}{%
\renewcommand{\algocf@eblock}{\BlockMarkersSty{#2}}%
}% end marker set
}
%
%%%%%%%%% block with a vertical line end by a little horizontal line
\newcommand{\algocf@Vline}[1]{% no vskip in between boxes but a strut to separate them,
\strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
\algocf@push{\skiprule}% move to the right before the vertical rule
\hbox{\vrule%
\vtop{\algocf@push{\skiptext}%move the right after the rule
\vtop{\algocf@addskiptotal #1}\Hlne}}\vskip\skiphlne% inside the block
\algocf@pop{\skiprule}%\algocf@subskiptotal% restore indentation
\nointerlineskip}% no vskip after
%
%%%%%%%%% block with a vertical line
\newcommand{\algocf@Vsline}[1]{% no vskip in between boxes but a strut to separate them,
\strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
\algocf@bblockcode%
\algocf@push{\skiprule}% move to the right before the vertical rule
\hbox{\vrule% the vertical rule
\vtop{\algocf@push{\skiptext}%move the right after the rule
\vtop{\algocf@addskiptotal #1}}}% inside the block
\algocf@pop{\skiprule}% restore indentation
\algocf@eblockcode%
}
%
\newcommand{\algocf@Hlne}{\hrule height 0.4pt depth 0pt width .5em}%
%
%%%%%%%%% block without line
\newcommand{\algocf@Noline}[1]{% no vskip in between boxes but a strut to separate them,
\strut\par\nointerlineskip% then interblock space stay the same whatever is inside it
\algocf@bblockcode%
\algocf@push{\skiprule}%
\hbox{%
\vtop{\algocf@push{\skiptext}%
\vtop{\algocf@addskiptotal #1}}}% inside the block
\algocf@pop{\skiprule}%\algocf@subskiptotal%
\algocf@eblockcode%
% \nointerlineskip% no vskip after
}%
%%%%%%%%%
%
%% default=NoLine
%
\newcommand{\algocf@group}[1]{\algocf@Noline{#1}}% group: set of instruction depending from another (ex: then part of the If)
\newcommand{\algocf@@@eblock}[2]{#1\ifArgumentEmpty{#2}{\relax}{\KwSty{\@algocf@endoption{#2}}\strut\par}}% block: group with a end keyword.
\newcommand{\algocf@@@block}[3]{#1\ifArgumentEmpty{#2}{\ifArgumentEmpty{#3}{\relax}{ #3\relax}}{\KwSty{\@algocf@endoption{#2}}\ifArgumentEmpty{#3}{\relax}{ #3}\strut\par}}% block: group with a end keyword.
\newcommand{\algocf@@block}[3]{\algocf@@@block{#1}{#2}{#3}}% block: group with a end keyword.
\newcommand{\algocf@block}[3]{\algocf@@block{#1}{#2}{#3}}% command that will be used and redefined accordingly to noend option
%\newcommand{\algocf@nblock}[3]{\algocf@@block{#1}{#2}{#3}}% command that will be used and redefined accordingly to noend option
\newcommand{\algocf@setBlock}{%
\ifthenelse{\boolean{algocf@optnoend}}{% if no end option
\renewcommand{\algocf@block}[3]{\algocf@group{##1}}% block will be a group
}{% else
\renewcommand{\algocf@block}[3]{\algocf@@block{##1}{##2}{##3}}% block stays a block
}%
}%
%
\newcommand{\Hlne}{}% little hrizontal line ending a block in vline mode
%
\newcommand{\@algocf@endoption}[1]{#1}%
\newboolean{algocf@optnoend}\setboolean{algocf@optnoend}{false}%
%
\newcommand{\SetAlgoLongEnd}{%%%%%%%%%%%%%%%%%%%%%%%%% Long End
\setboolean{algocf@optnoend}{false}%
\renewcommand{\@algocf@endoption}[1]{##1}%
\algocf@setBlock}%
%
\newcommand{\SetAlgoShortEnd}{%%%%%%%%%%%%%%%%%%%%%%%% ShortEnd
\setboolean{algocf@optnoend}{false}%
\renewcommand{\@algocf@endoption}[1]{\@firstword##1 \@nil}%
\algocf@setBlock}%
%
\newcommand{\SetAlgoNoEnd}{%%%%%%%%%%%%%%%%%%%%%%%%%%% NoEnd
\setboolean{algocf@optnoend}{true}%
\renewcommand{\@algocf@endoption}[1]{}%
\algocf@setBlock}%
%
\newboolean{algocf@optAlgoNoLine}\setboolean{algocf@optAlgoNoLine}{false}
\newcommand{\SetAlgoNoLine}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline
\setboolean{algocf@optAlgoNoLine}{true}%
\renewcommand{\algocf@@block}[2]{\algocf@@@block{\algocf@Noline{##1}}{##2}}%
\renewcommand{\algocf@group}[1]{\algocf@Noline{##1}}%
\renewcommand{\Hlne}{}}%
%
\newcommand{\SetAlgoVlined}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Vline
\setboolean{algocf@optAlgoNoLine}{false}%
\renewcommand{\algocf@@block}[2]{\algocf@Vline{##1}}%
\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}}%\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}%
\renewcommand{\Hlne}{\algocf@Hlne}}%
%
\newcommand{\SetAlgoLined}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line
\setboolean{algocf@optAlgoNoLine}{false}%
\renewcommand{\algocf@@block}[2]{\algocf@@@block{\strut\algocf@Vsline{##1}}{##2}}% no skip after a block so garantie at least one line
\renewcommand{\algocf@group}[1]{\algocf@Vsline{##1}}%\ifthenelse{\boolean{algocf@optnoend}}{\relax}{\strut\ignorespaces}}%
\renewcommand{\Hlne}{}}%
%
\newcommand{\SetNothing}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Noline
\setboolean{algocf@optAlgoNoLine}{true}%
\renewcommand{\algocf@@block}[2]{\algocf@Noline{##1}\par}%
%\long
\renewcommand{\algocf@group}[1]{\algocf@Noline{##1}}%
\renewcommand{\Hlne}{}}%
%
%%
%%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ``Input:'''s like command
%
%%%
% text staying at the right of the longer keyword of KwInOut commands
% (text of KwInOut commands are all vertically aligned)
%
\newcommand{\algocf@newinout}{\par\parindent=\inoutindent}% to put right indentation after a \\ in the KwInOut
\newcommand{\SetKwInOut}[2]{%
\sbox\algocf@inoutbox{\KwSty{#2\algocf@typo:}}%
\expandafter\ifx\csname InOutSizeDefined\endcsname\relax% if first time used
\newcommand\InOutSizeDefined{}\setlength{\inoutsize}{\wd\algocf@inoutbox}%
\sbox\algocf@inoutbox{\parbox[t]{\inoutsize}{\KwSty{#2\algocf@typo\hfill:}}~}\setlength{\inoutindent}{\wd\algocf@inoutbox}%
\else% else keep the larger dimension
\ifdim\wd\algocf@inoutbox>\inoutsize%
\setlength{\inoutsize}{\wd\algocf@inoutbox}%
\sbox\algocf@inoutbox{\parbox[t]{\inoutsize}{\KwSty{#2\algocf@typo\hfill:}}~}\setlength{\inoutindent}{\wd\algocf@inoutbox}%
\fi%
\fi% the dimension of the box is now defined.
\algocf@newcommand{#1}[1]{%
\ifthenelse{\boolean{algocf@hanginginout}}{\relax}{\algocf@seteveryparhanging{\relax}}%
\ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\algocf@seteveryparnl{\relax}}%
% {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}%
{\let\\\algocf@newinout\hangindent=\inoutindent\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2\algocf@typo\hfill:}}~##1\par}%
\algocf@linesnumbered% reset the numbering of the lines
\ifthenelse{\boolean{algocf@hanginginout}}{\relax}{\algocf@reseteveryparhanging}%
}}%
%
%% allow to ajust the skip size of InOut
%%
\newcommand{\ResetInOut}[1]{%
\sbox\algocf@inoutbox{\hbox{\KwSty{#1\algocf@typo:}\ }}%
\setlength{\inoutsize}{\wd\algocf@inoutbox}%
}%
%
%
%%%
% text staying at the right of the keyword.
%
\newcommand{\algocf@newinput}{\par\parindent=\wd\algocf@inputbox}% to put right indentation after a \\ in the KwInput
\newcommand{\SetKwInput}[2]{%
\algocf@newcommand{#1}[1]{%
\sbox\algocf@inputbox{\hbox{\KwSty{#2\algocf@typo:} }}%
\ifthenelse{\boolean{algocf@hanginginout}}{\relax}{\algocf@seteveryparhanging{\relax}}%
\ifthenelse{\boolean{algocf@inoutnumbered}}{\relax}{\algocf@seteveryparnl{\relax}}%
{\let\\\algocf@newinput\hangindent=\wd\algocf@inputbox\hangafter=1\unhbox\algocf@inputbox##1\par}%
\algocf@linesnumbered% reset the numbering of the lines
\ifthenelse{\boolean{algocf@hanginginout}}{\relax}{\algocf@reseteveryparhanging}%
}}%
\newcommand{\SetKwData}[2]{%
\algocf@newcommand{@#1}[1]{\DataSty{#2(}\ArgSty{##1}\DataSty{)}}%
\algocf@newcommand{#1}{%
\@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}%
}%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tallent:
%
% Add following macros:
% \SetKwHangingKw: [kw] ------------ <= hanging determined by [kw]
% ------------
% Should act like a combination of \SetKwInput and \SetKw.
% Based on \SetKwInput:
% - remove ':' at end of keyword
% - do not reset numbering
% - use separate savebox
\newsavebox{\algocf@hangingbox}
\newcommand{\algocf@newhanging}{\par\parindent=\wd\algocf@hangingbox}% to put right indentation after a \\ in the KwInput
\newcommand{\SetKwHangingKw}[2]{%
\algocf@newcommand{#1}[1]{%
\sbox\algocf@hangingbox{\hbox{\KwSty{#2}\algocf@typo\ }}%
{\let\\\algocf@newhanging\hangindent=\wd\algocf@hangingbox\hangafter=1\unhbox\algocf@hangingbox##1\;}%
}%
}%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Comments macros
%
%%%%
% comment in the text, first argument is the name of the macro, second is
% the text put before the comment, third is the text put at the end of the
% comment.
%
% first side comment justification
\newcommand{\SetSideCommentLeft}{\setboolean{algocf@scleft}{true}}%
\newcommand{\SetSideCommentRight}{\setboolean{algocf@scleft}{false}}%
\newcommand{\SetNoFillComment}{\setboolean{algocf@optfillcomment}{false}}%
\newcommand{\SetFillComment}{\setboolean{algocf@optfillcomment}{true}}%
%
% next comment and side comment
%
\newcommand{\algocf@endmarkcomment}{\relax}%
\newcommand{\algocf@fillcomment}{%
\ifthenelse{\boolean{algocf@optfillcomment}}{\hfill}{\relax}}%
%
\newcommand{\algocf@startcomment}{%
\hangindent=\wd\algocf@inputbox\hangafter=1\usebox\algocf@inputbox}%
\newcommand{\algocf@endcomment}{\algocf@fillcomment\algocf@endmarkcomment\ignorespaces\par}%
\newcommand{\algocf@endstartcomment}{\algocf@endcomment\algocf@startcomment\ignorespaces}%
%
\newboolean{algocf@sidecomment}%
\newboolean{algocf@altsidecomment}\setboolean{algocf@altsidecomment}{false}%
\newcommand{\algocf@scpar}{\ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\par}}%
\newcommand{\algocf@sclfill}{\ifthenelse{\boolean{algocf@scleft}}{\algocf@fillcomment}{\relax}}%
\newcommand{\algocf@scrfill}{\ifthenelse{\boolean{algocf@scleft}}{\relax}{\hfill}}%
\newcommand{\algocf@startsidecomment}{\usebox\algocf@inputbox}%
\newcommand{\algocf@endsidecomment}{\algocf@endmarkcomment\algocf@scpar}%
\newcommand{\algocf@endstartsidecomment}{%
\algocf@sclfill\algocf@endsidecomment%
\algocf@scrfill\algocf@startsidecomment\ignorespaces}%
%
\newcommand{\SetKwComment}[3]{%
\algocf@newcommand{#1}{\@ifstar{\csname algocf@#1@star\endcsname}{\csname algocf@#1\endcsname}}%
\algocf@newcommand{algocf@#1}[1]{%
\ifthenelse{\boolean{algocf@hangingcomment}}{\relax}{\algocf@seteveryparhanging{\relax}}%
\sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}%
\ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\algocf@seteveryparnl{\relax}}%
{\renewcommand{\algocf@endmarkcomment}{#3}%
\let\\\algocf@endstartcomment%
\algocf@startcomment\CommentSty{%
\strut\ignorespaces##1\strut\algocf@fillcomment#3}\par}%
\algocf@linesnumbered% reset the numbering of the lines
\ifthenelse{\boolean{algocf@hangingcomment}}{\relax}{\algocf@reseteveryparhanging}%
}%
%%% side comment definitions
\algocf@newcommand{algocf@#1@star}[2][]{%
\ifArgumentEmpty{##1}\relax{% TODO: Is this even necessary, with all those \ifx's?
\ifthenelse{\boolean{algocf@scleft}}{\setboolean{algocf@sidecomment}{true}}{\setboolean{algocf@sidecomment}{false}}%
\ifx##1h\setboolean{algocf@altsidecomment}{true}\SetSideCommentLeft\fi%
\ifx##1f\setboolean{algocf@altsidecomment}{true}\SetSideCommentRight\fi%
\ifx##1l\setboolean{algocf@altsidecomment}{false}\SetSideCommentLeft\fi%
\ifx##1r\setboolean{algocf@altsidecomment}{false}\SetSideCommentRight\fi%
}%
\sbox\algocf@inputbox{\CommentSty{\hbox{#2}}}%
\ifthenelse{\boolean{algocf@commentsnumbered}}{\relax}{\algocf@seteveryparnl{\relax}}%
{%
\renewcommand{\algocf@endmarkcomment}{#3}%
\let\\\algocf@endstartsidecomment%
% here is the comment
\ifthenelse{\boolean{algocf@altsidecomment}}{\relax}{\@endalgocfline\ }%
\algocf@scrfill\algocf@startsidecomment\CommentSty{%
\strut\ignorespaces##2\strut\algocf@sclfill#3}\algocf@scpar%
}%
\algocf@linesnumbered% reset the numbering of the lines
\ifArgumentEmpty{##1}\relax{%
\ifthenelse{\boolean{algocf@sidecomment}}{\setboolean{algocf@scleft}{true}}{\setboolean{algocf@scleft}{false}}%
\setboolean{algocf@altsidecomment}{false}%
}%
}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% KwProg
%
\newcommand{\SetKwProg}[4]{%\SetKwProg{Env}{Title}{is}{end}
\algocf@newcmdside@koif{#1}{\KwSty{#2}\ifArgumentEmpty{#2}\relax{\ }\ProgSty{##2}\KwSty{#3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#4}{##4}}%
\algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}%
\algocf@newcmdside{algocf@l#1}{3}{\KwSty{#2} \ProgSty{##2}\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode\@endalgocfline\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}%
\algocf@newcmdside{algocf@l#1star}{3}{\KwSty{#2} \ProgSty{##2}\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode}%
}%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% KwProgFn
%
\newcommand{\SetKwProgFn}[4]{%\SetKwProg{Env}{Title}{is}{end}
\algocf@newcmdsides{#1}{4}{\KwSty{#2}\ifArgumentEmpty{#2}\relax{\ }{##2}\KwSty{#3}{##3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@group{##4}\KwSty{#4}}{\relax}{\strut\par}%
\algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}%
\algocf@newcmdside{algocf@l#1}{3}{\KwSty{#2} \ProgSty{##2}\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode\@endalgocfline\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}%
\algocf@newcmdside{algocf@l#1star}{3}{\KwSty{#2} \ProgSty{##2}\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode}%
}%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Kw
%
\newcommand{\SetKw}[2]{%
\algocf@newcommand{@#1}[1]{\KwSty{#2} \ArgSty{##1}}
\algocf@newcommand{#1}{\@ifnextchar\bgroup{\csname @#1\endcsname}{\KwSty{#2}\xspace}}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% KwFunction
%
\newcommand{\SetKwFunction}[2]{%
%%% use of gdef since newcommand doesn't manage to define the macro when SetKwFunction is used in \algocf@caption@proc
\expandafter\gdef\csname @#1\endcsname##1{\FuncSty{#2(}\FuncArgSty{##1}\FuncSty{)}}%
\expandafter\gdef\csname#1\endcsname{%
\@ifnextchar\bgroup{\csname @#1\endcsname}{\FuncSty{#2}\xspace}}%
}%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% KwTab
%
\newcommand{\SetKwArray}[2]{%
%%% use of gdef since newcommand doesn't manage to define the macro when SetKwFunction is used in \algocf@caption@proc
\expandafter\gdef\csname @#1\endcsname##1{\DataSty{#2[}\ArgSty{##1}\DataSty{]}}%
\expandafter\gdef\csname#1\endcsname{%
\@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% KwBlock
%
\newcommand{\SetKwBlock}[3]{%
\algocf@newcmdside@kobe{#1}%
{\KwSty{#2}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##2}{#3}{##3}\par}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% condition typo
%
\newcommand{\algocf@scond}{\ }
\newcommand{\algocf@econd}{\ }
\newcommand{\algocf@ucond}{}
\newcommand{\SetStartEndCondition}[3]{%
\renewcommand{\algocf@scond}{#1}\renewcommand{\algocf@econd}{#2}\renewcommand{\algocf@ucond}{#3}}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% For Switch
%
\newcommand{\SetKwSwitch}[9]{% #1=\Switch #2=\Case #3=\Other #4=switch #5=do #6=case #7=otherwise #8=endcase #9=endsw
% \algocf@newcmdside{#1}{3}%
\algocf@newcmdside@koif{#1}%
{\KwSty{#4}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#9} {##4\relax}}%
%%%% Case
\algocf@newcmdside@koif{#2}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#8}{##4\relax}}%
%uCase
\algocf@newcmdside{u#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@group{##3}}%
%lcase
\algocf@newcommand{l#2}{\@ifstar{\csname algocf@l#2star\endcsname}{\csname algocf@l#2\endcsname}}%
\algocf@newcmdside{algocf@l#2}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\algocf@bgroupcode\ ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\ \relax{ ##1}\strut\par}%
\algocf@newcmdside{algocf@l#2star}{3}{\KwSty{#6}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\algocf@bgroupcode\ ##3\algocf@egroupcode}%
%%%% Other
\algocf@newcmdside@kobe{#3}{\KwSty{#7} \KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##2}{#8}{##3\relax}}%
%lOther
\algocf@newcommand{l#3}{\@ifstar{\csname algocf@l#3star\endcsname}{\csname algocf@l#3\endcsname}}%
\algocf@newcmdside{algocf@l#3}{2}{\KwSty{#7} \KwSty{#5}\algocf@bgroupcode\ ##2\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}%
\algocf@newcmdside{algocf@l#3star}{2}{\KwSty{#7} \KwSty{#5}\algocf@bgroupcode\ ##2\algocf@egroupcode}%
%uOther
\algocf@newcmdside{u#3}{3}{\KwSty{#7} \KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@group{##2}}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% If macros
%
\newcommand{\SetKwIF}[8]{% #1=\If #2=\ElseIf #3=\Else #4=if #5=then #6=elseif #7=else #8=endif
%
% common text
\algocf@newcommand{#1@ifthen}[1]{\KwSty{#4}\algocf@scond\ArgSty{##1}\algocf@econd\KwSty{#5}}%
\algocf@newcommand{#1@endif} [2]{\algocf@block{##1}{#8}{##2}}%
\algocf@newcommand{#1@noend} [1]{\algocf@group{##1}}%
\algocf@newcommand{#1@else} [1]{\algocf@group{##1}\KwSty{#7}}%
\algocf@newcommand{#2@elseif}[1]{\KwSty{#6}\algocf@scond\ArgSty{##1}\algocf@econd\KwSty{#5}}%
\algocf@newcommand{#3@else} {\KwSty{#7}}%
%%%% If then { } endif
\algocf@newcmdside@koif{#1}{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##3}{##4\relax}}%
%%%% If then {} else {} endif
% first command to handle optional side comment of else (so just after first braces)
\algocf@newcmdside@kobe{algocf@e#1thenelse}{\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##2}{##3}}%
% the definition of if-then-else command using command above
\algocf@newcmdside{e#1}{3}{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@else\endcsname{##3}\csname algocf@e#1thenelse\endcsname}%
%%% leif
\algocf@newcommand{le#1}{\@ifstar{\csname algocf@le#1star\endcsname}{\csname algocf@le#1\endcsname}}%
\algocf@newcmdside{algocf@le#1}{4}{\csname #1@ifthen\endcsname{##2} \algocf@bgroupcode##3 \csname #3@else\endcsname\ ##4\@endalgocfline\ \algocf@egroupcode\ifArgumentEmpty{##1}\relax{##1}\strut\par}%
\algocf@newcmdside{algocf@le#1star}{4}{\csname #1@ifthen\endcsname{##2} \algocf@bgroupcode##3 \csname #3@else\endcsname\ ##4\algocf@egroupcode}%
%%%% If then
% \algocf@newcmdside{l#1}{3}{\csname #1@ifthen\endcsname{##2}\algocf@bgroupcode\
% ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}%
\algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}%
\algocf@newcmdside{algocf@l#1}{3}{\csname #1@ifthen\endcsname{##2}\algocf@bgroupcode\ ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}%
\algocf@newcmdside{algocf@l#1star}{3}{\csname #1@ifthen\endcsname{##2}\algocf@bgroupcode\ ##3\algocf@egroupcode}%
\algocf@newcmdside{u#1}{3}{\csname #1@ifthen\endcsname{##2}\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@noend\endcsname{##3}}%
%%%% ElseIf {} endif
\algocf@newcmdside@koif{#2}{\csname #2@elseif\endcsname{##2}\relax\ifArgumentEmpty{##1}\relax{ ##1}\csname #1@endif\endcsname{##3}{##4\relax}}%
%%%% ElseIf
\algocf@newcommand{l#2}{\@ifstar{\csname algocf@l#2star\endcsname}{\csname algocf@l#2\endcsname}}%
\algocf@newcmdside{algocf@l#2}{3}{\csname #2@elseif\endcsname{##2}\algocf@bgroupcode\ ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}%
\algocf@newcmdside{algocf@l#2star}{3}{\csname #2@elseif\endcsname{##2}\algocf@bgroupcode\ ##3\algocf@egroupcode}%
\algocf@newcmdside{u#2}{3}{\csname #2@elseif\endcsname{##2}\relax\ifArgumentEmpty{##1}\relax{##1}\csname #1@noend\endcsname{##3}}%
%%%% Else {} endif
\algocf@newcmdside@kobe{#3}{\csname #3@else\endcsname\ifArgumentEmpty{##1}\relax\ ##1\csname #1@endif\endcsname{##2}{##3\relax}}%
%%%% Else
\algocf@newcommand{l#3}{\@ifstar{\csname algocf@l#3star\endcsname}{\csname algocf@l#3\endcsname}}%
\algocf@newcmdside{algocf@l#3}{2}{\csname #3@else\endcsname\algocf@bgroupcode\ ##2\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}%
\algocf@newcmdside{algocf@l#3star}{2}{\csname #3@else\endcsname\algocf@bgroupcode\ ##2\algocf@egroupcode}%
\algocf@newcmdside{u#3}{2}{\csname #3@else\endcsname\ifArgumentEmpty{##1}\relax\ {##1\relax}\csname #1@noend\endcsname{##2}}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% For macros
%
\newcommand{\SetKwFor}[4]{%
\algocf@newcmdside@koif{#1}{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#4}{##4\relax}}%
\algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}%
\algocf@newcmdside{algocf@l#1}{3}{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3}\algocf@bgroupcode\ ##3\@endalgocfline\algocf@egroupcode\ifArgumentEmpty{##1}\relax\ {##1}\strut\par}%
\algocf@newcmdside{algocf@l#1star}{3}{\KwSty{#2}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#3}\algocf@bgroupcode\ ##3\algocf@egroupcode}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Repeat macros
%
\newsavebox{\algocf@untilbox}% to handle width of until keyword needed to have good skip
% for line numbers
\newskip\algocf@skipuntil
\newcommand{\SetKwRepeat}[3]{%
\algocf@newcmdsides{#1}{3}{%
\sbox\algocf@untilbox{\KwSty{#3}\algocf@scond}\algocf@skipuntil=\wd\algocf@untilbox%
\KwSty{#2}\ifArgumentEmpty{##1}\relax{##1}\algocf@group{##3}%
\KwSty{#3}\algocf@scond% until keyword and start condition typo
%\advance\skiptotal by\algocf@skipuntil%
\ArgSty{##2}%
%\advance\skiptotal by-\algocf@skipuntil%
\algocf@ucond%
\algocf@skipuntil=0pt% reset counter
}{\@endalgocfline}{\strut\par}%
\algocf@newcommand{l#1}{\@ifstar{\csname algocf@l#1star\endcsname}{\csname algocf@l#1\endcsname}}%
\algocf@newcmdside{algocf@l#1}{3}{\KwSty{#2}\algocf@bgroupcode\ ##3\algocf@egroupcode\ \KwSty{#3}\algocf@scond\ArgSty{##2}\algocf@ucond\@endalgocfline\ifArgumentEmpty{##1}\relax{ ##1}\strut\par}%
\algocf@newcmdside{algocf@l#1star}{3}{\KwSty{#2}\algocf@bgroupcode\ ##3\algocf@egroupcode\ \KwSty{#3}\algocf@scond\ArgSty{##2}\algocf@ucond}%
}%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% Environments definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%
%% Caption management
%%
% for the following macros:
% #1 is given by caption and is equal to fnum@algocf
% #2 is the text given in argument by the user in the \caption macro
%
%%%%% text of caption
\newcommand{\algocf@captionlayout}[1]{#1}%
\newcommand{\SetAlgoCaptionLayout}[1]{%
\renewcommand{\algocf@captionlayout}[1]{\csname #1\endcsname{##1}}}%
\newcommand{\algocf@capseparator}{:}%
\newcommand{\SetAlgoCaptionSeparator}[1]{\renewcommand{\algocf@capseparator}{#1}}%
\newcommand{\algocf@captiontext}[2]{%
\algocf@captionlayout{\AlCapSty{\AlCapFnt #1\algocf@typo\algocf@capseparator}\nobreakspace%
\AlCapNameSty{\AlCapNameFnt{}#2\endgraf}}}% text of caption
%
%%%%% default caption of algorithm: used if no specific style caption is defined
\newcommand{\algocf@makecaption}[2]{%
\addtolength{\hsize}{\algomargin}%
\sbox\@tempboxa{\algocf@captiontext{#1}{#2}}%
\ifdim\wd\@tempboxa >\hsize% % if caption is longer than a line
\hskip .5\algomargin%
\parbox[t]{\hsize}{\algocf@captiontext{#1}{#2}}% then caption is not centered
\else%
\global\@minipagefalse%
\hbox to\hsize{\hfil\box\@tempboxa\hfil}% else caption is centered
\fi%
\addtolength{\hsize}{-\algomargin}%
}%
%
\newsavebox\algocf@capbox%
\newcommand{\algocf@makecaption@plain}[2]{%
\global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}}%
\newcommand{\algocf@makecaption@boxed}[2]{%
\addtolength{\hsize}{-\algomargin}%
\global\sbox\algocf@capbox{\algocf@makecaption{#1}{#2}}%
\addtolength{\hsize}{\algomargin}%
}%
%
\newlength{\algocf@lcaptionbox}%
\newcommand{\algocf@makecaption@plainruled}[2]{\algocf@makecaption@plain{#1}{#2}}%
\newcommand{\algocf@makecaption@tworuled}[2]{\algocf@makecaption@ruled{#1}{#2}}%
\newcommand{\algocf@makecaption@algoruled}[2]{\algocf@makecaption@ruled{#1}{#2}}%
\newcommand{\algocf@makecaption@boxruled}[2]{\algocf@makecaption@ruled{#1}{#2}}%
\newcommand{\algocf@makecaption@ruled}[2]{%
\global\sbox\algocf@capbox{\hskip\AlCapHSkip% .5\algomargin%
\setlength{\algocf@lcaptionbox}{\hsize}\addtolength{\algocf@lcaptionbox}{-\AlCapHSkip}%
\parbox[t]{\algocf@lcaptionbox}{\algocf@captiontext{#1}{#2}}}% then caption is not centered
}%
%
\newlength{\algoheightruledefault}\setlength{\algoheightruledefault}{0.8pt}%
\newlength{\algoheightrule}\setlength{\algoheightrule}{\algoheightruledefault}%
\newlength{\algotitleheightruledefault}\setlength{\algotitleheightruledefault}{0.8pt}%
\newlength{\algotitleheightrule}\setlength{\algotitleheightrule}{\algotitleheightruledefault}%
\newcommand{\algocf@caption@plain}{\vskip\AlCapSkip\box\algocf@capbox}%
\newcommand{\algocf@caption@plainruled}{\algocf@caption@plain}%
\newcommand{\algocf@caption@boxed}{\vskip\AlCapSkip\box\algocf@capbox}%
\newcommand{\algocf@caption@ruled}{\box\algocf@capbox\kern\interspacetitleruled\hrule
width\algocf@ruledwidth height\algotitleheightrule depth0pt\kern\interspacealgoruled}%
\newcommand{\algocf@caption@tworuled}{\box\algocf@capbox\hrule height0pt depth0pt\kern\interspacealgoruled}%
\newcommand{\algocf@caption@algoruled}{\algocf@caption@ruled}%
\newcommand{\algocf@caption@boxruled}{%
\hbox{%
\vrule%
\vbox{%
\addtolength{\hsize}{-0.8pt}%
\hrule\vskip\interspacetitleboxruled%
\hbox to\hsize{\unhbox\algocf@capbox\hfill}\vskip\interspacetitleboxruled%
\addtolength{\hsize}{0.8pt}%
}%
\vrule%
}\nointerlineskip%
}%
%
%
%%%% set caption for the environment
\newcommand{\algocf@captionref}{%
\renewcommand{\fnum@algocf}[1]{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\algocf@algocfref}}%
\addtocounter{algocf}{-1}% \caption do a refstepcounter, so we restore the precedent value
\let\old@thealgocf=\thealgocf\renewcommand{\thealgocf}{{\relsize{\algocf@refrelsize}\algocf@algocfref}}%
\gdef\@currentlabel{\algocf@algocfref}% let the label use the new ref
}%
%
% Unfortunatly, we also need our own caption to set some specific stuff for special references. But after these
% settings, we call the original caption.
%
\long\def\algocf@caption@algo#1[#2]#3{%
\ifthenelse{\equal{\algocf@algocfref}{\relax}}{}{\algocf@captionref}%
\@ifundefined{hyper@refstepcounter}{\relax}{% if hyper@refstepcounter undefind, no hyperref, else...
\ifthenelse{\equal{\algocf@algocfref}{\relax}}{\renewcommand{\theHalgocf}{\thealgocf}}{% take algocf as Href
\renewcommand{\theHalgocf}{\algocf@algocfref}}%else if SetAlgoRefName done, take this name as ref.
\hyper@refstepcounter{algocf}%set algocf as category of ref
}%
\algocf@latexcaption{#1}[{#2}]{{#3}}% call original caption
}%
%
% beamer define is own caption overrinding latex caption!
% as we need it, we have put here the original definition
% to handle manual ref, unfortunately we have to add one line to handle algocf@algocfref
\long\def\algocf@latexcaption#1[#2]#3{% original definition of caption
\par%
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup%
\@parboxrestore%
\if@minipage%
\@setminipage%
\fi%
\normalsize%
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par%
\endgroup%
}%
%
% \ifx\beamer@makecaption\undefined%
% \else% beamer detected
\ifx\@makecaption\undefined%
\newcommand{\@makecaption}[2]{\relax}%
\fi%
%%
%
% more and more packages redefine \@caption instead of just \@makecaption which makes algorithm2e
% caption not works since based on standard \@caption. So we force the definition of \@caption to be
% the standard one (the one from LaTeX) inside algorithm environment.
%
% unfortunately, makecaption is called with \ignorespace #3 so
% we can't do the @currentlabel definition inside \algocf@captionproctext
\long\def\algocf@caption@proc#1[#2]#3{%
\ifthenelse{\boolean{algocf@nokwfunc}}{\relax}{%
\SetKwFunction{\algocf@captname#3@}{\algocf@captname#3@}%
}%
% we tell hyperref to use algocfproc as category and to take the appropriate ref.
\ifthenelse{\boolean{algocf@func}}{\def\@proc@func{algocffunc}}{\def\@proc@func{algocfproc}}%
\@ifundefined{hyper@refstepcounter}{\relax}{% if hyper@refstepcounter undefind, no hyperref, else...
\ifthenelse{\boolean{algocf@procnumbered}}{%
\expandafter\def\csname theH\@proc@func\endcsname{\thealgocf}%if procnumbered, take \thealgocf as ref
}{%
\expandafter\def\csname theH\@proc@func\endcsname{\algocf@captname#3@}%else take procedure or function name
}%
\hyper@refstepcounter{\@proc@func}%
}%
\ifthenelse{\boolean{algocf@procnumbered}}{\relax}{%
\addtocounter{algocf}{-1}% \caption do a refstepcounter, so we restore the precedent value
\gdef\@currentlabel{\algocf@captname#3@}% let the label be the name of the function, not the counter
}%
\ifthenelse{\equal{\algocf@captparam#2@}{\arg@e}}{% if no paramater, we remove the ()
\algocf@latexcaption{#1}[\algocf@procname\nobreakspace\algocf@captname#2@]{#3}%
}{% else we give the complete name
\algocf@latexcaption{#1}[\algocf@procname\nobreakspace#2]{#3}%
}%
}%
%%
%%% setcaption
\newcommand{\algocf@setcaption}{%
\ifthenelse{\boolean{algocf@procenvironment}}{% if proc environment, caption text must be changed
\let\algocf@oldcaptiontext=\algocf@captiontext%
\renewcommand{\algocf@captiontext}[2]{%
\algocf@captionproctext{##1}{##2}%
}%
}{}%
\let\algocf@savecaption=\@caption%
\ifthenelse{\boolean{algocf@procenvironment}}{\let\@caption=\algocf@caption@proc}{\let\@caption=\algocf@caption@algo}%
\let\algocf@oldmakecaption=\@makecaption%
\renewcommand{\@makecaption}[2]{%
\expandafter\csname algocf@makecaption@\algocf@style\endcsname{##1}{##2}%
}%
}%
%
%%%%% reset caption
%
% since we have force the LaTeX caption for algorithm environment, we must go back to the caption
% used in the text.
\newcommand{\algocf@resetcaption}{%
\ifthenelse{\boolean{algocf@procenvironment}}{% if proc environment
\let\thealgocf=\old@thealgocf% restore normal counter printing
\let\algocf@captiontext=\algocf@oldcaptiontext% restore normal caption text
}{}%
\let\@caption=\algocf@savecaption% now restore caption outside algo/proc/func environment
\let\@makecaption=\algocf@oldmakecaption% and restore makecaption outside outside algo/proc/func environment
\algocf@resetfnum%
}%
%
%%%%% nocaptionofalgo and restorecaptionofalgo --
\newcommand{\NoCaptionOfAlgo}{%
\let\@old@algocf@captiontext=\algocf@captiontext%
\renewcommand{\algocf@captiontext}[2]{\AlCapNameSty{\AlCapNameFnt{}##2}}%
}%
\newcommand{\RestoreCaptionOfAlgo}{%
\let\algocf@captiontext=\@old@algocf@captiontext%
}%
%
% ---------------------- algocf environment
%
\newcounter{algocfline}% % new counter to make lines numbers be internally
\setcounter{algocfline}{0}% % different in different algorithms
\newcounter{algocfproc}% counter to count all algo environment (proc, func), just used by hyperref to avoir "same
\setcounter{algocfproc}{0}% identifier" error caused by algocf being set to '-' for procedure or function or not
% changed if no caption is given.
%
\expandafter\ifx\csname algocf@within\endcsname\relax% if \algocf@within doesn't exist
\newcounter{algocf}% % just define a new counter
\renewcommand{\thealgocf}{\@arabic\c@algocf}% and the way it is printed
\else% else
\newcounter{algocf}[\algocf@within]% % counter is numbered within \algocf@within
\renewcommand\thealgocf{\csname the\algocf@within\endcsname.\@arabic\c@algocf}%
\fi%
%
\def\fps@algocf{htbp}% % default
\def\ftype@algocf{10}% % float type
\def\ext@algocf{\algocf@list} % loa by default, lof if figure option used
\newcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}%
\newcommand{\algocf@resetfnum}{\renewcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf}}}%
\newenvironment{algocf}% % float environment for algorithms
{\@float{algocf}}%
{\end@float}%
\newenvironment{algocf*}% % float* environment for algorithms
{\@dblfloat{algocf}}%
{\end@dblfloat}%
%
\def\algocf@seclistalgo{}%
\ifx\l@chapter\undefined\let\algocf@seclistalgo=\section\else\let\algocf@seclistalgo=\chapter\fi%
\@ifundefined{if@restonecol}{\newif\if@restonecol}\relax%
\newcommand\listofalgocfs{%
\ifx\algocf@seclistalgo\chapter%
\if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi%
\fi%
\algocf@seclistalgo*{\listalgorithmcfname}%
\@mkboth{\MakeUppercase\listalgorithmcfname}%
{\MakeUppercase\listalgorithmcfname}%
\@starttoc{loa}%
\ifx\algocf@seclistalgo\chapter%
\if@restonecol\twocolumn\fi%
\fi%
}
%
\newcommand*\l@algocf{\@dottedtocline{1}{1em}{2.3em}}% line of the list
%
% ---------------------- algorithm environment
%
%%%%%%%
%%
%% Algorithm environment definition
%%
%%%%%%%
%%
%
\newsavebox\algocf@algoframe%
\def\@algocf@pre@plain{\relax}% action to be done before printing the algo.
\def\@algocf@post@plain{\relax}% action to be done after printing the algo.
\def\@algocf@capt@plain{bottom}% where the caption should be localized.
\def\@algocf@pre@boxed{\noindent\begin{lrbox}{\algocf@algoframe}}
\def\@algocf@post@boxed{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}%
\def\@algocf@capt@boxed{under}%
\def\@algocf@pre@ruled{\hrule width\algocf@ruledwidth height\algoheightrule depth0pt\kern\interspacetitleruled}%
\def\@algocf@post@ruled{\kern\interspacealgoruled\hrule width\algocf@ruledwidth height\algoheightrule\relax}%
\def\@algocf@capt@ruled{top}%
\def\@algocf@pre@algoruled{\hrule width\algocf@ruledwidth height\algoheightrule depth0pt\kern\interspacetitleruled}%
\def\@algocf@post@algoruled{\kern\interspacealgoruled\hrule width\algocf@ruledwidth height\algoheightrule \relax}%
\def\@algocf@capt@algoruled{top}%
\def\@algocf@pre@tworuled{\hrule height\algoheightrule depth0pt\kern\interspacetitleruled}%
\def\@algocf@post@tworuled{\kern\interspacealgoruled\hrule height\algoheightrule\relax}%
\def\@algocf@capt@tworuled{top}%
\def\@algocf@pre@boxruled{\noindent\begin{lrbox}{\algocf@algoframe}}%
\def\@algocf@post@boxruled{\end{lrbox}\framebox[\hsize]{\box\algocf@algoframe}\par}%
\def\@algocf@capt@boxruled{above}%
\def\@algocf@pre@plainruled{\@algocf@pre@ruled}% action to be done before printing the algo.
\def\@algocf@post@plainruled{\@algocf@post@ruled\kern\interspacealgoruled}% action to be done before printing the algo.
\def\@algocf@capt@plainruled{under}%
%
\newcommand{\noalgocaption}{\def\@algocf@capt@ruled{none}}
%
%% before algocf environment (not figure environment)
\newcommand{\@algocf@init@caption}{%
\ifthenelse{\boolean{algocf@procenvironment}}{% if we are inside a procedure/function environment
\@algocf@proctitleofalgo% set Titleofalgo to Procedure: or Function:
% accordingly to the environment
\let\old@thealgocf=\thealgocf\ifthenelse{\boolean{algocf@procnumbered}}{\relax}{%
\renewcommand{\thealgocf}{-}}%
}{% else inside environment algorithm
\@algocf@algotitleofalgo% fix name for \Titleofalgo to \algorithmcfname
}%
\algocf@setcaption% set caption to our caption style
}%
%
\newcommand{\@algofloatboxreset}{\@setminipage}
\newcommand{\@algocf@init}{%
\refstepcounter{algocfline}%
\stepcounter{algocfproc}%to have a different counter for each environment and being abble to make the difference
%between href of algoline in different algorithms.
\ifthenelse{\boolean{algocf@optnoend}}{%
\renewcommand{\algocf@block}[3]{\algocf@group{##1}}%
}{%
\renewcommand{\algocf@block}[3]{\algocf@@block{##1}{##2}{##3}}%
}%
}%
%% after the end of algocf or figure environment
\newcommand{\@algocf@term@caption}{%
\algocf@resetcaption% restore original caption
}%
%
\newcommand{\@algocf@term}{%
\setboolean{algocf@algoH}{false}% no H by default
\ifthenelse{\boolean{algocf@optnoend}}{%
\renewcommand{\algocf@block}[3]{\algocf@@block{##1}{##2}{##3}}%
}{%
\renewcommand{\algocf@block}[2]{\algocf@group{##1}}%
}%
\SetAlgoRefName{\relax}%
}%
%
%%%%%%%%%%%%%%%%%
%% makethealgo: macro which print effectively the algo in its box
%%
\newsavebox\algocf@algobox%
\newcommand{\algocf@makethealgo}{%
\vtop{%
% place caption above if needed bye the style
\ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{above}}%
{\csname algocf@caption@\algocf@style\endcsname}{}%
%
% precommand according to the style
\csname @algocf@pre@\algocf@style\endcsname%
% place caption at top if needed bye the style
\ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{top}}%
{\csname algocf@caption@\algocf@style\endcsname}{}%
%
\box\algocf@algobox% the algo
% place caption at bottom if needed bye the style
\ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{bottom}}%
{\csname algocf@caption@\algocf@style\endcsname}{}%
% postcommand according to the style
\csname @algocf@post@\algocf@style\endcsname%
% place caption under if needed bye the style
\ifthenelse{\equal{\csname @algocf@capt@\algocf@style\endcsname}{under}}%
{\csname algocf@caption@\algocf@style\endcsname}{}%
}%
}%
%%%%%%%%%%%%%%%%%%%
%
%% at the beginning of algocf or figure environment
\newenvironment{algomathdisplay}{\[}{\@endalgocfline\]\ifthenelse{\boolean{algocf@linesnumbered}}{\nl}{\relax}}%
\newcommand{\@algocf@start}{%
\@algoskip%
\begin{lrbox}{\algocf@algobox}%
\setlength{\algowidth}{\hsize}%
\vbox\bgroup% save all the algo in a box
\hbox to\algowidth\bgroup\hbox to \algomargin{\hfill}\vtop\bgroup%
\ifthenelse{\boolean{algocf@slide}}{\parskip 0.5ex\color{black}}{}%
% initialization
\addtolength{\hsize}{-\algomargin}\addtolength{\hsize}{-1.5em}% 1.5em to let space for line numbering
\let\@mathsemicolon=\;\def\;{\ifmmode\@mathsemicolon\else\@endalgoln\fi}%
\raggedright%
\AlFnt{}%
\ifthenelse{\boolean{algocf@slide}}{\IncMargin{\skipalgocfslide}}{}%
\@algoinsideskip%
% \let\@emathdisplay=\]\def\]{\algocf@endline\@emathdisplay\nl}%
}%
%
%% at the end of algocf or figure environment
\newcommand{\@algocf@finish}{%
\@algoinsideskip%
\egroup%end of vtop which contain all the text
\hfill\egroup%end of hbox wich contains [margin][vtop]
\ifthenelse{\boolean{algocf@slide}}{\DecMargin{\skipalgocfslide}}{}%
%
\egroup%end of main vbox
\end{lrbox}%
\algocf@makethealgo% print the algo
\@algoskip%
% restore dimension and macros
\setlength{\hsize}{\algowidth}%
\lineskip\normallineskip\setlength{\skiptotal}{\@defaultskiptotal}%
\let\;=\@mathsemicolon%
\let\]=\@emathdisplay%
}%
%
%%%%%%%%%%%%%%%%%%%%
%% basic definition of the environment algorithm
%%
%
\newboolean{algocf@procenvironment}\setboolean{algocf@procenvironment}{false}%
\newboolean{algocf@func}\setboolean{algocf@func}{false}%
\newboolean{algocf@algoH}\setboolean{algocf@algoH}{false}%
\newboolean{algocf@algostar}\setboolean{algocf@algostar}{false}%
%
%%% environment for {algorithm}[H]
\newenvironment{algocf@Here}{\noindent%
\def\@captype{algocf}% if not defined, caption exit with an error
\begin{minipage}{\hsize}%
}{%
\end{minipage}%\par%
}%
%%% real algorithm environment which manages H and * option
% \let\algocf@originalfloatboxreset=\@floatboxreset%
% \let\@floatboxreset=\@algofloatboxreset%
\newenvironment{algocf@algorithm}[1][htbp]{%
\@algocf@init%
\ifthenelse{\equal{\algocf@float}{figure}}{% if option figure set
\ifthenelse{\boolean{algocf@algostar}}{% if algorithm* with figure option
\begin{figure*}[#1]% call figure*
\ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}%
\let\algocf@oldeverypar=\everypar%
\algocf@seteverypar%
\addtolength{\linewidth}{-\algomargin}% caption package use \linewidth as basic width of caption
}{% else algorithm environment with figure option
\begin{figure}[#1]% call figure
\ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}%
\let\algocf@oldeverypar=\everypar%
\algocf@seteverypar%
\addtolength{\linewidth}{-\algomargin}% so now \linewidth==\hsize. Needed by caption package that uses \linewidth as basic width of caption
}%
}{% else normal algorithm environment
\@algocf@init@caption%
\ifthenelse{\equal{#1}{H}}{% if [H] algorithm
\if@twocolumn\@latex@error{[H] in two columns mode is not allowed for algorithms}\fi% TODO: SCREAM if H in two colums!
\setboolean{algocf@algoH}{true}\begin{algocf@Here}% call corresponding environment
\ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}%
\let\algocf@oldeverypar=\everypar%
\algocf@seteverypar%
}{% else floating algorithm environment
\ifthenelse{\boolean{algocf@algostar}}{% if algorithm*
\begin{algocf*}[#1]% call algocf*
\ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}%
\let\algocf@oldeverypar=\everypar%
\algocf@seteverypar%
}{% else algorithm environment
\begin{algocf}[#1]% call algocf
\ifthenelse{\boolean{algocf@customruledwidth}}{\relax}{\setlength{\algocf@ruledwidth}{\linewidth}}%
\let\algocf@oldeverypar=\everypar%
\algocf@seteverypar%
}%
}%
}% fin test option figure ou pas
\@algocf@start%
\@ResetCounterIfNeeded%
\algocf@linesnumbered\ignorespaces%
}{%
\@algocf@finish%
\ifthenelse{\equal{\algocf@float}{figure}}{%
\ifthenelse{\boolean{algocf@algostar}}{% if algorithm* with figure option
\let\everypar=\algocf@oldeverypar%
\end{figure*}% call figure*
}{% else algorithm environment with figure option
\let\everypar=\algocf@oldeverypar%
\end{figure}% call figure
}%
}{%
\@algocf@term@caption%
\ifthenelse{\boolean{algocf@algoH}}{% if [H] algorithm
\let\everypar=\algocf@oldeverypar%
\end{algocf@Here}\par% call corresponding environment
}{% else floating algorithm environment
\ifthenelse{\boolean{algocf@algostar}}{% if algorithm*
\let\everypar=\algocf@oldeverypar%
\end{algocf*}% call algocf*
}{% else algorithm environment
\let\everypar=\algocf@oldeverypar%
\end{algocf}% call algocf
}%
}%
}%
\@algocf@term\ignorespacesafterend%
}%
%
%%% user algorithm environment
\newenvironment{\algocf@envname}[1][htbp]{%
\setboolean{algocf@algostar}{false}%
\setboolean{algocf@procenvironment}{false}\gdef\algocfautorefname{\algorithmautorefname}%
\begin{algocf@algorithm}[#1]\ignorespaces%
}{%
\end{algocf@algorithm}\ignorespacesafterend%
}%
%%% user algorithm* environment
\newenvironment{\algocf@envname*}[1][htbp]{%
\setboolean{algocf@algostar}{true}%
\setboolean{algocf@procenvironment}{false}\gdef\algocfautorefname{\algorithmautorefname}%
\begin{algocf@algorithm}[#1]\ignorespaces%
}{%
\end{algocf@algorithm}\ignorespacesafterend%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%
%%%
%
\expandafter\newcommand\csname\algocf@listofalgorithms\endcsname{%
\ifthenelse{\equal{\algocf@float}{figure}}{\listoffigures}{\listofalgocfs}%
}%
%%%
%%%
%
% ---------------------- procedure and function environments
%
%
% -- new style (used in particular in the caption of function and procedure environments)
%
% three macros to extract parts of the caption
\gdef\algocf@captname#1(#2)#3@{#1} % keep characters before the first brace
\gdef\algocf@captparam#1(#2)#3@{#2} % keep character in between the braces
\gdef\algocf@captother#1(#2)#3@{#3} % keep character after the braces
%
%%% Text of caption for Procedure or Function
\newcommand{\algocf@captionproctext}[2]{%
{%
\ProcSty{\ProcFnt\algocf@procname\ifthenelse{\boolean{algocf@procnumbered}}{\nobreakspace\thealgocf\algocf@typo\algocf@capseparator}{\relax}}%
\nobreakspace\ProcNameSty{\ProcNameFnt\algocf@captname #2@}% Name of the procedure in ProcName Style.
\ifthenelse{\equal{\algocf@captparam #2@}{\arg@e}}{}{% if no argument, write nothing
\ProcNameSty{\ProcNameFnt(}\ProcArgSty{\ProcArgFnt\algocf@captparam #2@}\ProcNameSty{\ProcNameFnt)}%else put arguments in ProcArgSty:
}% endif
\algocf@captother #2@%
}%
}%
%
%
% -- procedure and function environments are defined from algocf@algorithm environment
%
\newenvironment{procedure}[1][htbp]{%
\setboolean{algocf@algostar}{false}%
\setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{false}%
\newcommand{\algocf@procname}{\@algocf@procname}\gdef\algocfprocautorefname{\procedureautorefname}%
\begin{algocf@algorithm}[#1]\ignorespaces%
}{%
\end{algocf@algorithm}\ignorespacesafterend%
}%
\newenvironment{function}[1][htbp]{%
\setboolean{algocf@algostar}{false}%
\setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{true}%
\newcommand{\algocf@procname}{\@algocf@funcname}\gdef\algocffuncautorefname{\functionautorefname}%
\begin{algocf@algorithm}[#1]\ignorespaces%
}{%
\end{algocf@algorithm}\ignorespacesafterend%
}%
%
\newenvironment{procedure*}[1][htbp]{%
\setboolean{algocf@algostar}{true}%
\setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{false}%
\newcommand{\algocf@procname}{\@algocf@procname}\gdef\algocfprocautorefname{\procedureautorefname}%
\begin{algocf@algorithm}[#1]\ignorespaces%
}{%
\end{algocf@algorithm}\ignorespacesafterend%
}%
\newenvironment{function*}[1][htbp]{%
\setboolean{algocf@algostar}{true}%
\setboolean{algocf@procenvironment}{true}\setboolean{algocf@func}{true}%
\newcommand{\algocf@procname}{\@algocf@funcname}\gdef\algocffuncautorefname{\functionautorefname}%
\begin{algocf@algorithm}[#1]\ignorespaces%
}{%
\end{algocf@algorithm}\ignorespacesafterend%
}%
%
%
%%%%%%%%%%%%%%%%%%%%
%% definition of algondfloat environment
%%
\ifthenelse{\boolean{algocf@endfloat}}{% if endfloat option then
\newcommand{\algoplace}{% macro which is used to writhe algorithm about there
\begin{center}%
[\algorithmcfname~\thepostfig\ about here.]%
\end{center}%
}%
\newcommand{\algoendfloat}{% use as a \begin{algoendfloat} environment to start scanning of line
% \immediate\openout\@mainfff\jobname.fff%
\efloat@condopen{fff}
\efloat@iwrite{fff}{\string\begin{\algocf@envname}}%
\if@domarkers%
\ifthenelse{\equal{\algocf@list}{lof}}{%
\addtocounter{postfig}{1}%
}{%
\addtocounter{postalgo}{1}%
}%
\algoplace%
\fi%
\bgroup%
\let\do\ef@makeinnocent\dospecials%
\ef@makeinnocent\^^L% and whatever other special cases
\endlinechar`\^^M \catcode`\^^M=12 \ef@xalgocfendfloat}%
}{\relax}%%%% end of endfloat option ifthenelse
%% some macros useful for endfloat option that cannot be defined inside the ifthenelse
%scan algoendfloat algorithm and write the text into .fff file
{\catcode`\^^M=12 \endlinechar=-1 %
\gdef\ef@xalgocfendfloat#1^^M{% scan the lines inside algoendfloat environment being read by latex
\def\test{#1}% test is the line being currently scan by latex
\ifx\test\ef@endalgocftest% if it is \end{algoendfloat}
\def\next{% define next as to not continue the scan and write \end{algorithm} into .fff file
\egroup\end{algoendfloat}%
\efloat@iwrite{fff}{\string\end{\algocf@envname}}%
\efloat@iwrite{fff}{\string\efloatseparator}%
\efloat@iwrite{fff}{ }%
}%
\else% else write the current line being scanned by latex and set next to continue the scan
\efloat@iwrite{fff}{#1}%
\let\next\ef@xalgocfendfloat%
\fi% endif
\next}% next is continue if it was else condition, else it does not continue the scan and write end to file
}%
% test if the scan is finish by looking at the string \end{algoendfloat}
{\escapechar=-1%
\xdef\ef@endalgocftest{\string\\end\string\{algoendfloat\string\}}%
}%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
\newcommand{\TitleOfAlgo}[1]{\@titleprefix\
\TitleSty{#1}\par\smallskip}%
%
\newcommand{\SetAlgorithmName}[3]{%
\renewcommand{\listalgorithmcfname}{#3}%
\renewcommand{\algorithmcfname}{#1}%
\renewcommand{\algorithmautorefname}{#2}%
}%
%
\newcommand{\algocf@refrelsize}{-2}\newcommand{\SetAlgoRefRelativeSize}[1]{\renewcommand{\algocf@refrelsize}{#1}}%
\newcommand{\SetAlgoRefName}[1]{%
\renewcommand{\algocf@algocfref}{#1}%
}%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% ------------------------- Default Definitions
%
%%
%%
%
\SetKwComment{tcc}{/* }{ */}%
\SetKwComment{tcp}{// }{}%
%
%\newcommand{\algocf@defaults@common}{
%
%
% english keywords (default)
%
\SetKwHangingKw{KwHData}{Data$\rightarrow$}
\SetKwInput{KwIn}{Input}%
\SetKwInput{KwOut}{Output}%
\SetKwInput{KwData}{Data}%
\SetKwInput{KwResult}{Result}%
\SetKw{KwTo}{to}
\SetKw{KwRet}{return}%
\SetKw{Return}{return}%
\SetKwBlock{Begin}{begin}{end}%
\SetKwRepeat{Repeat}{repeat}{until}%
%
\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}%
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{end switch}%
\SetKwFor{For}{for}{do}{end for}%
\SetKwFor{ForPar}{for}{do in parallel}{end forpar}
\SetKwFor{ForEach}{foreach}{do}{end foreach}%
\SetKwFor{ForAll}{forall}{do}{end forall}%
\SetKwFor{While}{while}{do}{end while}%
%
% French keywords
%
\ifthenelse{\boolean{algocf@localkw@french}\OR\equal{\algocf@languagechoosen}{french}}{%
%\SetKwInOut{AlgDonnees}{Donn\'ees}\SetKwInOut{AlgRes}{R\'esultat}
\SetKwHangingKw{HDonnees}{Donnees$\rightarrow$}
\SetKwInput{Donnees}{Donn\'ees}%
\SetKwInput{Res}{R\'esultat}%
\SetKwInput{Entree}{Entr\'ees}%
\SetKwInput{Sortie}{Sorties}%
\SetKw{KwA}{\`a}%
\SetKw{Retour}{retourner}%
\SetKwBlock{Deb}{d\'ebut}{fin}%
\SetKwRepeat{Repeter}{r\'ep\'eter}{jusqu'\`a}%
%
\SetKwIF{Si}{SinonSi}{Sinon}{si}{alors}{sinon si}{sinon}{fin si}%
\SetKwSwitch{Suivant}{Cas}{Autre}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}%
\SetKwFor{Pour}{pour}{faire}{fin pour}%
\SetKwFor{PourPar}{pour}{faire en parall\`ele}{fin pour}%
\SetKwFor{PourCh}{pour chaque}{faire}{fin pour chaque}%
\SetKwFor{PourTous}{pour tous les}{faire}{fin pour tous}%
\SetKwFor{Tq}{tant que}{faire}{fin tq}%
}{}%
%
% --- German keywords
%
\ifthenelse{\boolean{algocf@localkw@german}\OR\equal{\algocf@languagechoosen}{german}}{%
\SetKwInput{Ein}{Eingabe}%KwIn
\SetKwInput{Aus}{Ausgabe}%KwOut
\SetKwInput{Daten}{Daten}%KwData
\SetKwInput{Ergebnis}{Ergebnis}%KwResult
\SetKw{Bis}{bis}%KwTo
\SetKw{KwZurueck}{zur\"uck}%KwRet
\SetKw{Zurueck}{zur\"uck}%Return
\SetKwBlock{Beginn}{Beginn}{Ende}%Begin
\SetKwRepeat{Wiederh}{wiederhole}{bis}%Repeat
%
\SetKwIF{Wenn}{SonstWenn}{Sonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf
\SetKwSwitch{Unterscheide}{Fall}{Anderes}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}{Ende Unt.}%Switch
\SetKwFor{Fuer}{f\"ur}{tue}{Ende f\"ur}%For
\SetKwFor{FuerPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar
\SetKwFor{FuerJedes}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach
\SetKwFor{FuerAlle}{f\"ur alle}{tue}{Ende f\"ur}%ForAll
\SetKwFor{Solange}{solange}{tue}{Ende solange}%While
}{}%
%
% --- Czech keywords
%
\ifthenelse{\boolean{algocf@localkw@czech}\OR\equal{\algocf@languagechoosen}{czech}}{%
\SetKwInput{Vst}{Vstup}%
\SetKwInput{Vyst}{V\'{y}stup}%
\SetKwInput{Vysl}{V\'{y}sledek}%
}{}%
%
% --- Portuguese keywords
%
\ifthenelse{\boolean{algocf@localkw@portuguese}\OR\equal{\algocf@languagechoosen}{portuguese}}{%
\SetKwInput{Entrada}{Entrada}%
\SetKwInput{Saida}{Sa\'{i}da}%
\SetKwInput{Dados}{Dados}%
\SetKwInput{Resultado}{Resultado}%
\SetKw{Ate}{at\'{e}}
\SetKw{KwRetorna}{retorna}%
\SetKw{Retorna}{retorna}%
\SetKwBlock{Inicio}{in\'{i}cio}{fim}%
\SetKwRepeat{Repita}{repita}{at\'{e}}%
%
\SetKwIF{Se}{SenaoSe}{Senao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
\SetKwSwitch{Selec}{Caso}{Outro}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}{fim selec}%
\SetKwFor{Para}{para}{fa\c{c}a}{fim para}%
\SetKwFor{ParaPar}{para}{fa\c{c}a em paralelo}{fim para}
\SetKwFor{ParaCada}{para cada}{fa\c{c}a}{fim para cada}%
\SetKwFor{ParaTodo}{para todo}{fa\c{c}a}{fim para todo}%
\SetKwFor{Enqto}{enquanto}{fa\c{c}a}{fim enqto}%
}{}%
%
% --- Italian keywords
%
\ifthenelse{\boolean{algocf@localkw@italiano}\OR\equal{\algocf@languagechoosen}{italiano}}{%
\SetKwInput{KwIng}{Ingresso}%
\SetKwInput{KwUsc}{Uscita}%
\SetKwInput{KwDati}{Dati}%
\SetKwInput{KwRisult}{Risultato}%
\SetKw{KwA}{a}%
\SetKw{KwRitorna}{ritorna}%
\SetKw{Ritorna}{ritorna}%
\SetKwBlock{Inizio}{inizio}{fine}%
\SetKwRepeat{Ripeti}{ripeti}{finch\'e}%
%
\SetKwIF{Sea}{AltSe}{Altrimenti}{se}{allora}{altrimenti se}{allora}{fine se}%
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{endsw}%
\SetKwFor{Per}{per}{fai}{fine per}%
\SetKwFor{PerPar}{per}{fai in parallelo}{fine per}%
\SetKwFor{PerCiascun}{per ciascun}{fai}{fine per ciascun}%
\SetKwFor{PerTutti}{per tutti i}{fai}{fine per tutti}%
\SetKwFor{Finche}{finch\'e}{fai}{fine finch\'e}%
}{}%
%
% --- Spanish keywords
%
\ifthenelse{\boolean{algocf@localkw@spanish}\OR\equal{\algocf@languagechoosen}{spanish}}{%
\SetKwInput{Datos}{Datos}
\SetKwInput{Resultado}{Resultado}
\SetKwInput{Entrada}{Entrada}
\SetKwInput{Salida}{Salida}
\SetKw{KwA}{a}
\SetKw{KwDevolver}{devolver}
\SetKw{Devolver}{devolver}
\SetKwBlock{Inicio}{inicio}{fin}
\SetKwIF{SSi}{EnOtroCasoSi}{EnOtroCaso}{si}{entonces}{sin\'o, si}{sin\'o}{fin si}
\SetKwSwitch{Seleccionar}{Caso}{Otro}{seleccionar}{hacer}{caso}{sin\'o}{fin caso}{fin seleccionar}
\SetKwFor{Para}{para}{hacer}{fin para}
\SetKwFor{ParaPara}{par}{hacer en paralelo}{fin para}
\SetKwFor{EnParalelo}{para}{hacer en paralelo}{fin para}
\SetKwFor{Mientras}{mientras}{hacer}{fin mientras}
\SetKwFor{ParaCada}{para cada}{hacer}{fin para cada}
\SetKwFor{ParaTodo}{para todo}{hacer}{fin para todo}
\SetKwRepeat{Repetir}{repetir}{hasta que}
}{}%
%
% Croatian keywords
%
\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{croatian}}{%
\SetKwInput{KwUlaz}{Ulaz}%KwIn
\SetKwInput{KwIzlaz}{Izlaz}%KwOut
\SetKwInput{KwPodatci}{Podatci}%KwData
\SetKwInput{KwRezultat}{Rezultat}%KwResult
\SetKw{KwDo}{do}%KwTo
\SetKw{KwVrati}{vrati}%KwRet
\SetKw{Vrati}{vrati}%Return
\SetKwBlock{Pocetak}{po\v{c}etak}{kraj}%Begin
\SetKwRepeat{Ponavljaj}{ponavljaj}{dok ne bude}%Repeat
%
\SetKwIF{Ako}{InaceAko}{Inace}{ako}{onda}{ina\v{c}e ako}{ina\v{c}e}{kraj ako}%gIf
\SetKwSwitch{Granaj}{Slucaj}{OstaliSlucajevi}{granaj}{\v{c}ini}{slu\v{c}aj}{ostali slu\v{c}ajevi}{kraj slu\v{c}aj}{kraj granaj}%Switch
\SetKwFor{Za}{za}{\v{c}ini}{kraj za}%For
\SetKwFor{ZaPar}{za}{\v{c}ini paralelno}{kraj za paralelno}%ForPar
\SetKwFor{ZaSvaki}{za svaki}{\v{c}ini}{kraj za svaki}%mForEach
\SetKwFor{ZaSvaku}{za svaku}{\v{c}ini}{kraj za svaku}%fForEach
\SetKwFor{ZaSvako}{za svako}{\v{c}ini}{kraj za svako}%nForEach
\SetKwFor{ZaSve}{za sve}{\v{c}ini}{kraj za sve}%ForAll
\SetKwFor{Dok}{dok}{\v{c}ini}{kraj dok}%While
}{}%
%
%
% --- Turkish keywords
%
\ifthenelse{\boolean{algocf@localkw@turkish}\OR\equal{\algocf@languagechoosen}{turkish}}{%
\SetKwInput{KwIn}{Girdi}%
\SetKwInput{KwOut}{\c{C}{\i}kt{\i}}%
\SetKwInput{KwData}{Veri}%
\SetKwInput{KwResult}{Sonu\c{c}}%
\SetKw{KwTo}{to}
\SetKw{KwRet}{return}%
\SetKw{Return}{return}%
\SetKwBlock{Begin}{begin}{end}%
\SetKwRepeat{Repeat}{repeat}{until}%
% %
\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}%
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{end switch}%
\SetKwFor{For}{for}{do}{end for}%
\SetKwFor{ForPar}{for}{do in parallel}{end forpar}
\SetKwFor{ForEach}{foreach}{do}{end foreach}%
\SetKwFor{ForAll}{forall}{do}{end forall}%
\SetKwFor{While}{while}{do}{end while}%
}{}%
%
% --- End
%}
%
%\algocf@defaults@common
%
% option onelanguage redefinition
%
\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{french}}{%
\SetKwInput{KwIn}{Entr\'ees}%
\SetKwInput{KwOutSortie}{Sorties}%
\SetKwInput{KwData}{Donn\'ees}%
\SetKwInput{KwResult}{R\'esultat}%
\SetKw{KwTo}{\`a}%
\SetKw{KwRet}{retourner}%
\SetKw{Return}{retourner}%
\SetKwBlock{Begin}{d\'ebut}{fin}%
\SetKwRepeat{Repeat}{r\'ep\'eter}{jusqu'\`a}%
%
\SetKwIF{If}{ElseIf}{Else}{si}{alors}{sinon si}{sinon}{fin si}%
\SetKwSwitch{Switch}{Case}{Other}{suivant}{faire}{cas o\`u}{autres cas}{fin cas}{fin d'alternative}%
\SetKwFor{For}{pour}{faire}{fin pour}%
\SetKwFor{ForPar}{pour}{faire en parall\`ele}{fin pour}%
\SetKwFor{ForEach}{pour chaque}{faire}{fin pour chaque}%
\SetKwFor{ForAll}{pour tous}{faire}{fin pour tous}%
\SetKwFor{While}{tant que}{faire}{fin tq}%
}{}%
\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{german}}{%
\SetKwInput{KwIn}{Eingabe}%KwIn
\SetKwInput{KwOut}{Ausgabe}%KwOut
\SetKwInput{KwData}{Daten}%KwData
\SetKwInput{KwResult}{Ergebnis}%KwResult
\SetKw{KwTo}{bis}%KwTo
\SetKw{KwRet}{zur\"uck}%KwRet
\SetKw{Return}{zur\"uck}%Return
\SetKwBlock{Begin}{Beginn}{Ende}%Begin
\SetKwRepeat{Repeat}{wiederhole}{bis}%Repeat
%
\SetKwIF{If}{ElseIf}{Else}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf
\SetKwSwitch{Switch}{Case}{Other}{unterscheide}{tue}{Fall}{sonst}{Ende Fall}{Ende Unt.}%Switch
\SetKwFor{For}{f\"ur}{tue}{Ende f\"ur}%For
\SetKwFor{ForPar}{f\"ur}{tue gleichzeitig}{Ende gleichzeitig}%ForPar
\SetKwFor{ForEach}{f\"ur jedes}{tue}{Ende f\"ur}%ForEach
\SetKwFor{ForAll}{f\"ur alle}{tue}{Ende f\"ur}%ForAll
\SetKwFor{While}{solange}{tue}{Ende solange}%While
}{}%
\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{portuguese}}{%
\SetKwInput{KwIn}{Entrada}%
\SetKwInput{KwOut}{Sa\'{i}da}%
\SetKwInput{KwData}{Dados}%
\SetKwInput{KwResult}{Resultado}%
\SetKw{KwTo}{at\'{e}}
\SetKw{KwRet}{retorna}%
\SetKw{Return}{retorna}%
\SetKwBlock{Begin}{in\'{i}cio}{fim}%
\SetKwRepeat{Repeat}{repita}{at\'{e}}%
%
\SetKwIF{If}{ElseIf}{Else}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
\SetKwSwitch{Switch}{Case}{Other}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim caso}{fim selec}%
\SetKwFor{For}{para}{fa\c{c}a}{fim para}%
\SetKwFor{ForPar}{para}{fa\c{c}a em paralelo}{fim para}
\SetKwFor{ForEach}{para cada}{fa\c{c}a}{fim para cada}%
\SetKwFor{ForAll}{para todo}{fa\c{c}a}{fim para todo}%
\SetKwFor{While}{enquanto}{fa\c{c}a}{fim enqto}%
}{}%
\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{italiano}}{%
\SetKwInput{KwIn}{Ingresso}%
\SetKwInput{KwOut}{Uscita}%
\SetKwInput{KwData}{Dati}%
\SetKwInput{KwResult}{Risultato}%
\SetKw{KwTo}{a}%
\SetKw{KwRet}{ritorna}%
\SetKw{Return}{ritorna}%
\SetKwBlock{Begin}{inizio}{fine}%
\SetKwRepeat{Repeat}{ripeti}{finch\'e}%
%
\SetKwIF{If}{ElseIf}{Else}{se}{allora}{altrimenti se}{allora}{fine se}%
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end case}{endsw}%
\SetKwFor{For}{per}{fai}{fine per}%
\SetKwFor{ForPar}{per}{fai in parallelo}{fine per}%
\SetKwFor{ForEach}{per ciascun}{fai}{fine per ciascun}%
\SetKwFor{ForAll}{per tutti i}{fai}{fine per tutti}%
\SetKwFor{While}{finch\'e}{fai}{fine finch\'e}%
}{}%
\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{spanish}}{%
\SetKwInput{KwIn}{Entrada}%
\SetKwInput{KwOut}{Salida}%
\SetKwInput{KwData}{Datos}%
\SetKwInput{KwResult}{Resultado}%
\SetKw{KwTo}{a}%
\SetKw{KwRet}{devolver}%
\SetKw{Return}{devolver}%
\SetKwBlock{Begin}{inicio}{fin}%
\SetKwRepeat{Repeat}{repetir}{hasta que}%
%
\SetKwIF{If}{ElseIf}{Else}{si}{entonces}{si no, si}{en otro caso}{fin si}
\SetKwSwitch{Switch}{Case}{Other}{seleccionar}{hacer}{caso}{si no}{fin caso}{fin seleccionar}
\SetKwFor{For}{para}{hacer}{fin para}%
\SetKwFor{ForPar}{para}{hacer in paralelo}{fin para}%
\SetKwFor{ForEach}{para cada}{hacer}{fin para cada}
\SetKwFor{ForAll}{para todo}{hacer}{fin para todo}
\SetKwFor{While}{mientras}{hacer}{fin mientras}
}{}%
%
\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{croatian}}{%
\SetKwInput{KwIn}{Ulaz}%KwIn
\SetKwInput{KwOut}{Izlaz}%KwOut
\SetKwInput{KwData}{Podatci}%KwData
\SetKwInput{KwResult}{Rezultat}%KwResult
\SetKw{KwTo}{do}%KwTo
\SetKw{KwRet}{vrati}%KwRet
\SetKw{Return}{vrati}%Return
\SetKwBlock{Begin}{po\v{c}etak}{kraj}%Begin
\SetKwRepeat{Repeat}{ponavljaj}{dok ne bude}%Repeat
%
\SetKwIF{If}{ElseIf}{Else}{ako}{onda}{ina\v{c}e ako}{ina\v{c}e}{kraj ako}%gIf
\SetKwSwitch{Switch}{Case}{Other}{granaj}{\v{c}ini}{slu\v{c}aj}{ostali slu\v{c}ajevi}{kraj slu\v{c}aj}{kraj granaj}%Switch
\SetKwFor{For}{za}{\v{c}ini}{kraj za}%For
\SetKwFor{ForPar}{za}{\v{c}ini paralelno}{kraj za paralelno}%ForPar
\SetKwFor{ForEach}{za svaki}{\v{c}ini}{kraj za svaki}%ForEach
\SetKwFor{ForAll}{za sve}{\v{c}ini}{kraj za sve}%ForAll
\SetKwFor{While}{dok}{\v{c}ini}{kraj dok}%While
}{}%
%
\ifthenelse{\boolean{algocf@optonelanguage}\AND\equal{\algocf@languagechoosen}{turkish}}{%
%
\SetKwInput{KwIn}{Girdi}%
\SetKwInput{KwOut}{\c{C}{\i}kt{\i}}%
\SetKwInput{KwData}{Veri}%
\SetKwInput{KwResult}{Sonu\c{c}}%
\SetKw{KwTo}{to}
\SetKw{KwRet}{return}%
\SetKw{Return}{return}%
\SetKwBlock{Begin}{begin}{end}%
\SetKwRepeat{Repeat}{repeat}{until}%
%
\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}%
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end switch}%
\SetKwFor{For}{for}{do}{end for}%
\SetKwFor{ForPar}{for}{do in parallel}{end forpar}
\SetKwFor{ForEach}{foreach}{do}{end foreach}%
\SetKwFor{ForAll}{forall}{do}{end forall}%
\SetKwFor{While}{while}{do}{end while}%
}{}%
%
%
%%%% old commands compatibility
%
\ifthenelse{\boolean{algocf@oldcommands}}{%
\newcommand{\SetNoLine}{\SetAlgoNoLine}%
\newcommand{\SetNoline}{\SetAlgoNoLine}%
\newcommand{\SetVline}{\SetAlgoVlined}%
\newcommand{\SetLine}{\SetAlgoLined}%
%
\newcommand{\dontprintsemicolon}{\DontPrintSemicolon}%
\newcommand{\printsemicolon}{\PrintSemicolon}%
\newcommand{\incmargin}[1]{\IncMargin{#1}}%
\newcommand{\decmargin}[1]{\DecMargin{-#1}}%
\newcommand{\setnlskip}[1]{\SetNlSkip{#1}}%
\newcommand{\Setnlskip}[1]{\SetNlSkip{#1}}%
\newcommand{\setalcapskip}[1]{\SetAlCapSkip{#1}}%
\newcommand{\setalcaphskip}[1]{\SetAlCapHSkip{#1}}%
\newcommand{\nlSty}[1]{\NlSty{#1}}%
\newcommand{\Setnlsty}[3]{\SetNlSty{#1}{#2}{#3}}%
\newcommand{\linesnumbered}{\LinesNumbered}%
\newcommand{\linesnotnumbered}{\LinesNotNumbered}%
\newcommand{\linesnumberedhidden}{\LinesNumberedHidden}%
\newcommand{\showln}{\ShowLn}%
\newcommand{\showlnlabel}[1]{\ShowLnLabel{#1}}%
\newcommand{\nocaptionofalgo}{\NoCaptionOfAlgo}%
\newcommand{\restorecaptionofalgo}{\RestoreCaptionOfAlgo}%
\newcommand{\restylealgo}[1]{\RestyleAlgo{#1}}%
%
\newcommand{\Titleofalgo}[1]{\TitleOfAlgo{#1}}%
% \SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}
\newcommand{\SetKwIf}[6]{\SetKwIF{#1}{#2#1}{#2}{#3}{#4}{#5 #1}{#5}{#6}}
%
\SetKwIF{gSi}{gSinonSi}{gSinon}{si}{alors}{sinon si}{sinon}{fin si}%
\SetKwIF{gIf}{gElsIf}{gElse}{if}{then}{else if}{else}{end if}%
\SetKwIF{gIf}{gElseIf}{gElse}{if}{then}{else if}{else}{end if}%
\SetKwIF{gWenn}{gSonstWenn}{gSonst}{wenn}{dann}{sonst wenn}{sonst}{Ende wenn}%gIf
\SetKwIF{gSe}{gSenaoSe}{gSenao}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
\SetKwIF{gSea}{gAltSe}{gAltrimenti}{se}{allora}{altrimenti se}{allora}{fine se}%
\SetKw{Ret}{return}%
\SetKwInput{Data}{Data}%
\SetKwInput{Result}{Result}%
}{%
\relax%
}%
%
%
%
%%
%%%
%%%% END
|