summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/toptesi/toptesi.dtx
blob: 3572289e173203dd998e2314a5b024d604633093 (plain)
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
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
% \iffalse meta-comment
% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
%<*internal>
\begingroup
\input docstrip.tex
\keepsilent


\preamble
  ______________________________________________________
  The TOPtesi bundle 
  Copyright (C) 2015-2019 Claudio Beccari 
  All rights reserved

  License information appended

\endpreamble
\postamble

Copyright 2005-2019 Claudio Beccari

Distributable under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt

For important further details see the English or the Italian 
documentation.

This work is "author-maintained"

This work consists of this file toptesi.dtx, a README file
the manifest.txt file, and the derived files: 
    toptesi.cls, 
    toptesi.sty, 
    topfront.sty, 
    topcommand.sty,
    toptesi-scudo.sty, 
    toptesi.cfg, 
    toptesi-monografia.sty,
    toptesi-sss.sty, 
    toptesi-magistrale.sty, 
    toptesi-dottorale.sty, 
and the English documentation toptesi.pdf.
 
Furthermore the bundle contains the documentation source
file toptesi-it.tex and the derived file 
toptesi-it.pdf.

The toptesi-example.tex source file is just an example 
that shows how to use the various commands; by commenting 
or uncommenting certain source lines it is possible to 
typeset different kind of theses and their front pages.

The topfront-example.tex source file is an example of how 
to produce just the title page with TOPtesi and the external
package frontespizio.

The toptesi-scudo-example.tex source file is an example 
that shows the particular features available with TOPtesi, 
when a doctoral thesis is produced for the Scuola di 
Dottorato (ScuDo) of Politecnico di Torino.

The toptesi.cfg file is a sample of a local configuration 
file that can be copied to another file and its copy freely 
edited and customised.

The other toptesi-*.sty files are extension modules for 
typesetting the specific thesis kinds described by the 
suffix that replaces the asterisk.

By running pdflatex on toptesi.dtx the user gets the class, 
sty and cfg files and the English documentation file in
PDF format.

The source file of the Italian documentation file 
toptesi-it.pdf is another example of how to use TOPtesi. 
This file toptesi-it.tex may be typeset with pdfLaTeX, 
XeLaTeX, and LuaLateX; see the first comment lines of 
the file for how-to information. In spite of being mainly
written in Italian, it contains several sections in English
for the benefit of foreign students attending the Doctoral 
School of Turin.
\endpostamble

\askforoverwritefalse

\generate{\file{toptesi.cls}{\from{toptesi.dtx}{class}}
          \file{toptesi.sty}{\from{toptesi.dtx}{topsty}}
          \file{topcoman.sty}{\from{toptesi.dtx}{topcmn}}
          \file{topfront.sty}{\from{toptesi.dtx}{topfrn}}
          \file{toptesi.cfg}{\from{toptesi.dtx}{topcfg}}
          \file{toptesi-scudo.sty}{\from{toptesi.dtx}{topscu}}
          \file{toptesi-monografia.sty}{\from{toptesi.dtx}{topmon}}
          \file{toptesi-sss.sty}{\from{toptesi.dtx}{topsss}}
          \file{toptesi-magistrale.sty}{\from{toptesi.dtx}{topmag}}
          \file{toptesi-dottorale.sty}{\from{toptesi.dtx}{topdoc}}
         }

\def\tmpa{plain}
\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
\endgroup
%</internal>
%
% Copyright 1989--2019 Claudio Beccari
%
% This file is part of the TOPtesi bundle
% -------------------------------------------
%
% It 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 2003/12/01 or later.
%
% This file has the LPPL maintenance status "author-maintained".
%
% The list of all files belonging to the TOPtesi bundle is
% given in the file `manifest.txt'.
%
% The set of derived (unpacked) files belonging to the distribution
% and covered by LPPL is created by the self unpacking file toptesi.dtx
% which is the principal part of the distribution.
%
% \fi
%
% \iffalse
%^^A The following trick uses the same date for every file header.
%<class,topsty,topcmn,topfrn,topscu,topmon,topsss,topmag>\NeedsTeXFormat{LaTeX2e}[2018/01/01]
%<*driver>
\ProvidesFile{toptesi.dtx}[%
%</driver>
%<class>\ProvidesClass{toptesi}[%
%<topsty>\ProvidesPackage{toptesi}[%
%<topcmn>\ProvidesPackage{topcoman}[%
%<topfrn>\ProvidesPackage{topfront}[%
%<topscu>\ProvidesPackage{toptesi-scudo}[%
%<topmon>\ProvidesPackage{toptesi-monografia}[%
%<topsss>\ProvidesPackage{toptesi-sss}[%
%<topmag>\ProvidesPackage{toptesi-magistrale}[%
%<topdoc>\ProvidesPackage{toptesi-dottorale}[%
%<*driver,class,topsty,topcmn,topfrn,topscu,topmon,topsss,topmag,topdoc>
2019-07-01 v.6.3.05 
%<class>Class for typesetting university theses]
%<topsty>Extension for toptesi.cls]
%<topcmn>Additional commands for the TOPtesi bundle]
%<topfrn>Title page for TOPtesi and other classes]
%<topscu>Extension for ScuDo theses]
%<topmon>Bachelor degree title page]
%<topsss>High school title page]
%<topmag>Master degree title page]
%<topdoc>Ph.D. degree title page]
%</driver,class,topsty,topcmn,topfrn,topscu,topmon,topsss,topmag,topdoc>
%<*driver>
]
%</driver>
%<*driver>
\documentclass{ltxdoc}
\GetFileInfo{toptesi.dtx}
\title{The TOPtesi bundle}
\date{\fileversion\space--- \filedate}
 \author{\makebox[\textwidth]{Claudio Beccari --- \texttt{claudio dot beccari at gmail dot com}}}
\usepackage[utf8]{inputenc}
\usepackage[LGR,T1]{fontenc}
\usepackage{metalogo,multicol,enumitem,xspace,
   xparse,curve2e,etoolbox,textcomp}
\let\originalmeta\meta
\renewcommand\meta[1]{{\normalfont\originalmeta{#1}}}
\def\prog#1{\textsf{#1}}
\def\pack#1{\textsf{\slshape#1}}
\def\env#1{\textit{#1}}\let\amb\env
\def\file#1{\texttt{#1}}
\def\marg#1{{\normalfont\texttt{\{}\meta{#1}\texttt{\}}}}
\def\Marg#1{{\texttt{\{#1\}}}}
\def\opz#1{{\normalfont\textsl{#1}}}
\def\oarg#1{{\normalfont\texttt{[\meta{#1}]}}}
\def\Oarg#1{{\normalfont\texttt{[#1]}}}
\def\parg#1{{\normalfont\texttt{(\meta)}}}
\def\Parg#1{{\normalfont\texttt{(#1)}}}
\def\TeXLive{TeXLive\xspace}
\def\pdfLaTeX{pdf\/\LaTeX\unskip\xspace}
\newcommand*\Bambiente[1]{\texttt{\char92begin}\Marg{#1}}
\newcommand*\Eambiente[1]{\texttt{\char92end}\Marg{#1}}
\DeclareRobustCommand\sigla[1]{\lowercase{\textsc{#1}}}
\newenvironment{ttsintassi}{\flushleft\ttfamily\obeylines}{\endflushleft}
%
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% Some macros to typeset a framed box of natural or specified
% width and height within the picture environment.
% Needs packages curve2e, etoolbox, and xparse.
% Syntax:
% \Zbox(<position>)(<dimensions>)[<alignment>]{<box contents>}
% The first and fourth arguments are mandatory; the second
% and third arguments are optional; their default values are
% (0,0) and [bl]. Furthermore the <position> and <dimension>
% values are a comma separated pair of numbers representing
% measures in \unitlength units, as well as it is done within the
% picture environment. No provision is coded to take the measure
% of the <box contents>. This contents should be some text, and when
% <dimensions> are specified larger than zero, a \parbox is used
% to typeset it. The <alignment> value(s) define the reference point
% that is \put at the <position> coordinates.
%
\def\TOPsplitArgs(#1,#2)#3#4{\edef#3{#1}\edef#4{#2}}

\NewDocumentCommand\Zbox{R(){0,0} D(){0,0} O{bl} m}{%
\TOPsplitArgs(#2)\ZboxX\ZboxY % separa la x e la y della scatola
\fboxsep=2\unitlength
\ifnum\ZboxX=\csuse{z@}
  \def\ZTesto{\fbox{#4}}%
\else
  \ifnum\ZboxY=\csuse{z@}
    \def\ZTesto{\fbox{\parbox{\ZboxX\unitlength}{#4}}}%
  \else
    \def\ZTesto{%
    \setbox2560=\hbox{\fbox{%
         \parbox[c][\ZboxY\unitlength][c]{\ZboxX\unitlength}{#4}}}%
      \dimen2560=\dimexpr(\ht2560 +\dp2560)/2\relax
      \ht2560=\dimen2560\relax 
      \dp2560=\dimen2560\relax
      \box2560%
      }%
  \fi
\fi
\put(#1){\makebox(0,0)[#3]{\ZTesto}}}

\NewDocumentCommand\fileicon{R(){0,0} m}{%
\put(#1){\moveto(0,-10)
\curveto(7.5,-10)(7.5,-7.5)(15,-7.5)
\lineto(15,10)
\curveto(7.5,10)(7.5,7.5)(0,7.5)
\lineto(0,-10)
\strokepath}\put(#1){\put(7.5,0){\makebox(0,0){\ttfamily#2}}}
}

\def\ifTOPnextchar{\csuse{@ifnextchar}}

\def\polyvector(#1){\def\TOPlastpoint{#1}\TOPpolyvector}

\def\TOPpolyvector(#1){\ifTOPnextchar({\segment(\TOPlastpoint)(#1)%
\def\TOPlastpoint{#1}\TOPpolyvector}{\VECTOR(\TOPlastpoint)(#1)}} % )


%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

\begin{document}\errorcontextlines=9
\maketitle
\begin{multicols}{2}
\tableofcontents
\end{multicols}
 \setlength\hfuzz{20pt}
 \DocInput{toptesi.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{7658}
%
% \begin{abstract}
% This file describes the TOPtesi bundle; it consists of a set of files
% designed to typeset  a university final report that in Italian
% is generally called “tesi”; it was originally developed at
% the Technical University of Turin (Politecnico di Torino) but
% it was adapted for typesetting theses in any Italian university.
% Well\dots\ since the Erasmus student mobility is very extended
% and many Italian students participate in the so called
% \textit{double degree} programs, their theses, or whatever they
% are called in other countries, may be typeset so as to comply
% also with the host university rules; therefore this set of
% files has the ambition to be suited for typesetting theses in
% any university in the world\dots\ This ambition can't be
% fulfilled, though, because of the complexity of the title
% page (and possibly of the legal page) requirements. This
% version is compliant with the \XeLaTeX\ and the \LuaLaTeX\ 
% programs. Up to now the few conflicts that have
% been spotted have been solved with suitable corrections or
% additions. The most important feature with \XeLaTeX\ is that
% the option \opz{pdfa} cannot be used any more; this is due to the
% fact that the typesetting engine \XeTeX\ does not directly
% produce any \sigla{PDF} output but a modified, extended DVI one,
% that is immediately converted into a \sigla{PDF} file through
% |xdvipdfmx|, a special version of the conversion program. Another
% minor \XeLaTeX\ feature is that it cannot fully exploit the
% typesetting facilities of the |microtype| package, but the wide
% choice of OpenType font properties replaces almost completely
% such missing |microtype| features.
%
% With version~6.xx, the bundle has been modularised in a (hopefully)
% more efficient way, although it is backwards compatible, so that
% version~5.xx functionalities are still available.
%
% A totally new module is the one that allows to typeset the Italian
% high school “tesina”, a document that is examined by the
% graduation exam committee at the end of secondary studies.
%
% The user should not be scared by the number of pages of this
% documentation; s/he should read part of the first 31 pages,
% those that concern his/her thesis. The rest is just the code
% and its documentation; it is useful mostly for me, as the
% author, and to other programmers and/or curious users.
% The “normal” user should not spend his/her time to read
% unnecessary information.
%
% \textcolor{red}{This bundle is distributed under the \LaTeX\ Project
% Public Licence (LPPL) which is appended to the Italian documentation
% file \texttt{toptesi-it.pdf} included in this bundle; personal
% customisation of parts of this bundle are discouraged but are
% permitted only in conformance with the LPPL. See also section~\ref{sec:LPPL}.}
% \end{abstract}
%
% \section{History}
% The TOPtesi bundle at its very beginning in the early nineties
% was just one |.sty| file to be used with the |report| class.
% At that time there was only \LaTeX{\,209} and extension
% packages were called “style files”; the |.sty| extension
% is still used today for backwards compatibility, but |.sty|
% files are not any more used to change the style of the document.
%
% With version 2.x, suitable for \LaTeXe, the bundle was
% modified in order to have a class of its own,
% |toptesi.cls|, which provided to collecting the necessary
% options and to pass them to the |report| class; it
% loaded the |toptesi.sty| just afterwords.
% The latter file was not monolithic any more; it was split
% in three parts: |toptesi.sty| contained most settings and
% the macros to be used in the body of the document;
% |topfront.sty| provided the commands for entering all the
% necessary and optional data for the frontispiece (or title
% page) and actually typeset the title page in different
% styles; |topcoman.sty| contained the definitions of several
% useful commands; actually this module could be used without
% reference to the TOPtesi bundle, being suitable as an
% extension to any class.
%
% The general scheme may be represented by the flow diagram
% in figure~\ref{fig:simple-flow-diagram}.
%\begin{figure}\centering
%\unitlength=0.00925\textwidth
%\begin{picture}(106,20)
%\fileicon(0,10){.tex}\VECTOR(15,10)(20,10)
%\Zbox(20,10)(18,0)[l]{\ttfamily toptesi.cls\\toptesi.sty}\VECTOR(41.5,10)(47,10)
%\Zbox(47,10)[l]{\ttfamily topfront}\VECTOR(63.5,10)(70,10)
%\Zbox(70,10)[l]{\ttfamily topcoman}\VECTOR(86.5,10)(91,10)
%\fileicon(91,10){.pdf}
%\end{picture}
%\caption{Quasi original TOPtesi bundle flow diagram}
%\label{fig:simple-flow-diagram}
%\end{figure}
%
% Version 3.x was modified, on request of several users, in
% order to avoid the |toptesi.cls| class file, but to allow
% the other files, from |toptesi.sty| on, to be used with
% any standard or custom class.
%
% On request of other users, after other upgrades, the bundle was
% upgraded to version 5.85; the purpose was to introduce the
% possibility of typesetting the thesis title page with a package
% totally independent from the TOPtesi bundle. In particular the
% |frontespizio| package by Enrico Gregorio was considered
% a fancy choice for most Italian users, but the new approach
% was open to any other package. The choice was made by
% setting suitable switches (boolean variables). The solution
% opened the bundle to other external contributions, although
% the mechanism was sort of tricky. The bundle was made
% compatible with other packages, for example |caption|
% and/or |geometry|, while before this change such packages produced
% options clashes and/or other errors, so that their use
% was explicitly forbidden. Meanwhile the |topfront| module
% was configured to be loaded just after the preamble end,
% so as to be able to check if the user loaded packages that
% required special attention in order to avoid conflicts;
% see figure~\ref{fig:toptesi+frontspizio}.
%
%\begin{figure}\centering\unitlength=0.009\textwidth
%\begin{picture}(115,45)(0,-3)
%\fileicon(0,10){.tex}\VECTOR(15,10)(20,10)
%\Zbox(20,10)(18,0)[l]{\ttfamily toptesi.cls\\toptesi.sty}
%\Zbox(20,30)(18,0)[l]{\centering\ttfamily user loaded\\packages}
%\VECTOR(42,10)(50,10)
%\VECTOR(31,23)(31,15)
%\polygon(50,10)(55,5)(60,10)(55,15)
%\polyvector(55,5)(55,0)(60,0)
%\Zbox(60,0)[l]{\ttfamily topfront}
%\polyvector(55,15)(55,20)(60,20)
%\Zbox(60,20)[l]{\ttfamily frontespizio}
%\VECTOR(42,30)(47,30)\put(49,30){\circle{4}}\VECTOR(51,30)(60,30)
%\polyvector(42,12)(49,12)(49,28)
%\Zbox(60,30)[l]{\ttfamily topcoman}
%\put(87,10){\circle{4}}\VECTOR(89,10)(95,10)
%\polyvector(84,20)(87,20)(87,12)
%\polyvector(77,0)(87,0)(87,8)
%\polyvector(77,30)(90,30)(90,15)(95,15)
%\fileicon(95,10){.pdf}
%\end{picture}
%\caption{Advanced TOPtesi bundle flow diagram}
%\label{fig:toptesi+frontspizio}
%\end{figure}
%
% Version 5.x introduced a new feature: the specific settings
% for the doctoral theses written at Politecnico di Torino
% (Technical Institute od Turin); after all the bundle was
% born in that university. The switching mechanism to select
% the various thesis title page settings still worked with
% suitable boolean variables, but it was becoming a little
% too clumsy.
%
% In order to put some order in this situation I decided to
% upgrade to version 6.x; the class options now use the
% \emph{key\,$=$\,value} syntax (of course the value
% |true| is the default setting for boolean variables).
% This allows to select the thesis type with a
% \emph{key\,$=$\,value} option, therefore the selection and
% configuration of the title page should be simpler than before.
%
% The new situation flow diagram is represented in
% figure~\ref{fig:key-value-option}; the diagram is
% complicated but, once selected  a specific option
% for the thesis type, the diagram reduces to a linear one.
%
%\begin{figure}[p]\centering
%\unitlength=0.010\textwidth
%\makebox[\textwidth]{\begin{picture}(112.5,140)
%\fileicon(0,33){.tex}
%\polyvector(15,33)(20,33)(20,48)(0,48)(0,58)(5,58)
%\Zbox(5,58)(18,0)[l]{\small\ttfamily toptesi.cls\\toptesi.sty}
%\VECTOR(27,58)(32,58)
%\put(36.5,57){\rotatebox[origin=Bl]{90}{%
%  \makebox(0,0){\fboxsep=2\unitlength
%    \framebox(116,9){\parbox[c][5\unitlength][c]{112\unitlength}%
%    {\centering Options\\\texttt{tipotesi\,=\,}\emph{value}}}}}}
%\VECTOR(41,6)(45,6)\Zbox(45,6)(25,0)[l]{%
%\centering\texttt{topfront} (\emph{default})}
%\VECTOR(41,22)(45,22)\Zbox(45,22)(31,0)[l]{\centering\texttt{toptesi-triennale}}
%\VECTOR(41,37)(45,37)\Zbox(45,37)(33,0)[l]{\centering\texttt{toptesi-magistrale}}
%\VECTOR(41,52)(45,52)\Zbox(45,52)(31,0)[l]{\centering\texttt{toptesi-dottorale}}
%\VECTOR(41,67)(45,67)\Zbox(45,67)(31,0)[l]{\centering\texttt{toptesi-scudo}}
%\VECTOR(41,81)(45,81)\Zbox(45,81)(32,0)[l]{\centering\texttt{toptesi-sss}}
%\VECTOR(41,96)(45,96)\Zbox(45,96)(32,0)[l]{\centering\texttt{frontespizio}}
%\VECTOR(41,111)(45,111)\Zbox(45,111)(32,0)[l]{\centering\texttt{custom}}
%\Zbox(5,129.5)(18,0)[l]{\centering\ttfamily user loaded\\packages}
%\VECTOR(16,125)(16,63)
%\VECTOR(27,129.5)(35,129.5)\put(37,129.5){\circle{4}}
%\VECTOR(39,129.5)(45,129.5)
%\Zbox(45,129.5)(16,0)[l]{\centering\ttfamily topcoman}
%\polyvector(27,61)(29,61)(29,120)(37,120)(37,127.5)
%\put(90,67){\circle{4}}\VECTOR(92,67)(97.5,67)
%\polyvector(65,129.5)(93,129.5)(93,70)(97.5,70)^^A topcomand
%\polyvector(81,111)(90,111)(90,69)^^A custom
%\polyvector(81,96)(88,96)(88,72)(89,68.4)^^A frontespizio
%\polyvector(81,81)(86,81)(86,70)(88.4,68.2)^^A secondaria
%\VECTOR(80,67)(88,67)^^A scudo
%\polyvector(80,52)(86,52)(86,63)(88.4,65.6)^^A dottorale
%\polyvector(82,37)(88,37)(88,60)(89,65.2)^^A magistrale
%\polyvector(80,22)(90,22)(90,65)^^A triennale
%\polyvector(74,6)(92,6)(92,62)(91,65.1)^^A topfront
%\fileicon(97.5,68.5){.pdf}
%\end{picture}}
%\caption{Version 6.x TOPtesi bundle flow diagram}
%\label{fig:key-value-option}
%\end{figure}
%
% Special care was paid to maintain backwards compatibility;
% the various |.sty| module-files (with descriptive names)
% should be usable also with other classes, if desired.
% It is possible to specify a |custom| value for a thesis type; 
% in this case the user is required to explicitly load his/her
% personal package, or to avoid loading anything and use
% either a different typesetting program to produce a title
% page (in \sigla{pdf} format to be included by means of
% the |pdfpages| package), or even create his/her personal
% title page by means of the standard |titlepage| environment.
%
% All this implied the rewriting of both the English and
% Italian documentation files; the user can find useful
% information in the English file |toptesi.pdf| included
% in the bundle; this file is pretty lengthy because it
% contains also the documented code. The Italian documentation
% in |toptesi-it.pdf|, is also part of this bundle; it is
% partly written in English for the benefit of the many foreign
% students that study in the doctoral school of Politecnico di
% Torino; it contains many examples enriched with graphic
% “demonstrations”. These two documentation files complement
% one another.
%
% \section{Introduction}
% The new TOPtesi bundle contains a certain number of files.
% \begin{enumerate}[noitemsep]
% \item
%   A class file \texttt{toptesi.cls} to be used as the main
%   document class; the main document may be any of a certain
%   number of reports that in Italy are called with various names:
%   “monografia”, “monografia di laurea”, “tesi di laurea”,
%   “tesi di laurea triennale”, “tesi di laurea specialistica”,
%   “tesi di laurea magistrale”, “tesi di dottorato”,
%   “dissertazione di dottorato”, and so on.
%   All these documents have in common the fact that they all
%   conclude a period of university education. Moreover since they
%   may conclude a double degree university program, they may receive
%   foreign names such as, for example, “Projet de fin d'\'etudes”,
%   “Master thesis”, and the like.
% \item
%   An extension package \texttt{toptesi.sty} that contains most
%   of the code for the real typesetting; it might be used as an
%   extension to other classes, although this use is seldom necessary.
% \item
%   A second extension package \texttt{topfront.sty} that contains
%   the commands and the typesetting macros for the title page; this
%   file may be used as an independent extension package to be added
%   to, say, the report or the book class files for typesetting just
%   the title page; this file might be used as a template for setting
%   up the title page fixed information in languages different from
%   Italian. This package is part of the bundle, but it is
%   automatically loaded only if the user did not specify the
%   |tipotesi=|\meta{thesis type} option to the class; if the
%   |toptesi=frontespizio| option is specified, the external package
%   |frontespizio| gets loaded; if the |toptesi=custom| option is
%   specified the user should do everything by him/herself.
%   The |tipotesi=custom| is very tolerant; in the sense that the user
%   is allowed to avoid loading any custom package, and simply create
%   the title page by means of the standard |titlepage| environment.
%   The available thesis kinds are the following; for each value of
%   the |tipotesi|key e differnet titlepage is typeset as the following
%   list specifies.
%  \begin{itemize}[noitemsep]
%    \item \opz{tipotesi=triennale} (or \opz{monografia} for
%          backwards compatibility) for the bachelor degree final work;
%    \item \opz{tipotesi=magistrale} for the master thesis;
%    \item \opz{tipotesi=dottorale} for a generic  Ph.D.\ thesis;
%    \item \opz{tipotesi=scudo} for the special version of the Ph.D.\
%          thesis at Politecnico di Torino;
%    \item \opz{tipotesi=secondaria} for the high school “tesina”;
%    \item \opz{tipotesi=custom} for using another title page package,
%    	 possibly  a customised one the user may create in
%    	 accordance with a certain template that implements his/her
%    	 university requirements.
%     \item \opz{tipotesi=frontespizio} for typesetting a
%    	 title page according to the style of the |frontespizio| package.
%  \end{itemize}
%   The user who needs a different title page  style is neither
%   obliged to create a custom module, nor to create his/her title
%   page “by hand” within the |titlepage| environment: before this
%   decision we suggest to use the package |frontespizio| and we
%   address the user to its documentation.
%  
%   It is important to recall that if the |topfront| package has
%   to be loaded, it is only at the execution of the |\begin{document}|
%   command. Therefore no title page commands of any kind (those
%   defined by |topfront| or by the other modules) can be used in the
%   preamble.
% \item
%   A third extension package \texttt{topcoman.sty} that defines
%   a certain number of user commands suitable for typesetting
%   technical matters.
% \item
%   Several  extension files are available by means of the
%   |toptesi=|\meta{module} option. They share the \meta{module}
%   name in the form \texttt{toptesi-\meta{module}.sty}.
%   The \meta{module}  may assume the following values:
%     \begin{itemize}
%      \item |monografia| or |triennale|, 
%      \item |magistrale|, 
%      \item |dottorale|,
%      \item |scudo|,
%      \item |sss|. 
%     \end{itemize}
%   These modules are specifically designed to typeset particular
%   thesis kinds; |scudo| refers to the particular doctoral school
%   of Politecnico di Torino, whose official name is \emph{Scuola di
%   Dottorato}, whence the acronym “ScuDo”. Such ScuDo theses must
%   be typeset only in English, and must have a special title page,
%   very different from the other ones that can be typeset with
%   the various options of the TOPtesi bundle, and by the
%   commands contained in the  various modules. In all cases where
%   specific modules exists, a specific module switch is set such
%   that \texttt{topfront.sty} does not get loaded, and
%   another set of commands is made available to set up
%   the necessary information.
% \item
%   Previous versions of this bundle contained also the logos of
%   a set of universities; these logos are not distributed anymore
%   because of legal constraints. Every user who is working on
%   his/her degree course final report may retrieve the logo of
%   his/her university, but s/he should pay attention to use it in 
%   accordance with the rules and limitations of the university.
% \item
%   A documentation file \texttt{toptesi-it.pdf} written mostly
%   in Italian, explains in detail every feature; essential information
%   is given in this Italian documentation. The source file of the
%   documentation \texttt{toptesi-it.tex} may be used as a sample
%   or template for typesetting one's thesis with any of \pdfLaTeX,
%   \XeLaTeX, or \LuaLaTeX.
% \end{enumerate}
%
% The above files are complemented with a configuration file
% that any user may customise at will; this customisation file
% makes it easy to configure the bundle so as to make it suitable
% for another language; in facts the \textsf{babel} and
% \textsf{polyglossia} packages contain localisations for many
% languages, but such localisations deal with the standard infix
% \LaTeX\ names and phrases and do not cope with the thesis
% title page requirements. This configuration file is usable only
% when no custom or external files are used for typesetting
% the title page; but they may be used for all standard modules
% of this bundle.
%
% TOPtesi was specifically conceived for typesetting theses
% with the \LaTeX\ mark-up, and initially it was using the
% \textsf{tex} typesetting engine; later on this engine was
% substantially substituted by the \textsf{pdftex} one, which
% was capable of direct output of \sigla{PDF} files. Since about 2006
% the typesetting engine \XeTeX\ has been available; the most important
% feature of this engine is its capability of using OpenType
% fonts, among which those that are available to the
% operating system of the specific platform where the document
% is being typeset.  Since 2017 a stable version of \LuaTeX\ is
% available that does much more than \XeTeX.
%
% For what concerns theses these programs might be of essential
% importance when they deal with specific languages that use
% different scripts (Greek, Russian, Bulgarian, Chinese, Japanese,
% Korean, Hebrew, Arabic, Farsi, Thai, and so on). Of course
% \LuaLaTeX\ has many more functionalities and can perform very
% well where the other engines are sort of limited; in particular
% \LuaLaTeX\ can produce \sigla{ISO}-compliant archivable-documents more
% easily than the other typesetting engines; but the user does not
% have to learn too many more concepts in order to typeset a 
%“normal” thesis.
%
% This version of TOPtesi has been tested also with \XeLaTeX\ and
% \LuaLaTeX. Some conflicts have been spotted and solved; may
% be there are still hidden ones, so that feedback from users
% is particularly welcome. The only main drawback still present
% when running \XeLaTeX\ is the fact that this program cannot still
% \emph{directly} produce the output file in \sigla{PDF} format,
% although it automatically transforms its specific output file
% into that format.
% This implies that the specific \textsf{pdftex} features required
% to produce a \sigla{PDF/A} compliant output \sigla{PDF} file suitable for
% long term archiving cannot be used. But with some attention the
% \sigla{PDF} file output by \XeLaTeX\ may be converted to \sigla{PDF/A}
% by using the \pack{pdfpages} package.
%
% \section{User commands}
% The \texttt{toptesi.cls} is basically an extension of the
% standard class \texttt{report.cls}; it redefines the page
% typesetting grid, the headers and the footers, and the title
% page layout and commands. \texttt{toptesi.cls} does not set
% such crazy settings as “double spaced” text; it is intended
% to typeset the thesis with the quality of a \LaTeX\ well typeset
% document, not as a typewriter written one.
%
% Very often theses are full of specialised material: formulas,
% diagrams and pictures, texts written in non Latin alphabets,
% special symbols for philological mark-up, and the like; a
% common typewriter would not be suitable because the specific
% contents requires professional typesetting; this is why
% I strongly believe that instructions on typesetting styles that
% refer to the “good, old, gone-by times” of mechanical typewriters
% should be banned.
%
% At the same time the class allows to typeset theses on any paper
% format; nowadays, in facts, Universities are requesting theses
% in smaller formats than A4 or letter paper. With smaller paper
% sizes the layout changes automatically, but the title page might
% require some more attention. The default paper size is A4, but
% the user can set any paper size among those accepted by the
% |report| standard class. If the \opz{tipotesi=frontespizio}
% option is specified so that package |frontespizio| gets
% loaded, it is necessary to remind that it can easily create
% pretty nice title pages, but by default it is preset to use A4
% paper, onto which it can typeset the title page in two styles, one so
% called “standard”, and the other called “elements”; the latter one
% mimics that of the famous book \emph{Elements of typographic
% style} by Robert Bringhurst; this is so at least with
% |frontespizio| version dated 2011/09/21 or earlier. It is
% possible to use |frontespizio| to use a different paper size,
% but it is necessary to use certain customisation commands
% described in its documentation.
%
% Therefore if you want to typeset your thesis while typesetting
% the title page by means of the functionalities of package
% |frontespizio|, you have to follow carefully how to use that
% package options in the proper way as to bypass the two fixed
% styles it can produce. See also the Italian documentation
% contained in the document |toptesi-it.pdf|.
%
% Most new commands refer themselves to the information that should
% be typeset in the title page; some class options specify special
% stylistic page details; the rest is simple and traditional
% \LaTeX\ mark-up as it is implemented in the \LaTeX\ kernel and
% in the report class. If \XeLaTeX\ or \LuaLaTeX\ has to be used,
% some essential preamble specific commands are to be used, but
% the body of the thesis has the same mark-up.
%
% For theses to be typeset for the ScuDo doctoral school,
% all necessary commands become available when the class
% option \opz{tipotesi=scudo} is specified; such commands are
% available \emph{only} with that option. 

% Notice that only the ScuDo module of TOPtesi contains a setup
% for typesetting the bibliography. For other thesis kinds
% the user is in charge of loading the suitable extension
% packages s/he likes best in order to customise his/her
% bibliography/ies. Instructions for customisation are given
% only in the specific section~\ref{sec:scudo}. Other suitable
% sections describe the other special thesis modules and their
% specific options. 
%
% \subsection{Class options}
% The class honors all the options accepted by the |report|
% document class plus the ones defined here:
% \begin{description}[noitemsep]\def\Item[#1]{\item[\opz{#1}]}
% \Item[chapterbib] Allows to typeset a list of references at the
% end of each chapter and the bibliography items are numbered with
% a \emph{chapter.item} indication. This implies a manual build
% up of each end-of-chapter bibliography by means off a specific
% |thebibliography| environment. This work may be avoided if the
% user relies on the various packages already available in any
% complete \TeX\ system distribution and the facilities offered
% by packages such as \pack{biblatex}, and on the sorting and formatting
% engines such as \prog{biber}. The use of this option, retained for
% backwards compatibility, is strongly deprecated.
%
% \Item[stile=classica] Specifies a general modification of certain
% details that are supposed to be more adequate for theses in
% humanities; specifically this option lets old style numbers to
% be used for some numerical pieces of information; some variations
% are also introduced in the title page. This option is active also
% when using some of the modules for specific theses, in particular
% with the |dottorale| thesis option.
%
% \Item[cucitura=\meta{displacement}]  In two sided printing
% it is better to move the typesetting grid towards the outer
% edge so as to cope with the thesis binding that is generally
% not made up by sewing together a number of signatures; the
% default outer displacement is fixed to~7mm, but it can be
% customised by means of a proper value to the class option
% |cucitura=|\meta{displacement} or by using  an explicit command
% in the preamble: \cs{setbindingcorrection}\marg{displacement}.
% The \meta{displacement} specification is necessary but it
% remains inactive if the key \texttt{cucitura} is absent while
% using the \cs{setbindingcorrection} command.
%
% \Item[corpo=\meta{font size}] Extends the normal size
% choice to the chosen \meta{font size}; it is
% appreciated in certain fields of humanities, but I would
% discourage this use in a technical thesis, where the default
% 10 point size sometimes might be too small, but 11 point or
% 12 point typesetting may be adequate. In any case the
% \meta{font size} may be specified in any units the \TeX\ 
% system accepts, and any value, even fractional, may be used.
% Please, do not exaggerate with small sized normal fonts, where
% I would say that 9.5pt is the absolute minimum acceptable size
% for normal text. Do not exaggerate with large sizes; 14pt is
% acceptable for certain theses where unusual signs are
% used above or below some alphabetic strings, otherwise 14pt
% is already too much; let us say that 12.5pt or 13pt are
% the maximum normally accepted; larger sizes are used only
% for books to be used in the first years of the elementary
% school or for people with various types of visual impairment. 
%
% \Item[autoretitolo] This option modifies the left hand (even
% numbered) pages in two side typesetting; normally the even
% numbered page headings contain the chapter title, while the
% odd numbered ones contain the current section title.
% If and only if the \opz{classica} option has been specified, then
% the |autoretitolo| option makes even  numbered page headings
% contain the author's name and the thesis title, while the odd
% numbered ones contain the chapter title.
% Since the thesis title might be too long to fit into the header
% together with the author's name, the |\title| macro as been
% redefined so as to accept an optional short title: this feature
% mimics  the ordinary sectioning commands.
%
% \Item[oldstyle] Also this option works only if \opz{classica}
% had already been specified; it typesets several numerical data
% with the old style numbers.
%
% \Item[numerazioneromana] Sets the front matter folios in Roman
% numerals; if this option is not used, the folios are in Arabic
% numerals and do not restart from~1 when the first main matter
% chapter is typeset. The traditional Roman numbering of front
% matter folios had its explanation when typesetters used metal
% type; with this technique they could produce all the front
% matter material, including references, tables of contents, and
% the like, only when the main matter was complete, corrected
% and stable. Nowadays with electronic typesetting there is no
% need to to use this artifice, but in some disciplines it is
% still considered an elegant touch.
%\end{description}
%
% Since version 6.xx.yy options to the TOPtesi class follow the
% syntax \emph{key${}={}$value}; depending on the kind of thesis
% there there are some values that are particularly significant;
% the key for all of them is |tipotesi| (\emph{thesis kind});
% the values are indicated hereafter.
%
%\begin{description}[noitemsep]\def\Item[#1]{\item[\opz{#1}]}
%
% \Item[tipotesi-topfront] is the default and it is not necessary
% to specify it. This means that if you specify |tipotesi| without
% a value, or if you completely omit this option, the generic
% |topfront| module is used to typeset the title page.
%
% \Item[tipotesi=frontespizio] omits loading the generic module
% |topfront| and loads the external package |frontespizio|'
% without any option; this implies that the user should read its
% documentation and use it accordingly.
%
% \Item[tipotesi=scudo] sets up the suitable switches and allows
% loading the specific extensions to typeset doctoral theses for
% the ScuDo doctoral school. This implies that not only the title
% page is typeset according to this School regulations, but that
% some other packages get preloaded; the user can read further
% on what actually becomes available with this option; the most
% relevant difference is that the default language becomes English
% also for the naming of the user commands.
%
% \Item[tipotesi=triennale] and \opz{tipotesi=monografia}
% (aliases of one another)  load the specific module to
% typeset the bachelor degree final-work title-page. Some
% user commands are redefined so as to be more user friendly
% than those of the generic package |topfront|.
%
% \Item[tipotesi=magistrale] loads the specific module
% to typeset the master degree thesis title-page. This module
% is substantially equivalent to the generic module |topfront|
% except that typesets only the master-degree thesis title-page.
%
% \Item[tipotesi=dottorale] loads the specific
% module to typeset doctoral thesis title-pages. This module is
% very basilar and has nothing to do with the module for the
% ScuDo doctoral theses that require a particular title-page
% layout; we suggest to customise this module through a suitable
% configuration file, rather than tweaking the ScuDo module.
%
% \Item[tipotesi=secondaria] loads the module to typeset the
% secondary school (high school) final work title page. The
% default language, also for the user commands, is Italian.
% Of course the secondary school final work title page is very
% different from the one suited for university theses. In any
% case, except for few additional packages, the body of the
% TOPtesi functionality is maintained intact.
%
% \Item[tipotesi=custom]
% is a very simple option: sets the various internal switches
% so as not to load any internal module or external file.
% If the user explicitly loads one before the |\begin{document}|
% statement, this file becomes the one that the user must follow
% to create his/her own title page; otherwise if the user wants
% a custom title page s/he may use the |titlepage| environment;
% in this case the user is completely free to write what s/he
% wants, where s/he prefers, using the fonts s/he likes, and
% so on. In alternative the user prepares the title page in
% \sigla{pdf} format with some other program and includes it
% in his/her thesis by means of the functionalities of the
% |pdfpages| package. In any case the user is not forced by
% this TOPtesi bundle to use any of its title page facilities;
% its title page facilities are highly recommended for theses
% to be submitted to the Student Office of Politecnico di Torino,
% and for the ScuDo doctoral theses; in other universities and
% in disciplines different from those connected with Politecnico
% di Torino, the user is free to follow his/her University
% prescriptions without any constraint by the TOPtesi bundle.
%
% \item[Attention!] It goes by itself that each one of the last
% options does not load the generic module |topfront|, therefore
% the commands provided by this standard module are not available
% any more. Every effort has been made in the various modules to
% maintain the same commands, but in certain thesis kinds they
% might behave differently than expected. 
%
% The user therefore is strongly urged to consult the documentation
% files, both |toptesi.pdf| and |toptesi-it.pdf|, in order to
% avoid problems with commands that are not suited for a particular
% thesis type. Please examine also the examples that accompany
% this bundle
% \end{description}
%
% \subsection{Title page commands}
% Note: Skip this section if you decide to load an external
% package, such as, for example, |frontespizio|, for typesetting the
% title~page. Notice also that if you want to load an external
% package for this task, you should load it \emph{after}
% specifying the input encoding you use for your text files.\bigskip
%
% \noindent The user must specify a certain number of commands
% in order to have the title page contain all the required
% information. It must be specified that most of these commands
% may be used in the configuration file so as to avoid repeating
% the same data for different “final reports”: a university
% student might write a bachelor's “monografia”, then a master
% thesis and finally a doctoral dissertation;  why should s/he
% repeat his/her name, the name of the institution, and so on?
%
% Many user commands for the title page redefine default
% values or strings; they are particularly usefull when the thesis is
% typeset in a different language; if none of the required information
% is given, the default values and strings are typeset, possibly
% with hilarious results\dots
% 
% Except for the self made customised module for the title-page,
% all the modules accept the same commands as those available in
% the |TOPfront| module. Pay attention, though, that some commands are
% meaningless in certain theses, therefore do not reverse the
% statement: for example the doctoral cycle command (|\cycle|)
% is meaningless in a bachelor degree final-work title-page.
%
% Since most users are supposed to be Italian, the user commands
% are mostly in Italian; the following description gives their
% names and meanings; every command receives one argument; only
% the command |\title| accepts an optional argument according to
% the usual \LaTeX\ syntax:
% \[
%   \makebox[0pt]{%
%  \texttt{\char92}\meta{command}\oarg{opt-arg}\marg{req-arg}\relax
%               }
% \]
% Since the only language allowed in the ScuDo doctoral thesis is
% English, all its commands are in English; this was done to help
% the high number of foreign Ph.D.\ students in that school.
% Therefore, for example, the general environment |frontespizio|
% becomes |ThesisTitlePage|\footnote{Actually
% \texttt{ThesisTitlePage} is a wrapper to a particular instance
% of environment \texttt{frontespizio}. Similar wrappers are
% defined in the other specific thesis modules.}. Except this
% module, and, possibly, the personal customised module, the
% other ones use mostly the same commands for the same purposes.
%
% \begin{description}[noitemsep]
% \def\cs#1{\texttt{\char92#1}}
% \def\Item[#1]{\item[\normalfont\cs{#1}]}
%^^A
% \item[\textnormal{\ttfamily frontespizio}] and
% \texttt{frontespizio*} are two environments that typeset the
% title page with two opposite styles: with the university logo
% in the header vs the university logo in the lower part of the
% front page. The commands described in the following items shall
% be used either in the configuration file or within the body of
% these environments.
%
% \Item[frontespizio] {\tolerance=6000 Even if the above
% environments are strongly recommended, the command
% |\frontespizio|, defined in the previous versions of the
% TOPtesi bundle, is still usable. It typesets the title page
% according to the actual status of the boolean |\topTPTlogos|;
% the user, before issuing the |\frontespizio| command, may set
% this boolean by means of the |\topTPTlogostrue|
% or |\topTPTlogosfalse|, or with either one of the commands
% |\booltrue{topTPTlogos}| and |\boolfalse{topTPTlogos}|.\par}
%
% \Item[monografia]  sets the bachelor's report style and retrieves
% its title; the command\cs{titolo} that is not available for this 
% purpose with the standard module |TOPfront|, is available when
% the specific module has been loaded by means of the
% \opz{monografia} or \opz{triennale} options.
%
% \Item[titolo]  gets the master or PhD thesis title and an
%  optional thesis short title.
%
% \Item[sottotitolo]  gets the thesis subtitle if any.
%
% \Item[materia] gets the name of the discipline the thesis deals with.
%
% \Item[Materia]  alias for \cs{materia}.
%
% \Item[direttore] gets the name of the Doctoral School Director.
%
% \Item[coordinatore]  gets the name of the Doctoral School
%                 Coordinator
% \Item[QualificaDirettore]  gets the phrase that describes the
%                 director or coordinator official position; by
%                 using the command \cs{direttore} the default phrase
%                 “Direttore della Scuola di Dottorato” is printed
%                 above the “director's” name; if \cs{coordinatore}
%                 is used the default phrase “Coordinatore della
%                 Scuola di Dottorato” is printed instead.
%                 If neither one is applicable or a description 
%                 in another language is required, this macro is
%                 available for specifying such position.
%
% \Item[relatore]  gets the name of the thesis principal supervisor.
%
% \Item[secondorelatore] gets the name of the second supervisor,
%                 if any.
% \Item[terzorelatore]  gets the name of the third supervisor,
%                 if any; it is assumed that the number of 
%                 supervisors never exceeds three; in case follow
%                 one of the tricks exemplified
%                 in the example file \file{toptesi-example.tex} in
%                 order to manage such situation.
% \Item[tutore]   gets the name of the doctorate tutor; there is no
%                 difference with regards to the \cs{relatore}, but
%                 the default phrase “Tutore” is printed above this
%                 person's name.
% \Item[TutorName]  gets the phrase that describes the tutor
%                   position, possibly in a different language.
% \Item[AdvisorName] gets the string that qualifies the
%                   supervisor(s); the default string
%                   is “Relatore:” or “Relatori:” for the plural;
%                   in another language this command is used to
%                   define the string, say, “Supervisors:” if the
%                   thesis has been supervised by more than one
%                   person.
% \Item[CoAdvisorName] gets the string that qualifies the 
%                   co-supervisor(s); the default string is
%                   “Correlatore:” or “Correlatori:” in the
%                   plural; this command may be used to define the
%                   string, say, “Corapporteur:” in a French Projet
%                   de fin d'\'etudes. This command may be used also
%                   for setting an Italian singular name when the
%                   tricks exemplified in file
%                   \file{toptesi-example.tex} are used.
% \Item[candidato]  gets the name and surname of a male author (M).
% \Item[candidata]  gets the name and surname name of a female author (F).
% \Item[secondocandidato] gets the name and surname of the second M author.
% \Item[secondacandidata] gets the name and surname of the second F author.
% \Item[terzocandidato] gets the name and surname of the third M author.
% \Item[terzacandidata] gets the name and surname of the third F author;
%                   most often the thesis author is just one person;
%                   but there are some institutions where group final
%                   works are accepted; it is assumed that the group
%                   does not contain more than three authors. The
%                   specification of the gender allows the software
%                   to determine the correct labelling phrase in
%                   the proper gender and proper number.
%                   For different languages there might be no
%                   difference in gender but there is a difference 
%                   in plural.
% \Item[CandidateName]  gets the string that describes the student
%                   status in a foreign
%                   language or even in Italian; the default string
%                   is `Candidato:” (with colons) adjusted to
%                   masculine or feminine, singular or plural; with
%                   option \opz{classica} the string becomes
%                   “Laureando:”; in other languages it is
%                   necessary to specify this string in the proper
%                   gender and number.
% \Item[sedutadilaurea] gets the date of the final exam, or
%                   presentation, or defence of the thesis; if this
%                   date is omitted the default date is the current
%                   month and year in the current language (generally
%                   Itallian).
% \Item[esamedidottorato] an alias for \cs{sedutadilaurea} to be used
%                   for doctoral dissertations.
% \Item[ciclodidottorato]  gets the roman numeral that specifies
%                   the doctoral cycle.
% \Item[CycleName]  redefines the string that expresses the name of
%                   the doctoral cycle; by default this is “ciclo”
%                   but this command is useful to set the name in a
%                   different language.
% \Item[corsodilaurea] gets the proper name of the degree course;
%                   the phrase that describes the degree course is
%                   specified, if necessary, with the next command;
%                   with this one you specify just, say,
%                 “Electrical Engineering”.
% \Item[CorsoDiLaureaIn]  gets the generic name of the degree course,
%                   for example “Bachelor Degree in”.
% \Item[TesiDiLaurea] gets the generic phrase that describes the
%                   thesis; by default it is “Tesi di Laurea”; in
%                   English one might set it to “Master Thesis”.
% \Item[NomeMonografia]  gets the phrase that describes the
%                   bachelor's report; by default it is “Monografia
%                   di Laurea”. In some Italian universities
%                   it might be called
%                   “Tesi di Laurea”, so that the master thesis
%                   should be given another qualification, for
%                   example “Tesi di Laurea Magistrale”.
% \Item[NomeDissertazione] gets the phrase that describes the
%                   doctoral thesis; by default it is “Tesi di
%                   Dottorato”.
% \Item[InName]     infix strings often require adjusting of the
%                   prepositions; this macro gets the preposition
%                   that stands for “in” (the default). In German
%                   it might become “auf”.
% \Item[NomeAnnoAccademico] defines the infix string that stands for
%                   “Academic year”. This macro is defined only if
%                   the option \opz{classica} is in force;
%                   after all the command |\annoaccademico| is
%                   defined only with that option. In any case, even
%                   without the \opz{classica} option you can use
%                   any string in the field of \cs{sedutadilaurea}.
% \Item[logosede]   specifies the name of the file or the files that
%                   contain the university logos; no  default is
%                   defined; rather a warning message is issued if
%                   no name is given or the file is missing, but
%                   typesetting goes on without the inclusion of any
%                   logo. A list of logos can be specified, useful
%                   when a thesis is carried on in a multiple
%                   University environment such as, for example, in
%                   a double degree Erasmus program; or under the
%                   Erasmus Mundus program. The “string” of
%                   logos is scaled properly so that they may fit
%                   in |\textwidth|.
% \Item[setbindingcorrection] sets up the length to displace the text
%                   block to the external margin so as to have a
%                   wider internal margin to accommodate the binding
%                   correction. Its argument is not optional and is
%                   used to modify the default correction of 7\,mm.
%                   Notice that 7\,mm is already a large 
%                   displacement; most often than not the binding
%                   correction is unnecessary.
% \Item[retrofrontespizio] with its argument, made up of one or more 
%                   paragraphs, defines what should be printed on the
%                   verso of the title page, generally named
%                   “copyright page”; if this command is specified
%                   with an empty text or if it is not used at all,
%                   no copyright page is assumed.
% \end{description}
%
% Since the infix strings are all memorised into control sequences
% and for each of them it is possible to use a defining command,
% all strings can be modified at will, so that there is no
% difficulty to localise the package in another language; this
% comes particularly handy for the Erasmus students on double
% degree programs.

% As a final remark notice that the commands for typesetting the
% title page and the copyright page are contained in the 
% package \texttt{topfront.sty}, which can be used as an autonomous 
% extension to the \texttt{report} document class. One could easily
% typeset either just the title page with a separate \TeX\ source
% so as to test the completeness of the commands and coherence of the 
% configuration file, or for just printing the isolated title and 
% copyright pages (if any). The same applies if you use the special
% modules for each thesis type.
%
% \section{ScuDo doctoral theses}\label{sec:scudo}
% Theses at the ScuDo doctoral school require special facilities
% that are described in the code description section; here we
% focus on the title page.
%
% \subsection{The ScuDo titlepage}
% The title page for such special theses is typeset by making
% use of a specific environment within which the following
% commands are available to set up the necessary information.
% \begin{description}[noitemsep]
% \def\cs#1{\texttt{\char92#1}}
% \def\Item[#1]{\item[\normalfont\cs{#1}]}
%
% \item[\normalfont\ttfamily ThesisTitlePage] is the environment
% within which the title page data are specified; some data are
% preset to default values; some data receive global definitions
% so that they remain available for setting up some metadata.
% In the following every command with its argument is described
% and it is specified which is the preset value, if any. If a
% preset value is specified, the user does not need to use the
% command, unless s/he wants to change the preset value. If an
% empty preset value is specified, the command and its value
% may be optional; but personal data are never preset because,
% obviously, they are mandatory.
%
% \Item[PhDschoolLogo]\marg{logo file name} (preset: Logo-Scudo) 
% selects an image
% specified by \meta{logo file name} to insert the school logo;
% a file logo \file{Logo-Scudo.jpg} is available from the ScuDo
% doctoral school; the students must ask such logo file from
% the Student Office, because such file is a legal property of
% the School and can be used only with permission. In any case
% the logo file must be of one of the allowed formats: \sigla{PDF},
% \sigla{EPS}, \sigla{JPG}, \sigla{PNG}; vector files are generally
% preferred, but they might not be available; raster files should
% be of a minimum definition of 150 pixels per inch.
%
% \Item[Ndissertation]\marg{dissertation name} (preset: Doctoral
% Dissertation) specifies the specific name of the document.
%
% \Item[Ndoctoralprogram]\marg{doctoral program} (preset: Doctoral
% Program in) specifies the degree course name prefix. 
%
% \Item[ProgramName]\marg{program name} (mandatory: preset empty)
% specifies the degree course name.
%
% \Item[CycleNumber]\meta{ordinal number} (optional; preset
% empty) specifies the ordinal number of the program cycle; at
% ScuDo it is a mandatory information. In other doctoral schools
% it might be useless.
%
% \Item[title]\marg{dissertation title} (preset empty) sets the
% specific title of the dissertation; it is better to keep it
% short, and use the sub title to add further titling information.
%
% \Item[subtitle]\marg{dissertation subtitle} (optional: preset
% empty) adds a possible subtitle.
%
% \Item[author]\marg{author's name} (mandatory: preset
% empty); it is recommended to pay attention to insert proper
% name(s) first and surname(s) second. 
%
% \Item[Nsupervisor]\meta{Supervisor(s) heading} (preset:
% Supervisor:) specifies the short heading labelling the list
% of supervisors; the preset value is singular and followed by
% a colon. In case of more than one supervisor, it is necessary
% to specify a plural name; the colon sign is optional.
%
% \Item[SupervisorList]\marg{list of supervisors} (mandatory:
% preset empty) specifies the list of supervisors, one per line,
% with a |\\| at the end of each line; the name(s) and surname(s)
% are preceded by their academic title, and followed by their
% role as supervisor, or co-supervisor.
%
% \Item[NExaminationCommittee]\marg{examination committee
% heading} (preset: Doctoral Examination Committee:) specifies
% the heading of the list of examiners.
%
% \Item[ExaminerList]\marg{list of examiners} (preset empty)
% specifies the list of examiners, one per line, each line
% terminated by |\\|; each line contains the academic title,
% the name(s) and surname(s), the role (referee for the
% supervisors; nothing for the other examiners), the academic
% institution they belong to -- full official institution name,
% city and country.
%
% \Item[Nlocation]\marg{examination location} (preset:
% Politecnico di Torino) specifies the institution where the
% examination takes place.
%
% \Item[ExaminationDate]\marg{examination date} (preset empty)
% specifies the date when the examination is to take place.
%
% \Item[Disclaimer]\marg{disclaimer statement} (preset: some long
% sentences agreed upon by the ScuDo doctoral school) mandatory
% in most universities; the specific statement(s) may be different
% in different universities.
%
% \Item[Signature]\marg{the author's signature} (preset: a few
% lines where the city is preset to “Turin”, and the date is
% assumed to be equal to the examination date; also the signer
% name is assumed equal to that of the dissertation author)
% specifies a different layout of the signature field.
%
% \end{description}
%
% Several examples of thesis title-page are shown in the
% \texttt{toptesi-it.pdf} Italian"-English documentation.
%
% \subsection{Languages}
% The TOPtesi bundle and the |toptesi| document class accept
% all \LaTeX\ commands provided by the \LaTeX\ \texttt{kernel},
% the \texttt{report} document class, and the \texttt{graphicx}
% extension package, besides those provided by the \texttt{babel}
% package. If the source thesis file is being typeset by means
% of \XeLaTeX\ or \LuaLaTeX\ the \texttt{babel} package is not
% loaded; in its place the \texttt{polyglossia} package gets
% loaded that should implement in \XeLaTeX\ and \LuaLaTeX\ most of
% the functionality provided by \texttt{babel} in \LaTeX.
% “Most” means that not  all the functionality is available,
% therefore it is better to  consult the documentation of
% \texttt{polyglossia} before using its built-in commands.
%
% With this respect it must be underlined that the Italian and
% English languages are specified by default, the Italian one
% being the main language. Only with the \opz{tipotesi=scudo} option
% in force, the main language is English. An initial specification
% of |\selectlanguage{english}| sets the English language as the
% default (unnecessary when \opz{scudo} is in force).
%
% Should a student typeset the thesis in French by means of
% \prog{pdflatex}, it would be necessary to specify the option
% \opz{french} among the \emph{class} options, and then start
% the document by specifying |\selectlanguage{french}|.
% But the user should pay attention to use \texttt{babel} in the
% proper way.
% \begin{enumerate}[noitemsep]
% \item Due to the way \LaTeX\ classes load the requested files,
% and to the fact that the \texttt{babel} package has already
% been loaded by the \texttt{toptesi} class, the user cannot
% reload it with a different list of language options; therefore
% the latter language options \emph{must be specified} as a global
% class options; so if the thesis has to be typeset, for example,
% in French, is is necessary to do the following:
%\begin{verbatim}
%\documentclass[...,french,...]{toptesi}
%...
%\begin{document}
%\selectlanguage{french}
%\end{verbatim}
% But if the thesis should be typeset in French by means of
% \XeLaTeX\ or \LuaLaTeX, then it is perfectly legal to specify the
% auxiliary language in this way:
%\begin{verbatim}
%\documentclass[...]{toptesi}
%\setotherlanguage{french}
%...
%\begin{document}
%\selectlanguage{french}
%\end{verbatim}
%
% \item With the 2010 \TeX\ system complete distributions,
% both \TeXLive and MiKTeX, all language hyphenation rules
% known (to \LaTeX) are preloaded; with other less up to date
% \TeX\ system distributions this might not be true. With both
% distributions also the language hyphenation rules known to
% \XeLaTeX\ are all preloaded. On the opposite \LuaLaTeX\ 
% loads the hyphenation rules at run time and only for the
% declared languages of the current document. 
%
% Remember that \texttt{babel} and \texttt{polyglossia} macros
% select the language typesetting rules, but hyphenation is
% activated only if the program format file has been generated
% with the pertinent language hyphenation rules. You can check
% this detail by reading the first dozen lines of your thesis
% \texttt{.log} file; it contains the list of all language
% hyphenation rules that are available in the format file.
%
% While (American) English is the default language and almost
% any \emph{basic} distribution of the \TeX\ system has several
% preloaded languages, it is more likely that French is preloaded
% while Italian is not. Complete distributions don't exhibit
% this~flaw.
%
% Should the required language(s) be missing, the user is forced
% to read his/her distribution instructions, so as to find out
% how to configure his/her system in order to preload the
% languages s/he wants to work with, and finally s/he must recreate
% the format files.
%
% The user is invited to carefully investigate on these fine
% points and to properly configure the system; it would be very
% upsetting to use fine software to produce a perfectly typeset
% thesis that, unfortunately, has wrong hyphenation points!
% Luckily enough, most recent distributions of the \TeX\ 
% system have all the known hyphenation rules preloaded; in any
% case, even older distributions have available command-line
% commands or graphical user interfaces that make it easy to
% perform the tasks of changing the list of preloaded hyphenation
% rules and rebuilding all the format files, moving them to the
% proper places.
% \end{enumerate}
%
% \subsection{Bibliography}
% \textcolor{red}{The ScuDo module is the only one that preloads some
% suitable packages to typeset one or more bibliographies. None of the
% other modules preload any bibliography management utility.}  This is due
% to the fact that the module was originally developed for
% typesetting PhD theses in the scientific domains related to the
% Institute of Electrical and Electronics Engineers (IEEE); such
% module was in facts used primarily by PhD students in those fields.
% The ScuDo doctoral School does not manage doctoral curriculums only
% for the “electrically oriented doctorands”, therefore alternatives
% had to be offered to the other PhD students in order to typeset
% their bibliographies according to the styles normally used in their
% scientific domains. The procedure is better described in
% section~\ref{sec:scudo} but it is suitable with minimal
% modifications also for the other thesis types.
%
%\subsection{Typesetting commands provided by \pack{topcoman}}
% The TOPtesi bundle adds very little to the user commands defined
% by the |report| class; nevertheless the package \texttt{topcoman.sty},
% that is part of this bundle and is automatically loaded, defines some
% useful commands for typesetting technical matters in such a way as to
% fulfil some (not all)  \sigla{ISO} regulations.
% Some of these commands are already defined with the \texttt{babel}
% Italian option, but if your thesis is written in different languages
% it may happen that such commands are not available any more when you
% select another language; with the presence of the definitions contained
% in \texttt{topcoman.sty} such useful commands should remain available
% with every language. The \texttt{polyglossia} package does not
% produce any useful additional command for writing in an almost
% \sigla{ISO} compliant way\footnote{Nevertheless, when typesetting with
% \XeLaTeX\ or \LuaLaTeX\ and using OpenType fonts, even for
% typesetting math, the calling of the |unicode-math| package with
% option \opz{mathstyle=\sigla{ISO}} lets you typeset in an \sigla{ISO}
% compliant way almost everything you need.}, therefore the macros
% contained in the \texttt{topcoman.sty} package may come handy. 
%
% The following description specifies these particular commands.
% \begin{description}[noitemsep]
% \def\Item[#1]{\item[\normalfont\texttt{\char92#1}]}
%
% \Item[DeclareSlantedCapitalGreekLetters] does exactly what
% its name means: it changes the definitions of the mathematical
% capital Greek letters so that they are typeset in “italics”;
% they are actually taken from the math italic alphabet,
% instead of the default roman one. This command is useful with
% \LaTeX, while with \XeLaTeX\ and \LuaLaTeX\ it is unnecessary
% due to the larger set of math alphabets and math font commands
% that are available with proper \sigla{UNICODE} math fonts and
% options.
% 
% \Item[ensuremath] should be already defined in the \LaTeX\ kernel;
% should one still be using an obsolete version, this command gets
% available anyhow.
% %
% \Item[ohm] typesets an upright capital omega even if the
% capital Greek letters are in italics; another good point
% is that |\ohm| can be used also  in text mode.
% %
% \Item[ped] inserts an index/subscript in upright type; the \sigla{ISO}
% regulations require the use of italics for physical or
% mathematical variables, and upright type for anything that
% is not a variable, from the names of functions (such as sin,
% cos, log, etc.), to the indices that contain information
% on something that is not variable. This means that $V_i$
% requires an italic index to imply that the object $V$ is
% the $i$-th in a set, while, say, $V_{\mathrm{max}}$
% indicates the maximum value of the variable $V$. This
% command |\ped| may be used  in both math and text mode.
% %
% \Item[ap] similarly |\ap| inserts an apex/superscript in
% upright type, in both math and text mode.
% %
% \Item[unit] sets the unit of measure close to the numerical
% measure value by inserting a non breakable thin space and
% by setting the units of measure in upright type; this works
% both in math and text mode. Of course it is necessary to
% input the |\unit| command without intervening spaces in the
% source file; it's necessary to typeset, say, |35\unit{km}|
% while avoiding a form such as \verb*+35 \unit{km}+.
% This command, as it is defined, conflicts with the definition
% of the homonymous command |\unit| as defined by some packages such as 
% \texttt{unitx}, \texttt{siunitx}, etc., but since this latter package is
% necessarily input in the preamble, while \texttt{topcomand.sty}
% is read at the execution of |\begin{document}|, the latter file has
% provisions to test  if any of those packages has already been loaded,
% so as not to overwrite the latter package definition and to avoid
% every possible conflict.
% %
% \Item[micro] sets the decimal prefix $\mu$ (providing, if
% possible, the sign with serifs, \textmu, taken from the Text
% Companion font or any other font that contains this variety
% of the Greek letter {\usefont{LGR}{lmr}{m}{rs}m}) when typesetting
% units of measure.
% %
% \Item[gradi] sets the small circle that defines the sexagesimal
% degrees, for example $35^\circ$; it may be used also for the
% celsius degrees by writing in the source file, say,
% |35\unit{\gradi C}| in order to get $35\,^\circ\mathrm{C}$;
% notice the difference with |35\gradi|, that yields $35^\circ$
% without any space between the measure and the “degree” little
% circle; this is what the \sigla{ISO} regulations require; the small
% space inserted by |\unit| is required when the unit of measure
% symbol contains at least one letter.
% %
% \Item[gei] inserts the imaginary unit in upright type with the
% “spelling” used by the Italian technologists: “j”. This command
% may be redefined, of course, but this strange name is due to the fact
% that nowadays the letter “j” in Italian is called with the
% one-syllable English name (much shorter than the traditional
% Italian three syllable name “i~lunga”) and the indicated spelling 
%“gei” is the phonetic Italian rendering of the English word.
% The imaginary unit is not a variable, and the \sigla{ISO} regulations
% require it is typeset with an upright serifed font.
% %
% \Item[eu] inserts the Napier number symbol “e” in upright
% type; since this entity is not a variable, but it is
% a mathematical constant, the \sigla{ISO} regulations require it to
% be typeset in upright type. The \sigla{ISO} regulations require the
% upright type for “e” and any other mathematical constant,
% but requires the electron charge $e$ is typeset in math italics because
% this is a physical “constant”, not a mathematical one.
% \XeTeX\ and \LuaLaTeX\ allow to typeset upright math Greek
% letters, so there is the facility to typeset an upright
% “{\usefont{LGR}{lmr}{m}{rs}p}” (the number) to be distinguished 
% from a slanted “$\pi$” (the angle).
% %
% \Item[goodpagebreak] inserts a conditional page break after
% the point where this command appears; it is not equivalent to
% the |\raggedbottom| declaration that does not vertically
% justify \emph{any} page; this command tests the amount of space
% remaining on the page, and if it is less than a given number
% of lines, it inserts a page break; the result is a ragged
% bottom \emph{single} page, that sometimes is better than excessive
% spacing between paragraphs, or within items of a list, or
% before or after displayed material. It is handy also to use
% before starting a new section, because at least four
% lines are required by \LaTeX\ in order to avoid orphan lines.
% \cs{goodpagebreak} accepts an optional argument that sets the
% number of lines to test the necessary space for a break;
% by default this number is~4.
%
% \Item[listing] requires for its argument the name of a file
% and typesets it in verbatim mode; this command is very useful
% for typesetting the listings of the programs that were written
% for the thesis; for best results it is recommended that the
% source program has lines not longer than 80 characters.
%
% The original definition of command |\listing| dates back to the
% old times of \LaTeX\,209; it has become \textcolor{red}{obsolete}; for
% backwards compatibility it is maintained but as {\color{red}an alias
% to the command |\VerbatimInput| of package |fancyvrb|}; its
% functionality may be configured with the same commands
% specified in the |fancyvrb| documentation for the original
% command. The |fancyvrb| package was preferred to the |listings|
% one, because it typesets verbatim material even while
% using font with multibyte encoding (therefore it works fine
% with \XeLaTeX\ and \LuaLaTeX), while the fancier package
% |listings| performs correctly only with \sigla{ascii}
% characters and requires special settings to use selected characters
% encoded with more than 7~bits.
% \end{description}
%
% All these commands are defined into the separate package
% \texttt{topcoman.sty} that might be used as an independent
% extension package with any document class.
%
% \section{The monografia module}
%
% The |toptesi-monografia| module gets loaded if one of the
% \opz{tipotesi=triennale} or \opz{tipotesi=monografia} options
% was specified to the |TOPtesi| class. It can be used as a
% standalone module, as well as the |topfront| general one, although
% supposedly, it is used most often with its mother class.
%
% In order to use it as a standalone module, some definitions
% must be established in order to have available at least some
% if not all of the settings and the switches that are available
% when the module is used with |TOPtesi|. Of course suitable
% tests are made in order to check if certain packages are
% already loaded and if certain switches are already defined;
% and some options are defined.
%
% The rest of the module is a subset of the |topfront| package;
% all commands that refer to information used for other types
% of theses are eliminated and the title page is typeset by means
% of another environment that does not rely on the environment
% |frontespizio| (with or without asterisk). The new environment
% |ThesisTitlePage| is more or less the only difference compared
% to the way a bachelor thesis title page is typeset with the
% |topfront| package. It will be described later on; but, with
% the due differences, this environment mimics the one defined
% in the |toptesi-scudo| module.
%
% The commands contained in this module are divided in there sorts.
% \begin{enumerate}[noitemsep]
% \item
%   The commands to define the infix words, so as to use them
%   explicitly within the |ThesisTitlePage| environment or
%   within a configuration file either to change the default
%   strings or to define them for languages different from
%   Italian; no attempt was made to establish such strings
%   for English, because is is supposed the most often than
%   not this module is used by Italian students to write their
%   bachelor degree final works in Italian universities;
%   nevertheless the possibility to change these strings is
%   always available.
% \item
%   The commands that define the default values for every
%   command that may be used or may be skipped while setting
%   up the title page.
% \item 
%   The commands that define the values for the variable
%   information necessary for every individual thesis.
% \end{enumerate}
% As explained above the first group is used essentially to
% define or redefine the infix strings. The second group is to
% define most default values for information that might or
% might not be entered by the user; these values are tested
% against the |\empty| value in order to decide if using or
% neglecting them. The third group is the one that the user
% directly or through a configuration file uses for his/her
% personal data and his/her specific thesis.
%
% \subsection{The configuration file}
% This module for the bachelor thesis final work searches
% for a configuration file with the same name as the thesis
% main file and with extension |.cfg|. Internally this main
% file name is stored in the internal variable |\jobname|;
% therefore this module searches the file |\jobname.cfg|. If
% this file does not exist, the typesetting engine does
% not use any specific setup, except what has been defined
% in this module for the default settings.
%
% Such configuration file might contains the redefining commands
% for the infix strings, and/or the other commands that can be
% used within the |ThesisTitlePage| environment.
%
% If a configuration file was loaded, the commands it contains
% are overwritten by those that are specified within the
% |ThesisTitlePage| environment. So the user should pay attention
% to what the configuration file contains and to what s/he writes
% within the |ThesisTilePage| environment, but if s/he uses again
% a command already used in the configuration file, it should be
% for a good reason; simply s/he should remember that the last
% setting is the one that is actually used.
%
% \subsection{Module options}
% If the module is loaded by |toptesi|, it receives the necessary
% options by |toptesi| itself. If the module is used as a self
% standing one and called by another class, it may be called with
% specific options that are listed here. In general they behave
% as the |toptesi| options; should they perform differently the
% details are explained hereafter.
% \begin{description}[noitemsep]
%\def\Item[#1]{\item[\opz{#1}]}
%
% \Item[evenboxes] The boxe containing the supervisor name(s)
%   and that containing the candidate name(s) are typeset by 
%   aligning their first lines; if this option is not specified 
%   the boxes are skewed, so that there is enough place to set 
%   the supervisor signature(s) on the right and the candidate 
%   signature on the left; if the bachelor degree final work does 
%   not imply a supervisor, the candidate name is centred and 
%   there is no question of aligning any box.
%
% \Item[cucitura]
%   Specifies a displacement of the text body  towards 
%   the outer margin. See the |toptesi| description. This option,
%   differently from the one defined in |toptesi| and |topfront|
%   is not of the type \emph{key\,$=$\,value}; therefore in
%   order to change its preset value it is necessary to use
%   the \cs{setbindingcorrection} command. This remark  applies
%   only to the case when this module is called by another class.
%
% \Item[classica]
%   Uses some \opz{classica} features; see the |toptesi| 
%   description.
%
% \Item[autoretitolo]
%   Similarly with the main stream |toptesi| bundle, this
%   questionable option is for changing the internal page
%   style; it is useless for this module, but there are some
%   tests that derive from the general |topfront| package,
%   so that the option is maintained for compatibility purposes.
%
% \Item[oldstyle] On the opposite this option is maintained,
%   at least to typeset the academic year interval with old
%   style numbers.
% \end{description}
%
% \subsection{User commands and environments}
%
% The only user environment defined by this module is
% |ThesisTitlePage|. It plays the same role as the |frontespizio|
% environment, but it is incompatible with the |\frontespizio|
% command. In other words if this module is used, the user must
% use the |ThesisTitlePage| environment only and does not have
% available the various title page environments and commands
% available with the |topfont| package.
%
% This environment accepts an optional asterisk as an argument;
% the syntax is the following:
%\begin{ttsintassi}
%\cs{begin}\Marg{ThesisTitlePage}\meta{*}
%\meta{thesis definition commands}
%\cs{end}\Marg{ThesisTitlePage}
%\end{ttsintassi}
% where, differently from other \LaTeX\ environments that accept
% an optional asterisk, this optional token is not within the
% opening (and closing) environment braces, but it is the very
% first entered element into the environment body. Its function
% is the following: if the asterisk is missing, the university
% logo(s) are typeset at the top of the page; if the asterisk
% is present, the logo(s) are set in the page lower half, below 
% the possible subtitle.
%
% The commands available with this module, divided into the three
% groups described above, are the following.
% \begin{description}[noitemsep]
% \def\Item[#1]{\item[\normalfont\cs{#1}]}
% \item[String settings]
%   \begin{description}[noitemsep]
%   \Item[NomeAnnoAccademico] Sets the default string for the
%     “Academic Year”; by default it is “Anno accademico”.
%   \Item[NomeCorso] sets the default string “Corso di laurea
%      in” followed by an intelligent space.
%   \Item[AnnoAccademico] sets a different string in place
%      of the default “Anno Accademico” one.
%   \Item[Struttura di] sets the default structure prefix;
%      for example this prefix might be “Department of”,
%      and the structure name entered with \cs{struttura}
%      might be “Electrical Engineering”; therefore the
%      title page is typeset with the complete string 
%    “Department of “Electrical Engineering”. The default
%      string is in Italian, but by using this command,
%      remember to enter the string you need terminated by
%      the intelligent space macro \cs{xspace}.
%   \Item[CorsoDiStudi] sets the default string for the
%      degree course type; it might be “Laurea triennale”,
%      or “Bachelor degree” or similar strings in other
%      languages. It replaces the obsolete following command:
%   \Item[CorsoDiLaureaIn] that remains available with the backwards
%      compatible |topfront| standard module.
%   \Item[NomeElaborato] Sets the name that qualifies the
%      document; by default it is “Monografia”, but this
%      user command may be used to set it, for example, to
%      “Tesi di laurea triennale”, or anything else in
%      Italian, in English, or the used main language.
%      The |topfront| command |\NomeMonografia| is let to
%      to |\NomeElaborato| for backwards compatibility and its
%      use is evidently discouraged.
%   \Item[CandidateNames] sets the labelling command for the
%      box that lists the candidate names; by default these names are the 
%      masculine, feminine, singular and plural Italian names 
%      starting with “Candidato”; if the \opz{classica} option 
%      is in force they start with “Laureando”;
%      the user couldn use this command which it has a non standard syntax
%      (delimited arguments); therefore it is suggested that 
%      end users refrain from using it, unless they know how to handle
%      the delimited argument commands.
%      This command sets the four strings to any desired value, 
%      if, as in English, there is no difference between masculine 
%      and feminine, repeat the same name for the feminine positions, 
%      the last ones; the syntax in facts is the following:
%\begin{ttsintassi}
%\cs{CandidateNames},\% 
%\qquad\marg{masculine singular},\% 
%\qquad\marg{masculine plural},\% 
%\qquad\marg{feminine singular},\% 
%\qquad\marg{feminine plural},!
%\end{ttsintassi}
%   \Item[TitoloListaCandidati] is a much simpler command the user
%      should prefer to the previous one; in facts it accepts a single
%      argument formed by a comma separated list of names; from zero
%      up to four names (in the same order as described above).
%      Therefore the following commands are all valid ones:
%\begin{ttsintassi}\small%
%\cs{TitoloListaCandidati}\Marg{}
%\cs{TitoloListaCandidati}\Marg{\'Etudiant}
%\cs{TitoloListaCandidati}\Marg{Estudiante,Estudiantes}
%\cs{TitoloListaCandidati}\Marg{Kandidat,Kandidaten,Kandidatin,Kandidatinen}
%\end{ttsintassi}
%   \Item[CandidateName] this command used to be the default one
%      with the standard |topfront| module, and remains available
%      with this package; it sets just one name (disregarding
%      singular/plural and masculine/feminine variants) to substitute
%      the default ones. Please notice that this command is not
%      available with the other thesis type options.
%   \Item[Relatore] Sets the string that labels
%      the supervisor box; by default it is the Italian
%      name “Relatore”; the command my be used to set
%      any different string.
%   \Item[Correlatore] sets the string that
%      labels the list of co-superpervisors when there is
%      just one “second” supervisor.
%   \Item[Correlatori] sets the string that
%      labels the list of co-supervisors when there are
%      three supervisors, a supervisor and two co-supervisors.
%    \end{description}
% \item[Variable data settings]
%   \begin{description}[noitemsep]
%   \Item[titolo] sets the bachelor degree final work title.
%      The main module |topfront| uses in its place the command
%      \cs{monografia}; the user can still use the old command,
%      but |\titolo| is more descriptive.
%   \Item[sottotitolo] sets the optional subtitle.
%   \Item[corsodistudi] and \cs{corsodilaurea} specify the actual
%      name of the degree course; \cs{corsodistudi} should be
%      preferred; \cs{corsodilaurea} is deprecated, but is maintained
%      for backwards compatibility.
%   \Item[materia] and \cs{Materia} set the optional discipline
%      the thesis deals with.
%    \Item[relatore] sets the name of the only or the principal
%      supervisor.
%    \Item[secondorelatore] sets the name of a second supervisor,
%      if any.
%    \Item[terzorelatore] sets the name of a third supervisor,
%      if any.
%    \Item[candidato] sets the name of the first or only ‘M’
%      candidate; in general bachelor degree final works are
%      done by just one candidate but, in case, there are
%      available also the commands for a second and a third
%      candidate. Masculine and feminine commands are available
%      and the heading of the candidates box il labelled accordingly.
%    \Item[candidata] sets the name of the first or only ‘F’
%      candidate.
%    \item[\normalfont\cs{secondocandidato} or \cs{secondacanddata}]
%       set the names of a possible second ‘M’ or ‘F’ candidate.
%    \item[\normalfont\cs{terzocandidato} or \cs{terzacandidata}]
%       set the names of a possible ‘M’ or ‘F’ third candidate.
%    \Item[ID] to be used just after the candidate's name, but as
%       part of the setting command  argument, establishes the
%      candidate's ID label string |\IDlabel| that prefixes the 
%      candidate's ID number. The user should not worry about this string, 
%      unless s/he wants to modify it; by default it is set to
%      |\\\quad matricola\ |; in other words, the ID number is set
%      indented under the candidate's name and a space is put between 
%      the string and the number.
%    \Item[sedutadilaurea] sets the date of the final examination;
%      by default the current month and year are typeset if this 
%      command is not specified; but the user can specify anything; 
%      s/he can even prefix the year range with the 
%      \cs{AnnoAccademico} command, that typesets (in the current 
%      language if localisation has been made by means of the 
%      suitable command of group~1) a string equivalent to 
%      “Academic Year”; in any case the user can write down what
%      s/he likes best in place of the predefined value.
%    \Item[NomeAteneo] sets the proper name of a specific
%      university; it will be typeset in suitable uppercase type
%      under the generic name of the university; if this command
%      is not used, no name gets typeset in the title page.
%    \Item[struttura] sets the name of the university entity
%      that supervises the development of the degree course;
%      it may be a “faculty”, a “department”, a “school”,
%      it depends from the specific university. Some universities
%      do not require this information on the title page. In any
%      case if this command is used it accepts two arguments: 
%      the first one is optional, and, if used, is an uppercase 
%      roman numeral that indicates the ordinal of the structure;
%      the second argument is the complete structure name.
%    \Item[setlogodistance] sets the distance between adjacent
%      university  logos, if more then one is used.
%    \Item[logosede] sets the name of a graphics file that
%      contains the logo of the university; the default value of
%      this command il \cs{empty}; this macro may be used several 
%      times, in case the bachelor degree final work is developed 
%      within a multiple degree Erasmus program; this might be 
%      unusual with bachelor degree courses but not impossible. 
%      In any case if no logo file 
%      name is specified, no logos are printed and no space 
%      is used in the title page; if one or more logos are used 
%      they are assembled with the same height into a horizontal 
%      box, that before being printed is measured; if the width 
%      exceeds the text width, the whole box is scaled down by 
%      preserving the aspect ratio so as to fit it inside the 
%      text width; after these tests and possible scaling down, 
%      the logo box is printed. The logo distance my be varied 
%      from its 3em default value by using \cs{setlogodistance}, but 
%      it is suggested not to vary it too much. The \cs{logosede} 
%      accepts an optional value that is the common height of the 
%      logos; this possibility does exist but it is strongly
%      discouraged.
%    \Item[tutoreaziendale] set the name of a possible company
%      tutor, in case the final work is developed in a Company
%      external to the university
%    \end{description}
% \end{description}
%
% \section{The module for a master degree thesis}
%\label{sec:topmagistrale}
%
% The module for the master degree thesis,
% |toptesi-magistrale.sty| is almost identical to the generic
% module |topfront|; the obvious differences are that it
% lacks the latter module commands that refer to the bachelor
% degree or the Ph.D.~theses. Evidently such specific commands
% are useless in a master degree thesis.
%
% \begin{sloppypar}
% Such eliminated commands include |\manografia|,
% |\sedutadidottorato|, |\ciclo|, |\Direttore|, and so forth.
% \end{sloppypar}
%
% A tricky situation arises if the thesis is typeset in several
% tomes. There are substantially two different situations with
% different implementations with the generic module |topfront|
% and this specific module |toptesi-magistrale|.
%\begin{enumerate}[noitemsep]
%\item
%   Setting the tome number on each tome title-page is realised by means 
%   of the |\tomo| command that requires a preliminary 
%   specification of all the necessary data before |\tomo| 
%   can play its role; it actually uses the |\frontespizio| 
%   environmnet, but before the |tomo| counter is stepped up.
%
%  This allows to typeset the various tomes in a single 
%  document, so that the user can cross-reference elements 
%  belonging to different tomes. When the single multi\-tome 
%  document is completed the user can split its \sigla{PDF} file 
%  in separate files (by means of the |pdfpages| package 
%  functionalities) and print them; in printed pages the 
%  cross-references do not require hyperlinking, while 
%  the single document file may be completely hyperlinked; 
%  reading the printed tomes is correct, and reading the 
%  whole thesis in a single document on the screen allows 
%  the cross-linked navigation from one point to another.
%
%  The draw back of this procedure is that splitting the 
%  single \sigla{PDf} file in several files require another processing 
%  job, and any editing of the source thesis files may require 
%  repeating this splitting job because the number of pages 
%  may be modified and/or  cross references do not point 
%  to the correct page number.
%  
%\item
%  With the |ThesisTitlePage| environment of this 
%  |toptesi-magistrale| module the |\tomo| command is used 
%  before or within within the environment and it just 
%  steps up the |tomo| counter while allowing typesetting 
%  the necessary tome information on the title page.
%  
%  In this way it is necessary to typeset each tome with 
%  its own source file(s) to produce different output \sigla{PDF} 
%  files; when printed they are substantially identical to 
%  the split documents obtained with the previous approach 
%  but it simply avoids splitting  the single document file 
%  in several files. The drawback is thet if hyperlinked cross-referencing 
%  is used, each tome is correctly hyperlinked to its 
%  internal targets, but no cross-referencing can be 
%  automatically done to items in other tomes. I do not 
%  think this is a real draw back in practical situations, 
%  but of course it produces a limitation to reading the 
%  tomes on the screen.
%\end{enumerate}
%
% I assume that multi\-tome theses are very rare; \LaTeX can
% handle the production of different documents (different
% tomes/volumes) maintaining correct cross references also to
% material external to any specific volume, but the handling 
% of the whole job becomes very complicated not to mention
% the programming difficulties. For master theses I would avoid 
% splitting one's thesis is several tomes; nevertheless this
% functionality has been asked for, so that this bundle
% realises a couple of solutions that require some compromise
% and some manual work by the author. A better solution 
% is on the TODO list, but it is not to come in a short time.
% 
% In summary this |toptesi-magistrale| module keeps all the
% commands defined on the |topfront| module; modifies the
% definition of the |\tomo| command; adds the |ThesisTitlePage|
% environment within which the configuration file is read and where all
% commands for the title page data are to be inserted. The
% peculiarity of thes environment is that the possible asterisk
% necessary to switch from the the logos set in the title page
% lower half (no asterisk) to the logos at the page top
% (asterisk) must be inserted the same way as in the other
% modules, that is as the first token at the beginning of
% the environment.
%
% \section{The Ph.D.\ module for general use}
% Except for  the ScuDo theses, for which the University
% specified the necessary requirements for both contents
% and appearance of the title page, we provide a generic
% module for Ph.D.\ theses for other universities. It goes
% by itself that if the specifications cannot be customised
% by using the customising commands of the ScuDo module,
% nor by this module, it is necessary to use a custom
% module that the user must create as specified in the next
% section.
%
% This module is generic as much as the |topfront| one.
% It differs only for the elimination of the title page commands
% that refer to  other thesis types and the only addition is
% the |ThesisTitlePage| environment, just as it has been done
% for the other bundle modules.
%
% The data insertion or modification commands are a subset
% of those described in subsection~\ref{sec:topfront},
% of course without those that are specific to other thesis
% types; therefore we do not repeat them here.
%
% Special care should be dedicated to the university
% specifications; in some universities the supervisor(s)
% should not be indicated and in such a case the (unique)
% candidate  may be indicated without any legend on top of
% it. The University logo might already contain the explicit
% wording with the the university name and in this case
% repeating the name would be pleonastic. At my level I
% cannot foresee the user requirements therefore it is up
% to the user to take care of inputting the correct
% fixed word data and the specific thesis data. I hope
% this module is useful for most Ph.D.\ students, but if
% the user  compares the title page requirements with those
% prescribed for the ScuDo theses, s/he sees how much such
% requirement might be different from one university to the other. 
%
% May be in such circumstances the user might prefer to create
% his/her custom title page and would not use this module at all. 
%
% \section{The custom module for the title-page}\label{sec:custom}
% The construction of the customised title page module is the full
% responsibility of the user.
% In facts the user, beyond specifying the |tipotesi=custom|
% to the |toptesi|  class  class, at the beginning of the
% document explicitly inputs a personal package file, say
% |mycustomfile.sty| by means of the simple
% |\usepackage{mycustomfile}| command, and this is all the user
% needs. Of course this is an understatement; in facts s/he
% should select a package form the many existing ones, s/he
% can create him/herself a new package branched on other existing
% software; s/he may refrain form using external packages,
% and simply insert his/her title page data within a |titlepage|
% environment where s/he wants, with the fonts families, series,
% shapes, and sizes s/he prefers and so on.
%
% Needless to say that in order to create a custom title page
% module the user must perfectly know the intricacies of the
% \LaTeX\ language. It may be helpful to read the Italian
% documentation |toptesi-it.pdf| where an example of landscape
% title page is already described in full detail. Of course a
% landscape title page requires a custom layout and is no
% surprise that the example deals with this particular one.
% Nevertheless that example gives a good idea on how to create
% a custom title page.
%
% We don't go further in describing the |tipotesi=custom| option,
% except remembering the this option just inhibits loading both
% the standard default module, and any other predefined module, unless the
% user directly loads one with or without the specific module options.
%
% \section{The high school final work module}
%
% The suffix |sss| is the acronym for the Italian name of
% “High School”, \emph{Scuola Secondaria Superiore}.
% Elegance of bureaucratic language; the elementary school
% now is `Scuola Primaria', and junior high school is `Scuola
% Secondaria Inferiore'. As well as it was in Germany and
% in some Swiss Cantons, the total number of school years
% is 13 instead of 12, as  it is in most countries. The advantage
% is that no general education is taught in university, no
% \emph{classes pr\'eparatoires}, because it is assumed that
% the high school diploma assures a sufficient level of general
% education.
%
% Differently from most high school systems in the world,
% in Italy each school has a special “mission” and receives
% different names, all under the general definition of Scuola
% Secondaria Superiore. But it s possible to distinguish
% between Licei (University preparatory), Istituti tecnici
% with various specialisation (for technical education in
% different domains); Istituti professionali (for vocational
% training); all of them end with a state examination, and
% almost all of them allow entrance in University, although
% a certain level of auto\-selection is actually performed.
% Many university Schools, formerly Faculties, submit applicants
% to entrance tests intended mostly to let them perform a
% conscious choice of their future studies; sometimes the
% tests are intended also to form ranks in those schools where
% the \emph{numerus clausus} is applied.
% 
% This off topic is necessary to let the general reader
% understand the importance of the \emph{esame di maturità}
% and the important role that the high school final work
% (nicknamed \emph{thesina}, `little thesis') plays in this
% generally difficult exam; statistics say that the percentage of
% flunking students is very low, but the final passing grade
% (a numerical value in the range from 60 to 100 with honours)
% plays also an important role in the following career, therefore
% students work very hard to pass with good grades.
%
% The above off topic explains why in Italy the final high
% school state exam includes the evaluation of a personal
% written report on some subject chosen by each student;
% this choice is often performed  with
% an initial support by a teacher, that gives help in
% choosing the subject, and, maybe, offers some initial input.
% They do not supervise the student work; but this work is
% submitted to the examining committee (the members of which
% are external to the specific school) that after due reading,
% ask questions on the work and investigate the depth to which
% the student has gone into his/her chosen subject.
%
% Certainly this final work has not the importance of a
% university thesis, but it is the first time when the
% student is asked questions on a subject of his/her choice,
% where the examining committee assumes s/he has examined all
% the facets with the approach of a young adult, not that
% of an old teenager.
%
% Some high school students have discovered \LaTeX, and some
% of them do really appreciate the typesetting results all
% \LaTeX\ users love; therefore they like the idea of
% typesetting their final high school work with the powerful
% \LaTeX\ functionalities.
%
% Of course their title page must be very different from those
% suitable for university theses, therefore a special module is
% necessary, and I decided to to add such a module to this bundle.
%
% Actually high school students require less information on the
% title page; the school generic and proper names, obviously the
% title and a possible subtitle, their name, maybe the logo of
% their school, the examination date, and such similar data.
%
% They certainly do not need the advanced features needed for
% the functionalities of the |topfront| extension package;
% nevertheless the title page must have a professional look,
% not just what they may achieve by using a word processor.
%
% The contents of the \emph{tesina} may also have a professional
% look if the students do not tickle the typesetting program
% to behave as a word processor. Several guides are available
% for high school students, as well for university ones, to
% recall how a “technical report” should be properly written;
% unfortunately today students prefer to read their smartphones,
% rather than real printed or electronic books; but those
% students who use \LaTeX\ know very well that they need reading
% suitable guides for using the program \emph{and} for structuring
% their document.
% 
% Mirko Mondini suggested to extend the TOPtesi bundle to
% include the title page for high school final works. He
% also suggested the layout of the page. This module may be
% considered “work in progress” because we both have little
% experience with the requirements of such final works.
% As the maintainer of this bundle I thank him very much;
% Marco may suggest specific changes in the near future;
% his contributions are very welcome. I would add that
% commentaries and suggestions by the students to whom this
% module is dedicated are very welcome just as well.
%
% We assume the student already knows the fundamentals of \LaTeX;
% we assume the Italian student has read the companion
% documentation |toptesi-it.pdf| distributed with this bundle;
% we assume also that the student has already a valid
% installation of the \TeX\ system, preferably \TeXLive,
% that is available for all most popular operating systems,
% Windows included of course, although for Windows there is
% also the alternative installation MiKTeX. As my  personal opinion,
% I think that \TeXLive may be updated more easily than MiKTeX
% and, not negligibly, its default installation is complete,
% while MiKTeX by default has a basic installation, so that very
% often offline MiKTeX users suffer from “missing package” errors.
%
% Since this module is going to be used only by Italian high
% school students, all user commands are in Italian.
%
% Here we concentrate on the title page. But before entering
% this subject let us recall that this module already loads a
% certain number of packages.
% \begin{enumerate}[noitemsep]
%\item
%   Packages |amsmath|, |amssymb| (only \pdfLaTeX) and |amsthm|
%   are already loaded, but a test is made to verify if the user
%   has loaded in his/her preamble the math  packages |newtxmath|
%   or |newpxmath| (possibly together with their companions
%   |new...text|), because the latter packages already provide
%   for their functionalities.
%\item
%   If they typeset with \LuaLaTeX\ or \XeLaTeX, the suitable
%   packages are already loaded, in particular the |unicode-math| 
%   one; the user, though, should load a matching OpenType Math 
%   font among those available with the \TeXLive distribution.
%\item
%   Service packages such as |xparse|, |xspace|, and |xcolor| 
%   are already loaded for the benefit of this bundle and this 
%   module, but the user is free to use their functionalities, 
%   mostly those of |xcolor|.
%\item
%   Packages |calc| and |ifthen| are functional for the module; 
%   supposedly the end users should not have any necessity to use 
%   them, but, of course, they can if they need to.
%\item
%   Package |multirow| has been loaded, because many users like
%   to imitate word processor functionalities; this package allows 
%   to create table cells that span several rows; as a general 
%   rule this practice should be avoided.
%\item
%   Package |booktabs|, is very useful to set professional
%   tables (reading its documentation is necessary).
%\item
%   No particular package has been loaded to create a specialised
%   bibliography; either the student directly uses its own 
%   |thebibliography| environment, or provides to chose whatever 
%   style s/he likes best and, if s/he decides to load package 
%   |biblatex|, s/he should specify the desired options. In the first 
%   case one of the most useful packages is |natbib|; in the 
%   second case |biblatex| supports other bibliographic style 
%   files. Both approaches require the preparation of a 
%   bibliography database by means of programs |jabref|,
%   |bibdesk|, or similar applications: but with |natbib|
%   the |bibtex| database handler is required, while with
%   |biblatex| case the |biber| handler yields the best
%   performances. In both cases it is required the careful
%   reading of either package documentation.
%\end{enumerate}
%
% The commands the user can use for the title page follow.
%
% Remember that they may be used directly within the
% |FrontespizioTesina| environment; if the user prefers, s/he
% can write them in a configuration file; such file must be
% named with the same name as the document main file, and
% it must be saved in the same folder; the information
% read from the configuration file is possibly overridden
% by the same commands, with different data, specified within
% the |FrontespizioTesina| environment.
% Just to be sure to be clear, if your document main file is
% named |LaMiaBellaTesina.tex|, the configuration file should
% be named |LaMiaBellaTesina.cfg| and both files should be
% saved in the same folder.
%
% The title page commands are the following:
%\begin{description}\def\Item[#1]{\item[\normalfont\cs{#1}]}
%\Item[SSSLogo] 
%   is used to define the name of the graphic file containing 
%   the high school logo; not necessarily the school allows to 
%   use its logo; in any case if such command is not used, the 
%   logo information is ignored. The syntax is
%   \begin{ttsintassi}
%   \cs{SSSLogo}\marg{file name}
%   \end{ttsintassi}
%   Remember that the graphic file must have one of these 
%   extensions: |.pdf|, |.eps|, |.png|, or |.jpg|; the first 
%   two may contains vector images and give the best results; 
%   the second two are bitmapped, therefore their rendering 
%   depends very much on the pixel density of the file contents.
%\Item[NomeTesina] sets the name of the document; the default value 
%   is “Tesina di maturità”. Syntax:
%   \begin{ttsintassi}
%   \cs{NomeTesina}\marg{nome dell'elaborato}
%   \end{ttsintassi}
%\Item[NomeCandidato]
%   is used to set the label to typeset over the author's name;
%    default “Studente” or “Studentessa” depending on the
%   state of the boolean switch |femminile|, but if this command
%   is used for the user tesina, s/he needs not to specify any
%   switch and uses the only name necessary for his/her document.
%   Syntax:
%   \begin{ttsintassi}
%   \cs{NomeCandidato}{examinand label}
%   \end{ttsintassi}
%   This command might be used to set the label with a different
%   name in the correct gender.
%\Item[IndirizzoMiur] 
%   sets the Ministry of Education special address. If this 
%   command is omitted, this address, considered optional, 
%   is neglected. Syntax: 
%   \begin{ttsintassi}
%   \cs{IndirizzoMiur}\marg{Ministry of Education special address}
%   \end{ttsintassi}
%\Item[OpzioneMiur]
%   sets the specification that distinguishes the  school 
%   mission, if any. Syntax:
%   \begin{ttsintassi}
%   \cs{OpzioneMiur}\marg{Ministry of Education option}
%   \end{ttsintassi}
%\Item[TipoScuola]
%   sets the specific generic name of the school; default 
%   none; therefore use of this commands is mandatory; 
%   the user might specify “Liceo classico”, or “Istituto 
%   tecnico industriale di stato”, or whatever applies for 
%   the students' specific school. Syntax:
%   \begin{ttsintassi}
%   \cs{TipoScuola}\marg{generic school name}
%   \end{ttsintassi}
%\Item[NomeScuola]
%   sets the specific name of the school; generally schools 
%   are dedicated to famous scientists or heroes, or presidents, 
%   or kings/queens, or writers, et cetera; default “empty”.
%   Syntax:
%   \begin{ttsintassi}
%   \cs{NomeScuola}\marg{specific school name}
%   \end{ttsintassi}
%\Item[SedeScuola]
%   sets the actual location of the school; it may be just the 
%   city or a full postal address; it may contain new line 
%   commands in order to format a full address of several lines; 
%   no default. Syntax:
%   \begin{ttsintassi}
%   \cs{SedeScuola}\marg{the school basic or full address}
%   \end{ttsintassi}
%\Item[AnnoScolastico]
%   sets the school year at the end of which the state 
%   examination is undertaken; no default. Syntax:
%   \begin{ttsintassi}
%   \cs{AnnoScolastico}\marg{school year}
%   \end{ttsintassi}
%\Item[titolo]
%   sets the title of the document; please don't use long titles;
%   if a short sentence is not descriptive enough, use the 
%   |\sottotitolo| argument to add specifications to the title; 
%   no default. Syntax:
%   \begin{ttsintassi}
%   \cs{titolo}\marg{main title}
%   \end{ttsintassi}
%\Item[sottotitolo]
%   sets an optional subtitle; if this command is not used
%   the subtitle field is ignored; no default. Syntax:
%   \begin{ttsintassi}
%   \cs{sottotitolo}\marg{optional subtitle}
%   \end{ttsintassi}
%   The subtitle, if any, is typeset in a normal sized font, 
%   therefore it can be several lines long; nevertheless pay 
%   attention to use the tie command |~| to connect  with an
%   unbreakable space to the following ones such words as
%   prepositions, articles, short adverbs, and such similar
%   items.
%\Item[studente] or \cs{studentessa}, depending on the gender
%   of the student, sets the name of the author of the
%   document, i.e.\ the name of the student undergoing the
%   examination; no default. Syntax:
%   \begin{ttsintassi}
%   \cs{studente}\marg{proper name(s) followed by the surname(s)}
%   \cs{studentessa}\marg{proper name(s) followed by the surname(s)}
%   \end{ttsintassi}
%   Remember: \textbf{never ever use the surname(s) before 
%   the name(s)}.
%   If the \cs{NomeCandidato} macro has not been used, these commands
%   set the proper status to the |femminile| switch, so that the
%   proper default label is used.
%\Item[Presidente]
%   sets the name of the chairperson of the examining committee; 
%   no default. Syntax:
%   \begin{ttsintassi}
%   \cs{Presidente}\marg{examining committee chairperson full name}
%   \end{ttsintassi}
%   Again remember to write the necessary academic titles 
%   in lowercase, end the name(s) before the surname(s).
%\Item[NumeroCommissione]
%   sets the examining committee ID number; no default.Syntax:
%   \begin{ttsintassi}
%   \cs{NumeroCommissione}\marg{Examing committee ID number}
%   \end{ttsintassi}
%\end{description}
%
% The actual title page is created within the environment
% |FrontespizioTesina|. This environment first reads a the
% configuration file if one exists, then it analyses the
% commands possibly set within the environment by the author, 
% possibly superseding the information read from the 
% configuration file; the closing commands actually typeset 
% the title page; the schematic working is the following:
%\begin{flushleft}\ttfamily\obeylines
%\Bambiente{FrontespizioTesina} \% reads the config.\ file if any
%\meta{user commands with user data}
%\Eambiente{FrontespizioTesina} \% typesets the title page
%\end{flushleft}
% There are no options to specify; the title page is sort
% of rigid in the sense that every piece of information goes
% where it should  and interlaced with proper spaces so as to fill
% up the text grid in a sensible way. No doubt some users may
% complain that the title page does not allow to do this or
% that; that the spacings should be different from what they
% actually are. 
%
% There are work-arounds to these complains.
%\begin{enumerate}[noitemsep]
% \item
% Instead of using the above environment, s/he uses the |titlepage|
% environment within which s/he inserts what s/he wants and
% where s/he likes best, with the typefaces s/he prefers,
% with the vertical spacings that accomodate his/her aesthetical
% feelings. Of corse it is necessary to know what is being done;
% if not, the results may be worse than the predefined layout.
%\item
% Even better: the user may use a custom layout and set it
% following the instructions described in section~\ref{sec:custom}.
% \end{enumerate}
%
%^^A                          PDFA/A
%
% \section{\sigla{PDF/A} archivable format}
% This section in general applies also if the thesis is typeset
% by means of  \LuaLaTeX\ or \XeLaTeX, but with \XeLaTeX\ special
% attention should be paid to the details of the procedure as
% described in the documentation of the \pack{pdfx} package. Even
% better, \LuaLaTeX, whose source file is practically the same as
% that of \XeLaTeX, may produce in a simpler way a \sigla{PDF/A}
% compliant output file if the users follow attentively the
% instructions contained in the documentation of the \pack{pdfx}
% package.
%
% More details are given in the Italian documentation contained
% in the \texttt{toptesi\discretionary{-}{}{-}it} which is part
% of the TOPtesi bundle.
%
% Politecnico di Torino and several other Italian and foreign
% universities are moving towards archiving theses in electronic
% format, specifically in the \sigla{PDF} one. The problem of
% course is: “Will it be possible to read the archived documents,
% say, fifty years from now?”
%
% This essential question has been answered by the International
% Standards Organisation (\sigla{ISO}) that in 2005 published the
% regulation \sigla{ISO}~19005-1; in 2011 and 2012 enhancements of
% this regulation have been published. This regulation defines
% a \sigla{PDF} variant suitable for archiving, named \sigla{PDF/A}, that
% has two sub-formats distinguished as \sigla{PDF/A}-1a, and
% \sigla{PDF/A}-1b.
% The `a' sub-format is more exacting, while the `b' one is less
% stringent. In spite of the recently published  upgrades,
% here we stick to the older ones, that are a sub set of the
% newer ones, and for which suitable software is available.
%
% The requirements for the `a' sub-format imply not only those
% requested for the `b' one, but also that the logical structure
% of the document be accessible from outside (Tagged \sigla{PDF}).
% The requirements for the `b' sub-format are that the
% document must be reproducible without modifications exactly
% as it was at the moment of archiving. Both sub-formats must
% contain \emph{metadata} that are searchable even without
% decompressing the normally compressed \sigla{PDF} file, and that
% contain information useful for archive maintenance; among
% these informations, of course, the \sigla{PDF/A} category the document
% belongs to, the document title, the authors, and few other
% optional pieces of information, such as the keywords that
% ease up library searches.
%
% Since version 1.40, the program \texttt{pdflatex} is capable
% of producing \sigla{PDF/A}-1b compliant files, provided that some
% attention is put into editing of the thesis source file. Since the
% year 2008  the \TeX\ system, the executable \texttt{pdflatex} has
% version number 1.40.9 (or higher); therefore today there should not
% be any difficulty in producing \sigla{pdf/a} compliant documents.
%
% The particular attention needed to avoid problems with the
% \sigla{PDF/A} compliance is summarised as follows:
% \begin{enumerate}[noitemsep]
% \item
% The preliminary essential requirement is that the
% \texttt{pdflatex} engine used to typeset the thesis be
% sufficiently recent to support the \sigla{PDF/A} requirements.
% It's better to have the most recent distribution of
% the \TeX\ system installed on your PC. Do not try to
% typeset the thesis with the `old' \prog{latex}; you
% \emph{must} process the input thesis file(s) with
% \texttt{pdflatex} or with \prog{lualatex} or with \prog{xelatex};
% in the following, no specific check will be made in
% order to verify if you are actually using \texttt{pdflatex}.
% If you really need to use the `old' \LaTeX, you get a DVI
% file and you need to transform it with |dvips| into a
% PS file; at this point you have lost the possibility of
% exploiting the internal commands of |pdflatex|
% version~1.40.9 or later. You can still produce a \sigla{PDF/A}
% final document, but you have to transform it by means of the
% procedures described in the Italian documentation; such
% documentation describes several more or less effective
% methods to transform a non compliant \sigla{PDF/A} file into a
% compliant one, and how to correct the “imperfections”
% that forbid any valid transformation.
%
% \item 
% Since 2016 the TeXLive distribution contains a new version
% of \pack{pdfx} and now \sigla{PDF} documents produced with
% \prog{lualatex} may be fully compatible with the standard
% \sigla{PDF/A}. With some special care and some post"processing,
% even \prog{xelatex} can now produce \sigla{PDF/A} compliant output
% files.
%
% \item
% Your up-to-date complete \TeX\ distribution should
% contain the package \textsf{pdfx}; if it does not,
% upgrade your \TeX\ system complete distribution. Be sure
% that the version number of the \pack{pdfx} package has
% version number~1.5.8 or higher.
%
% \item
% In the 2018 version of \TeXLive, with the upgrade of |pdfx|
% a glitch emerged due to licence questions; the |sRGB.icc| distributed
% with earlier versions was under a limited licence that is not 
% compliant with the free nature of the \TeX\ system. The maintainers
% are aware of this problem and, while they are further upgrading the
% \pack{pdfx} file, they suggest a work-around (that will be described
% below); it is possible that when you read this documentations the
% work-around, described below, is not necessary any more. 
% With version 1.61 of \pack{pdfx} the problem is solved even if one uses
% a \TeXLive\ installation prior to the one distributed in the year 2018.
% In any case the most recent version 1.61 or higher of |pdfx| is
% necessary.
%
% \item
% If your thesis main file, the one you run your typesetting
% program on, is named, say, \texttt{JohnSmithMasterThesis.tex},
% prepare in the same directory another file named
% \texttt{JohnSmithMasterThesis.xmpdata} that contains the
% \emph{metadata} relative to the thesis. 
% Pay attention to follow the stringent metadata syntax described
% and exemplified in the \textsf{pdfx} documentation. A minimal 
% example set of \emph{metadata} would be the following one:
% \begin{verbatim}
% \Title{Experiments in Trichotetratomy}
% \Author{John Smith}
% \end{verbatim}
% The keyword list requires a specific format that can be
% examined in the |pdfx| package documentation. The best way to
% be sure that this file accompanies the thesis main file,
% is to put its contents in a \env{filecontents*} environment.
% The details are in the documentation of the \pack{pdfx} package and
% examples are shown in the Italian documentation of |TOPtesi|.
% In order to override the constraints of the \LaTeX\ kernel 
% |filecontents| environment, TOPtesi loads the package |filecontents|
% that eliminates the mentioned constraints, but requires that the
% environment be used within the preamble, in any case before
% loading the |pdfx| package. Actually this does not forbid to use the
% environment before the |\documentclass| statement, as it was in the
% previous versions of TOPtesi. The new version is backwards compatible
% with the previous ones with this simple difference: when the environment
% is used before the |\documentclass| statement, any modification of
% its contents does not take place unless the previous |xmpdata| file
% is deleted, because the kernel environment does not overwrite existing
% files; on the opposite, if the environment is used after the
% |\documentclass| statement ,the |xmpdata| file is simply overwritten
% without the need to delete a previous version.
%
% The work-around mentioned above consists in adding another line 
% at the very end of the metadata file; it looks like this:
%\begin{verbatim}
%\setRGBcolorprofile{sRGB.icc}{sRGB}{Argyll CMS, sRGB color profile}%
%{https://www.argyllcms.com/}
%\end{verbatim}
% Thanks to the new |filecontents| functionalities there is no need
% to delete a previous |.xmpdata| file. But, as specified above, this
% work-around is not necessary anymore if the most recent version 1.6.1
% or later of \pack{pdfx} is used; this work-around information is
% maintained in this documentation just for backwards compatibility.
%
% This work-around is required if you get an error message that
% refers to line 1084 of the |pdfx.sty| file; if you don't patch
% the metadata file and you do not get the above error, it means
% that the |pdfx| package has already been corrected.
%
% \item
% Some mathematical symbol commands obtained from the standard
% \LaTeX\ set-up and the standard mathematical fonts require
% some patching that is already included in this \texttt{TOPtesi}
% bundle; but it is not excluded that with other fonts similar
% patches might be requested. The \sigla{UNICODE} math fonts used
% by \XeLaTeX\ and \LuaLaTeX\ do not require any patch.
%
% \item
% Use only \sigla{PNG} and \sigla{JPG} images with \sigla{RGB} color
% profiles. But if a \sigla{PNG} image file contains some transparencies,
% the document \sigla{PDF} cannot be validated as \sigla{PDF/A}-1b
% compliant.
%
% \item
% If you include \sigla{PDF} images that contain some text, be sure
% that the fonts for this text are completely embedded in
% the included files. Should the \sigla{PDF} files come from an external
% drawing program be sure to configure that program so that
% it embeds all the fonts used in each image. If you don't
% succeed, open the \sigla{PDF} file with the free software
% \texttt{inkscape} and save it back in \sigla{PDF} format; the
% missing fonts will be replaced with their outlines and
% this will not disturb the \sigla{PDF/A} conformity. Pay attention,
% because Inkscape might save your file with some
% specifications for transparency; but transparency
% specifications destroy the \sigla{PDF/A} compliance.
% Should this inconvenience take place, instead of asking
% \texttt{inkscape} to save in \sigla{PDF} format, ask to save in
% \sigla{EPS} format; this one does not support transparencies,
% therefore they get abolished from the very beginning. This is useful
% also when \texttt{inkscape} is used to change the color
% profile of an image. Once this program is used to convert an
% image to \sigla{EPS} format without transparencies and/or with the
% accepted \sigla{RGB} color profile, import the image as usual with
% |\includegraphics|; all the suggested typesetting programs,
% \prog{pdflatex} included, can import \sigla{EPS} files, therefore
% these problems, thanks \texttt{inkscape} may be easily overridden. 
% Once you got the corrected EPS file, you might distill it to PDF,
% so as to compress it in a compatible way; EPS files are generally
% human readable so they are very large in terms of memory size.
%
% \item
% Verify your final \sigla{PDF} file with a suitable program and
% do not give up doing the necessary corrections or
% modifications while the verification program keeps saying
% that this or that is not compliant with the \sigla{PDF/A}
% specification. A suitable program is the Preflight module
% of Adobe Acrobat Pro~XI (or later), but this, although the most
% authoritative, is a commercial program; probably your
% university has special facilities for this task. In any
% case you can install the \prog{veraPDF} free software
% from the Internet, and use this handy verification program
% (in 2017 the stable release was made available).
%
%\end{enumerate}
%
% Warning: if you are using Adobe Reader X (or later), this
% program will open a \sigla{PDF} file beginning with an information
% header stating that the file claims to be \sigla{PDF/A} compliant;
% maybe it's true, but do not trust this information too much,
% at least don't believe that this information is a
% “certification” of the \sigla{PDF/A} compliance. I have seen
% files with this comforting information that did not pass
% the Preflight test! Actually the Reader is correct in saying
% that “\dots\ the program claims to be \sigla{PDF/A} compliant\dots”;
% the Reader just notices that the metadata contain such a claim,
% but this does not imply that the claim is true.
%
% Up to today the realisation of \sigla{PDF/A} conforming files sets
% forth several problems that are of great concern for 
% large Institutions that have thousands of documents a year
% to archive; it is not a question implied in the free nature
% of the \prog{pdflatex}, \prog{xelatex}, and \prog{lualatex}
% programs, that, on the opposite, according to my experience,
% have a very high rate of success in producing \sigla{PDF/A}
% compliant documents.  If you stick to the default \TeX\ system
% Type~1, 256-glyph fonts, or to the \sigla{UNICODE} encoded otf
% or ttf fonts and use this version of the TOPtesi bundle
% you should be able to avoid most problems.
%
% \section{Customisation}\label{sec:LPPL}
% Customisation of parts of this bundle is discouraged, but is not
% forbidden, provided that it is done according to the \LaTeX\ Project
% Public Licence (LPPL). The full text of this licence is contained at the
% end of the Italian documentation file \texttt{toptesi-it.pdf},
% besides being available from the \sigla{ctan} web site.
%
% The parts of this bundle already contain several customising
% commands and environments; other parts are not directly
% customisable; for example the geometry of the page; the various
% standard title pages (where the \texttt{tipotesi=custom} option
% already allows complete customisation of the title page); the
% super sectioning of the final document by means of |\frontmatter|,
% |\mainmatter|, and |\backmatter|; what appears in the table of
% contents; and so on.
%
% Nevertheless, in spite of being discouraged,  some user might
% want to customise some details. There are several ways to do
% such customisation that conform the LPPL. 
%
% \textcolor{red}{The main restriction set by the LPPL is that
% the bundle files may be modified, but their names must be changed,
% although the original author and licence are maintained in their
% initial comments, and that the file maintainer name is changed so
% that any user of the modified version knows to whom address
% him/herself in case of need; the original author  is not responsible
% of any modified file.}
%
% \paragraph{Direct modification}
% In order to make a direct modification to any original file, first
% duplicate the original file and change name to the duplicated file;
% the modify this copy name and make the changes that are deemed
% necessary, without forgetting to delete my name as the maintainer
% while adding your name; it would be useful if some comments are
% added so as to describe what has benne modified, why and how.
%
% Remember to change accordingly the references to the modified
% file(s) in the other bundle files; this implies that all the
% bundle files get modified and that their names must be changed
% accordingly while modifying the initial  comment lines so as to
% delete my name as the maintainer.
%
% \paragraph{Modification of single commands and/or environments}
% Another way to perform some customisation that does not infringe
% the LPPL licence is the following.
%
% In facts a simpler way to customise some commands and or
% environments is to copy their code from the original bundle
% files, and paste it  into a personal \texttt{.sty} file to be
% input with a |\usepackage| command inside the argument of
% another |\AtBeginDocument| command; modify your personal file
% the way you like, and test the result.

% If your modifications do not produce any difference in the 
% output PDF file, then you have to load your modified file after
% the |\begin{document}| line. In this case you have to change
% your file extension from \texttt{.sty} to \texttt{.tex}, and 
% you probably have to start your file with a |\makeatletter| and
% finish it with a |\makeatother| commands, since many macros
% used inside the original code are “protected” with an |@| sign
% with its category code changed to “letter”. Needless to say that
% in order to suse thei |.tex| file, the |\input| command must be
% used in place of the |\usepackage| one.
%
% \paragraph{Command patching}
% A third way to modify some commands and/or environments is to
% patch their definitions by means of the patching commands provided
% by the |etoolbox| package, that is already loaded by this bundle.
% Such |etoolbox| commands allow to add or to append some code to
% selected macros; other |etoolbox| commands allow to insert some code
% in the middle of a replacement text of selected macros or to replace
% some code in any position of its replacement text.
%
% The use of these patching commands requires some attention and
% is not recommended for \LaTeX\ beginners; nevertheless it is the
% best way to apply personal modifications to existing commands.
% The details of this procedure must be examined in the |etoolbox|
% documentation.
%
% \StopEventually{}
%
% \newpage
%
% \section{Documented code}
% \subsection{The class code}
%
% Here begins the usual machinery for stating the required
% \TeX\ format and for sharing some code between the driver
% and the class part of the code, since they are supposed to
% carry the same date and version number, besides their specific
% description string.
% \iffalse
%<*class>
% \fi
%
% The class itself is very simple since it loads just the
% \texttt{report} document class and some packages with a few
% default options. All options specified to the \texttt{toptesi}
% class are passed on to the \texttt{report} class; the
% |a4paper| option is made the default, but the user can invoke
% the class with any valid \LaTeX\ paper size. According to the
% \LaTeX\ and |xkeyval| machinery of option passing, the |\ExecuteOptionX|
% command assures that |a4paper| is the default size, but it
% is not used if another paper size code is specified to the class.
%
% The same holds true for the other class options, except for
% the encoding string because their option passing machinery does
% not hold true for the \pack{inputenc} package; therefore this
% package is not loaded any more as it was in previous versions
% of the class\footnote{Thanks to Enrico Gregorio who pointed
% out this feature.}. 
%
% On the opposite, while typesetting with
% |pdfLaTeX|, if another language is specified in the list of
% \pack{toptesi} class options this language is appended to the
% \pack{babel} package default options and, beware!, it would
% become the default language; with XeLaTeX and LuaLaTeX a
% language option is useless (and harmless) due to their way of
% specifying languages; with these programs other languages must
% be specified with their |\setotherlanguage| or |\setotherlanguages|
% commands which do not change the preset main language.
%
% The |filecontents| package is loaded: it removes the constraints
% the original kernel environment |filecontents|, with or without
% the asterisk, sets up for its use. In particular that what is
% contained in the environment gets saved in the named file, only
% if the named file does not exist. This implies that if some
% changes are introduced in the environment contents, such changes
% do not get saved in the named file unless a pre\-existing file is
% deleted.
%
% Another piece of code follows in order to abort the job if the
% |toptesi| date, contained in it |\ProvidePacckage| argument is
% older than the class date. Should this happen, the job is aborted
% with a strong message on the console. In order to work properly
% the |toptesi| package is loaded and its date is fetched by means
% of the defined |\GetFileInfo|macro. This macro is almost identical
% to the one that is available when this documented file is processed;
% it simply differs in the sense that the |v.| prefix to the file
% version number is taken as a separator; should be necessary to
% compare also the version number, the |\fileversion| macro gets
% defined properly without any prefix. The |\@parse@version| macro
% is a \LaTeX\ kernel one; in spite spite of its name, it extracts
% from the first macro token the data in a form suitable for comparison
% with the second macro token, so that a numerical test can be performed
% without the intervention of non digit symbols. The prominent class
% error message is output only if the numerical value of the package
% date is strictly lower than the class date. This version control was
% necessary because apparently there are some vintage versions still
% on the web, and some newbie \TeX{}ies fetch them instead of using
% the most recent \TeX\ system complete and updated installation.
%    \begin{macrocode}
\usepackage{trace}
\RequirePackage{xkeyval}
\DeclareOptionX{formato}[a4paper]{\PassOptionsToClass{#1}{report}}
\DeclareOptionX*{\PassOptionsToClass{\CurrentOption}{report}}
\ExecuteOptionsX{formato}
\ProcessOptionsX*\relax
\LoadClass{report}

\RequirePackage{iftex}
\ifPDFTeX
  \usepackage[english,italian]{babel}
\else
  \usepackage{fontspec}
  \defaultfontfeatures{Ligatures=TeX}
  \usepackage{polyglossia}
  \setmainlanguage{italian}
  \setotherlanguage{english}
  \renewcommand*{\iflanguage}[1]{%
  \ifnum\the\language=\csname l@#1\endcsname
  \expandafter\@firstoftwo\else
  \expandafter\@secondoftwo\fi}
\fi
\RequirePackage{filecontents}
\providecommand\GetFileInfo[1]{%
  \def\filename{#1}%
  \def\@tempb##1 v.##2 ##3\relax##4\relax{%
    \def\filedate{##1}%
    \def\fileversion{##2}%
    \def\fileinfo{##3}}%
  \edef\@tempa{\csname ver@#1\endcsname}%
  \expandafter\@tempb\@tempa\relax? ? \relax\relax}

\usepackage{toptesi}
\GetFileInfo{toptesi.sty}\let\stydate\filedate
\GetFileInfo{toptesi.cls}\let\classdate\filedate

  \ifnum\expandafter\@parse@version\stydate//00\@nil<%
        \expandafter\@parse@version\classdate//00\@nil
    \ClassError{toptesi}{\MessageBreak
      ******************\MessageBreak
      This class requires a sty file not older than the class\MessageBreak
      This class has a date of \classdate\space while\MessageBreak
      the sty file you are using  has a date of \stydate\MessageBreak
      \MessageBreak
      This job is therefore aborted\MessageBreak\@gobble
      ******************\MessageBreak
      \MessageBreak
      Update your TeX system installation and/or \MessageBreak
      avoid using vintage toptesi.sty files%
    }{%
    }
    \expandafter\stop
  \fi
%
%    \end{macrocode}
% \iffalse
%</class>
% \fi
% \subsection{The \texttt{toptesi.sty} code}
% The greatest part of the \texttt{toptesi} class code is
% saved into a separate file partly for backward compatibility
% reasons (before version 3.x \texttt{toptesi} was just an
% extension to the \texttt{report} class) and partly because
% it might be used as a stand alone package, but, take
% notice, it might create some conflicts with with other
% classes internal code, although with the latest versions
% of |toptesi| we did not notice any conflict with the |book|
% class; it is certainly  incompatible with the \texttt{article}
% class.
%
% This package |toptesi.sty| must contain its own \TeX\ format
% declaration in view that it might be used as an extension to
% other classes 
%
% \iffalse
%<*topsty>
% \fi
%
% We start by defining the debugging macros; these trace
% commands and macros are the usual ones I used for debugging.
% I know the \texttt{trace} package is supposed to be much better,
% but sometimes I use these ones, especially when I want to
% trace math snippets, where the tracing functionalities of
% \pack{trace} are turned off.
%    \begin{macrocode}
\def\TRON{\tracingcommands \tw@ \tracingmacros \tw@}
\def\TROFF{\tracingcommands\z@ \tracingmacros \z@}
\let\TROF\TROFF
%    \end{macrocode}
%
% Now we define the specific package options: \texttt{classica} and
% \texttt{trieste} are identical; the use of \texttt{trieste} is
% deprecated, but this option is maintained for backward
% compatibility.
%
% The  option \opz{scudo} is used only to typeset doctoral
% dissertations with the special look required by the “Scuola
% di Dottorato” of Politecnico di Torino. The other options for
% specific types of thesis, \opz{triennale}, \opz{monografia},
% \opz{magistrale}, \opz{dottorale}, \opz{secondaria}, are
% described further on; options \opz{frontespizio}  and
% \opz{custom} avoid loading the  default module |topfront| or any
% of the previous listed modules; the are used to create title pages
% different from the ones that are available with TOPtesi.
%
% The |corpo = value| option can receive “any” value; if this
% value is not lower than  14\,pt , the |\if@xixpt| switch is
% set to true; the value assigned to |corpo| specifies the normal
% size; the TOPtesi bundle uses the |\changefontsizes| macro
% provided by package |scrextend|, that is part of any \TeX\ 
% system complete and up-to-date TeXLive or MiKTeX  installation.
%
% Option \opz{chapterbib} allows to set a list of references at
% the end of each chapter. The option is maintained for backward
% compatibility, but we discourage its use, because of the amount
% of manual work involved; it is much better to use the |biblatex|
% functionalities and/or other packages created for this purpose.
%
% For other options some boolean variables are
% defined and the option definitions set some of them to the value
% “true”.
%    \begin{macrocode}
\newif\ifevenboxes \evenboxesfalse
\newif\if@utoretitolo \@utoretitolofalse
\newif\if@ldstyle \@ldstylefalse
\newif\if@xivpt \@xivptfalse
\newif\iflibro \librofalse
\newif\ifT@Pfrontespizio \T@Pfrontespiziofalse
\newif\ifTOPfront \TOPfronttrue
%
\newif\ifScuDo \ScuDofalse
\newif\ifmonografia\monografiafalse
\newif\iftriennale\monografiafalse
\newif\ifmagistrale\magistralefalse
\newif\ifdottorato\dottoratofalse
\newif\ifsecondaria\secondariafalse
\newif\ifcustom\customfalse
\newif\ifTOPnumerazioneromana\TOPnumerazioneromanafalse
%    \end{macrocode}
%
% A binding correction is established; its default value is
% parametrised to the paper dimensions, even if this correction
% should actually not depend on the paper size; the paper
% flexibility at the spine margin should be independent from
% its width; nevertheless large sizes allow for larger default
% corrections. In any case the user can override this setting by
% using the specific command |\setbindingcorrection|.
% The recommendation to the user is to not exaggerate with this
% correction. In particular the user is warned not to use this
% option in order to move che text body grid towards the outer
% edge, simply because s/he does not understand why two side
% typesetting uses an inner margin smaller than the outer one.
% In any case see further on a deeper explanation about margins
% and binding correction.
%
% The options |usefrontespizio| and |noTOPfront| are set by the
% specific “function” executed by the |tipotesi=|\meta{value} options.
%    \begin{macrocode}
\newlength\T@Pbinding
\def\setbindingcorrection#1{\T@Pbinding=#1}
\newif\if@binding \@bindingfalse
\newif\ifchapterbibliography \chapterbibliographyfalse
\newif\ifclassica \classicafalse

\@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}}
\@ifpackageloaded{scrextend}{}{\RequirePackage{scrextend}}
\@ifpackageloaded{iftex}{}{\RequirePackage{iftex}}
\@ifpackageloaded{xspace}{}{\RequirePackage{xspace}}
\@ifpackageloaded{xparse}{}{\RequirePackage{xparse}}

\DeclareOptionX{cucitura}[7mm]{\setlength\T@Pbinding{#1}\@bindingtrue}
\DeclareOptionX{corpo}[10pt]{\unless\ifdim#1<\@xivpt\p@\@xivpttrue\fi
   \changefontsizes{#1}}
\DeclareOptionX{chapterbib}[true]{\chapterbibliographtrue}
\DeclareOptionX{evenboxes}[true]{\evenboxestrue}
\DeclareOptionX{libro}[true]{\librotrue}
\DeclareOptionX{stile}[standard]{\setkeys{toptesi}{stile=#1}}
\define@choicekey{toptesi}{stile}[\val\nr]{standard,classica,trieste}{%
    \ifcase\nr
       \typeout{valore=\number\nr}\classicafalse
    \or
       \typeout{valore=\number\nr}\classicatrue
    \or
       \typeout{valore=\number\nr}\classicatrue
    \else
       \typeout{valore=\number\nr}\classicafalse
    \fi}
\DeclareOptionX{autoretitolo}[true]{\ifclassica\@utoretitolotrue\fi}
\DeclareOptionX{oldstyle}[true]{\ifclassica\@ldstyletrue\fi}
\DeclareOptionX{pdfa}{\PackageWarning{toptesi}{%
    ***********************************************\MessageBreak%
    Option pdfa ignored.\MessageBreak%
    Read documentation toptesi-it-*.pdf,\MessageBreak%
    because package pdfx has changed\MessageBreak%
    ***********************************************\MessageBreak%
    }}

\DeclareOptionX{numerazioneromana}[true]{\TOPnumerazioneromanatrue}

\newcommand\NoValidTipo[1]{%
\PackageError{toptesi}{Option value `#1' not defined\MessageBreak
}{Type `X' to exit and check your input}}


\DeclareOptionX{tipotesi}[topfront]{%
  \ifstrequal{#1}{frontespizio}{\TOPfrontfalse\T@Pfrontespiziotrue
    \AtEndOfPackage{\RequirePackage{frontespizio}}%
    }{%
    \ifstrequal{#1}{topfront}{\TOPfronttrue\T@Pfrontespiziofalse
      \AtEndOfPackage{\RequirePackage{topfront}}%
    }{%
      \TOPfrontfalse\T@Pfrontespiziofalse 
        \ifstrequal{#1}{custom}{\relax}{%
          \ifstrequal{#1}{triennale}{%
             \def\TPT@tipo{toptesi-monografia}% opz: monografia
          }{\ifstrequal{#1}{secondaria}{% opz: secondaria
             \edef\TPT@tipo{toptesi-sss}%
            }{%
             \edef\TPT@tipo{toptesi-#1}% opz: triennale,
            }%                         % magistrale, dottorale
          }%
          \AtEndOfPackage{%
            \IfFileExists{\TPT@tipo.sty}%
              {\RequirePackage{\TPT@tipo}}{\NoValidTipo{#1}}%
          }%
        }% opz: custom
      }% opz: topfront
    }% opz: frontespizio
  }
\ProcessOptionsX*

%    \end{macrocode}
% The \texttt{graphicx} package is loaded by default; it is
% required to insert the university logo(s); if the user
% forgets that this package has already been loaded nothing
% dramatic happens, because the |\usepackage| and |\RequirePackage|
% macros perform the necessary tests in order to avoid
% reloading the same packages again and again.
% On the occasion of loading package|etoolbox|, we define
% |\ifempty| that controls if its argument is a void or empty
% string; it is not sufficient to use |\ifdefempty| or |\ifdefvoid|,
% because the argument generally is not a macro; neither it is
% possible to check the string by means of |\ifcsempty| or
% |\ifcsvoid|, because sometimes it is a macro and in any case
% there might be situations when the argument string happens
% to equal an existing control sequence name; therefore first
% we expand the possible argument into an internal macro, then we test
% such macro for emptiness.
%
%    \begin{macrocode}
\RequirePackage{graphicx}
\RequirePackage{etoolbox}
\RequirePackage{xspace}
\newcommand*\ifempty[1]{\edef\@tempA{#1}%
\ifx\@tempA\@empty\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
%    \end{macrocode}
%
% The |\textheight| is parametrised to the paper height and
% adjusted so as to contain an integer number of normal text
% lines. A new dimension is defined to hold the actual value
% of the inner/spine margin.
%
%    \begin{macrocode}
\newlength\interno
\normalsize% necessary to have the correct value for \baselineskip
\textheight \paperwidth
\setlength{\textheight}{%
\dimexpr\textheight*\baselineskip/\baselineskip+\topskip}
%    \end{macrocode}
% The inner margin is parametrised to the paper width, but
% a small correction is made if the extra size of 14pt is
% chosen. Also |\footskip| is parametrised to the paper height
% in a slightly different way when the large normal font size  
% is not smaller than 14\,pt; the |\if@xivpt| switch is set to true when the value is assigned to the key |corpo|.
%    \begin{macrocode}
\iflibro
  \unless\if@xivpt 
    \textwidth=\dimexpr0.70711\paperwidth\relax
    \setlength\interno{\dimexpr\paperwidth/8}
    \footskip=1.5\baselineskip
  \else
    \textwidth=\dimexpr0.79549875\paperwidth\relax
      \setlength\interno{\dimexpr\paperwidth/9}
      \footskip=2\baselineskip
  \fi
\else
  \unless\if@xivpt 
    \textwidth=\dimexpr0.70711\paperwidth\relax
    \setlength\interno{\dimexpr\paperwidth/6}
    \footskip=1.5\baselineskip
  \else
    \textwidth=\dimexpr0.79549875\paperwidth\relax
      \setlength\interno{\dimexpr\paperwidth/7}
      \footskip=2\baselineskip
  \fi
\fi
%    \end{macrocode}
% The convenience of holding the spine margin within a
% dimensional register becomes really useful now in order
% to define the other text-body-grid dimensions.
% Without binding correction the inner and outer margin
% are chosen equal, but the grid is moved outwards if the
% binding correction option is specified. With the |libro|
% option in force, the outer, lower margin are larger than
% the corresponding inner and top margins. Without such
% option, the margins are initially set equal, unless the
% binding correction is specified.
%    \begin{macrocode}
\iflibro 
  \interno=\dimexpr\paperwidth-\textwidth\relax
  \oddsidemargin=0.414214\interno\relax
  \evensidemargin=\dimexpr\paperwidth-\textwidth-\oddsidemargin\relax
\else
  \oddsidemargin=\dimexpr(\paperwidth-\textwidth)/2\relax
  \evensidemargin=\oddsidemargin
\fi
\marginparwidth=\dimexpr\evensidemargin-2.5\marginparsep
\oddsidemargin=\dimexpr\oddsidemargin-1in\relax
\evensidemargin=\dimexpr\evensidemargin-1in\relax
\AtBeginDocument{%
\if@binding
 \PackageInfo{TOPtesi}{Margin width recalculation}
 \PackageInfo{TOPtesi}{Before:\MessageBreak
 oddsidemargin\space\space \the\oddsidemargin\MessageBreak
 evensidemargin\space \the\evensidemargin}
 \advance\oddsidemargin \T@Pbinding
 \advance\evensidemargin -\T@Pbinding
 \advance\marginparwidth -\T@Pbinding
 \PackageInfo{TOPtesi}{After:\MessageBreak
 oddsidemargin\space\space \the\oddsidemargin\MessageBreak
 evensidemargin\space \the\evensidemargin}
\fi}

%    \end{macrocode}
%
% We now establish the page style. We start by setting to
% “empty” the tokens that keep the left and the right
% marks; we define a box so as to set the headers inside
% this box; we redefine also the plain page style; it is
% actually a leftover from the previous versions when the
% page number was set at the foot in bold face, but we leave
% it here without the bold face specification, so that in
% future versions folios may be redefined in a common way
% with the other page styles. Notice that in all page styles
% folios are always in the footers.
%
% By defining |\lapagina| to be equivalent to |\thepage|
% we can later on redefine |\lapagina| the way we like; we
% actually do so with the option \texttt{classica}.
%    \begin{macrocode}
\def\lapagina{\thepage}
\mark{{}{}}
\newbox\@intesta
%
\def\ps@plain{\let\@mkboth\@gobbletwo
\def\@oddfoot{\null\hfill {\scshape\lapagina}\hfill \null}\def\@oddhead{}
\def\@evenhead{}\let\@evenfoot\@oddfoot}
%    \end{macrocode}
% Other page styles are defined in a different way according
% to the choice of one side or two side printing. In any case
% the header is set without the uppercasing that is done in
% all the default document classes, and it is underlined at
% a fixed distance from the base line. If the chapter or section
% heading exceed the |\textwidth| a warning is issued so as
% to invite the user to exploit the sectioning commands
% optional short argument.
%    \begin{macrocode}
\if@twoside
   \def\ps@headings{\let\@mkboth\markboth% autoretitolo
   \def\@oddfoot{\null\hfill {\scshape\lapagina} \hfill\null}
   \let\@evenfoot\@oddfoot
   %
   \def\@evenhead{\setbox\@intesta\hbox{\footnotesize\slshape
        \leftmark}%
   \ifdim\wd\@intesta>\textwidth \headWarn{\chapter}\fi%
   \underline{\makebox[\textwidth]{\footnotesize\slshape
        \strut\leftmark}}}%
   \def\@oddhead{\setbox\@intesta\hbox{\footnotesize\slshape
        \rightmark}%
   \ifdim\wd\@intesta>\textwidth \headWarn{\section}\fi%
   \underline{\makebox[\textwidth]{\footnotesize\slshape
        \strut\rightmark}}}%
   \def\chaptermark##1{%
       \markboth{\thechapter\ -- ##1}{\thechapter\ -- ##1}}
   \def\sectionmark##1{\markright{\ifnum\c@secnumdepth>\z@
   \thesection\ -- \fi ##1}}}
\else
   \def\ps@headings{\let\@mkboth\markboth
   \def\@oddfoot{\null\hfill {\scshape\lapagina} \hfill\null}
   \def\@evenfoot{}
   \def\@oddhead{\setbox\@intesta\hbox{\footnotesize\slshape
        \rightmark}%
   \ifdim\wd\@intesta>\textwidth \headWarn{\chapter}\fi%
   \underline{\makebox[\textwidth]{\footnotesize\slshape
        \strut\rightmark}}}%
   \def\chaptermark##1{\markright{\thechapter\ -- ##1}}}
\fi

\def\headWarn#1{\PackageWarning{toptesi}{%
*******************************************\MessageBreak
   THE HEADING IS TOO LONG\MessageBreak
   Use the optional argument of command \string#1\MessageBreak
   See the LaTeX Handbook (1994) on section C.4.1\MessageBreak
*******************************************\MessageBreak}}
%    \end{macrocode}
% It is also necessary to redefine the format of the unnumbered
% chapter entries in the table of contents so as to have page
% numbers in small caps.
%    \begin{macrocode}
\renewcommand\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak
      \hb@xt@\@pnumwidth{\hss\ifPDFTeX\normalfont\fi\scshape{#2}}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
%    \end{macrocode}
% The various tables of contents, or figures, or tables
% require some boolean variables to be defined; in facts,
% although the \sigla{ISO} regulations require that every technical
% report contains the list of figures and/or tables,
% in Italy theses rarely contain these lists; the question is: “is a
% thesis a technical report?”. In Italy, in most cases, the answer is “no”.
% We require also some other boolean variables to handle the
% difference between front matter and main matter; this
% differences are already defined in the \texttt{book}
% document class, but not in the \texttt{report} one.
%    \begin{macrocode}
\newif\iffigurespage
\newif\iftablespage
\newif\ifnumeriromani
\newif\if@mainmatter
\newif\iffrontmatter
%    \end{macrocode}
% The |\frontmatter| and |\mainmatter| commands are defined
% and at the beginning of the document the default situation
% of front matter is established. For the |\backmatter|
% command it suffices to turn out sectional numbering, and
% to allow opening chapters also on even numbered pages.
%    \begin{macrocode}
\def\frontmatter{\clearpage\ps@plain\@mainmatterfalse
  \ifTOPnumerazioneromana\numeriromanitrue\fi
  \frontmattertrue\@openrightfalse\c@secnumdepth=-2\relax
}
    
\def\mainmatter{\@mainmattertrue
\if@twoside\@openrighttrue\fi
  \ifTOPnumerazioneromana\numeriromanifalse\fi
  \frontmatterfalse
  \c@secnumdepth=2
  \clearpage\ps@headings
  \ifTOPnumerazioneromana\pagenumbering{arabic}\fi
}
\newcommand\backmatter{\cleardoublepage[empty]%
\@mainmatterfalse
\setcounter{secnumdepth}{-1}\if@twoside\@openrightfalse\fi}

\AtBeginDocument{%
  \ifTOPnumerazioneromana\pagenumbering{roman}\fi\frontmatter
}
%    \end{macrocode}
%
% The main matter is automatically established with the
% first |\chapter| command issued by the user; this means
% that every command that starts a section at the
% “chapter” level within the front matter must be
% executed without an explicit call to |\chapter|. This
% refers especially to the |\sommario|/|\summary| and
% |\ringraziamenti|/|\acknowledgements| sections. On the
% contrary even  an unnumbered chapter (for example a preface)
% turns on the main matter typesetting style.
%
% By default we set to false the boolean variables that
% control the typesetting of the list of figures and the list
% of tables.
%    \begin{macrocode}
\figurespagefalse
\tablespagefalse

%    \end{macrocode}
%
% Before going further on, we redefine the |\cleardoublepage|
% command so that it uses by default the plain page style
% for the blank page to be possibly inserted if chapters
% should start on an odd page: but with the |\blankpagestyle|
% command can be set to any other style, for example the
% |empty| page style.
%    \begin{macrocode}
\let\ps@blank\ps@plain
\newcommand*\blankpagestyle[1]{%
   \expandafter\let\expandafter\ps@blank\csname ps@#1\endcsname}
\renewcommand\cleardoublepage[1][blank]{\clearpage
\unless\ifodd\value{page}
   \if@twoside
      \if@openright
         \null\thispagestyle{#1}\clearpage
   \fi\fi\fi}
   
%    \end{macrocode}
%
% We have to define the front matter sectioning names |\sommario|
% (alias |\summary|) and |\ringraziamenti| (alias
% |\acknowledgements|) so as to remain in the front matter.
%    \begin{macrocode}
\def\sommario{%
 \iffrontmatter\else\frontmattertrue\fi
 \chapter*{\summaryname}}
\let\summary\sommario
%
\def\ringraziamenti{%
 \iffrontmatter\else\frontmattertrue\fi
 \chapter*{\acknowledgename}}
\let\acknowledgements\ringraziamenti
%    \end{macrocode}
% The strings |\summaryname| and |\acknowledgename| are not
% defined for every language option to \texttt{babel}. Default
% definitions are given below, and the user must define new
% names for localising the package in a language different
% from Italian and English.
%
% We have to modify the |\chapter| and |\part| commands so
% that as the user first uses one of these commands the
% typesetting style is switched to that of the main matter.
% But by exploiting certain facilities of the |xparse| package,
% some delicate tests could be developed by |xparse| itself; therefore
% the whole command was redefined so that the new syntax is the following:
%\begin{flushleft}\obeylines
%\cs{chapter}\meta{$\star$}\oarg{toc entry}\oarg{headings entries}\marg{title}\oarg{pagestyle}
%\end{flushleft}
% The \meta{$\star$} is optional, and simply implies that no toc
% entry will be generated and the chapter title will not be
% numbered. In this way the previous \LaTeX\ kernel macros
% |\chapter| and |\chapter*| maintain their usual behaviour:
%\begin{flushleft}\obeylines
%\cs{chapter}\oarg{toc entry}\marg{title}
%\cs{chapter*}\marg{title}
%\end{flushleft}
% But the various optional arguments play different roles and
% implement new functionalities. The star itself now is a special
% argument, numbered |#1|, therefore the total number of arguments
% is five. Their meaning is the following.
%\begin{description}
%
%\item[\meta{$\star$}] Controls the chapter numbering and the
% toc entry; its absence implies numbering and toc entry;
% its presence implies no numbering and no toc entry;
% nevertheless is does not cancels the possibility of having
% an header (if the page style accepts left and right marks);
% for example, a command such as this one\\[1ex]
%\cs{chapter*}\Oarg{Short entry}\Marg{Long title}\\[1ex]
% does not number the chapter with the |Long title|, but gets
% the string |Short entry|; lacking the optional argument both
% headers (see below) will contain the string |Long title|.
% If you want an empty header, you have to specify an empty
% optional argument; or before using the command, you specify
% an empty or a plain page style
%\item[\meta{toc entry}] is the entry for the table of contents;
% its default value is \meta{title}, but since more often than
% not the actual \meta{title} is a long string, it is better 
% to use such optional argument: of course, if the optional star
% is used, its \meta{toc entry} is passed on as a default value
% for the \meta{headings entry}.
%
%
%\item[\meta{headings entry}] contains the string to be inserted
% in both left and right headers, if the page style uses such
% pieces of information; this is a deliberate choice in order
% to have both headers correctly indicating the chapter title
% even if the “chapter” contains no sections, for example indices,
% lists of figures and/or tables, forewords and similar thesis
% items. Of course if sections are used, their entries replace
% that chapter entry in the right header. This choice of defining
% both headings is useful also for those numbered chapters that
% have a longish text preceding the first section.
%
%
%\item[\meta{title}] with no surprise is the chapter title that
% is printed in its opening page. It defines also the default 
% \meta{toc entry} and therefore the \meta{headings entry}.
%
%
%\item[\meta{pagestyle}] solves a problem that arises more often
% than not: by default the chapter opening page is typeset with
% the |plain| page style; sometimes a different style is desired,
% for example the |empty| one. The use can specify this optional
% argument with |empty| to have a headerless opening page without
% a printed folio. Actually the user can specify any page style,
% provided it satisfies the typographical best practice.
%
%\end{description}
% Actually the  commands to typeset the Summary and the
% Acknowledgements chapters, as defined above, are regularly
% typeset in the front matter style, opening on any page
% (even or odd) and possibly numbered with small caps roman numerals.
%    \begin{macrocode}
\RenewDocumentCommand{\chapter}
  {s O{#4} O{#2} m O{plain}}{%
  \if@openright\cleardoublepage
    \else\clearpage\fi
  \thispagestyle{#5}%
  \global\@topnum\z@
  \@afterindentfalse
\IfBooleanTF{#1}{%
  \c@secnumdepth=-3\relax
  \let\iftoc\iffalse
}{%
  \iffrontmatter\mainmatter\fi
  \let\iftoc\iftrue
}%
% Numbering and TOC entry
  \ifnum \c@secnumdepth >\m@ne 
    \if@mainmatter % where \if@mainmatter is defined 
                   % (e.g. book.cls, toptesi.cls) 
      \refstepcounter{chapter}%
      \typeout{\@chapapp\space\thechapter.}%
      \iftoc\addcontentsline{toc}{chapter}{%
        \protect\numberline{\thechapter}#2}\fi
      \else % 
        \iftoc\addcontentsline{toc}{chapter}{#2}\fi
      \fi
  \else % Were \mainmatter is not defined (e.g.report.cls)
    \iftoc\addcontentsline{toc}{chapter}{#2}\fi
  \fi
%  Headers
  \markboth{#3}{#3}% No \MakeUppercase
  \iftoc
    \addtocontents{lof}%
      {\protect\addvspace{10\p@}}%
    \addtocontents{lot}%
      {\protect\addvspace{10\p@}}%
  \fi
% Actual title in the opening chapter page.
  \if@twocolumn
    \@topnewpage[\@makechapterhead{#4}]%
  \else
    \@makechapterhead{#4}%
    \@afterheading
  \fi
}
%    \end{macrocode}
% It would be possible to redefine in a similar manner also
% the |\part| command, but it was deemed unnecessary, since
% theses are seldom divided into parts.
%    \begin{macrocode}
\def\@part[#1]#2{\iffrontmatter\mainmatter\fi
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >-2\relax
       \huge\bfseries \partname\nobreakspace\thepart
       \par
       \vskip 20\p@
     \fi
     \Huge \bfseries #2\par}%
    \@endpart}
    
%    \end{macrocode}
% At the same time we have to make sure that |\tableofcontents|,
% |\listoftables| and |\listoffigures| do not exit from the
% front matter style. We assume these commands are issued
% while in front matter, the default at the begin document phase,
% so we  use starred |\chapter| commands but add the necessary
% toc entries with the native  commands. We need not define the
% headers, because the default title is good for this purpose;
% but since such thesis elements are typeset with the front
% matter page style (|plain|), no headers are used; With long
% indices and/or lists of tables and/or figures, the user might
% desire to have headers, so that the declaration
% |\pagestyle{headings}| should be specifies before using the
% |\indici| or |\allcontents| commands.
%
% The table of contents itself is not linked at all, but in order
% to link the lists of tables and figures, that are listed into
% the toc, it is better that such lists contain a possible
% target; the |\phantomsection| macro defined by the |hyperref|
% package is used; in case |hyperref| is not loaded, a dummy
% definition avoids “Undefined control sequence” error messages. 
%    \begin{macrocode}
\renewcommand\tableofcontents{%
 \chapter*{\contentsname}%
 \@starttoc{toc}%
 \clearpage
 \if@restonecol\twocolumn\fi
    }
    
\providecommand\phantomsection{}% in case \hyperref was not loaded

\renewcommand\listoffigures{%
    \phantomsection
    \chapter*{\listfigurename}%
    \addcontentsline{toc}{chapter}{\listfigurename}
    \@starttoc{lof}%
    \clearpage
    \if@restonecol\twocolumn\fi
    }

\renewcommand\listoftables{%
    \phantomsection
    \chapter*{\listtablename}%
    \addcontentsline{toc}{chapter}{\listtablename}
    \@starttoc{lot}%
    \clearpage
    \if@restonecol\twocolumn\fi
    }
%    \end{macrocode}
%
% We need to define |\indici| (alias |\allcontents|) that typesets
% the table of contents and, optionally, the lists of tables and/or
% figures while softly maintaining the front matter style for
% typesetting. In facts, if the user wants a diffferent styl s/he can select it with a suitable argument the |\pagestyle| command.
%    \begin{macrocode}
\def\indici{% If headings are desired, the pagestyle must be set in advance
 \iffrontmatter\else\frontmattertrue\fi
        \tableofcontents
        \iftablespage
                {\addvspace{10pt}
                \let\saveaddvspace=\addvspace
                \def\addvspace##1{}
                \listoftables
                \let\addvspace=\saveaddvspace}
        \fi
        \iffigurespage% 
                {\addvspace{10pt}
                \let\saveaddvspace=\addvspace
                \def\addvspace##1{}
                \listoffigures
                \let\addvspace=\saveaddvspace}
        \fi
\ifbool{@twoside}{\cleardoublepage[empty]}{}}
\let\allcontents\indici

%    \end{macrocode}
%
% Command |\onecolumn| is not actually necessary; it simply
% overrides the possible misused option \texttt{twocolumn}
% in the opening document class statement; no thesis should
% be typeset in two columns.
%    \begin{macrocode}
\onecolumn
%    \end{macrocode}
%
% Here come some declarations for vertical justification
% and for avoiding  an hyphenated word at the bottom of a page
%    \begin{macrocode}
\if@twoside
    \unless\ifScuDo
        \flushbottom
    \else
        \raggedbottom
    \fi
\else
    \ifx\@xivpt\f@size
        \raggedbottom
    \else
        \flushbottom
    \fi
\fi
\brokenpenalty=10000
%    \end{macrocode}
%
% Here comes a questionable command and/or environment; good
% typesetting requires the baseline skip to be proportioned
% to the font size, generally it is some 10--20\%  larger
% than the font size. In some reasonable instances a larger
% or a smaller baseline skip might be required; the \LaTeX\ 
% kernel allows to use the |\linespread| command; in the
% previous versions of this bundle a command |\interlinea|
% and an environment \texttt{interlinea} were defined so as
% to allow setting the line spread factor. The experience has
% shown that some students tend to use this command so as
% to typeset a poor and thin thesis on more pages. Well, every
% instrument can be judiciously or maliciously used; this is
% one of those double sided instruments.
%    \begin{macrocode}
\def\interlinea#1{\linespread{#1}\selectfont}
\def\endinterlinea{\par}
%    \end{macrocode}
% But whatever might be the current line spread factor within
% figures and tables we reset this factor to the unit value;
% floating bodies do not belong to this or that section
% of text where a different spread factor might be reasonable.
%    \begin{macrocode}
\def\@floatboxreset{%
        \reset@font
        \linespread{1}%
        \normalsize
        \@setminipage
}
%    \end{macrocode}
% Since we are at it we define the floating bodies placing
% parameters; not only the values “here”, “page top”
% and “page bottom”, that we set as the default ones
% leaving to the user to explicitly specify the
% “page of floats”, but also the numerical and geometrical
% parameters that control the float placements.
% These geometrical parameters are critical and everybody
% has his/her own ideas of what are the best values for them.
% According to my experience the parameters set by this
% extension file work quite well but I would not suggest
% them for every kind of typewritten document.
%
% In particular the zero value for the text fraction appears
% strange, but students have the tendency to create large figures
% (more often than large tables) and these tend to clog the
% figures queue. A 100\% space for the top of page figures
% and a requirement of 0\% text allows large floats
% to exit the queue provided they do not exceed the
% text height.
%    \begin{macrocode}
\def\fps@figure{htb} \def\fps@table{htb}
%
\setcounter{topnumber}{2}
\def\topfraction{1}
\setcounter{bottomnumber}{1}
\def\bottomfraction{.5}
\setcounter{totalnumber}{2}
\def\textfraction{0}
\def\floatpagefraction{0}
\setcounter{dbltopnumber}{2}
\def\dbltopfraction{1}
\def\dblfloatpagefraction{0}

%    \end{macrocode}
% One command that the default definition does not satisfy
% me very much is the |\caption| command; of course it is
% possible to configure the caption styles by means of the
% \pack{caption} package and its handy set of option styles
% specified by means of the \textit{key$=$value} syntax;
% but if this package is not used, then it is convenient
% to redefine the internal |\@makecaption| macro that
% performs the job as explained hereafter. Since it does
% not cost much I add also the definition of |\captionof|.
%
% The issue is that I prefer a narrower justified caption
% rather than one where the last line is just a short word
% or the right segment of an hyphenated last word. If one
% sets the |\finalhyphendemerits| parameter to an extremely
% high value, one might succeed in avoiding a hyphenated
% penultimate caption line, but this might lead to a very
% loose typesetting of the caption paragraph, especially
% if the horizontal box that contains it hardly exceeds the
% caption width. I initially set the caption width (a new
% length) to the overall text width diminished by 3em; then
% if the caption text, inclusive of the caption label and
% number, is shorter than the text width it is typeset as
% centred text; if it exceeds the text width, it is set as
% a justified paragraph whose line width equals the
% established caption width; but in any case the last
% line of the paragraph is measured and, if it is shorter
% than one third of the caption width, this width is
% shortened a little bit and the paragraph is set again
% with this shortened caption width; in order to be sure
% that one iteration is sufficient, the caption width
% shrinking must be computed according to the number of
% lines the paragraph occupies.
%
% In order to count the number of lines of the caption
% paragraph, it is necessary to recall that the first line
% occupies a vertical space that equals |\topskip| while
% the other lines occupy a vertical space equal to
% |\baselineskip|; the latter one is generally larger
% than |\topskip| therefore the integer division of the
% height of the vertical box divided by the |\baselineskip|
% is truncated to count one line less than the true value.
% In our case if the caption does not stay in one line,
% its text is typeset in a vertical box with a line spread
% of~0.95 so as to make the caption a little more compact
% than the regular text.
% Therefore the baseline skip is a little shorter than the
% regular one, but it should still exceed the default
% |\topskip|; when we first typeset the caption in a
% vertical box we strip off the last line and we must
% remember the presence of this line in our arithmetics.
%
% If the length of the stripped last line is larger that
% one third of the caption width, then the vertical box
% is recomposed by re\-stacking the individual lines,
% but if this last line is shorter than one third of the
% caption width, this width is recomputed in this way:
% let $N-1$ be the number of lines obtained with the
% integer division, i.e.\ one line less than those
% actually contained in the vertical box. Let $x$ be
% the initial caption width, and $x_2$ the last line
% width; let $y$ be the new caption width; then the total
% length of the caption of width $x$ is $Nx+x_2$ and this
% should be distributed over $N+1$ lines; if we obtained
% the new caption width $y$ by dividing the total length
% by $N+1$ we should be able to typeset the whole
% caption with all the lines of equal length. This does
% not actually take  place because the new lines do not
% necessarily contain the same amount of inter word space,
% some words might have been hyphenated in a different way,
% and so on.
%
% Moreover we do not want a caption that barely exceeds the
% length of |\captionwidth| to be retyped into a two
% line caption width that is about one half of the width of
% the other captions.
%
% Therefore we allow for some white space in the last
% line by computing the new caption width with the following formula
% \[ y=\frac{(N+0.5)x + x_2}{N+1} \]
% By the way, if the package \pack{caption} has been loaded
% in the preamble, this specific recalculation must not be 
% executed at all; it is necessary to delay this definition
% at |\AtBeginDocument| so we know for sure if that the package
% has been actually loaded. Of course if the \pack{caption} package
% has not been loaded the  |\captionsetup| macro is not
% defined and its use (for example, as a leftover of some
% experiments with the \pack{caption} package) would produce
% an error for this reason we define it as a gobbling macro
% so as to neutralise its presence.
%
% At this point it is very simple to add the |\captionof|
% command in order to use a caption also for figures that
% are set outside floating bodies; it might be useful when
% small figures or tables are inserted in unusual places,
% such as a table, a minipage, or similar non floating
% environments. The only thing that suffices to insert is
% the name of the corresponding not used float.
%    \begin{macrocode}
\AtBeginDocument{\@ifpackageloaded{caption}{}{%
\providecommand\captionsetup{}\renewcommand\captionsetup[2][]{}%
\providecommand\captionof[1]{\def\@captype{#1}\caption}
\let\originalcaption\caption
\newdimen\captionwidth
\newdimen\fullwidth 
\if@twocolumn\fullwidth=\columnwidth\else\fullwidth=\textwidth\fi
\belowcaptionskip=\abovecaptionskip
\long\def\@makecaption#1#2{%
   \begingroup
   \small \parskip\z@ \parindent\z@
   \finalhyphendemerits 100000\relax
   \linespread{0.95}\selectfont
   \vskip \abovecaptionskip
   \ifdim\hsize<\fullwidth \captionwidth=\hsize\else
   \captionwidth=\dimexpr\hsize-3em\fi
   \setbox0 \hbox{\ifblank{#1}{}{#1.\quad}#2}%
   \ifdim\wd0>\hsize
      \setbox1 \vbox{\hsize=\captionwidth
      \unhbox0\par\global\setbox2\lastbox}%
      \setbox2\hbox{\unhbox2}%
      \ifdim\wd2<0.333333\captionwidth
         \count255=\ht1 \advance\count255 \dp1
         \divide\count255\baselineskip
         \advance\count255\@ne
         \@tempdima=\wd2
         \advance\@tempdima \count255\captionwidth
         \advance\@tempdima 0.5\captionwidth
         \advance \count255\@ne
         \divide \@tempdima \count255
         \captionwidth=\@tempdima
         \setbox0 \vbox{\hsize\captionwidth
         #1.\quad#2}
      \else
         \setbox2\hbox to\captionwidth{\unhbox2 \hfill}%
         \setbox0\vbox{\unvbox1\box2}%
      \fi
   \fi
   \makebox[\hsize]{\box0}%
   \vskip \belowcaptionskip
   \endgroup
}}}

%    \end{macrocode}
%
% ^^A                      SDFIGURE
% Always delayed to the |\begin{document}| statement execution
% we  define a new (possibly floated) environment
% |SD| that creates a box where there is the main environment
% contents with its caption to a side, precisely to the side
% close to the outer  margin of the page. This implies that
% in one side printing  the caption is always on the right,
% while in two side printing the caption is on the right in
% right/odd pages and on the left in left/even pages.
%
% The environment opening statements requires the name of
% a floating object, even if this environment does not float
% anything, but the name is just used to describe its contents;
% it is possible therefore to specify \verb|\begin{SD}{figure}|
% or \verb|\begin{SD}{table}|, or whatever other environment
% name defined with the \pack{float} package functionality;
% this little repetition is for using the correct prefix to
% the caption text even when the environment is used outside
% a formal floating one. In the following paragraphs we speak
% about an “image” to mean the “environment main contents”.
%
% This new special environment box gets actually  floated if
% explicitly inserted within a formal floating  environment;
% but this special environment box is usable even as 
% a standalone environment, or as an object in a fixed position,
% such as when it is set within a mini-page or another similar
% environment; in such situations it is not required to use
% |\captionof|; actually this command is simulated within this
% very \amb{SD} environment
%.
% The actual commands for inserting
% the picture and its caption within the |figure| environment
% have names starting with |SD|, namely |\SDcaption| and
% |\SDimage|. Its syntax is as follows:
%\begin{flushleft}\obeylines
%\Bambiente{SD}\marg{contents kind}\meta{*}\oarg{fraction}
%\cs{SDimage}\marg{image commands}
%\cs{SDcaption}\oarg{lof entry}\marg{caption}\marg{label}
%\Eambiente{SDfigure}
%\end{flushleft}
% The \meta{contents kind} equals one of the formal floating
% environments; this information is used to prefix the
% caption text with the proper name and number.
%
% The meaning of the optional asterisk is that its presence
% allows protrusion of the box into the external margin,
% while its absence forces the box width to equal the text
% width. The optional \meta{fraction} is used to specify the
% fraction of the current object width that is dedicated to the
% caption, the remaining space being dedicated to the image;
% actually both widths are reduced a little bit to allow a space
% between the caption and image boxes. But remember this simple
% rule: a small value of this \meta{fraction} implies a narrow caption.
%
% Since it is necessary to maintain in separate independent
% areas the picture and the caption, and we need to shuffle
% them when odd or even pages are involved, their handling
% is particular. The |\SDimage| (or |\SDtabular| as an alias
% of |\SDimage|) command syntax is very simple:
%\begin{flushleft}
%\cs{SDimage}\marg{image commands}
%\end{flushleft}
% where the \meta{image commands} may be anything suitable so be
% used within a a floating environment; a picture, a tabular,
% a drawing, a box, any command to place the object in the
% correct position within the dedicated space; any argument
% is substantially valid with the caution that this “anything”
% remains local to that particular “image”. In any case when
% the “mage” is a real picture  and has  to be resized  to a
% relative dimension, remember that both the picture and its
% caption are typeset within boxes narrower than the total text
% width or the total environment width; the best way to access
% the width is to use its |\hsize| value.
%
% The |\SDcaption| is very similar to that of |\caption| except
% for a small detail; its syntax is the following:
%\begin{flushleft}
%\cs{SDcaption}\oarg{lof entry}\marg{image}\marg{label}
%\end{flushleft}
% where the parameters have the following meanings.
%\begin{enumerate}
%\item The \oarg{lof entry} optional bracket delimited argument
%   contains the usual short caption entry for the list of
%   figures or tables or specific other floats.
%\item The \marg{caption} mandatory brace delimited argument
%    contains the image caption.
%\item The \marg{label} mandatory brace delimited argument
%   contains the string that is usually passed to the |\label|
%   command; this string is mandatory in the sense that it
%   is the |\SDcaption| command that takes care of issuing
%   the |\label|\marg{label} command but, since this \meta{label}
%   is used to recover the page number (possibly after a second
%   compilation run) in order to establish the page number parity,
%   it is necessary that the |\label| command is issued at the
%   proper moment and that at the same time the \meta{label}
%   string is globally saved into a suitable macro so as to use
%   it at the right moment.
%\end{enumerate}
% Remember: the TOPtesi caption setting differs from the
% standard one and from its redefinitions with other packages
% such as the |caption| one. The TOPtesi particular redefinition
% tries to adjust the caption with in such a way as to avoid an
% unusually short last line in multi line captions. Therefore
% it may be noticed that sometimes some captions are slightly
% less wide than expected. It is not a bug, it may be considered
% a feature.
%
% Here comes its documented code. First some dimension registers,
% counters and boxes must be defined.
%    \begin{macrocode}

\newdimen\SDcaptionwidth
\newdimen\SDfigurewidth
\newdimen\SDlinewidth
\newbox\SDfigbox \setbox\SDfigbox\hbox{}%
\newbox\SDcapbox \setbox\SDcapbox\hbox{}%
\newcounter{SDpage}%
\newcounter{NumberSD} \setcounter{NumberSD}{0}
\providecommand*\theNumberSD{\value{NumberSD}}
\newif\ifNumberFloat \NumberFloattrue
%    \end{macrocode}
%
% Then we redefine the |\caption| command in order to add
% the |\caption*| variety that prints just the caption
% without any numbering and any prefix; of course it does
% not increment the suitable float counter nor it adds any
% entry to the list of any float.
% We have to memorise  the original definition and add
% the |xparse| extended new definition. Notice that this
% new |\caption| macro accepts the same syntax as the
% original one when no asterisk is specified, while when
% the |\caption*| command is used only the long caption
% argument is used, and the list of floats entry, if
% present, is neglected. This new command may be directly
% used by the final user in those rare circumstances where
% just an explanation is required and the object being
% explained does not require to be cross referenced.
%^^A CONFLITTO CON \CAPTION* DI LONGTABLE? -- CONTROLLARE<<<< !
%    \begin{macrocode}
\NewDocumentCommand\captionSD{s O{} m}{% O: optional arg. with null default 
  \IfBooleanTF{#1}%
    {%
     \@makecaption{}{#3}%
    }{%
      \ifempty{#2}%
        {%
          \originalcaption{#3}%
        }{%
          \originalcaption[#2]{#3}%
        }%
    }%
}
%    \end{macrocode}

% Then the environment |SDbox| is defined by means of the
% facilities of the |xparse| package; this allows the use of
% the “non delimited” asterisk argument.  It also requires other
% arguments, the first of which is mandatory and specifies the
% contents kind, be it a figure, or a table, or an algorithm,
% or anything else that has been introduced with the facilities
% of the |float| package; \dots\ or nothing, in the sense that
% the float should not be numbered and therefore its caption
% should have no number. Among the opening commands we deal
% with the (optional) asterisk dependent box width; with the
% asterisk the SD environment protrudes into the external margin.
%    \begin{macrocode}
\DeclareDocumentEnvironment{SDbox}{ G{} s O{0.5} }{%------OPENING
\NumberFloattrue
\ifempty{#1}%
   {\NumberFloatfalse}%
   {\def\@captype{#1}}%
\IfBooleanTF{#2}%
  {\SDlinewidth=\dimexpr\textwidth+0.8\marginparwidth}%
  {\SDlinewidth=\textwidth}%
%    \end{macrocode}
% Then we fix our attention to the correct use of the optional third
% argument, whose descriptor  assigns it a default value of |0.5|:
%    \begin{macrocode}
\SDcaptionwidth=#3\SDlinewidth
\ifdim\SDcaptionwidth<0.3\SDlinewidth 
  \SDcaptionwidth=0.3\SDlinewidth
\fi
\ifdim\SDcaptionwidth>0.7\SDlinewidth
  \SDcaptionwidth=0.7\SDlinewidth
\fi
\SDfigurewidth=\dimexpr\SDlinewidth-\SDcaptionwidth\relax
\SDcaptionwidth=\dimexpr\SDcaptionwidth-\columnsep\relax
\SDfigurewidth=\dimexpr\SDfigurewidth-\columnsep\relax
%    \end{macrocode}
% We add some test to verify if the environment is used within
% the |figure| floating environment, or it is used ad a fixed
% object; we first test if we are within a floating environment;
% if not we define |\@captype| to contain the string `figure';
% if yes we have to test if we are really within the |figure|
% environment: if not, we locally define |\@captype| else 
% we relax. This means that we can insert the |SDfigure| even
% within a |table| environment as sometimes  a tabular and a
% drawing should float together (may be because a drawing with
% its own caption represents the tabular entries).
%
% And this is all for the opening commands; all these settings
% shall be used by |\SDimage| and |\SDcaption| described hereafter;
% here we describe the environment closing commands,
% taking into account that the above commands have saved the
% \meta{label} string into the |\@tempSD| macro and have set
% their image and caption-text respectively into boxes
% |\SDfigbox| and |\SDcapbox|.
%
% The code tests if the saved \meta{label} string is empty;
% this should never take place, but it is better to perform
% such task. If the string is  empty, a fall back value equal
% to the page number of the page that is still open at
% processing time is used; may be a warning message would
% be helpful, but since this empty string should never be
% empty, it appears as a super luxury feature, that we can
% do without.
%
% But if the string is not empty, we test if the saved
% |\label| data, possibly read from the |.aux| file on a second
% typesetting run, has the normal \LaTeX\ structure or the
% |hyperref| modified one; the former contains two braced
% arguments, while the latter contains five such arguments;
% in both cases the interesting page number is the second
% argument. The existence of a |ver@hyperref.sty| macro
% allows to know if the |hyperref| package has been invoked
% in the preamble, therefore upon testing this macro  we
% know if we should use |\@secondoffive| or |\@secondoftwo|
% to read the real page number of the current |SDfigure|
% environment. Before reading the actual value of the
% |.aux| file |\label| saved data, we must access the
% string that contains these data but we have to expand
% several times the saved macros until we have the real
% string in |\@temD|.
%    \begin{macrocode}
}{%---------------------------------------------------CLOSING
  {\ifcsdef{r@\@tempSD}%
      {% 
         \edef\@tempD{r@\@tempSD}%
         \edef\@tempD{\expandafter\csuse\expandafter{\@tempD}}%
         \edef\@tempD{\@tempD}%
         \ifcsdef{ver@hyperref.sty}%
           {%
             \edef\@tempD{\noexpand\@secondoffive\@tempD}%
           }%
           {%
             \edef\@tempD{\noexpand\@secondoftwo\@tempD}%
           }%
         \edef\@tempD{\@tempD}%
         \setcounter{SDpage}{\@tempD}%
      }%
      {% 
         \setcounter{SDpage}{\thepage}%
      }%
  }%
%    \end{macrocode}
% At this point we have all the necessary pieces of information
% and we can shuffle the caption and image boxes depending
% on one or two side typesetting, and on the parity of the
% correct page number.
%    \begin{macrocode}
\ifbool{@twoside}%
  {%
    \ifnumodd{\value{SDpage}}%
      {%
        \makebox[\textwidth][l]{\makebox[\SDlinewidth]{%
          \usebox{\SDfigbox}\hfill\usebox{\SDcapbox}}}%
      }{%
        \makebox[\textwidth][r]{\makebox[\SDlinewidth]{%
          \usebox{\SDcapbox}\hfill\usebox{\SDfigbox}}}%
      }%
  }{%
    \makebox[\textwidth][l]{\makebox[\SDlinewidth]{%
      \usebox{\SDfigbox}\hfill\usebox{\SDcapbox}}}%
  }
}
%    \end{macrocode}
%
% The |\SDcaption| code appears to be strangely complicated;
% but it actually performs several actions;  the first
% (optional) argument is intended to collect the “short
% caption” to be used, if specified, for the list of floats
% entry; if not specified ,as usual, the “long caption”
% second argument is used for this entry. The (optional)
% brace delimited argument, on the contrary, is the label
% string that usually is passed as the argument of the
% |\label| command. If specified it is this |\SDcaption|
% macro duty to enter this command at the proper moment;
% the caption prefix is established by the value of the
% first (optional) argument of the |SDbox| environment,
% or by the floating environment where the |SDbox| one is
% nested. On the opposite if this macro |\SDcaption| argument
% is not specified, the caption is not numbered nor prefixed,
% and cannot be cross referenced; there are circumstances
% when this situation is very useful, but it is up to the
% user to decide when it is useful for his/her needs.
% interpretation.
%
% In this macro definition the boolean switch |NumberSD|
% has been already set by the opening statement commands
% of the |SDbox| environment; it is true only if the first
% environment (optional) argument has been specified or
% the environment is nested within a floating environment.
% Therefore if this boolean is false the unnumbered caption
% gets typeset, otherwise a second boolean is tested, the
% contents of the third (optional) argument of this macro
% |\SDcaption|. If it is specified, the numbered and prefixed
% caption gets typeset and this argument is used to label
% this caption; otherwise and unnumbered and not prefixed
% caption gets typeset with and internally generated label
% that allows to fetch the final page number so as to decide
% if the caption has to be typeset to the right or to the
% left side of the object depending on the page number parity.
%    \begin{macrocode}
\NewDocumentCommand\SDcaption{ O{} m  G{} }{%
  \notbool{NumberFloat}%
    {% 
      \stepcounter{NumberSD}%
      \edef\@tempSD{SD\the\c@NumberSD}%
      \begin{lrbox}{\SDcapbox}%
        \parbox[t]{\SDcaptionwidth}%
        {%
          \captionSD*{#2}\relax
          \expandafter\label\expandafter{\@tempSD}%
        }%
      \end{lrbox}%
    }%
    {% 
      \ifempty{#3}%
        {% 
          \NumberFloatfalse
          \stepcounter{NumberSD}%
          \edef\@tempSD{SD\the\c@NumberSD}%
          \begin{lrbox}{\SDcapbox}%
            \parbox[t]{\SDcaptionwidth}%
            {%
              \captionSD*{#2}\relax
              \expandafter\label\expandafter{\@tempSD}%
            }%
          \end{lrbox}%
        }{% 
          \begin{lrbox}{\SDcapbox}%
            \parbox[t]{\SDcaptionwidth}%
            {% 
               \captionSD[#1]{#2}\label{#3}\gdef\@tempSD{#3}%
            }%
          \end{lrbox}%
      }%
    }%
}
%    \end{macrocode}
% 
% We call the object to be shown within the |SDbox| with the
% name “image” which can be anything that can be enclosed
% in a parbox or a minipage; it can be an actual picture
% imported with an |includegraphics| command, it can be a
% drawing or a diagram created with the |picture|, or |tikz|,
% or |pgfplots|, or |pstricks| commands; it can be a table,
% an algorithm, an example, a theorem; anything that can be
% typeset within a box. With this name in mind we create
% the |SDimage| command to insert the object into our |SDbox|.
% A |\SDtabular| command is an alias to |\SDimage|; the user
% may define other such aliases for inserting other objects
% that suit his/her preferences and the logical contents.
%
% Also the |\SDimage| command is not so simple; in order to
% have both caption and image boxes aligned at the top, we
% must be sure that such boxes have their reference points
% at their top left corner; due to the heterogeneity of such
% “images”, we need to lower the image box to have the
% upper left corner raised with respect to the base line the
% amount of a capital `M' in the current font.
%    \begin{macrocode}
\newcommand\SDimage[1]{%
   \setbox0\hbox{M}\dimen0\ht0\relax
   \begin{lrbox}{\SDfigbox}\parbox[t]{\SDfigurewidth}{#1}\end{lrbox}%
   \dimen2\dimexpr\ht\SDfigbox+\dimen0\relax
   \setbox\SDfigbox\hbox{\raisebox{-\dimen2}{\box\SDfigbox}}%
}
\let\SDtabular\SDimage
%    \end{macrocode}
% We do not suggest to use a floating or a fixed |SDbox|
% environment for all figures, tables or what else; its
% use simply depends on the box contents; this environment
% may be useful when a normal setting would cause a lot of white
% space around the displayed material.
%
% We define the |\goodpagepbreak| command; we have to
% distinguish if the command is issued in vertical or in
% horizontal mode; in the former instance we assume it
% has been issued between two paragraphs and a
% potential page break is required before the second
% paragraph; while in the latter case we assume that
% a |\vadjust| element should be inserted so that a page
% break takes place after the current line has been typeset.
% The command accepts an optional argument that represents
% the maximum number of lines that should be available on
% the page in order to issue a |\newpage| command; in other
% words if the number of lines available on the page are
% less or equal to the optional number, then a |\newpage|
% command is issued, otherwise noting is done; the test
% |\ifhmode| is used in order to avoid any action if in math mode.
%    \begin{macrocode}
\newcommand\goodpagebreak[1][4]{\ifvmode
\unless\ifdim\dimexpr\pagegoal-\pagetotal>#1\baselineskip\newpage\fi
\else\ifhmode\vadjust{\newpage}\fi\fi}
%    \end{macrocode}
%
% The (deprecated) option \opz{chapterbib} requires a redefinition
% of the \texttt{thebibliogrpahy} environment in case a
% separate reference list is required for every chapter.
% The point is that for this task the reference key must
% contain also the chapter number; the rest is simply a
% redefinition of the environment that behaves differently
% according to the chosen option. In any case the bibliography
% goes to the table of contents as an unnumbered chapter or
% section.
%    \begin{macrocode}
\def\redef@bibitem{\def\@bibitem##1{\item\if@filesw
       \immediate\write\@auxout
       {\string\bibcite{##1}{\thechapter.\the\c@enumi}}\fi\ignorespaces}}
%
\def\thebibliography#1{%
 \ifchapterbibliography\section*{\bibname}\relax
    \if@twoside\markright{\bibname}\fi
    \addcontentsline{toc}{section}{\bibname}\relax
    \redef@bibitem
    \list{[\thechapter.\arabic{enumi}]}{%
    \settowidth\labelwidth{[\thechapter.#1]}\leftmargin\labelwidth
    \advance\leftmargin\labelsep\itemsep\z@ plus 1pt\parsep\z@
    \usecounter{enumi}}
 \else
    \chapter*{\bibname}\relax
    \addcontentsline{toc}{chapter}{\bibname}\relax
    \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep\itemsep\z@ plus 1pt\parsep\z@
    \usecounter{enumi}}
 \fi
 \def\newblock{\hskip .11em plus .33em minus -.07em}
 \sloppy
 \sfcode`\.=1000\relax}

\let\endthebibliography=\endlist
%    \end{macrocode}
%
% For what regards footnotes nothing is changed except
% resetting the line spread to one, in case the current
% value is different.
%    \begin {macrocode}
\long\def\@footnotetext#1{\insert\footins{\linespread{1}\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
   \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
   \@makefntext{\rule{\z@}{\footnotesep}\ignorespaces#1\strut}}}
%    \end{macrocode}
%
% The following last heterogeneous definitions are partly important
% and partly residues of the good old times of MS-DOS~v.3
% when a Ctrl-Z character would be placed at the end of files.
% It's a long time that such DOS version is not being used,
% but some old time files might still be around.
%
% The cryptic code that redefines the comma in math mode
% establishes that this character is a normal math character,
% instead of a math punctuation mark. Actually the code
% that defines the mathematical active comma is a new
% addition that lets the comma perform correctly in its
% double function (decimal separator and punctuation mark).
% The only point where this code fails is when a list of
% numbers is typeset: when a numeric list must be typeset,
% such as, for example, $\forall i=0,\,1,\,2,\,3, n$, in the
% source code a space \emph{must} be inserted after every
% punctuating comma while no space follows a decimal comma:
% for example \verb*+$\forall i=0, 1, 2, 3,n$+.  The space
% before the |n| is not necessary (but it wouldn't hurt)
% because |n| is not recognised as a digit, therefore the
% “intelligent” comma inserts the necessary space by itself.
%
%    \begin{macrocode}
 \DeclareMathSymbol{\virgola}{\mathpunct}{letters}{"3B}
 \DeclareMathSymbol{\virgoladecimale}{\mathord}{letters}{"3B}
 \AtBeginDocument{\mathcode`\,=\string"8000}
 {\catcode `,=\active \gdef,{\futurelet\let@token\m@thcomma}}
\def\m@thcomma{\let\@tempB\virgola
\@tfor\@tempA:=0123456789\do{%
\expandafter\ifx\@tempA\let@token\let\@tempB\virgoladecimale 
\@break@tfor\fi}\@tempB}
%
\catcode`\^^Z=10
\topmargin 0pt
%    \end{macrocode}
%
% {\tolerance=3000\relax
% The TOPtesi bundle contains two new chapter like sections
% activated with the commands |\sommario| (alias |\summary|)
% and |\ringraziamenti| (alias |\acknowledgements|) respectively.
% The infix strings that start these sections depend on the
% used language.\par}
%
% Because of this, it is necessary to extend the list of infix
% string definitions provided by the |\captions|\meta{language}
% macros defined by the  \texttt{babel} or \texttt{polyglossia}
% language description files; for this purpose we define
% a macro for adding new items for these two new sectioning
% commands. This macro receives three arguments: the first
% is the babel language name, the second is the string for
% the summary name, and finally the third is the string for
% the acknowledgements name; everything is contained within
% a group and only the relevant sectioning macro is globally
% redefined. The token register `0' is normally for scratch
% usage, but the fact that its value is restored upon exiting
% the group provides the necessary protection against an
% involuntary reassignment to this register. At the same
% time if a specific language option was not specified, a
% warning message is issued, but compilation goes on any way
% without the sectioning string names. For being sure no
% other `undefined' error messages are issued, the |\summaryname|
% and |\acknowledgename| are let to |\empty|.
%    \begin{macrocode}
\providecommand*\summaryname{}
\providecommand*\acknowledgename{}
\newcommand*\ExtendCaptions[3]{{%
\@ifundefined{captions#1}{%
\PackageWarning{toptesi}{%
Language option #1 not specified\MessageBreak
Skipping any redefinition\MessageBreak}%
}{%
\expandafter\let\expandafter\@tempA\csname captions#1\endcsname
 \toks0=\expandafter{\@tempA%
    \def\summaryname{#2}%
    \def\acknowledgename{#3}}%
 \expandafter\xdef\csname captions#1\endcsname{\the\toks0}%
 }}}%
%    \end{macrocode}
% For Italian and English there are no problems; we provide
% immediately these extensions by means of the newly available macro:
%    \begin{macrocode}
\ExtendCaptions{italian}{Sommario}{Ringraziamenti}
\ExtendCaptions{english}{Summary}{Acknowledgements}
%    \end{macrocode}
% In facts the \texttt{babel} and \texttt{polyglossia}
% options for Italian and English have already been loaded
% by default; therefore both caption macros |\captionsitalian|
% and |\captionsenglish| are already defined and can be
% freely extended. For any other language the corresponding
% language option must be entered in the class opening
% statement, otherwise a warning is issued but compilation
% is not stopped. Therefore if, for example, the user wants
% to write the thesis in Spanish, the thesis main file shall
% start like this:
% \begin{verbatim}
% \documentclass[...,spanish]{toptesi}
% \ExtendCaptions{spanish}{Resumen}{Agradecimientos}
% ...
% \begin{document}
% \selectlanguahe{spanish}
% ...
% \end{verbatim}
% and the rest of the thesis will be typeset correctly in
% Spanish. Remember that Italian is the main language and
% nothing is necessary to set up the Italian defaults.
% If English is desired, then after |\begin{document}| it
% is necessary to specify the default language; for ease
% of use the following macros are defined so they can be
% used instead of the lengthy \texttt{babel} or
% \texttt{polyglossia} command; after the beginning of the
% document it is then possible to specify |\inglese| or
% |\english|, and the default language is changed to English.
% These shorthand commands can be alternated so as to switch
% from one language to the other; nevertheless remember that
% there are more correct ways to switch languages with the
% \texttt{babel} and \texttt{polyglossia} commands without
% changing the infix strings.
%    \begin{macrocode}
\def\italiano{\selectlanguage{italian}}%
\def\english{\selectlanguage{english}}%
\let\inglese\english
%    \end{macrocode}
% At the beginning of the document the following commands are
% executed; the general macro |\italiano| sets the summary
% and the acknowledgements names in Italian, as the main
% language; and the |\@chapapp| macro is redefined so as to
% agree with the default language. If a different default
% language is desired, we recall it again, it is necessary to
% do the following:
% \begin{itemize}[noitemsep]
% \item
% specify |\english| \emph{after} the |\begin{document}|
% statement, if English is supposed to be the main language, or
% \item
% specify the language name, other than Italian or English,
% among the class options; use the |\ExtendCaptions| macro
% for extending the list of sectioning commands infix strings
% as explained above; specify with |\selectlanguage| the new
% language as the default one \emph{after} the |\begin{document}|
% statement;
% \item
% if XeLaTeX\ or LuaLaTeX\ is being used for typesetting, it
% suffices to specify in the preamble the name of the other
% language to be used, by means of the |setotherlanguage|
% command, and to define the summary and acknowledgments names
% in the same way as with pdf\/\LaTeX; the same must be done
% at the beginning of the document to declare the new language
% as the default one.
% \end{itemize}
%    \begin{macrocode}
\AtBeginDocument{%
    \italiano
    \renewcommand\@chapapp{\chaptername}%
}
%    \end{macrocode}
%
% At last the subsidiary and independent packages
% \texttt{topcoman} and \texttt{topfront} are requested
% for input; the latter is loaded only when the 
% |documentclass| option |noTOPfront| has NOT been declared.
% This action, therefore has to be delayed till the “begin
% document” step, in order to be sure that other packages
% have possibly been loaded to typeset the title page, and/or
% other packages have been loaded to properly use the units
% of measure. This delayed loading implies that the
% commands defined in |topfront| and in |topcomand| cannot
% be used in the preamble. Notice that also the \textsl{scudo}
% option  implies that the title page is typeset with its
% special commands and environments, therefore it sets the
% suitable switches so as to avoid loading the |topfront|
% extension file. This applies also to the other modules particular to special thesis types.
%    \begin{macrocode}
\AtBeginDocument{%
	\unless\ifT@Pfrontespizio\ifTOPfront
       \RequirePackage{topfront}
    \fi\fi
	\RequirePackage{topcoman}%
}
%    \end{macrocode}
%
% Last but not least, here comes the specification set for the
% \sigla{PDF/A}-1b format.
%
% First of all the patches to the macros |\not| and
% |\mapstochar| that produce problems with that format,
% because they have a declared width of 0\,pt; this
% is no problem for \texttt{pdflatex}, but it is a problem
% for the \sigla{PDF/A} format. Therefore these commands must be
% replaced by equivalent ones that do not use zero-width
% glyphs. For |\not|, another slash can be used, but in
% order to have it the right size in all math typesetting
% modes it is necessary to have a different command for
% every mode; this is achieved with the |\mathchoice|
% primitive as such:
%    \begin{macrocode}
\ifPDFTeX
\renewcommand*\not{\mathrel{\mathchoice%
	{\rlap{$\displaystyle\mkern2.5mu\mathnormal{/}$}}%
	{\rlap{$\textstyle\mkern2.5mu\mathnormal{/}$}}%
	{\rlap{$\scriptstyle\mkern2.5mu\mathnormal{/}$}}%
	{\rlap{$\scriptscriptstyle\mkern2.5mu\mathnormal{/}$}}%
}}
%    \end{macrocode}
% Actually the zero-width property of the slash must be
% simulated with a zero-width box but within this box it
% is necessary to specify the typesetting style of the math
% mode material.
%
% A similar trick is used to patch the |\mapstochar| command
% but no other glyph was found suitable for substituting
% the original one; therefore we had to make it up with the
% |picture| environment:
%    \begin{macrocode}
\renewcommand\mapstochar{\mathrel{\mathchoice
{\displaystyle\unitlength=0.0555\fontdimen6\font
   \picture(0,0)\put(1,1.5){\linethickness{0.72\unitlength}%
   \line(0,1){6}}\endpicture}
{\textstyle\unitlength=0.0555\fontdimen6\font
   \picture(0,0)\put(1,1.5){\linethickness{0.72\unitlength}%
   \line(0,1){6}}\endpicture}
{\scriptstyle\unitlength=0.0555\fontdimen6\font
   \picture(0,0)\put(1,0.55){\linethickness{0.61\unitlength}%
   \line(0,1){5}}\endpicture}
{\scriptscriptstyle\unitlength=0.0555\fontdimen6\font
   \picture(0,0)\put(1,0.2){\linethickness{0.56\unitlength}%
   \line(0,1){4}}\endpicture}
}}\fi
%    \end{macrocode}
% The above patches are introduced irrespective of using
% \texttt{pdflatex} for producing a \sigla{PDF/A} compliant file;
% one might need to produce a traditional \sigla{PDF} file, or even
% a DVI file, to be converted to the \sigla{PDF} format, in order to
% possibly further transform it into a \sigla{PDF/A} one by means
% of other useful packages, such as \pack{pdfpages}.
%
% \subsection{The \opz{classica} option}
% As mentioned above, the \opz{classica} option was
% devised in order to cope with theses in humanities and
% the specifications came from Paolo Ciacchi, a student
% of the University of Trieste, who was preparing a master
% thesis in classical Greek philology. The necessity
% of the large normal size derived from the necessity of
% having clear mark-up signs among the myriad signs
% philologists use, that sometimes I believe that the
% philological mark-up requires typesetting environments
% similar to the mathematical ones: in facts the material
% to be typeset does not form linear sequences, as in plain
% text, but bi-dimensional structures as in mathematics.
%
% The other requirements involve the title page and I agreed
% to implement them, since they are likely to be useful
% for other universities as well; the effort for localising
% this bundle makes this point less stringent compared to
% previous versions, but there are other layout fine points
% that cannot be solved with a simple substitution of infix
% strings.
%
% The singular and plural masculine and feminine strings
% for “candidate” are redefined in the |topfront| module.
% For other languages the configuration file is very handy.
%
% Since theses in humanities may end up to occupy several
% volumes\footnote{Classically “tomo” in Italian means “volume”,
% although the latter word is valid also in Italian with 
% the same meaning but appears to be  neglected by the
% humanists; in English “tome” indicates a “large book”;
% in Italian the meaning nuance of “tomo” is a little
% different because it is used to indicate each of the volumes into
% which a large printed work is divided; the humanists, as
% usual, know well their words and use them properly!} a
% mechanism is set up to create a different title page for
% each volume; we need a volume counter and a command to
% start each volume.
%
% The localisation allows to change the infix string that
% is going to be printed in the title page. But when several
% tomes are involved, instead of using the |\frontespizio|
% macro or |frontespizio| environment, use the |\tomo| macro. 
% There is no equivalent to the |frontespizio| environment.
% |\tomo| provides to stepping up the volume counter before
% actually printing the new tome title page.
%    \begin{macrocode}
\newcounter{tomo}
\newcommand*{\tomo}{\clearpage\stepcounter{tomo}\boolfalse{topTPTlogos}%
   \fr@ntespizio}
%    \end{macrocode}
% Folios as well are to be redefined and also the page styles
% require a redefinition so as to being able to use old style
% numbers. The macro |\lapagina| (it's not a case that this
% macro name is the direct translation of “thepage”)
% contains the folio number; if it is in roman numerals
% nothing happens, but if the old style numbers are required
% the folio is surrounded by the proper macros so as to expand
% the folio macro before typesetting it in old style. The page
% style does not need an actual redefinition, because the
% original definition in file \texttt{toptesi.sty}
% already uses |\lapagina| as the typeset folio indicator.
%    \begin{macrocode}
\renewcommand*{\lapagina}{%
    \ifnumeriromani
        \thepage
    \else
        \if@ldstyle
            \expandafter\oldstylenums\expandafter{\thepage}%
        \else
            \thepage
        \fi
    \fi
}
%    \end{macrocode}
% But we actually have to redefine the page style for the new
% headings because the  \texttt{classica} option changes
% completely the left and the right headers depending on the
% option \opz{autoretitolo}; in this case the left header
% contains the candidate's name and a short version of the
% thesis title, while the right heading contains the chapter
% (short) title; if this option is not in force, headings
% appear as usual. The redefinition of the \texttt{headings}
% page style is made only if this option is in force. In case
% of two-sided printing where the left head and the right
% heads are different, the left heading contains the author
% name and the short title name; if there are other authors
% the first author name is printed followed by “et al.”;
% if the overall header string exceeds the text width, a
% message is printed so as to suggest the user to 
% use the optional |\titolo| argument, the one that is
% supposed to contain the short title. In the right heading
% there is the chapter title; again if the header turns out
% to be too wide, a message is issued to the user.
%
% More complicated things are done when typesetting on one
% side; in facts the author name (possibly followed by
% “et al.”) and the short thesis title are typeset on the
% left of the only header while the chapter title is typeset
% on the right; in the unlikely situation where these two
% elements separated by at least 2em of white space do not
% exceed the text width, they are printed, but if they do,
% as it is likely to happen, then my suggestion would be not
% to use the \opz{autoretitolo} option; but if the user
% absolutely wants this layout, then the author's name,
% possibly followed by “et al.”, and the short thesis title
% are set in a vertical box; the same happens for the
% chapter title in another box; these texts are set with
% ragged margins, and eventually these boxes are set one
% next to the other with an intermediate glob of infinitely
% stretchable glue, and finally set in the header box with
% a rule underneath the two of them. The result might be
% barely acceptable if both vertical boxes do not exceed
% two lines and no words have to be hyphenated, but in
% general I believe it is an ugly layout; the user is warned!
% Remember also that |\@@author| contains the author's name 
% without the ID number if any.
%    \begin{macrocode}
\if@utoretitolo
   \if@twoside
%
       \renewcommand*{\ps@headings}{\let\@mkboth\markboth%
       \def\@oddfoot{\null \hfill \textbf{\lapagina} \hfill \null}%
       \let\@evenfoot\@oddfoot
       \def\@evenhead{%
           \setbox\@intesta\hbox{\ifPDFTeX\latintext\fi
           \footnotesize\strut\textsc{%
           \@@author\ifcsvoid{@secondauthor}{\ et al.}: \@stitle}%
           }%
       \ifdim\wd\@intesta>\textwidth\headwrn{\titolo}\fi
       \underline{\makebox[\textwidth]{\box\@intesta}}}%
       \def\@oddhead{\ifPDFTeX\latintext\fi
           \setbox\@intesta\hbox{%
               \footnotesize\strut\textsl{\rightmark}}%
       \ifdim\wd\@intesta>\textwidth \headWarn{\section}\fi%
       \underline{\makebox[\textwidth]{\box\@intesta}}}%
       \def\chaptermark##1{\markright{\thechapter\ -- ##1}}%
       \def\sectionmark##1{}}%
   \else
       \renewcommand*{\ps@headings}{\let\@mkboth\markboth
           \def\@oddfoot{\null \hfill \textbf{\lapagina}\hfill \null}%
           \let\@evenfoot\empty\let\@evenhead\empty
           \def\@oddhead{{\setbox\z@\hbox{\ifPDFTeX\latintext\fi
           \footnotesize\textsc{%
           \@@author\ifcsvoid{@secondauthor}{}{\ et al.}: \@stitle}}%
           \setbox\tw@\hbox{\ifPDFTeX\latintext\fi
           \footnotesize\textsl{\rightmark}}%
           \dimen@=\dimexpr2em + \wd\z@ + \wd\tw@\relax
           \ifdim\dimen@<\textwidth \relax
           \else
             \setbox\z@\vbox{\hsize.48\textwidth\parindent\z@
             \raggedright
             \ifPDFTeX\latintext\fi\footnotesize\textsc{%
             \@@author\ifcsvoid{@secondauthor}{}{\ et al.}: \@stitle
             }}%
             \setbox\tw@\vbox{\hsize.48\textwidth\parindent\z@
             \raggedleft
             \ifPDFTeX\latintext\fi\footnotesize
                 \textsl{\rightmark}}%
             \fi
           \setbox\@intesta\vbox to\z@{%
                \vss\hbox to\textwidth{\strut\box\z@\hfill\box\tw@}}%
           \underline{\box\@intesta}}}%
           \def\chaptermark##1{\markright{\thechapter\ -- ##1}}}
   \fi
\fi
%    \end{macrocode}
%
% The footnote rule separator is also longer than the default
% one. Dealing with notes the footnote separator is also
% changed as well as the footnote skip. But the humanists
% like to have also unnumbered notes within numbered
% ones, as if they were two separate sets; of course
% specialised extension modules, such as, for example,
% the |eledmac| or |reledmac| packages, are available on
% CTAN, but as a poor man solution the command |\nota| was
% introduced that inserts a note with a symbol as a note
% mark; the symbol \emph{must} be a mathematical one as
% the dagger or the double dagger; by default it is the
% asterisk.  At the same time the default definition of
% the mathematical  asterisk is that of a binary operator;
% I have experienced that the note symbol gets a
% better positioning if it is used as an ordinary symbol
% through |\mathord|.
% This is why its math code is redefined.
%
% A final unusual request was to be able to put a blank
% unnumbered note, as a (rather wide) note separator.
% The command |\NoteWhiteLine| has to be used at the end
% of the text of the preceding note.
%    \begin{macrocode}
\renewcommand\footnoterule{%
  \kern-6\p@
  \hrule\@width.4\columnwidth
  \kern5.6\p@}
\setlength\footnotesep{12\p@}
\setlength{\skip\footins}{24\p@ \@plus 4\p@ \@minus 2\p@}
\newcommand*\nota[1][\mathord{*}]{%
    \xdef\@thefnmark{\ensuremath{\m@th#1}}\@footnotemark\@footnotetext
}
\newcommand*{\NoteWhiteLine}{\par\vspace*{-.3\baselineskip}}
%    \end{macrocode}
%
% The humanists asked me to create some other simple macros:
% one for skipping a whole page, without header and footer;
% another to compose a dedication page; a third one for
% typesetting a page with one or more witty sentences.
% The first request has a trivial solution, but at least
% |\paginavuota| (alias |\emptypage|) is much shorter to
% type in than its expansion.
%
% The environments \texttt{dedica} (alias \texttt{dedication})
% for the dedication, and \texttt{citazioni} (alias
% \texttt{wittysentences}) for the witty sentences are almost
% identical; both typeset their content with a reduced text
% width, half of the normal one; this column is typeset
% on the right of the page. The \texttt{dedica}/\texttt{dedication}
% environment is supposed to be used in the front matter,
% while the witty sentence environment may be used anywhere.
%
% The dedication is typeset in |\Large| font size and in
% italics; if the author wants a different size and/or a
% different shape s/he must specify it at the beginning
% of the dedication text.
% The \texttt{citazioni}/\texttt{wittysentences}
% environment typesets its material with the default font
% shape series and size, so the author has to specify any
% change s/he desires. These three commands, though, are
% available irrespective of the \texttt{classica} option,
% so that they can be used also for theses outside the
% field of humanities.
%
%    \begin{macrocode}
\newcommand*\paginavuota{\clearpage\thispagestyle{empty}\null\clearpage}
\let\emptypage\paginavuota
%
\newenvironment{dedica}{\clearpage
    \if@twoside
        \ifodd\c@page\else\thispagestyle{empty}\null\clearpage\fi
    \fi
    \thispagestyle{empty}%
    \list{}{\labelwidth\z@
    \leftmargin.5\textwidth
    \parindent\z@
    \raggedright\LARGE\itshape}\item[]
}{%
    \endlist\clearpage
}
\let\dedication\dedica \let\enddedication\enddedica
%
\newenvironment{citazioni}{%
    \clearpage\thispagestyle{empty}
    \list{}{\labelwidth\z@
    \leftmargin.5\textwidth
    \parindent\z@
    \raggedright}\item[]
}{%
    \endlist\clearpage
}
\let\wittysentences\citazioni \let\endwittysentences\endcitazioni
%    \end{macrocode}
% \iffalse
%</topsty>
% \fi
%
% \subsection{The \texttt{topfront.sty} code}\label{sec:topfront}
% This file is input by \texttt{toptesi}, version 6 and higher
% provided that no title page or thesis type options have been
% specified by the user; it can also be used as an independent
% extension module with (hopefully) any document class.
%
% It contains all the definition for the composition of just
% the title page of “standard” theses along the style
% requirements of \texttt{toptesi}, version 5.x or higher. It is not
% loaded by |toptesi| even when typesetting the title page
% for theses made according the requirements of the ScuDo
% doctoral school; with the \textsf{scudo} option to
% |toptesi| loading of |topfront| is inhibited and in its
% place another extension module, |toptesi-scudo|, is loaded.
% The same holds true with the other special thesis modules.
% This latter files are described in a subsequent sections.
%
% It |topfront| makes use of an optional configuration file
% where the user can define a lot of default information and
% all the infix language dependent strings that are peculiar
% to the title page. Among other things it can typeset
% also the copyright page on the verso of the title page if the
% |\retrofrontespizio| macro argument is not empty.
%
% This file specifies that it requires the \LaTeXe\ format
% and identifies itself. Since this module might be
% used to extend the performances of other classes, this
% file does not specify any input encoding, on the assumption
% that the calling class already provided this information.
% \iffalse
%<*topfrn>
% \fi
%
% In oder to use |topfront| as a stand-alone extension package
% with other classes it is necessary to verify if the \opz{classica}
% option  corresponds to a valid setting of |\ifclassica|;
% since this test is defined in the |toptesi| class,
% here we need to verify its existence and, in case, to set
% its value to |false|. This implies two points: we need a
% powerful macro package to test a “switch”, and, when this
% |topfront| module is used as a stand-alone one, the settings
% of the \opz{classica} options are not available. This requires
% to define switches and  counters, besides options for this
% package, even if they may be specified to the |toptesi|
% class; of course when |topfront| is used as a standalone
% package, the class might not be |toptesi| therefore a complete
% set up even with the \opz{classica} option must be set again.
%    \begin{macrocode}
\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
\@ifpackageloaded{xspace}{}{\RequirePackage{xspace}}
\@ifpackageloaded{xparse}{}{\RequirePackage{xparse}}

\ifcsundef{ifclassica}{\newif\ifclassica \classicafalse}{}
\ifcsundef{if@utoretitolo}{\newif\if@utoretitolo\@utoretitolofalse}{}
\ifcsundef{if@ldstyle}{\newif\if@ldstyle\@ldstylefalse}{}
\ifcsundef{if@xivpt}{\newif\if@xivpt \@xivptfalse}{}
\ifcsundef{if@binding}{\newif\if@binding\@bindingfalse}{}
\ifcsundef{ifScuDo}{\newif\ifScuDo \ScuDofalse}{}
\ifcsundef{ifmonografia}{\newif\ifmonografia\monografiafalse}{}
\ifcsundef{iftriennale}{\newif\iftriennale\triennalefalse}{}
\ifcsundef{ifmagistrale}{\newif\ifmagistrale\magistralefalse}{}
\ifcsundef{ifdottorale}{\newif\ifdottorale\dottoralefalse}{}
\ifcsundef{ifsecondaria}{\newif\ifsecondaria\secondariafalse}{}
\ifcsundef{ifplurale}{\newif\ifplurale\pluralefalse}{}

\ifcsundef{ifTOPfront}{\newif\ifTOPfront \TOPfronttrue
\newif\ifevenboxes \evenboxesfalse}{}

\ifcsundef{c@tomo}{\newcounter{tomo}}{}

\DeclareOption{evenboxes}{\evenboxestrue}
\DeclareOption{cucitura}{\@bindingtrue}
\DeclareOption{14pt}{\@xivpttrue}
\DeclareOption{classica}{\classicatrue}
\DeclareOption{autoretitolo}{\ifclassica\@utoretitolotrue\fi}
\DeclareOption{oldstyle}{\ifclassica\@ldstyletrue\fi}
\ProcessOptions*\relax

%    \end{macrocode}
%
% For the title page we need a special style, in order to
% put some information in the header and some other in the
% footer, without actually changing the page layout, except
% for horizontally centring the grid in the page.
% The headers, due to a specific request of Politecnico di
% Torino, is to have the university logo(s) in the header;
% other universities maintain their logo(s) in the lower part
% of the page as it was done all the time in the past.
% We need some device to switch position to the logos,
% without actually changing the page layout. Since the
% logo(s) are sort of large, the header must smash the
% header contents, so as to avoid any modification of the
% position and size of the other parts of the page.
% The |\TPT@logobox| box shall be defined later on and
% the |\logosede| command takes care of filling it up.
% Besides these devices, the |\frontespizio| command and
% the |frontespizio| environments (with or without asterisk)
% produce either layout depending on the state of the boolean
% |topTPTlogos|.
%    \begin{macrocode}
\def\headstrut{\vrule \@depth4\p@ \@height\z@ \@width\z@}
\def\ps@titlepage{\let\@mkboth\@gobbletwo
   \def\@oddfoot{\vbox to 0.05\paperheight{\vss
      \hbox to\hsize{\hfil{\Large{\@submitdate}}\hfil}}}%
   \let\@evenfoot\@oddfoot
   \def\@oddhead{%
      \vbox to\headheight{\vss
        \iftopTPTlogos
         \hbox to\textwidth{%
           \headstrut\hfil
           \raisebox{3\baselineskip}{\usebox\TPT@logobox}\hfil\null%
           }
         \fi\par
         \ifcsvoid{@ateneo}{}{%
         \hbox to\textwidth{\hss\LARGE\rule[-1ex]{0pt}{3.3ex}%
           \MakeUppercase{\@ateneo}\hss}}
         \vss
      }%
   }%
   \let\@evenhead\@oddhead
   \def\chaptermark##1{}\def\sectionmark##1{}%
}
%    \end{macrocode}
%
% Similarly a different title page style for typesetting 
% the logos in the lower half of the page is defined; since
% it is the only style usable with the \opz{classica} option, we
% call it the |classica| page style:
%    \begin{macrocode}
      \def\ps@classica{\let\@mkboth\markboth
      \def\@oddhead{\vbox{%
      \setbox256=\hbox{\LARGE\MakeUppercase{\@ateneo}}
      \unless\ifdim\wd256<\textwidth
         \setbox256=\hbox{\resizebox{\textwidth}{!}{\box256}}%
       \fi
      \hbox to \hsize{\hss\box256\hss}%
      \ifclassica
            \hbox to \hsize{\hfil\vrule\@width\z@
        \@height2ex\vrule\@height1.4\p@\@depth-\p@\@width50mm\hfil}%
      \fi
      }}%
      \def\@oddfoot{\vbox to \dimexpr\paperheight/20\relax{\vss
     \ifclassica
        \hbox to \hsize{\hfil\raisebox{-.3ex}[\z@][\z@]{%
        \vrule\@height-2.6\p@\@depth3\p@\@width
            \dimexpr\textwidth/3}\hfil}%
      \fi
      \hbox to\hsize{\hfill{\Large{\@submitdate}}\hfill}}%
      }%
      \let\@evenhead\@oddhead
      \let\@evenfoot\@oddfoot
      }%
%    \end{macrocode}
%
% The title page information depends on the type of “thesis”
% that is being typeset. The following commands specify the
% kind of information that is going to be typeset. Some boolean
% variables are automatically set by the commands in order
% to change some formatting depending on the kind of thesis.
% For languages that distinguish feminine from masculine
% adjectives or qualifications, some automatic machinery is
% set up in order to format some infix strings in a way
% that copes with the singular or plural forms; in
% particular when there is a multitude of authors (maximum 
% three) of different gender, the adjectives or qualifications
% are set as masculine plural names, while when there is just
% one author or the authors are of the same gender the
% adjectives or qualifications are set according to number
% and gender. All this is done by setting or resetting the
% truth value associated to  the boolean variable
% \texttt{femminile}. The boolean variable \texttt{dottorato}
% controls the Ph.D thesis format (except for the ScuDo
% school), while the other variable \texttt{triennale}
% controls the formatting of the bachelor's degree report.
% All other theses are treated as master theses,
% and in all cases the appropriate infix string is typeset
% in the title page:
%    \begin{macrocode}
\newif\iffemminile
\newif\ifdottorato \dottoratofalse
\newif\iftriennale \triennalefalse
%    \end{macrocode}
%
% The infix words for the |classica| option are redefined.
%    \begin{macrocode}
\ifTOPfront
\ifclassica
\def\Candidato{Laureando}
\def\Candidata{Laureanda}
\def\Candidati{Laureandi}
\def\Candidate{Laureande}
\fi\fi
%    \end{macrocode}
%
% The thesis title is specified by means of the following
% commands; |\monografia|, the name of the bachelors degree
% final report, sets also the corresponding boolean variables
% and redefines the command |\titolo| so as to avoid
% duplications and inconsistencies; of course something might
% still be inconsistent if the commands are given in the
% wrong order.
%
% |\titolo| accepts an optional argument, the “short title”,
% more or less as the standard sectioning commands; this is
% due to the fact that with the class option \opz{autoretitolo}
% the thesis title is written together with the author's
% name in the even page headings; if the thesis full title
% is too long it produces overfull headlines with ugly
% results; a short title may solve the inconvenience.
% The |\sottotitolo| command is another way to maintain
% a short title; all the supplementary title information may be
% typeset in  the subtitle.
%    \begin{macrocode}
\def\monografia#1{\global\triennaletrue
      \global\dottoratofalse
      \global\def\titolo##1{\PackageWarning{topfront}%
      {Il titolo e' gia' stato impostato con
            il comando \string\monografia}}%
      \gdef\@titolo{#1}}

\let\@stitle\empty

\newcommand*{\titolo}[2][]{%
\ifbool{triennale}{%
\PackageWarning{topfront}{Il titolo deve essere impostato con
                               il comando \string\monografia}
}{%
\def\@tempA{#1}\ifdefempty{\@tempA}%
     {\gdef\@stitle{#2}}{\gdef\@stitle{#1}}%
     \gdef\@titolo{#2}%
     }%
}
\def\sottotitolo#1{\gdef\@subtitle{#1}}
%    \end{macrocode}
%
% The |\materia| or its alias |\Materia| are used to
% specify the subject of the thesis; as a silly example
% a set of commands that reflects this subtle difference
% might be the following:
% \begin{verbatim}
% \materia{Applied Tetratricotomy}
% \titolo{Tetratricotomy of blond hair}
% \sottotitolo{Accurate measurements of the four fourths
%   of tetratricotomised blond hair}
%\end{verbatim}
% and the title page, for example, will contain something like this:\\[\bigskipamount]
% \begin{minipage}{\textwidth}\centering
% {\Large Master Thesis\\ in\\ Applied Tetratricotomy\par}\bigskip
% {\huge Tetratricotomy of blond hair\par}\bigskip
% {\large Accurate measurements of the four fourths\\
%   of tetratricotomised blond hair}
% \end{minipage}\bigskip
%    \begin{macrocode}
\let\@materia\empty
\def\Materia#1{\def\@materia{#1}}\let\materia\Materia
%    \end{macrocode}
%
% Things get more complicated for doctoral theses; in general
% there is no supervisor; at most if a professor is assigned to supervise or control the PhD student's work this may be called
% in whatever mode but here we assume his name is input
% with the command |\tutore| even if “tutor” does not appear
% as the best choice; in any case in Italian “tutore” does
% not have the same meaning as the English word “tutor”.
%
% Most Doctoral Schools require to name the School's director
% or coordinator instead of the tutor. This is why this
% person's name can be introduced with |\direttore| or
% |\coordinatore|; the actual label printed over this person
% name is “Direttore” or “Coordinatore”  but it can be
% changed with |\QualificaDirettore|.
%    \begin{macrocode}
\newif\ifDirettore \Direttorefalse
\def\tutore#1{\gdef\@tutore{#1}}
\def\direttore{\Direttoretrue\relatore}%
\def\coordinatore{\Direttorefalse\relatore}%
\def\QualificaDirettore#1{\gdef\@PhDdirector{#1}}%
%    \end{macrocode}
%
% For “normal” theses we may have from one to three
% supervisors and from one to three authors; not all
% universities accept a multitude of supervisors and/or
% authors of the same thesis, but some do; this is why
% this bundle accepts up to three names for each category.
% The |\second...| commands set the plural forms of the
% labels printed above the name lists. For the candidates
% there are different commands to input ladies or gentlemen
% names; according to the masculine (ending in `o')
% or feminine (ending in `a') commands, the appropriate
% true or false values are assigned to the boolean variable
% \texttt{femminile} and the labels are set accordingly.
%
% Notice that in the case of bachelor degree final report
% no supervisor name is printed even if one or more supervisor
% names are specified. This must be kept in mind in order
% to avoid surprises in finding missing information in the
% title page. Further on, there are suggestions for
% getting around this feature.
%    \begin{macrocode}
\def\relatore#1{\gdef\@principaladviser{#1}}
\def\secondorelatore#1{\gdef\@secondadviser{#1}}
\def\terzorelatore#1{\gdef\@thirdadviser{#1}}
%    \end{macrocode}
%
% The next set of macros is used to typeset the “date” of
% the thesis defence or presentation or whatever is done
% for the final exam. The macro is sort of complicated
% because the input format for this “date” may vary from
% a single year, to a year range, to a month and year
% specification so that different actions must be taken;
% if the option \texttt{classica} is in force, then the
% formatting of the “date” may be still different.
% This command is aliased with |\esamendidottorato|
% which literally means “defence of the doctoral dissertation”;
% nevertheless both commands refer to a simple date
% in one of those formats.
%
% |\getseduta| splits the date into its two components,
% month and year; if the argument is a single string without
% intervening spaces, the first one is the string itself
% and the second is empty; this emptiness may be tested and,
% in case, the date formatting is modified accordingly.
% In particular if the string is a single spaceless one,
% this string is assigned to |\@submitdate|; otherwise a
% different treatment is made according to the fact that
% \texttt{classica} is in force; if  \texttt{classica} is not
% in force the total string, including spaces,  is assigned
% to |\@submitade|. If \texttt{classica} is in force,
% |\s@dutaclassica| is called with the whole string.
% On turn |\s@dutaclassica| verifies if the date should be
% typeset with old style numbers or with the usual lining
% figures; in the latter case the whole string is assigned
% to |\@submitdate|; in the former one the year part may
% be either a single year or a year range; this separation
% is tested by splitting the year part across one dash;
% if the dash is present the extremes of the year range are
% assigned to |\1| and |\2|, otherwise the year part is a
% single year.
% If a single year is given, this is simply typeset with
% old style numbers and the appropriate commands are assigned
% to the |\@submitdate| control sequence. If a year range is
% given, this year range is also typeset with old style numbers,
% and the dash is executed with a special en-dash surrounded
% with white space.
%
%    \begin{macrocode}
\def\sedutadilaurea#1{\getseduta#1 !}
\def\getseduta#1 #2!{%
    \def\@tempA{#2}%
    \ifx\@tempA\empty
        \def\@submitdate{#1}%
    \else
        \unless\ifclassica
            \def\@submitdate{#1 #2}%
        \else
            \s@dutaclassica#1 #2!%
        \fi
    \fi
}%
\def\s@dutaclassica#1 #2!{%
    \if@ldstyle
        \s@paranumeri#2-!%
        \ifx\2\empty
            \edef\@submitdate{\noexpand#1 \noexpand\oldstylenums{#2}}%
        \else
            \s@paranumeri#2!%
            \edef\@submitdate{\noexpand#1
            \noexpand\oldstylenums{\1} -- \noexpand\oldstylenums{\2}}%
        \fi
        \let\1\undefined
        \let\2\undefined
    \else
        \def\@submitdate{#1 #2}%
    \fi
}
\def\s@paranumeri#1-#2!{\def\1{#1}\def\2{#2}}%
\let\esamedidottorato\sedutadilaurea
%    \end{macrocode}
% Here |\annoaccademico| is defined to typeset the infix
% string corresponding to “Anno accademico” followed by
% the year range in old style numbers (irrespective of the
% \texttt{oldstyle} option); localisation commands are
% provided so as to set a different string, possibly
% through the configuration file. In order to set an
% adequate en-dash between the old style numbers a new
% definition is given that takes care to set the dash
% at a height above the base line that copes with the
% specific shape of the old style numbers.
% Notice that |\annoaccademico| and |\sedutadilaurea| do
% not do the same things, besides the fact that |\annoaccademico|
% works only with the |classica| option in force and a
% special format is chosen. Therefore the user has to use
% only one of these two commands, and if s/he uses
% |\annoaccademico|  while the |classica| option is not
% in force, s/he gets an warning and the “date” gets
% formatted in a special way so as to remember the user
% that |\annoaccademico| requires the |classica| option.
%    \begin{macrocode}
\newcommand*\NomeAnnoAccademico[1]{\gdef\AnnoAccademico{#1}}
\@ifundefined{AnnoAccademico}{\gdef\AnnoAccademico{Anno accademico}}{}
%
\def\annoaccademico#1{\ifclassica
  \def\@submitdate{{\large\textsc{\AnnoAccademico}} {\Large\s@tanno#1!}}
  \else
  \PackageWarning{toptesi}{\string\annoaccademico\space
            is usable only when the\MessageBreak
  			`classica' option is in force}%
  \def\@submitdate{\AnnoAccademico\ #1 --- Needs the `classica' option}
  \fi}
\def\s@tanno#1-#2!{\oldstylenums{#1}\EnDash\oldstylenums{#2}}

\def\EnDash{{\settowidth{\dimen@}{\large\scshape I}%
\setbox\tw@\hbox{2}\dimen\tw@.5\ht\tw@\advance\dimen\tw@-.5\dp\tw@
\dimen4\dimen\tw@\advance\dimen4by.0385ex\relax
\advance\dimen\tw@-.0385ex\relax
\makebox[1.5\dimen@]{%
    \vrule\@width\dimen@\@height\dimen4\@depth-\dimen\tw@}}}
%    \end{macrocode}
%
% The next macros are used to assign strings to some
% literal information to be typeset in the title page.
% |\ciclodidottorato| requires an uppercase roman numeral
% (in Italy), but it can accept anything that can precede
% the infix word “cycle”.
% Macros |\corsodilaurea| and |\corsodidottorato| specify
% the degree course qualification; you would specify just
% “Elettronica”, for example, and the module will write
% in the title page “Corso di Laurea in Elettronica”.
% The infix part may be changed depending on the default
% language and the configuration file.
%
% |\scuoladidottorato| gets the name of the PhD School;
% |\ateneo| gets the generic name of the university;
% |\nomeateneo| gets the proper name of the university.
% In Italy Universities are generally named after the city they
% are in; in large cities where there are several
% universities, each one of them has a proper name.
% For example the generic name might be “Universit\`a di
% Roma” and the proper name might be “La Sapienza”.
%
% |\facolta| may receive an optional argument that is the
% uppercase roman numeral specific of the faculty and
% a compulsory argument that corresponds to the type of
% faculty; for example, with |\facolta[II]{Ingegneria}|
% the package typesets in the title page “II Facolt\`a di
% Ingegneria”; if the optional argument is not specified,
% no roman numeral is typeset; the infix string
% \verb*+Facolt\`a di + may be changed with the configuration
% file depending on the default language.
% It might be necessary to define another name in place of
% “Facolt\`a di\textvisiblespace”, since with recent bills,
% the administrative structure of all Italian universities
% has been changed and the activities formally assigned
% to the Faculties may be now the responsibility of other
% structures that may have different names in different
% universities. If the internal command defined by
% |\FacoltaDi| is empty, no name is printed at all and the
% title page will not have any indication of a particular
% faculty or other educational structure.
% Therefore the Degree Course name, specified with
% |\corsodilaurea| should always be specified.
% The alias commands |\StrutturaDidattica| and |\struttura|
% are defined as equivalent commands to |\FacoltaDi| and
% |\facolta| respectively.
%
% Finally |\logosede| gets the name of the graphic file that
% contains the information relative to the university logo;
% it may receive also a comma separated list of logo file
% names, as it might be necessary when a thesis
% is developed in a multiple university environment.
% If such logo file is not available, the user should not
% specify this command; if the thesis is
% typeset on smaller paper size than A4 or letter,
% it would be much better to avoid inserting one or more logos
% in the title page; this is particularly important when using
% A5 paper size. Nevertheless this decision is left to
% the user and this package neither controls this fact
% nor outputs any warning.
% If the user uses this command to insert one or more
% university logo files but some file is not available,
% the usual \texttt{graphicx} package warning is issued but
% compilation may go on without the missing logo.
%
% The treatment of one or more logo files requires some extra
% commands and control sequences suitable to store temporary
% data or to specify style parameters: one is the name of
% a save box; another is the default spacing between the
% logos in the typeset page; the third is the height of the logos.
% The default spacing may be set with the help of the
% macro |\setlogodistance| -- notice that the default value
% is |3em|, and if a different distance is desired, it should
% not be much larger or much smaller than the default one;
% the default logo height is specified as an option
% command to the |\logosede| command, while the default
% size is given by the |\T@Tlogoheight| length. This length
% is specified in the main |toptesi| package in order
% to compute the typesetting grid, so that if the |topfront|
% module is used by itself with other classes, the existence
% of the |\T@Tlogoheight| control sequence is tested and if it is
% undefined, then and only then it is defined in this
% module and assigned a default value.
%
% The save box name is just for internal workings and does
% not require any customisation.
%
% The analysis and processing to the possible list of logo
% file names is done through the usual means of the delimited
% argument extraction of the single names from the list;
% the “string” of logos is then composed in a save box;
% as the list has been completely processed, the box is
% measured; if its width is shorter than the |\textwidth|
% it is typeset without further processing; if it is larger,
% on the opposite, the box gets scaled down so that its width
% equals the |\textwidth|.
%
% The |\tutoreaziendale| macro is the last title page
% addition; several students, who work on their thesis
% or final project in a company, want to have the company
% supervisor name printed in the title page; this does not
% preclude expressing the student's deepest thanks in the
% acknowledgements section, but it does not harm to name
% this person also in the title page.
%
% Eventually the |\retrofrontespizio| command, that by
% default is empty, allows to typeset a copyright page;
% the argument of this command is in  total responsibility
% to the user who must write it in the thesis main language;
% the user can specify from zero to several paragraphs,
% separated by the vertical spaces s/he thinks best; the
% argument by default is typeset at the bottom of the text
% block of the copyright page. The user can specify any
% pertinent space at the bottom of his/her argument, so as
% to set the text in the position s/he likes best.
% In order to handle the copyright page in the proper way
% we need to test if its definition is empty or blank so
% we need the powerful advanced macros of the package
% |etoolbox| that has already been loaded by this module or
% by the main |toptesi| one.
%    \begin{macrocode}
\def\ciclodidottorato#1{\gdef\@ciclo{#1 \@cyclename}}%
\def\corsodilaurea#1{\global\dottoratofalse\gdef\@corso{#1}}
\def\corsodidottorato#1{\global\dottoratotrue\global\triennalefalse
    \gdef\@corso{#1}}
\def\scuoladidottorato#1{\global\dottoratotrue\global\triennalefalse
    \gdef\@phdschool{#1}}
\def\ateneo#1{\gdef\@ateneo{#1}}
\def\nomeateneo#1{\gdef\@nomeat{\expandafter\uppercase{\expandafter #1}}}
\newcommand\facolta[2][]{\gdef\@facname{#2}\gdef\@facnumber{#1}}
\let\struttura\facolta

\newlength{\TPT@logospace}\TPT@logospace=3em\relax
\newsavebox{\TPT@logobox}
\newdimen\TPT@logoheight 
\newcommand*\setlogodistance[1]{\TPT@logospace=#1}
\providecommand*{\@logosede}{}

\ifcsundef{T@Tlogoheight}{%\
    \newlength\T@Tlogoheight
    \setlength\T@Tlogoheight{0.8\dimexpr(\paperwidth-\textwidth)/2}}{}
    
\newcommand\logosede[2][\T@Tlogoheight]%
    {\def\@logosede{#2}\TPT@logoheight=#1\relax
    \ifcsvoid{@logosede}{\sbox{\TPT@logobox}{}}{%
    \begin{lrbox}{\TPT@logobox}%
    \expandafter\fillup@TCP@logobox\@logosede,!}}

\def\fillup@TCP@logobox#1,#2!{%
	\ifblank{#1}{\end{lrbox}\ifdim\wd\TPT@logobox>\textwidth
	\sbox\TPT@logobox{\resizebox{\textwidth}{!}{\box\TPT@logobox}}\fi}%
	{\def\@logosede{#2}%
	\includegraphics[height=\TPT@logoheight]{#1}\hskip\TPT@logospace
   \expandafter\fillup@TCP@logobox\@logosede,!}}

\newcommand\printloghi{\unless\ifvoid\TPT@logobox\usebox{\TPT@logobox}\fi}

\def\tutoreaziendale#1{\gdef\@tutoreaziendale{#1}}
\newcommand\retrofrontespizio[1]{\long\gdef\@retrofrontespizio{#1}}
%    \end{macrocode}
%
% The following commands are user commands that modify the
% infix strings according to the language used and to the
% specifications of the actual university. All these
% commands can be put in the configuration file so as
% to specify what is desired as a default.
% If these commands are specifically used to redefine
% something before issuing the |\frontespizio| command
% or one of the title page environments, the new definitions
% override the configuration ones.
%
% \begin{description}[noitemsep]
% \def\Item[#1]{\item[\normalfont\texttt{\char92#1}]
% sets or changes the string}
% \Item[FacoltaDi] “Facolt\`a di” in, say, “Faculty of”
% \Item[DottoratoIn] “Dottorato in” in, say, “PhD in”
% \Item[CorsoDiLaureaIn] “Corso di Laurea in” in, say,
% “Master of Science in”
% \Item[TesiDiLaurea] “Tesi di Laurea” in, say,
% “Tesi di Laurea Magistrale”
% \Item[NomeMonografia] “Monografia di Laurea” in, say,
% “Tesi di Laurea”
% \Item[NomeDissertazione] “Dissertazione” in, say,
% “PhD dissertation”
% \Item[InName] “in” in, say, “auf”
% \Item[CandidateName] “Candidato” in, say, “Laureando”
% \Item[AdvisorName] “Relatore” in, say, “Supervisors”
% \Item[CoAdvisorName] “Correlatore” in, say, “Corapporteur”
% \Item[NomeTutoreAziendale] “Supervisore aziendale” in, say,
% “XYZ Company Supervisor”
% \Item[TutorName] “Tutore” in, say, “Supervisor”
% \Item[CycleName] “ciclo” in, say, “cycle”
% \Item[NomePrimoTomo] “Tomo primo” in, say, “First volume”
% \Item[NomeSecondoTomo] “Tomo secondo” in, say, “Second volume”
% \Item[NomeTerzoTomo] “Tomo terzo” in, say, “Third volume”
% \Item[NomeQuartoTomo] “Tomo quarto” in, say, “Fourth volume”
% \end{description}
% In the above description the first string is generally
% the default one, while the second string is just an example
% of the corresponding string to be set in another language
% or to be changed in Italian. The last four commands clearly
% show the difficulty of localising language strings: it
% is necessary to localise the whole phrase, because of
% the position of the adjectives.
%    \begin{macrocode}
\newcommand\FacoltaDi[1]{\gdef\@faculty{#1}}
\let\StrutturaDidattica\FacoltaDi
\newcommand\DottoratoIn[1]{\gdef\@PhDname{#1}}
\newcommand\CorsoDiLaureaIn[1]{\gdef\@laureaname{#1}}
\newcommand\TesiDiLaurea[1]{\gdef\@TesiDiLaurea{#1}}
\newcommand\NomeMonografia[1]{\gdef\@monografia{#1}}
\newcommand\NomeDissertazione[1]{\gdef\@dissertazione{#1}}
\newcommand\InName[1]{\gdef\@InName{#1}}
\newcommand\CandidateName[1]{\gdef\@nomecandidato{#1}}
\newcommand\AdvisorName[1]{\gdef\Relatore{#1}\gdef\Relatori{#1}}
\newcommand\CoAdvisorName[1]{\gdef\Correlatore{#1}\gdef\Correlatori{#1}}
\newcommand\TutorName[1]{\gdef\Tutore{#1}}
\newcommand\NomeTutoreAziendale[1]{\gdef\@tutoreaziendalename{#1}}
\newcommand\CycleName[1]{\gdef\@cyclename{#1}}
\newcommand\NomePrimoTomo[1]{\gdef\PrimoTomo{#1}}
\newcommand\NomeSecondoTomo[1]{\gdef\SecondoTomo{#1}}
\newcommand\NomeTerzoTomo[1]{\gdef\TerzoTomo{#1}}
\newcommand\NomeQuartoTomo[1]{\gdef\QuartoTomo{#1}}
\providecommand\IDlabel{\\\quad matricola\ }
%    \end{macrocode}
%
% Now we can read the configuration file if it exists;
% in any case what is possibly defined or redefined in the
% configuration file must not be redefined in the following
% Lines and this is why everything is subject to the test
% |\@ifundefined|. Most default definitions are simply
% “blank”; the others are in Italian. All of them, except
% the supervisor and candidate strings may be individually
% redefined in the configuration file or in the preamble.
% Those that cannot be redefined such as the four
% “candidate” strings may be actually redefined through
% the single |\CandidateName| that should be used in a
% language depended way and with the correct number and
% gender once for all.
% The four endings in the Italian strings allow to
% exercise the correct selection only for Italian;
% a specific test is made inside the |\frontespizio|
% command; because of this, the same machinery cannot
% be used, say, for French but maybe in the future this
% feature is resolved in a proper way. The same is true
% for the supervisor and the co-supervisor strings that
% may be changed once for all with |\AdvisorName| and
% |\CoAdvisorName|.
%    \begin{macrocode}
\IfFileExists{\jobname.cfg}{\input{\jobname.cfg}}%
    {\IfFileExists{toptesi.cfg}{\input{toptesi.cfg}}{}}
%
\@ifundefined{@cyclename}{\def\@cyclename{ciclo}}{}
\@ifundefined{@titolo}{\def\@titolo{}}{}

\providecommand\@author{}\providecommand\@@author{}
\NewDocumentCommand\candidato{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}
\femminilefalse\pluralefalse}
\NewDocumentCommand\candidata{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}
\femminiletrue\pluralefalse}
\providecommand\@secondauthor{}
\NewDocumentCommand\secondocandidato{m o}{%
\IfNoValueTF{#2}{\gdef\@secondauthor{#1}}%
                {\gdef\@secondauthor{#1\IDlabel#2}}%
\femminilefalse\pluraletrue}
\NewDocumentCommand\secondacandidata{m o}{%
\IfNoValueTF{#2}{\gdef\@secondauthor{#1}}%
                {\gdef\@secondauthor{#1\IDlabel#2}}%
\pluraletrue}
\providecommand\@thirdauthor{}
\NewDocumentCommand\terzocandidato{m o}{%
\IfNoValueTF{#2}{\gdef\@thirdauthor{#1}}%
                {\gdef\@thirdauthor{#1\IDlabel#2}}%
\femminilefalse\pluraletrue}
\NewDocumentCommand\terzacandidata{m o}{%
\IfNoValueTF{#2}{\gdef\@thirdauthor{#1}}%
                {\gdef\@thirdauthor{#1\IDlabel#2}}%
\pluraletrue}
\providecommand\IDlabel{matricola\ }

\@ifundefined{@principaladviser}{\def\@principaladviser{}}{}
\@ifundefined{@secondadviser}{\def\@secondadviser{}}{}
\@ifundefined{@thirdadviser}{\def\@thirdadviser{}}{}
\ifcsundef{@PhDdirector}{%
   \ifDirettore\def\@PhDdirector{Direttore del corso di dottorato}\else
    \def\@PhDdirector{Coordinatore del corso di dottorato}\fi}{}
\@ifundefined{@tutore}{\def\@tutore{}}{}
%
\@ifundefined{@nomerelatore}{\def\@nomerelatore{}}{}
\@ifundefined{@nomecandidato}{\def\@nomecandidato{}}{}
\@ifundefined{Candidato}{\def\Candidato{Candidato}}{}
\@ifundefined{Candidata}{\def\Candidata{Candidata}}{}
\@ifundefined{Candidati}{\def\Candidati{Candidati}}{}
\@ifundefined{Candidate}{\def\Candidate{Candidate}}{}
\@ifundefined{Relatore}{\def\Relatore{Relatore}}{}
\@ifundefined{Relatori}{\def\Relatori{Relatori}}{}
\@ifundefined{Correlatore}{\def\Correlatore{Correlatore}}{}
\@ifundefined{Correlatori}{\def\Correlatori{Correlatori}}{}
\@ifundefined{Tutore}{\def\Tutore{Tutore}}{}
\@ifundefined{@tutoreaziendale}{\def\@tutoreaziendale{}}{}
\@ifundefined{@tutoreaziendalename}%
        {\def\@tutoreaziendalename{Supervisore Aziendale}}{}
\@ifundefined{@retrofrontespizio}{\def\@retrofrontespizio{}}{}
\@ifundefined{@subtitle}{\def\@subtitle{}}{}
%
\@ifundefined{@corso}{\def\@corso{}}{}
\@ifundefined{@ciclo}{\def\@ciclo{}}{}
\@ifundefined{@ateneo}{\def\@ateneo{POLITECNICO DI TORINO}}{}
\@ifundefined{@nomeat}{\def\@nomeat{}}{}% Nome proprio dell'ateneo
\@ifundefined{@facolta}{\def\@facname{}}{}
\@ifundefined{@facnumber}{\def\@facnumber{}}{}
\@ifundefined{@faculty}{\def\@faculty{}}{}
%
\@ifundefined{PrimoTomo}{\def\PrimoTomo{Tomo primo}}{}
\@ifundefined{SecondoTomo}{\def\SecondoTomo{Tomo secondo}}{}
\@ifundefined{TerzoTomo}{\def\TerzoTomo{Tomo terzo}}{}
\@ifundefined{QuartoTomo}{\def\QuartoTomo{Tomo quarto}}{}
%    \end{macrocode}
%
% The infix word for the |classica| option are redefined.
%    \begin{macrocode}
\ifTOPfront
  \ifclassica
    \def\Candidato{Laureando}
    \def\Candidata{Laureanda}
    \def\Candidati{Laureandi}
    \def\Candidate{Laureande}
  \fi
\fi
%    \end{macrocode}
% If the final exam date is not given, the default value is
% the current month and the current year typeset in Italian;
% therefore the user is strongly requested to enter a date
% either with the |\sedutadilaurea| or the |\esamedidottorato|
% commands. The default value of the university logo command has
% already been defined “empty”.
%    \begin{macrocode}
\@ifundefined{@submitdate}{\def\@submitdate{\ifcase\the\month\or%
  Gennaio\or Febbraio\or Marzo\or Aprile\or Maggio\or Giugno\or
  Luglio\or Agosto\or Settembre\or Ottobre\or Novembre\or Dicembre\fi
  \space \the\year}}{}
%
\@ifundefined{@TesiDiLaurea}{\def\@TesiDiLaurea{Tesi di Laurea}}{}
\@ifundefined{@phdschool}{\def\@phdschool{SCUOLA DI DOTTORATO}}{}
\@ifundefined{@PhDname}{\def\@PhDname{Dottorato in }}{}
\@ifundefined{@laureaname}{\def\@laureaname{Corso di Laurea in }}{}
\@ifundefined{@dissertazione}{\def\@dissertazione{Tesi di Dottorato}}{}
\@ifundefined{@monografia}{\def\@monografia{Monografia di Laurea}}{}
\@ifundefined{@InName}{\def\@InName{in}}{}
%    \end{macrocode}
%
% Finally we have the real macro |\frontespizio| and the
% corresponding environments, the real macros or environments
% that actually typeset the title page.
%
% I recommend to use the environments, a new feature of
% version 5.85. But the legacy command |\frontespizio| is
% still usable. The principle on which these environments
% work is that the |frontespizio| environment typesets the
% title page with logo(s) set in the page header, while the
% |frontespizio*| environment typesets the logos after the
% information on the title, the possible sub title and tome
% information, i.e.\ in the lower half of the title page.
% In order to achieve this result each environment sets the
% boolean variable |topTPTlogos| to either value |true|
% (for header logos) or |false| (otherwise).
% The key of the different typesetting style is this
% boolean-variable state.
%
% Now, since the internal |frontespizio| environment opening
% command is |\frontespizio| how is it possible to distinguish
% this opening statement from the homonymous user command?
% The solution is a little tricky, but, after all, very simple.
% The |\begin| command, with which an environment is started,
% before calling the opening statement defines the internal
% service macro |\@currenvir| to contain the environment name;
% this is used by the |\end| statement to control that it is
% closing the last opened environment.
%
% If the |\frontespizio| command is directly used, the
% |\@currenvir| macro does not contain the name “frontespizio”;
% therefore if in the opening environment definition we check
% the contents of |\@currenvir| against the string
% |frontespizio| we can decide if the user resorted to
% the legacy command, or the environment was correctly
% opened by means of |\begin|.
% If the user resorted to the legacy command, the
% service macro |\fr@ntespizio| is called that typesets
% the title page according to the current status of the
% boolean |topTPTlogos|, a boolean that has a default
% value but the user can set at its will. Otherwise the
% |frontespizio| environment is regularly executed.
% Notice that the service macro |\fr@ntespizio| tests
% the state of the boolean |classica| and accordingly
% uses a different page style.
%    \begin{macrocode}
\newbool{topTPTlogos} \booltrue{topTPTlogos}

\newenvironment{frontespizio*}{\boolfalse{topTPTlogos}}{\fr@ntespizio}

\newenvironment{frontespizio}{%
    \ifdefstring{\@currenvir}{frontespizio}
           {\booltrue{topTPTlogos}}{\TPTmaybestar}
 }{%
     \fr@ntespizio
 }

%    \end{macrocode}
%
% With the new boolean |AteneoInHead| we can mark these
% situations where the university common name goes into the
% header; with the |classica| option the title page
% \emph{must} have this name in the header and if the user
% forgets to specify one, this module fakes it with a clear
% message that the university name has been forgotten, but
% at the same time this fake message fills up the header
% position. On the other hand, when the |classica| option
% has not been specified, the user can use either an empty
% university name or a specific name. So only when the
% |\@ateneo| macro remains empty the university name
% in the header remains really blank; this is good when the
% university name is part of the university logo (this is
% the case for Politecnico di Torino, and for many other
% universities). When no university name is set in the header
% some little attention in formatting the title page is necessary.
%
%    \begin{macrocode}  
\newbool{AteneoInHead}\boolfalse{AteneoInHead}
%    \end{macrocode}
%
% In order to use the command |\frontespizio*| as an isolated
% command instead of the starting command of the |frontespizio*|
% environment, we have to behave as with the |\frontespizio|
% command, but we must test for a possible asterisk following
% the command; for this reason we defined the |\TPTmaybestar|
% that% absorbs one following token: if the token is an
% asterisk, we set the appropriate settings for the previous
% behaviour of the isolated command, but if it is
% not an asterisk we must set it back into the list after
% finishing the execution of the |\fr@ntespizio| service macro,
% whose function is to set the title page information at the
% proper position, but must not contain any spurious material.
%    \begin{macrocode}
\newcommand\TPTmaybestar[1]{\def\@tempA{#1}%
\ifdefstring{\@tempA}{*}%
  {\boolfalse{topTPTlogos}\booltrue{AteneoInHead}\fr@ntespizio}
  {\booltrue{topTPTlogos}\fr@ntespizio\@tempA}
}
%    \end{macrocode}
%
% We start defining the complex macro |\fr@ntespizio|. We start
% with a group so that any settings performed by this command
% remain local; if the title page environments had been
% used, this group would be useless, but if the isolated
% commands are used, then this group protects the rest of the
% document from unusual local settings valid only for the
% title page.
%    \begin{macrocode}
\def\fr@ntespizio{%
\begingroup\par
%    \end{macrocode}
%
% We want also the title page to be set in the middle of the
% page irrespective of the binding correction; so we assign
% the average of the two side margins to both
% of them.
%    \begin{macrocode}
   \oddsidemargin=\dimexpr(\oddsidemargin+\evensidemargin)/2\relax
   \evensidemargin \oddsidemargin
%    \end{macrocode}
% The |\null| command inserts a void horizontal box into
% the vertical list; it is useful to act as a block against
% which the vertical glue pushes for setting the subsequent
% material. The normal font is chosen in case preceding
% commands did change the font characteristics.
%    \begin{macrocode}
\null
\setcounter{page}{1}%
\normalfont
%    \end{macrocode}
% Depending on the style of the title page a different
% |\pagestyle| is set with appropriate switches and settings.
% If with the classica style a university name is blank,
% it is set to an explicit string equivalent to “The
% university name is missing”.
%    \begin{macrocode}
\ifclassica
   \boolfalse{topTPTlogos}
   \thispagestyle{classica}
   \ifcsvoid{@ateneo}{\def\@ateneo{Manca il nome dell'ateneo}
   }{}
\else
   \thispagestyle{titlepage}
\fi
\ifcsvoid{@ateneo}{}{\booltrue{AteneoInHead}}
%    \end{macrocode}
%
% The generic university name should already be in the header
% either in the logo or in the header text; but in spite of
% this we test if the university generic name macro is void,
% if it contains something, then we typeset also the generic
% name; some candidates might obey to university regulations
% that require the name of the university be at the top, just
% under the logo. The switch |\ifcsvoid| is true if |@ateneo|
% is empty or blank, false otherwise; but even with page top
% logos, no test is made in order to give the possibility to
% repeat the university name. It is the user responsibility to
% set an empty value to the |\ateneo| macro so as to avoid
% repeating the university name possibly already present in
% the logo itself.
%    \begin{macrocode}
\ifcsvoid{@ateneo}{%
    \ifbool{topTPTlogos}
    {}{\booltrue{AteneoInHead}\def\@ateneo{Manca il nome dell'ateneo}}%
}{%
    \booltrue{AteneoInHead}%
}

   \ifbool{AteneoInHead}{}{%
      {{\centering\LARGE \@ateneo\par}}
   }
%    \end{macrocode}
%
% If it is non blank the first thing we set on the page is
% the university proper name and some vertical glue.
%    \begin{macrocode}
   \ifcsvoid{@nomeat}{}
      {\ifbool{topTPTlogos}{\vspace*{\dimexpr \headsep+2.5ex}}{\vspace*{-3ex}}%
      {\centering\@nomeat\par}\vfill}

%    \end{macrocode}
% Then the faculty name comes next; but for the doctoral
% school it uses the doctoral school name entered with
% |\scuoladidottorato|, otherwise it inserts the faculty
% ordinal number or prefix and name already entered with
% the optional and required arguments of |\facolta|.
%    \begin{macrocode}
      \begin{center}
      {\rmfamily\mdseries
      \ifdottorato
            \large \@phdschool\par\medskip
      \else
            \ifcsvoid{@faculty}{}{%
            	\LARGE\ifx\@facnumber\empty\else\@facnumber\space\fi
            	\@faculty\unskip\xspace\@facname\par\medskip
            }
      \fi
      }%
%    \end{macrocode}
% Further specification: it inserts the field of the PhD
% research or the degree course name; it inserts a line
% such as, for example, “Philosophy Degree in Applied
% Tetratricotomy~--~XVI~cycle” or “Master of Science
% in Applied Tetratricotomy”.
%    \begin{macrocode}
      \ifcsvoid{@corso}{}{{\large
            \ifdottorato
                 \@PhDname\unskip\xspace
                      \@corso\ifx\@ciclo\empty\else~--~\@ciclo\fi
            \else
                  \@laureaname\unskip\xspace\@corso
            \fi
            \par}}
      \end{center}
%    \end{macrocode}
% It now centres the name of the report, be it “Doctoral
% Dissertation” or “Master Thesis” or whatever; in case
% the command |\materia| was used, it then centres the
% discipline which the thesis deals with.
%    \begin{macrocode}
      \vspace{\stretch{0.2}}
      \begin{center}
        \LARGE
        \ifdottorato
            \@dissertazione%
        \else
            \iftriennale
                  \@monografia%
            \else
                  \@TesiDiLaurea%
            \fi
        \fi
        \unless\ifx\empty\@materia
            \\\@InName\\\@materia
        \fi
      \end{center}
%    \end{macrocode}
%
% Next comes the real title entered with |\titolo| or
% |\monografia| and the possible subtitle.
%    \begin{macrocode}
      \vspace{\stretch{0.2}}
      \begin{center}
        {\huge\bfseries \baselineskip=0.95em plus 1pt
                \@titolo \par}
      \end{center}
%    \end{macrocode}
% with the possible subtitle:
%    \begin{macrocode}
      \unless\ifx\@subtitle\empty 
            \begin{center}%
              \large\textrm{\@subtitle}\par
            \end{center}%
      \fi
%    \end{macrocode}
% If the option \texttt{classica} is in force the thesis
% might be divided in several volumes; theses in humanities
% apparently are often oversized. In this case the |\tomo|
% command may be given at the beginning of every volume and the
% counter \texttt{tomo} is stepped up; the volume number
% is therefore printed in each title page; the infix string
% may be redefined as it was shown above. 
%    \begin{macrocode}
      \ifclassica
            \ifnum\value{tomo}>\z@
                  \par\bigskip
                  \noindent\makebox[\textwidth]{%
                  \large\textbf{%
                  \ifcase\c@tomo%
                        \or \PrimoTomo%
                        \or \SecondoTomo%
                        \or \TerzoTomo%
                        \or \QuartoTomo%
                        \else
                            \PackageWarning{toptesi}{%
                            Counter tomo equals 
                               \the\c@tomo\MessageBreak
                            We never considered a thesis might get
                            divided in more than four volumes}%
                        \fi}}%
            \fi
            \vspace{1em}
      \fi
      \par
%    \end{macrocode}
% Going down in the title page, now comes the optional
% insertion of the university logo(s); “optional” in both
% meanings: one or more university logos are not generally
% required in a thesis, and in case it depends if the
% logo(s) have to be put in the header or here.
% This is a simple task since the |\logosede| already
% defined the contents to the box |\TPT@logobox|, and this
% was done either with the explicit command |\logosede|
% with its argument in a specific line of the configuration
% file or within the |frontespizio| environment.
% If such box |\TPT@logobox| is void, the already defined
% |\printloghi| macro does not do anything.
%    \begin{macrocode}
     \unless\iftopTPTlogos
      {\vfill\centering \printloghi\par}\fi
%    \end{macrocode}
%
% The final task is to typeset the possible supervisors'
% names, the candidates' names and all the rest of the
% bureaucratical terms. We have to distinguish between
% a bachelor degree report that is not supposed to have
% a supervisor, from the doctoral dissertation where we
% do not indicate the supervisor, but the School Director,
% and the master thesis where there might be one or more
% supervisors; with the \texttt{classica} option in force
% no label is printed over the supervisor's name, unless
% there is a plurality of supervisors.
%    \begin{macrocode}
      \vfill
      \iftriennale
            \let\@nomerelatore\empty
      \else
            \ifdottorato
                  \edef\@nomerelatore{\@PhDdirector}%
            \else
                  \ifcsvoid{@principaladviser}{}{%
                        \def\@nomerelatore{\Relatore}}
                  \unless\ifclassica
                        \ifcsvoid{@secondadviser}{}{%
                              \def\@nomerelatore{\Relatori}}%
                  \fi
            \fi
      \fi
%    \end{macrocode}
% Similarly the label names for the exam candidates are
% chosen; in Italian such names are infix strings that are
% selected according to the gender and the number; if these
% labels have to be set in a different language it is
% necessary to define one string that has to be selected
% by the user according to number and gender.
% The label for the PhD candidate is left empty.
%    \begin{macrocode}
      \ifdottorato
            \let\@nomecandidato\empty
      \else
        \iflanguage{italian}{%
            \iffemminile
                  \def\@nomecandidato{\Candidata}%
            \else
                  \def\@nomecandidato{\Candidato}%
            \fi
            \ifcsvoid{@secondauthor}{}{%
                  \iffemminile
                        \def\@nomecandidato{\Candidate}%
                  \else
                        \def\@nomecandidato{\Candidati}%
                  \fi}
         }{}%
     \fi
%    \end{macrocode}
%
% For the supervisor(s) and the candidate(s) name(s)
% a different approach is used for each one of the three
% categories of theses. If a bachelor degree
% report is dealt with, the name of the \emph{single}
% candidate is centred and written in caps-and-small-caps.
%    \begin{macrocode}
      \iftriennale
            \begin{center}%
                  \large\mdseries\textsc{\@author}
            \end{center}%
%    \end{macrocode}
% For doctoral and master theses two virtual boxes
% (actually macros) are filled up so as to align the
% supervisor name(s) and, respectively,
% the candidate name(s). The label is set in the first
% line with proper number and gender; in the second line
% the first name, and in the subsequent lines,
% if there are any, the other names. These virtual boxes
% actually contain a tabular environment each; these
% environments shall be actually typeset when these virtual
% box macros are executed. If the \texttt{classica} option
% is in force no label is set over the principal advisor
% name, but a label is set over the co-advisor name(s).
% The type size is also a little different for the
% \texttt{classica} option. The |\protect| command is used
% to protect the names in case they contain accent macros
% that might be expanded at the wrong moment.
%
% The candidate name(s) are typeset in another nested
% tabular environment of two lines when the user typesets
% the entry in such a way:
%\begin{flushleft}
%\cs{candidato}\Marg{Mario Rossi}\Oarg{123456}\\[1ex]
%\end{flushleft}
% The optional argument contains the ID number of the candidate;
% if it is specified, it is typeset below the candidate name,
% with an indentation, and prefixed with  the \verb*|matricola |
% label; of course if the optional ID number (and the enclosing
% brackets) is not specified, nothing is printed after or
% below the candidate's name.
% If the user wants it typeset on the same line and or with a
% different label s/he has to redefine the macro |\IDlabel| by
% means of the \cs{ID} macro described in previous sections;
%
% Example redefinitions are shown in the sample files.
% Notice that with the new definition of the candidates' setting
% macros it is guaranteed that the ID number, if specified, is
% typeset in the title page, but not in the headers if the
% |autoretitolo| option is in force.
%
% It is useful to recall that the ID number must be entered
% only if required by the University regulations; it must
% not be typeset in the title page just because it is possible
% to do it.
%
%    \begin{macrocode}
      \else
% For theses of any kind that expect the supervisor and co-supervisor
% names:
         \def\BoxRelatori{%
            \begin{tabular}[t]{l}%
            \hbox{\ifclassica\else\large\fi
                  \textbf{\protect\@nomerelatore}}\\[.6ex]
            \hbox{\large\textrm{\protect\@principaladviser}}%
            \ifx\@secondadviser\empty \else
               \ifclassica
                  \ifx\@thirdadviser\empty
                     \ifx\@secondadviser\empty\else
                           \\[1.5ex]\textbf{\Correlatore:}%
                     \fi
                  \else
                     \\[1.5ex]\textbf{\Correlatori:}%
                  \fi
               \fi
               \\[.6ex]\hbox{{\large\textrm{\protect\@secondadviser}}}%
            \fi
            \ifx\@thirdadviser\empty \else
               \\[.6ex] \hbox{{\large\textrm{\protect\@thirdadviser}}}%
            \fi
            \end{tabular}%
         }%
%    \end{macrocode}
% A similar approach is taken for the candidate name(s),
% although for code clarity I prefer to define two secondary
% macros in order to format the other candidates names
% and ID in a clearer way.
%    \begin{macrocode}
      \def\print@secondocandidato{\\\relax
                  \hbox{\large\tabular{@{}l@{}}\@secondauthor\endtabular}}
      \def\print@terzocandidato{\\\relax
                  \hbox{\large\tabular{@{}l@{}}\@thirdauthor\endtabular}}
      \def\BoxCandidati{%
         \begin{tabular}[t]{l}%
            \hbox{\unless\ifclassica\large\fi
               \textbf{\protect\@nomecandidato}}\\[.6ex]
               \hbox{\large\tabular{@{}l@{}}\@author\endtabular}%
               \ifcsvoid{@secondauthor}{}{\print@secondocandidato}%
               \ifcsvoid{@thirdauthor}{}{\print@terzocandidato}%
         \end{tabular}%
      }%
%    \end{macrocode}
% The real typesetting of these name lists takes place now;
% if the thesis is referred to the PhD school, one type of
% layout is used, otherwise the default master thesis layout
% is used; remember that the bachelor degree case has
% already taken place. For the doctoral dissertation the
% doctoral candidate name is typeset centred in one line
% by itself and everything else is set 3em below into a three
% column table extended to the |\hsize|, the first line
% containing the applicable labels and the second line
% containing the true names. The central column is used just
% for spacing, but it does not contain anything.
%    \begin{macrocode}
         \ifdottorato
            \begin{center}\large
               \textbf{\@author}\\[3em]
               {\normalsize
                 \begin {tabular*}{\hsize}{@{\extracolsep{\fill}}ccc}
                     \ifcsvoid{@tutore}{}{\textbf{\Tutore}}
                 &\relax&
                     \ifcsvoid{@principaladviser}{}{\textbf{\@nomerelatore}}
                 \\
                     \ifcsvoid{@tutore}{}{\@tutore}
                 &\relax&
                     \ifcsvoid{@principaladviser}{}{\@principaladviser}
                 \end{tabular*}
               }%
            \end{center}
         \else
%    \end{macrocode}
% For the master thesis the two virtual boxes are set one
% besides the other but skewed to the right or, respectively,
% to the left of every name so that there is enough space
% for the signature. With the \texttt{classica} option in force
% the two boxes are simply aligned.
%    \begin{macrocode}
           \unless\ifclassica
             \unless\ifevenboxes
             \begin{flushleft}%
                \BoxRelatori
             \end{flushleft}\par\vspace*{-1.5\baselineskip}
             \begin{flushright}%
                \BoxCandidati
             \end{flushright}%
             \else 
                \makebox[\textwidth]{\BoxRelatori\hfill\BoxCandidati}
             \fi
             \else
               \noindent
               \makebox[\textwidth]{%
               \BoxRelatori\hfill\BoxCandidati}\par
             \fi
          \fi
      \fi
%    \end{macrocode}
% The final item is the optional name of the company supervisor.
%    \begin{macrocode}
\ifcsvoid{@tutoreaziendale}{}{%
    \vfill\vfill
    {\centering \textbf{\@tutoreaziendalename}\\[.6ex]
    \@tutoreaziendale\par}}
%    \end{macrocode}
% All the material now is on the page; we put some more
% vertical glue and handle the copyright page; then we
% close the page sending it to the output file; the final
% |\endgroup| closes the |\begingroup| that was set at
% the beginning of this long macro.
% In order to handle the copyright page, we test if the
% internal definition of the copyright page text is empty;
% in this case no copyright page should be output, and
% a |\cleardoublepage| works fine in both one and two side
% printing; if the copyright page text is not empty, after
% shipping out the title page, we set the copyright page
% text flush bottom with the text block, and then we ship
% out also this copyright page.
%    \begin{macrocode}
      \par\clearpage
      \ifcsvoid{@retrofrontespizio}{}%
      {\null\vfill\thispagestyle{empty}\@retrofrontespizio\par\clearpage}%
\endgroup}
%    \end{macrocode}
% \iffalse
%</topfrn>
% \fi
%
% \subsection{Further settings for the ScuDo doctoral school}
%
% Doctoral theses to be developed at the \emph{Scuola di 
% Dottorato} (ScuDo) doctoral school of Politecnico di
% Torino require a particular set of other packages and
% commands to be available by default to the student
% writing his/her doctoral thesis. It requires also
% a title page with a layout completely different from
% those that can be typeset with the |topfront| extension
% file and, as far as I can tell, different from what
% is possible to create with the excellent |frontespizio|
% package.
%
% This task is reached by selecting  the thesis type
% by means of the |tipotesi=scudo| option to the |toptesi|
% class; this option sets on or off  the necessary switches
% and loads the |toptesi-scudo.sty| module in place of the
% |topfront| one. This specific module loads the extra
% packages, defines some special commands, provides the
% customising commands to modify the title page infix
% words and labels, and the commands to introduce the
% specific thesis data; eventually it specifies the title
% page layout and provides for its generation and to a
% copyright and disclaimer sentence on its verso page.
% 
% It produces also a colophon where some data concerning
% the thesis typesetting details are given.  This colophon
% is saved and used on the last even page of the complete thesis.
%
% Some if not all the data required for the title page may
% be entered by means of a configuration file |\jobname.cfg|
% that can be modelled on the |toptesi.cfg| file that is part of
% this bundle. The user should remember to copy the sample file in
% his/her thesis directory, change its name (not the extension)
% to match that of the thesis, modify the data according
% to his/her needs, and this extension file will read the
% configuration file at the proper moment and acquire its data.
%
% This |toptesi-scudo.sty| module is meant to load a certain
% number of packages in order to ease the user work when
% typesetting a dissertation in an engineering doctorate
% school such as ScuDo. 
% 
% The chosen packages are supposed to be sufficient to
% typeset any technical thesis or dissertation; but this
% does not limit its use to the fields of engineering;
% anybody can load the packages
% s/he needs for the particular discipline s/he is
% working on. At the same time nobody forbids to load
% other packages, in addition, not in substitution, of
% the packages loaded by this extension file of the
% |toptesi| class. 
%
%\iffalse
%<*topscu>
%\fi
% We start by loading the math packages produced by the
% American Mathematical Society, differentiating what is
% necessary to load when using \pdfLaTeX\ or the
% OpenType-aware programs \XeLaTeX\ or \LuaLaTeX.
% The extension file |iftex| that defines the switches
% \cs{ifPDFTeX},, \cs{ifXeTeX}, and \cs{ifLuaTeX},
% has already been loaded. The AMS fonts should
% not be used when typesetting with \XeLaTeX\ or \LuaLaTeX,
% because these programs get them directly from the
% \sigla{UNICODE} math fonts, so that package |amssymb| has
% to be loaded only when \pdfLaTeX\ is used.
%    \begin{macrocode}
\ScuDotrue
\ifPDFTeX
   \RequirePackage{amsmath,amssymb,amsthm}
\else
   \RequirePackage{amsmath,amsthm}
   \RequirePackage{unicode-math}
\fi
%    \end{macrocode}
% The suitable macro for using the differential sign in the
% proper \sigla{ISO} compliant way (upright font) with the suitable
% spacing before and no space after, is the following:
%    \begin{macrocode}
\AtBeginDocument{%
\providecommand\diff{}%
\renewcommand{\diff}{\mathop{}\!\mathrm{d}}
\providecommand{\gei}{\ensuremath{{\mathop{\mathrm{j}}\nolimits}}}
\providecommand{\eu}{\ensuremath{{\mathop{\mathrm{e}}\nolimits}}}
\let\iu\gei}
%    \end{macrocode}
% Such a definition allows to typeset math expression containing
% integrals with a small space between the integrand and the
% integrating differential; on the contrary the leading space does
% not disturb typesetting differential equations. The above
% definitions include also the \sigla{ISO} compliant ways of writing
% the Napier number `e', and the imaginary unit |\iu| that
% sets an operator-like roman `j' as it is customary in
% most engineering disciplines. The alias |\iu| to the |\gei|
% command may be redefined if the PhD student wants to use for
% example ‘i’; the example file \texttt{toptesi-scudo-example.tex}
% uses the Greek ‘iota’ and specifies that this use is \emph{wrong}!
%
% Next an option is defined, |mybibliostyle| which allows the user to
% establish his own style for the bibliography. By default the
% |toptesi-scudo| module loads |biblatex| with a set of options that
% allow numerical listing and numerical citation according to the IEEE
% standards for its Transaction. PhD students doing their theses in
% other scientific domains may use different styles for bibliographics 
% listings and citation methods. By setting this option |mybibliostyle|
% among the class ones, it is automatically treated as a global option
% so that it is passed on to the called packages; in particular this 
% option reaches this |toptesi-scudo| module, that has the following
% definition and handling lines:
%    \begin{macrocode}

\ifcsundef{ifmybibstyle}{\newif\ifmybibstyle\mybibstylefalse}{}
\DeclareOption{mybibliostyle}{\mybibstyletrue}
\ProcessOptions*\relax

%    \end{macrocode}
% The switch |mybibstyle| is used below when the |biblatex|
% package is possibly loaded. Actually when this option is active
% (i.e. when this switch is `true') nothing is loaded, and the user
% is free to load the packages s/he likes best in order to handle the
% bibliographic databases and to typeset one or more bibliographies
% with different styles. Since in the other thesis types nothing
% is preloaded for customising the user's bibliography, the user
% does not need to specify the above |mybibliostyle| option, and
% can proceed loading his/her preferred packages for bibliographic
% styles. With the other thesis types if the user specifies this option,
% nothing is done and it remains in the list of ‘unused options’.
%
% Some other packages are loaded next. Please take notice that
% |xparse| is very useful to define advanced commands and
% environments containing different kind of delimited
% arguments;  parameters entered as arguments to the
% opening statement of an environment are available also
% for the closing commands; read the documentation if you
% want to use this package facilities. Since this package is
% already loaded by the |toptesi| class, a test is performed
% as to avoid reloading; but if this module is used independently
% from  the |toptesi| class, the package is actually loaded.
%
% Using the facilities of |setspace| may be tolerated only
% while typesetting a thesis draft. It is bad typography
% to use its facilities when doing the thesis final printing.
% 
% Packages |ifthen| and |calc|, in spite of being the
% standard traditional ones for accomplishing their tasks,
% are preferred by many users who are not aware that
% computations are now native of modern typesetting
% programs\footnote{All the three typesetting programs we are dealing
% with here. \LuaLaTeX\ can do also floating point computations
% thanks to the language Lua; all programs may benefit from the
% advances of the \LaTeX3 language, that has a special facilities
% to perform floating point calculations.}; also advanced
% tests are natively available with such programs, but
% since this class loads the |etooolbox|, its powerful
% and robust commands are already available; therefore
% these packages are loaded only for the user comfort,
% although they are not really required.
%
% Packages |caption| and |subcaption| have been optional
% for several TOPtesi versions before version 6.x; here they
% are pre-loaded only with the \textsf{tipotesi=scudo} option.
%
% Package |tabularx| provides an alternative way to produce
% tables of specified width by means of a new column type
% |X|; this column type behaves as |p|\marg{width}, where
% \meta{width} is computed by the package in order to expand
% the column(s) so as to fill the specified table
% width. It is very handy in a number of situations.
%
% For professional typesetting tables, package |booktabs|
% is highly recommended; we load also package |multirow|,
% although its use is deprecated by many professionals.
%
% The sample template file |toptesi-scudo-example.tex| shows a
% couple of tables typeset with and without using
% |multirow|; the results without using this package are
% marginally more elegant, but the user is more free to specify
% every detail, without the support of automatic (and
% limited) typesetting macros.
% 
% Package |siunitx| is highly recommended; its management
% of fractional measures, of units of measure, and of table
% columns that contain numerical values aligned on the decimal
% separator is very useful.
%
% Package |float| is very handy to define new floating
% environments; unfortunately many users load it in
% order to have available the float positioning
% option \textsf{H}, which should never be used,
% especially while using this TOPtesi class, where
% provisions for large floats are already taken care of.
%    \begin{macrocode}
\@ifpackageloaded{xparse}{}{%
  \RequirePackage{xparse}}% Command and environment advanced definitions 
\RequirePackage{lscape}   % Supports landscape Layout
\RequirePackage{setspace} % Define line spacing in paragraph. Don't use!
\RequirePackage{calc}     % Calculation macros
\RequirePackage{ifthen}   % Conditional statements
\RequirePackage{caption}  % Configure captions
\RequirePackage{subcaption}% Defines env. subfigure and its caption
\RequirePackage{tabularx} % Tables with expandable columns
\RequirePackage{booktabs} % professional rules in tables
\RequirePackage{multirow} % Multirow cells are not professional 
\RequirePackage{siunitx}  % advanced management of units of measure
\RequirePackage{float}    % Use only to define new floating objects!
%    \end{macrocode}
%
% Package |nomencl| is loaded and a sample of nomenclature
% groups is defined; they are mostly examples of “how to”;
% and in particular they are models to define other
% nomenclature groups. Notice that the string comparison
% tests are made through the testing robust commands
% provided by the |etoolbox| package.
%    \begin{macrocode}
\usepackage[intoc]{nomencl}% Generate nomenclatures or glossaries
\makenomenclature
\renewcommand{\nomgroup}[1]{%
\ifstrequal{#1}{A}{\item[\textbf{Roman Symbols}]}{%
\ifstrequal{#1}{G}{\item[\textbf{Greek Symbols}]}{%
\ifstrequal{#1}{Z}{\item[\textbf{Acronyms / Abbreviations}]}{%
\ifstrequal{#1}{R}{\item[\textbf{Superscripts}]}{%
\ifstrequal{#1}{S}{\item[\textbf{Subscripts}]}{%
\ifstrequal{#1}{X}{\item[\textbf{Other Symbols}]}{}}}}}}}

\renewcommand{\nompreamble}{\markboth{\nomname}{\nomname}}
%    \end{macrocode}
%
% It is important to note that the nomenclature
% raw file must be processed by means of program
% \prog{makeindex}  with special options. Assuming
% that your thesis main file is named |MyPhDthesis.tex|,
% after compiling with pdfLaTeX, you have to open a
% terminal, change the working directory into that
% where your main file is stored, and
% issue  and execute the line command
%{\small
%\begin{verbatim}
%makeindex -s nomencl.ist -t MyPhDthesis.nlg -o MyPhDthesis.nls MyPhDthesis.nlo
%\end{verbatim}
%\par}
% Afterwards you should have your processed nomenclature
% ready and up to date, so that by running again the
% typesetting program your nomenclature appears in the
% back matter; a second typesetting run, as usual, updates
% the table of contents with the entry and page number of
% the Nomenclature section. It is important to do this
% action before printing the final version of the thesis;
% you do not need to update the nomenclature every time
% you edit one of your thesis source files.
%
% All this fuzz is bypassed in the sense that all typesetting
% programs can run safe OS commands, among which \prog{makeindex},
% in order to do all these actions by themselves if we
% procede by closing the auxiliary file that collect
% nomenclature entries, and run \prog{makeindex} with
% the proper options and file names directly through the
% “magic command” |\write18|. 
%
% We then define a new command
% to process the nomenclature files and print them out.
%
% Again the test for an empty optional argument is made by
% means of a macro defined in |etoolbox|. When using LuaLaTeX
% it is necessary a special treatment, because the typesetting
% engine does not use the |\write18| functionality, but
% accesses the operating system commands by means
% of its own Lua facilities. The user is not obliged to
% know these details, but this extension file must be
% programmed accordingly.
%    \begin{macrocode}
\newcommand{\printnomencl}[1][]{%
\immediate\closeout\@nomenclaturefile
\ifLuaTeX
  \chardef\T@T@shellescape\directlua{tex.write(os.execute())}
  \def\exec@makeindex{%
     \directlua{os.execute("\luaescapestring
     {makeindex -s nomencl.ist -t \jobname.nlg -o \jobname.nls \jobname.nlo}")}}
\else
  \def\exec@makeindex{\immediate\write18{%
  makeindex -s nomencl.ist -t \jobname.nlg -o \jobname.nls \jobname.nlo}}
\fi
\exec@makeindex
\ifblank{#1}{\printnomenclature}{\printnomenclature[#1]}%
}
%    \end{macrocode}
% The result is a synchronous typesetting of the nomenclature
% in the same way as for the index.
%
% The bibliography by default is typeset through the facilities of
% package |biblatex| with suitable options; 
% according to the tradition in scientific works, in particular
% of the IEEE standards for its Transactions, the
% references are labelled with bracketed numbers as well
% as citations. Nevertheless some PhD students working in other
% scientific domains ask for different styles  for using |BiBTeX|
% compatible bibliographies to be run also with |pdflatex|, or
% bibliographies styled in a more humanistic way.
%
% In this case they should specify the specific option |mybibliostyle|
% to the |toptesi| class, and the following code will not be loaded,
% since the switch |mybibstyle| is set to `true' only when using
% such an option. Therefore if the user uses the above option, the code 
% loads neither |biblatex| with its options, nor |csquotes|; furthermore 
% the bibliographic database remains unspecified. It is the user
% responsibility to insert in his/her thesis preamble whatever necessary 
% to typeset his/her bibliography or bibliographies the way s/he prefers.
% In the following code the module preloads the bibliographic database
% |resources.bib|, if it exists; since  a generic name is not recommended,
% we suggest to name at least one of your databases with the same name
% as the user's thesis master file with extension |.bib|; the |\jobname|
% macro, actually contains the thesis master file. If neither
% |resources.bib| nor |\jobname.bib| exist or the typesetting engine
% cannot find them, it is the user's responsibility to create a |.bib|
% file and include it in his/her master file preamble as an argument to
% |\addbibresource| or to move an his/her existing |.bib| file(s) to the
% main file folder.
%
%    \begin{macrocode}
\unless\ifmybibstyle
  \usepackage[autostyle]{csquotes} % necessary for biblatex
  \usepackage[backend=biber, 
              style=numeric-comp,
              citestyle=numeric,
              sorting=nty,
              natbib]{biblatex} % LaTeX specific bibliography handler
  \IfFileExists{references.bib}% bibliographic data base(s}
    {\addbibresource{references.bib}}%
    {\IfFileExists{\jobname.bib}%
     {\addbibresource{\jobname.bib}}%
     {\relax}}
\fi
%    \end{macrocode}
%
% Package |imakeidx| is loaded, but it is up to the user
% to specify command \texttt{\string\makeindex} with its
% options; in the sample template file |toptesi-scudo-example.tex|
% the index is made by configuring \cs{makeindex}
% by specifying only the \textsf{intoc} option, so as to
% have an entry for the index in the table of contents.
% The user who wants to prepare an index for his/her thesis
% is urged to read the |imakeidx| package documentation.
%    \begin{macrocode}
\usepackage{imakeidx}% to generate automatic indices
%    \end{macrocode}
%
% Eventually while using \pdfLaTeX we require the |indentfirst|
% package so as to indent the first paragraph after a
% sectioning command, according to a common usage in Europe
% and in Italy in particular. 
% 
%    \begin{macrocode}
\ifPDFTeX \usepackage{indentfirst}\fi
\raggedbottom

\AfterEndPreamble{\english}% Set English as default language

%    \end{macrocode}
%
% The |toptesi-scudo.sty| module contains also everything is
% needed to typeset the Ph.D. title page and the disclaimer
% page; remember that the \textsf{tipotesi=scudo} option to the
% class sets the default language to English, and inhibits
% loading the |topfront| extension file; therefore a
% complete new set of commands and a complete new title
% page environment are required to fill up the necessary
% information.
%
% We start with the default values for all
% pieces of information. Those macros that contain an empty
% expansion are obviously for mandatory data. Those that
% contain a text string insert default data, that can be
% possibly modified by suitable commands. Those that
% contain just macros insert into the title page the
% expansions of these macros.
%    \begin{macrocode}
\TOPfrontfalse

\providecommand*\@Ndissertation{Doctoral Dissertation}
\providecommand*\@Ndoctoralprogram{Doctoral Program in\xspace}
\providecommand*\@programname{}
\providecommand\@Cyclenumber{}
\providecommand*\@title{}
\providecommand*\@subtitle{\vspace{\stretch{1}}}
\providecommand*\@author{}
\providecommand*\@Nsupervisor{Supervisor}
\providecommand*\@Nsupervisors{Supervisors}
\newcount\@supervisornumber
\providecommand*\@supervisorlist{}
\providecommand\@Nexaminationcommittee{Doctoral Examination Committee:}
\providecommand*\@Examinerlist{}
\providecommand*\@examlocation{Politecnico di Torino}
\providecommand*\@examinationdate{}
\providecommand*\@creativecommons{This thesis is licensed 
under a Creative Commons License, Attribution - Noncommercial- 
NoDerivative Works 4.0 International: see \url{www.creativecommons.org}.
The text may be reproduced for non-commercial purposes, provided that 
credit is given to the original author.}
\providecommand\@disclaimer{\noindent I hereby declare that
the contents and organisation of this dissertation constitute 
my own original work and does not compromise in any way the 
rights of third parties, including those relating to the 
security of personal data.}

%    \end{macrocode}
% There are the user macros to change or define the
% required data; of course the mandatory data must be
% present in the student's thesis source file; the other
% data may be changed, but don't need to be changed: it
% depends on the university specifications, if any are given.
%
% In any case if the “examiner list” is not specified, so
% that the default list remains empty, no label and no list
% is typeset; therefore leaving this list empty is an easy
% and logical method for completely omitting such a list.
%
%    \begin{macrocode}
\newcommand*\Ndissertation[1]{\gdef\@Ndissertation{#1}}
\newcommand*\Ndoctoralprogram[1]{\gdef\@Ndoctoralprogram{#1\xspace}}
\newcommand*\ProgramName[1]{\gdef\@programname{#1\xspace}}
\newcommand*\CycleNumber[1]{\gdef\@Cyclenumber{\ifblank{#1}{}{(#1 cycle)}}}
\renewcommand*\title[1]{\gdef\@title{#1}}
\newcommand*\subtitle[1]{\gdef\@subtitle{\ifblank{#1}{}{\medskip\par
   {\Large #1\par}}\vspace{\stretch{1}}}}
\renewcommand*\author[1]{\gdef\@author{#1}}
\newcommand*\NSupervisor[2]
   {\gdef\@Nsupervisor{#1}\gdef\@Nsupervisors{#2}}
\newcommand*\SupervisorList[1]{\gdef\@supervisorlist{#1}}
\newcommand\SupervisorNumber[1]{%
   \ifblank{#1}{\@supervisornumber=0}{\@supervisornumber=#1}}
\newcommand\Nexaminationcommittee[1]{\gdef\@Nexaminationcommittee{#1}}
\newcommand*\ExaminerList[1]{\gdef\@Examinerlist{#1}}
\newcommand*\Nlocation[1]{\gdef\@examlocation{#1}}
\newcommand*\ExaminationDate[1]{\gdef\@examinationdate{#1}}

\newlength{\TPT@logospace}\TPT@logospace=3em\relax
\newsavebox{\TPT@logobox} \setbox\TPT@logobox\hbox{}
\newdimen\TPT@logoheight 
\newcommand*\setlogodistance[1]{\TPT@logospace=#1}
\providecommand*{\@logosede}{}

\ifcsundef{T@Tlogoheight}{%\
    \newlength\T@Tlogoheight
    \setlength\T@Tlogoheight{0.8\dimexpr(\paperwidth-\textwidth)/2}}{}
    
\newcommand\PhDschoolLogo[2][\T@Tlogoheight]%
{\def\@logosede{#2}\TPT@logoheight=#1\relax
\ifcsvoid{@logosede}{\sbox{\TPT@logobox}{}}{\begin{lrbox}{\TPT@logobox}%
\expandafter\fillup@TCP@logobox\@logosede,!}}

\def\fillup@TCP@logobox#1,#2!{%
	\ifblank{#1}{\end{lrbox}\ifdim\wd\TPT@logobox>\textwidth
	\sbox\TPT@logobox{\resizebox{\textwidth}{!}{\box\TPT@logobox}}\fi}%
	{\def\@logosede{#2}%
	\includegraphics[height=\TPT@logoheight]{#1}\hskip\TPT@logospace
   \expandafter\fillup@TCP@logobox\@logosede,!}}

\newcommand\printloghi{\unless\ifvoid\TPT@logobox\usebox{\TPT@logobox}\fi}
%    \end{macrocode}
% Next the disclaimer and the signature macros are defined;
% the disclaimer text and the signature layout may be changed
% by these commands; but if the user does not use these
% macros, the name of the person who undersigns the disclaimer
% text is assumed to be the thesis author and the signature
% date is assumed to equal the examination date.
% The \cs{Signature} macro is intended to modify the signature layout
% contained in the internal macro \cs{@signature}; the PhD student
% can layout the signature part of the copyright page the way s/he
% likes best; the default definition of \cs{@signature} is an example
% from which the student can get a general idea of what is compulsory
% in this field. The sample file \texttt{toptesi-scudo-example.tex}
% contains also an example of modified signature.
% 
% Remember: the disclaimer text is very important, in the
% sense that the student writing his/her Ph.D.\ thesis must
% be completely aware that by undersigning that statement
% s/he assumes any legal liability for any event that
% might betray other people rights. A kind of
% infringement, of course, is plagiarism. Therefore the 
% under signer must be completely aware that his/her signature
% is not just a simple bureaucratical action.
%    \begin{macrocode}
\newcommand\Disclaimer[1]{\gdef\@disclaimer{#1}}
\newcommand\CClicence[1]{\gdef\@creativecommons{#1}}
\providecommand\@signature{%
\begin{flushright}
\parbox{0.5\textwidth}{\centering
\dotfill\\
\@author\\
Turin, \@examinationdate
}%
\end{flushright}}
\newcommand\Signature[1]{\gdef\@signature{#1}}
%    \end{macrocode}
% The |ThesisTitlePage| environment is defined; in the
% opening commands the configuration file is read;
% this file may contain any kind of definition or
% redefinition by using the above commands with suitable
% arguments.
%
% The data possibly read from the configuration file now
% are available, or they may be entered in the body of the
% title page environment |ThesisTitlePage|. If some commands
% are repeated, the last ones, i.e.~those entered in the
% body of the environment, prevail.
%    \begin{macrocode}
\newenvironment{ThesisTitlePage}{% Apertura
\InputIfFileExists{\jobname.cfg}{\relax}{\relax}%
}{%Chiusura
\begin{titlepage}\parindent=0pt
{\centering
\raisebox{-1ex}[0pt][0pt]{\makebox[\textwidth]{\printloghi}}\par
\vspace{\baselineskip}
\@Ndissertation\\
\@Ndoctoralprogram \@programname\@Cyclenumber
\bigskip

{\Huge\bfseries \@title\par}
\@subtitle
{\Large\bfseries \@author\par}
\smallskip
\mbox{* * * * * *}
\vspace{\stretch{1}}

{\large\bfseries \ifcase\@supervisornumber
\relax\or \@Nsupervisor\else\@Nsupervisors\fi\par}
\@supervisorlist
\par}

\vspace{\stretch{1}}

\ifcsvoid{@Examinerlist}{\relax}{%
\noindent\begin{tabular}{@{}l}
\bfseries \@Nexaminationcommittee\\
\@Examinerlist
\end{tabular}}

\begin{center}
\raisebox{-3\baselineskip}[0pt][0pt]{%
\parbox{0.5\textwidth}{\centering
\@examlocation\\
\@examinationdate}}
\end{center}
\end{titlepage}
%
\newpage\thispagestyle{empty}
\vspace*{\stretch{1}}
\@creativecommons
\vspace{3\baselineskip}

\ifempty{\@keywords}{\relax}{Keywords: \@keywords\par
\vspace{2\baselineskip}}

\@disclaimer
\vspace{3\baselineskip}

\@signature}

%    \end{macrocode}
% The above code is almost everything is needed to enter
% the relevant data and to typeset the doctoral thesis
% and the signed disclaimer. But it is wise to enter
% some basic metadata for a reasonably well typeset \sigla{PDF}
% file. Notice that these metadata have nothing to do
% with the metadata required for \sigla{PDF/A} compliance; for
% the latter metadata it is necessary to load the |pdfx|
% package and enter the required metadata in a special
% way that is taken care of by |pdfx|. Read the details in
% the Italian\discretionary{-}{}{-}English documentation
% |toptesi-it.pdf| that is part of the TOPtesi bundle.
%    \begin{macrocode}
\providecommand*\subject{}\providecommand*\@subject{}
\renewcommand\subject[1]{\gdef\@subject{#1}}
\providecommand*\keywords{}\providecommand*\@keywords{}
\renewcommand\keywords[1]{\gdef\@keywords{#1}}
\AtBeginDocument{% Set some metadata
  \hypersetup{%
    pdftitle   = {\@title},
    pdfauthor  = {\@author},
    pdfsubject = {\@subject},
    pdfkeywords= {\@keywords}
  }
}
%    \end{macrocode}
%
% The School required also a colophon where it is explained
% how the thesis has been typeset and who are the authors
% of the \LaTeX\ code; my name appears there because the School
% requested it in a formal way; mentioning the TOPtesi bundle
% might have been sufficient for this colophon.
%
% Of course this colophon must be typeset in the last page,
% possibly an even one if the thesis is typeset with the
% |twoside| option in force.
%    \begin{macrocode}
\AtEndDocument{%
\clearpage
\ifbool{@twoside}%
{\ifodd\value{page}\thispagestyle{empty}\newpage\fi}{\relax}%
\vspace*{\stretch{1}}%
\noindent
\begin{tabularx}{\textwidth}{Xp{0.45\textwidth}X}
&
This Ph.D.\ thesis has been typeset by means of the \TeX-system
facilities. The typesetting engine was
\ifPDFTeX
  \ifcsdef{pdfLaTeX}{\pdfLaTeX}{pdf\/\LaTeX}%
\else
   \ifLuaTeX
      \ifcsdef{LuaLaTeX}{\LuaLaTeX}{Lua\/\LaTeX}%
   \else
      \ifcsdef{Xe}{\Xe\LaTeX}{Xe\/\LaTeX}
   \fi
\fi.
The document class was \texttt{toptesi}, by Claudio Beccari, 
with option \texttt{tipotesi\discretionary{}{=}{=}scudo}.  
This class is available in every up-to-date and complete 
\TeX-system installation.
&
\end{tabularx}
\vspace*{\stretch{2}}%
}
%    \end{macrocode}

%\iffalse
%</topscu>
%\fi
%
% \subsection{A configuration file}
% The following code generates a sample configuration file
% that the user can change at will after changing also its
% name; it can be used as a template for generating a really
% personal configuration file. Remember: this template file
% is named |toptesi.cfg|, but in order to use it for a
% specific thesis, whose main file is named
% |JohnSmithMSthesis.tex|, the configuration file must be
% named |JohnSmithMSthesis.cfg|.
% \iffalse
%<*topcfg>
% \fi
%    \begin{macrocode}
%%
%%================================================================
%% This file is the only file of the TOPtesi bundle that the user
%% can modify without restrictions in order to customise the
%% contents of this configuration file to his/her needs. The user
%% can add or remove lines, comment or uncomment lines, change the
%% arguments to macros, add definitions and so on. 
%% Use  this file by copying the relevant section to another file
%% to be named as the thesis main file and with extension .cfg.
%% This bundle will try to read "\jobname.cfg"; if this file does
%% not exist, the bundle files don't do anything. This implies that
%% the provided file toptesi.cfg is to be used as a model, not to
%% be used directly.
%%================================================================
%%
\ifmagistrale
     \ateneo{}%% The PoliTO name is contained in its logo
    \facolta{}%% nessun nome di default/ no default name for PoliTO
    \FacoltaDi{}%% nessun prefisso per la facolta'/no default faculty
                %% label for PoliTO
    \CorsoDiLaureaIn{Corso di Laurea in\xspace}%% 
    \TesiDiLaurea{Tesi di Laurea Magistrale}
    \InName{in}
    %%\retrofrontespizio{Questo testo e' soggetto alla 
    %% Creative Commons Licence}
\fi
\ifsecondaria
   \relax
\fi
\ifScuDo
    \PhDschoolLogo{Logo-Scudo}
    \Ndissertation{Docoral Dissertation}
    \Ndoctoralprogram{Doctoral Program in\xspace}
    \NSupervisor{Supervisor}{Supervisors}
    \SupervisorNumber{1}
    \Nexaminationcommittee{Doctoral Examination Committee:}
    \Nlocation{Politecnico di Torino, Turin, Italy}
    \Disclaimer{\noindent I hereby declare that the
     contents and organisation of this dissertation
     constitute my own original work and does not 
     compromise in any way the rights of third parties, 
     including those relating to the security of personal 
     data.}
     \CClicence{This thesis is licensed under a Creative Commons
     License, Attribution - Noncommercial- NoDerivative Works 4.0 
     International: see \url{www.creativecommons.org}.
     The text may be reproduced for non-commercial purposes, 
     provided that credit is given to the original author.}
\fi
%    \end{macrocode}
% \iffalse
%</topcfg>
% \fi
%
% \subsection{The  \texttt{topcoman.sty} code}
% This file may be used as an independent extension package
% for the \texttt{report} document class, and possibly for
% other classes.
% \iffalse
%<*topcmn>
% \fi
%
% The new command |\DeclareSlantedCapitalGreekLetters|
% optionally sets the capital Greek letters in math mode
% with the glyphs taken from the math italic fonts, not
% from the math roman fonts, as it is by default; some
% authors prefer to use both symbols with different
% meanings, so this command lets them do so. This may be
% useful unless the \XeTeX\ or \LuaTeX\ typesetting engine
% is used; in facts the Unicode math defines specific
% commands for setting any Latin or Greek mathematical
% letter in any possible font shape and series.
% Actually with \XeLaTeX\ and \LuaLaTeX\ it is possible to
% invoke the |unicode-math| package with the |style=\sigla{ISO}|
% option; in this way the \sigla{ISO} math typesetting becomes
% available; this includes the slanted Greek letters and
% many other facilities necessary to fulfil the \sigla{ISO}
% regulations for “physical sciences and technology”.
%
% With \pdfLaTeX\ there are available several packages
% and fonts suitable for typesetting math according to
% the \sigla{ISO} regulations. The fonts Libertinus together
% with the math fonts LibertinusT1math are the best
% choice for this task; the |isomath| package can do
% an excellent work with other fonts; a “poor man”
% solution with the \pdfLaTeX\ typesetting program is
% given by the |pm-isomath| package; this latter package
% is, in facts, a poor man approach to the problem, so
% it has several limitations, but it completely avoids
% the problem of loading several other math alphabets,
% therefore avoiding to exhaust the limited number of
% math alphabets \pdfLaTeX\ can handle.
%
% This |topcoman| module offers another “poor man”
% solution only for using by default slanted capital
% Greek letters taken from the math italic font; the
% upright ones are still available within the |\mathrm|
% command argument.
% Attention: \cs{DeclareSlantedCapitalGreekLetters} is defined
% only when using \prog{pdflatex}; with the other two engines
% it is disabled and produces a warning.
%    \begin{macrocode}
\RequirePackage{iftex}
\ifPDFTeX
\newcommand*\DeclareSlantedCapitalGreekLetters{%
   \mathchardef\Gamma="7100
   \mathchardef\Delta="7101
   \mathchardef\Theta="7102
   \mathchardef\Lambda="7103
   \mathchardef\Xi="7104
   \mathchardef\Pi="7105
   \mathchardef\Sigma="7106
   \mathchardef\Upsilon="7107
   \mathchardef\Phi="7108
   \mathchardef\Psi="7109
   \mathchardef\Omega="710A
}\else
\newcommand*\DeclareSlantedCapitalGreekLetters{%
\PackageWarning{toptesi}{%
   When using LuaLaTeX or XeLaTeX specify\MessageBreak
   option math-style=ISO to package unicode-math\MessageBreak}
}
\fi
%    \end{macrocode}
% The |\ensuremath| command is defined in the \LaTeXe\ 
% kernel from a certain version on; should the user employ
% a really old \LaTeXe\ implementation, this definition
% supplies the missing one. Should the |babel| package
% not be loaded, then we provide the useful command
% |\textormath| provided by |babel|. We define the text
% version of the subscript and  ensure also that the
% |textcomp| package is loaded; of course if it is already
% loaded the |\RequirePackage| command performs the
% necessary tests and possibly does not load anything. 
%    \begin{macrocode}
\providecommand*\ensuremath[1]{\ifmmode#1\else$#1$\fi}%
\providecommand*\textormath{}
\renewcommand*\textormath{\ifmmode\expandafter\@secondoftwo\else
    \expandafter\@firstoftwo\fi}
\providecommand*\textsubscript{\raisebox{-0.5ex}}

\ifPDFTeX
\@ifpackageloaded{textcomp}{}{\RequirePackage{textcomp}}
\fi
%    \end{macrocode}
% The following commands may be already defined; should
% they be missing they are supplied here. Most of them
% are already defined in the Italian option to the
% \texttt{babel} language if the thesis is typeset with
% \textsf{pdflatex} that loads that package; these commands
% are not predefined if the thesis is typeset with \XeLaTeX\ 
% or \LuaLaTeX\ that do not load the \texttt{babel} package;
% but remember; this package may be used as a stand alone
% one, without the initial call by the \texttt{toptesi}
% document class, so that the language Italian might be
% undefined. These commands are also defined by the various
% \sigla{ISO} math compliant packages, in particular by |pm-isomath|;
% no problem: if they already defined they don't get redefined.
%    \begin{macrocode}
\providecommand{\ohm}{\textormath{\textohm}{\mathrm{\Omega}}}
\@ifpackageloaded{toptesi}{%
\providecommand\ped{}\providecommand\ap{}%
\renewcommand*{\ped}[1]{\textormath{\textsubscript{#1}}{_{\mathrm{#1}}}}%
\renewcommand*{\ap}[1]{\textormath{\textsuperscript{#1}}{^{\mathrm{#1}}}}}%
{\providecommand*{\ped}[1]{\textormath{\textsubscript{#1}}%
  {_{\mathrm{#1}}}}%
\providecommand*{\ap}[1]{\textormath{\textsuperscript{#1}}%
  {^{\mathrm{#1}}}}}
%
\@ifpackageloaded{siunitx}{\def\unit#1{\si{\,#1}}}%
  {\providecommand\unit{}%
   \renewcommand\unit[1]{\ensuremath{{\mathrm{\,#1}}}}%
  }
\providecommand{\gei}{\ensuremath{{\mathop{\mathrm{j}}\nolimits}}}
\providecommand{\eu}{\ensuremath{{\mathop{\mathrm{e}}\nolimits}}}
\providecommand{\micro}{\textormath{\textmu}{%
  \ifPDFTeX
    \ifdefined\muup\muup\else\mbox{\textmu}\fi
  \else
    \mathup{\mu}%
  \fi
}}
\providecommand{\gradi}{\textormath{\textdegree}{^\circ}}
%    \end{macrocode}
%
% Before this version 6.xx.yy this package used to define
% the command |\listing| for listing program sources; those
% definitions got very obsolete in front of several packages
% already available for this task. For example the package
% |listings|, very elegant also for the various configurations
% it can use; un fortunately it works fine only for verbatim
% sources that contain only \textsc{ascii} characters; yes,
% it is possible the definition of special commands to typeset
% isolated characters not belonging to the \textsc{ascii}
% table, but it is an error prone process. Giving up the
% niceties of |listings|, the |fancyvrb| works very fine
% with \sigla{UNICODE} and UTF-8 encoded characters.
%
% For backwards compatibility we maintain the command
% |\listing| as a user interface to the |VerbatimInput|
% of package |fancyvrb| with an initial setting of a 
%|\small| font size.
%    \begin{macrocode}
\RequirePackage{fancyvrb}
\fvset{fontsize=\small}
\let\listing\VerbatimInput
%    \end{macrocode}
% Of course before using |\listing| the user can set any other
% special configuration s/he desires among those usable with
% package |fancyvrb|; the default set up shown above is good
% for \LaTeX\ code input, as well as for any programming language, whose
% source lines are shorter than 75--80 characters, depending
% on the normal font size and the document text width; the user
% can edit the source file as well as setting a smaller font
% size than |\small|. In certain circumstances the user
% should accept protruding lines as well as a compromise
% between editing the source file and selecting a smaller
% font size. This is not a bug of the package, nor a fault
% of the algorithm; verbatim typesetting is always problematic.
%
% Let us come to another specific typesetting problem: the
% double role the comma character plays in math mode: a
% decimal separator and a punctuation mark.
%
% Remember that the comma as a decimal separator is
% required for all languages except English. If you
% use this module outside TOPtesi, but as an extension
% of other classes or modules, it's up to you to define
% an “intelligent comma” macro or to load either the
% |icomma.sty| or the |ncccomma.sty| modules that define
% such a macro: the |icomma| package defines the comma
% as a mathematical active character that recognises if the
% subsequent token is a space token so as to insert a
% punctuation comma; |ncccomma| behaves more or less as
% the macro defined in TOPtesi and recognises if the
% following token is a digit so as to use a decimal comma.
%
% This particular package |topcoman| does not define any
% intelligent comma command; therefore it does not do
% anything for other packages; the main |toptesi.sty|
% packages already define a form of intelligent comma,
% therefore |topcomand| does not have to add anything to
% |toptesi|. But if this package is used independently
% from |toptesi|, the user has two choices: either loads
% one of the two packages mentioned above, or, if s/he
% is typesetting in Italian, the |italian| module for
% |babel| already defines the intelligent comma, but its
% definition is disabled by default; the user can turn it
% on and off by using the commands |\IntelligentComma|
% and |\NoIntelligentComma|.
%
% The solution of the solutions would be using the |siunitx|
% package, whose command |\num| handles any fractional
% decimal number in the proper way adding also the digit
% triplets separation of digits when they exceed the number
% of four before and/or after the decimal separator. In
% many cases this might be a heavy burden to load a whole
% complex package just for this task, but  |siunitx|
% offers many other functionalities, so that it would be
% a good idea if the user loads that excellent package.
%
% The following commands are used to write the
% “lower case” roman numerals with the small-caps font;
% in order to avoid complications with missing fonts
% or with math environments, we make sure to typeset these
% numerals with script size capitals; this solution is
% not probably the best one but it works; it typesets
% these roman numerals with the current font; in TOPtesi
% roman numerals are used only for folios, but in order
% to comply with the |hyperref| module, I avoided using
% this new macro for folios; in other situations there
% are no problems with the choice of font shapes and
% series. We need a robust command in order to set the
% script math size and some attention to turn the operand
% into uppercase letters to be typeset in script size.
%    \begin{macrocode}
\DeclareRobustCommand*{\fakeSC}[1]{%
{\dimen@=\f@size\p@\dimen@=0.75\dimen@
\fontsize{\dimen@}{\f@baselineskip}\selectfont
\expandafter{\uppercase{#1}}}}%
\ifPDFTeX\let\simulatedSC\fakeSC\else\let\simulatedSC\textsc\fi
%    \end{macrocode}
% For example, the \textsc{Bib\TeX} contains the string ‘ib’
% in lowercase serifed small caps; if one wants to typeset it
% with sans serif fonts, that lack the small caps shape,
% the user could use the code
%\begin{verbatim}
%\textsf{B\simulatedSC{ib}\TeX}
%\end{verbatim}
% in order to get a decent approximation of small caps; this
% poor man solution should not be necessary when using OpenType
% fonts that have their facilities to use fake small caps in case
% this shape was missing from the collection. This is why the
% \cs{simulatedSC} macro is defined only if |pdfLaTeX| is being
% used for typesetting.
%
% A user, Antonio Mele, suggested and requested the
% possibility of having the figure and table names
% inserted automatically when the |\ref| command is
% issued. Actually this functionality is provided by
% package |hyperref|, but, in my opinion, it works fine
% in English, not in other languages. I do not think
% the solution reported here solves the problems that
% arise when a document is typeset in Italian. In any 
% case the definitions are here; they can be enabled and
% disabled; by default they are disabled.
%
% For single citations the solution works fine,
% but for range references it does not work. In Italian
% the name must be lower case while in other languages,
% specifically in English, the name has a capital initial.
% Since this feature might be handy in certain
% circumstances and annoying in other ones, this feature
% can be turned on and off at will with the enabling
% and disabling commands. As already said, by default the
% feature is disabled.
%    \begin{macrocode}
\def\ft@figure{\iflanguage{italian}{\MakeLowercase{\figurename}}%
            {\figurename}~}
\def\ft@table{\iflanguage{italian}{\MakeLowercase{\tablename}}%
            {\tablename}~}
%
\newcommand*\EnableFigTabNames{%
            \let\p@figure\ft@figure\let\p@table\ft@table}
\newcommand*\DisableFigTabNames{%
            \let\p@figure\empty\let\p@table\empty}
%
\DisableFigTabNames
%    \end{macrocode}
% \iffalse
%</topcmn>
% \fi
%
%\iffalse
%<*topmon>^^A               MONOGRAFIA -- TRIENNALE
%\fi
%\subsection{The \texttt{monografia} module code}
% We start by checking if certain files have ben loaded and in
% case we load then. We check if certain switches are defined,
% and in case we define  such switches.
%    \begin{macrocode}
\monografiatrue
\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
\@ifpackageloaded{xparse}{}{\RequirePackage{xparse}}
\@ifpackageloaded{xspace}{}{\RequirePackage{xspace}}

\ifcsundef{ifclassica}{\newif\ifclassica \classicafalse}{}
\ifcsundef{if@autoretitolo}{\newif\if@utoretitolo \@utoretitolofalse}{}
\ifcsundef{if@ldstyle}{\newif\if@ldstyle \@ldstylefalse}{}
\ifcsundef{if@xivpt}{\newif\if@xivpt \@xivptfalse}{}
\ifcsundef{if@binding}{\newif\if@binding \@bindingfalse}{}

\ifcsundef{ifTOPfront}{\newif\ifTOPfront \TOPfronttrue}{}
\ifcsundef{ifevenboxes}{\newif\ifevenboxes \evenboxesfalse}{}
%    \end{macrocode}
% We define the applicable options.
%    \begin{macrocode}
\DeclareOption{evenboxes}{\evenboxestrue}
\DeclareOption{cucitura}{\@bindingtrue}
\DeclareOption{classica}{\classicatrue}
\DeclareOption{autoretitolo}{\ifclassica\@utoretitolotrue\fi}
\DeclareOption{oldstyle}{\ifclassica\@ldstyletrue\fi}
\ProcessOptions\relax

%    \end{macrocode}
% We define the titling commands\dots
%    \begin{macrocode}
\def\monografia#1{\gdef\@titolo{#1}}
\let\titolo\monografia
\let\@stitle\empty 
\let\@subtitle\empty
\def\sottotitolo#1{\gdef\@subtitle{#1}}
%    \end{macrocode}
% \dots and the other setting or resetting commands to be used
% within the |ThesisTitlePage| environment. Remember that all
% these commands may be used within the configuration file,
% if the user wants to use such file.
%    \begin{macrocode} 
\providecommand\@materia{}
\def\Materia#1{\gdef\@materia{#1}}
\let\materia\Materia
\providecommand\@nomerelatoresingolare{}
\providecommand\@nomerelatoreplurale{}
\newcommand\NomeRelatore[2]{%
   \gdef\@nomerelatoresingolare{#1}\gdef\@nomerelatoreplurale{#2}}
\NomeRelatore{Relatore}{Relatori}
\providecommand\@principaladviser{}
\def\relatore#1{\gdef\@principaladviser{#1}}
\providecommand\@secondadviser{}
\def\secondorelatore#1{\gdef\@secondadviser{#1}}
\providecommand\@thirdadviser{}
\def\terzorelatore#1{\gdef\@thirdadviser{#1}}

\unless\ifcsname iffemminile\endcsname
   \newif\iffemminile\femminilefalse
\fi
\unless\ifcsname ifplurale\endcsname
   \newif\ifplurale\pluralefalse
\fi
\providecommand\@author{}\providecommand\@@author{}
\NewDocumentCommand\candidato{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}
\femminilefalse\pluralefalse}
\NewDocumentCommand\candidata{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}
\femminiletrue\pluralefalse}
\providecommand\@secondauthor{}
\NewDocumentCommand\secondocandidato{m o}{%
\IfNoValueTF{#2}{\gdef\@secondauthor{#1}}%
                {\gdef\@secondauthor{#1\IDlabel#2}}%
\femminilefalse\pluraletrue}
\NewDocumentCommand\secondacandidata{m o}{%
\IfNoValueTF{#2}{\gdef\@secondauthor{#1}}%
                {\gdef\@secondauthor{#1\IDlabel#2}}%
\pluraletrue}
\providecommand\@thirdauthor{}
\NewDocumentCommand\terzocandidato{m o}{%
\IfNoValueTF{#2}{\gdef\@thirdauthor{#1}}%
                {\gdef\@thirdauthor{#1\IDlabel#2}}%
\femminilefalse\pluraletrue}
\NewDocumentCommand\terzacandidata{m o}{%
\IfNoValueTF{#2}{\gdef\@thirdauthor{#1}}%
                {\gdef\@thirdauthor{#1\IDlabel#2}}%
\pluraletrue}

\providecommand\IDlabel{\\\quad matricola\ }

\edef\@submitdate{{\let\today\relax\unskip\today}}


\def\sedutadilaurea#1{\getseduta#1 !}
\def\getseduta#1 #2!{%
  \def\@tempA{#2}%
  \ifx\@tempA\empty
    \def\@submitdate{#1}%
  \else
    \unless\ifclassica
      \def\@submitdate{#1 #2}%
    \else
      \s@dutaclassica#1 #2!%
    \fi
  \fi
}%
\def\s@dutaclassica#1 #2!{%
  \if@ldstyle
    \s@paranumeri#2-!%
    \ifx\2\empty
      \edef\@submitdate{\noexpand#1 \noexpand\oldstylenums{#2}}%
    \else
      \s@paranumeri#2!%
      \edef\@submitdate{\noexpand#1
      \noexpand\oldstylenums{\1} -- \noexpand\oldstylenums{\2}}%
    \fi
    \let\1\undefined
    \let\2\undefined
  \else
    \def\@submitdate{#1 #2}%
  \fi
}
\def\s@paranumeri#1-#2!{\def\1{#1}\def\2{#2}}%

\newcommand*\NomeAnnoAccademico[1]{\gdef\AnnoAccademico{#1}}
\@ifundefined{AnnoAccademico}{\gdef\AnnoAccademico{Anno accademico}}{}

\newcommand\NomeCorsoDiStudi{Corso di laurea in\xspace}
\providecommand\@ateneo{}
\newcommand\ateneo[1]{\gdef\@ateneo{#1}}
\providecommand\@NomeAteneo{}
\newcommand\NomeAteneo[1]{\gdef\@NomeAteneo{#1}}
\let\nomeateneo\NomeAteneo
%    \end{macrocode}
% The following command accepts a first optional argument that
% should contain an ordinal number, in general an uppercase
% roman numeral, that optionally qualifies the “academic
% structure” in charge of the degree course. The user might,
% for example specify something as
% |\struttura[III]{Faculty of Engineering}|, if such kind of
% information is required.
%    \begin{macrocode}
\providecommand\@strutturadi{}
\newcommand\StrutturaDi[1]{\gdef\@strutturadi{#1\unskip\xspace}}
\newcommand\struttura[2][]{\gdef\@struttura{\ifempty{#1}{}{#1 }%
   \@strutturadi #2}}
%    \end{macrocode}
% Generally bachelor degree courses are not developed within 
% international agreements such as Erasmus, but it may not be
% excluded; therefore several University names and several
% university logos might be necessary. The following is the
% general machinery for lining several logos within a horizontal
% box to be output at the proper moment. Remember, though, that
% if the logos are output in the lower half of the page, the
% top of the title page should contain the university name
% list (if this list does not fit in one line, it is necessary
% to use some tricks described in the Italian documentation
% |toptesi-it.pdf|); but if the logos contain also the name
% of the university, and are printed at the top of the page,
% the university name list becomes unnecessary.
%    \begin{macrocode}
\ifcsundef{TPT@logospace}{\newlength{\TPT@logospace}\TPT@logospace=3em}{}
\ifcsundef{TPT@logobox}{\newsavebox{\TPT@logobox}}{}
\ifcsundef{TPT@logoheight}{\newdimen\TPT@logoheight}{}
\providecommand*\setlogodistance[1]{\TPT@logospace=#1}
\providecommand*{\@logosede}{}

\ifcsundef{T@Tlogoheight}{%\
    \newlength\T@Tlogoheight
    \setlength\T@Tlogoheight{0.8\dimexpr(\paperwidth-\textwidth)/2}}{}
    
\newcommand\logosede[2][\T@Tlogoheight]%
{\def\@logosede{#2}\TPT@logoheight=#1\relax
\ifcsvoid{@logosede}{\sbox{\TPT@logobox}{}}{\begin{lrbox}{\TPT@logobox}%
\expandafter\fillup@TCP@logobox\@logosede,!}}

\def\fillup@TCP@logobox#1,#2!{%
	\ifblank{#1}{\end{lrbox}\ifdim\wd\TPT@logobox>\textwidth
	\sbox\TPT@logobox{\resizebox{\textwidth}{!}{\box\TPT@logobox}}\fi}%
	{\def\@logosede{#2}%
	\includegraphics[height=\TPT@logoheight]{#1}\hskip\TPT@logospace
   \expandafter\fillup@TCP@logobox\@logosede,!}}

\providecommand\printloghi{}
\renewcommand\printloghi{%
\unless\ifvoid\TPT@logobox\usebox{\TPT@logobox}\fi}
%    \end{macrocode}
% The name of a company tutor may be required if the bachelor
% degree final work is developed within an institution or
% a company external to the university.
%    \begin{macrocode}
\providecommand\@tutoreaziendale{}
\def\tutoreaziendale#1{\gdef\@tutoreaziendale{#1}}
\providecommand\@tutoreaziendalename{Supervisore Aziendale}
\def\NomeTutoreAziendale#1{\gdef\@tutoreaziendalename{#1}}
%    \end{macrocode}
% The following command sets up the information for a legal or
% copyright page; this information might contain just a simple
% statement that indicates a copyright notice or a licence that
% specifies the clauses for the intellectual property of the
% work. But it might also contain  a disclaimer where the only
% author takes his/her responsibility and liability for not
% infringing any applicable law on intellectual property;
% such disclaimer should be dated and undersigned by the (single)
% author. Therefore within this |\retrofrontespizio| command
% two more commands are optionally used: |\luogo| to establish
% the location of the signature, and |\giorno| to establish a
% signature date different from the current date. If the |\giorno|
% is not specified, its value maintains a meaningless default
% string, and upon testing for such a string, no location,
% date and signature is typeset in the legal page; if the
% current date should be used, the user should specify
% |\giorno{}|, with a really empty argument.
%    \begin{macrocode}
\let\@luogo\empty\def\@giorno{*}
\def\luogo#1{\def\@luogo{#1}}%
\def\giorno#1{\def\@giorno{#1}}
\let\@retrofrontespizio\empty
\newcommand\retrofrontespizio[1]{%
\long\gdef\@retrofrontespizio{#1}}
%    \end{macrocode}
% We restart with the definition of other data setting commands.
%    \begin{macrocode} 
\providecommand\@corsodistudi{}
\newcommand\corsodistudi[1]{\gdef\@corsodistudi{#1}}
\let\corsodilaurea\corsodistudi
\providecommand\@monografia{Monografia}
\newcommand\NomeElaborato[1]{\gdef\@monografia{#1}}
\let\NomeMonografia\NomeElaborato
\def\@nomecandidato{\ifclassica Laureando\else Candidato\fi}
\def\@nomecandidata{\ifclassica Laureanda\else Candidata\fi}
\def\@nomecandidati{\ifclassica Laureandi\else Candidati\fi}
\def\@nomecandidate{\ifclassica Laureande\else Candidate\fi}
%    \end{macrocode}
% The label for the candidate list requires a list of comma
% separated names, to a maximum of four names; in order they
% should be the singular masculine, the plural masculine, the 
% singular feminine, and  the plural feminine names. No one is 
% mandatory, and the list may be completely empty if the label 
% should remain blank. The list is scanned and the names are
% assigned to some internal variables that will be used according
% the the gender and the number of candidates. If the list is void,
% no name is going to be used at all, and the candidates list is
% typeset as a centred one without any label.
%
% In this way, these settings are all valid:
%\begin{ttsintassi}
%\cs{TitoloListaCandidati}\Marg{}
%\cs{TitoloListaCandidati}\Marg{Estudiante,Estudiantes}
%\cs{TitoloListaCandidati}\Marg{ExamenKandidat,ExamenKandidaten,\%
%\qquad ExamenKandidatin,ExamenKandidatinen}
%\end{ttsintassi}
% This command, as it may be seen, may be used also to set the
% name list in languages different from Italian.
% It goes by itself that if the user typesets the thesis in a
% language where names are gender indifferent (as English,
% Spanish, and other ones) s/he has two choices: ether s/he
% uses the command with just two arguments, as shown above,
% and uses only the masculine commands |\candidato|,
% |\secondocandidato|, and |\terzocoandidato| even with names
% of female students, or s/he specifies the same names in the
% arguments~3 and~4, as in arguments ~1 and~2. Lacking this
% action, the corresponding titling names are blank.
%    \begin{macrocode}
\newcommand\TitoloListaCandidati[1]{\CandidateNames#1,,,,!}
\def\CandidateNames#1,#2,#3,#4,!{%
    \gdef\@nomecandidato{#1}% Masc/neutr-sing
    \gdef\@nomecandidati{#2}% Masc/neutr-plur
    \gdef\@nomecandidata{#3}% Fem-sing
    \gdef\@nomecandidate{#4}% Fem-plur
}
\providecommand\Relatore{Relatore}
\newcommand\AdvisorName[1]{\gdef\Relatore{#1}}
\providecommand\Correlatore{Correlatore}
\providecommand\Correlatori{Correlatori}
\newcommand\CoAdvisorName[2]{\gdef\Correlatore{#1}%
                             \gdef\Correlatori{#2}}
%    \end{macrocode}
% A new boolean is defined in order to have a suitable switch to set
% the logo(s) “string” at the top or in the second half of the page.
%    \begin{macrocode}
\ifcsundef{iftopTPTlogos}{\newbool{topTPTlogos}% 
  \booltrue{topTPTlogos}}{}
%    \end{macrodoe}
% We eventually define the whole construction of the title
% page with this new command defined by means of the |xparse|
% package facilities. This environment accepts an optional
% asterisk; its presence means that the logo(s) string should
% be typeset in the lower half of the title page; differently
% from the \LaTeX\ kernel environments that accepts an optional
% asterisk that becomes part of the environment name, and must
% be repeated in the closing environment statement, with the
% |xparse| facilities the asterisk is just an argument to the
% argument list of the opening command: therefore the source
% file contains an opening statement of the form
% |\begin{environment}*|, not |\begin{environment*}|. The user
% should remember this peculiar way of specifying certain optional
% arguments, in particular the optional “star” one.
% 
% Another important difference is that environments defined
% with the |xparse| facilities  may receive  optional and
% mandatory arguments of many kinds in the opening command,
% but differently form the standard \LaTeX\ kernel environments
% such arguments are available not only in the opening commands,
% but also in the closing ones. We actually don't use this
% property during the definition of the |ThesisTitlePage|
% environment, but we preferred to use the previously defined
% switch.
%    \begin{macrocode}
\NewDocumentEnvironment{ThesisTitlePage}{s}
{% OPENING
\IfBooleanTF{#1}{\boolfalse{topTPTlogos}}{\booltrue{topTPTlogos}}%
   \begin{titlepage}
   \oddsidemargin=\dimexpr(\oddsidemargin+\evensidemargin)/2\relax
   \evensidemargin \oddsidemargin
         \IfFileExists{\jobname.cfg}{\input{\jobname.cfg}%
        }{%C
          \PackageWarning{monografia}{No configuration file found}%
         }%C
}{% CLOSING
   \ifbool{topTPTlogos}{\noindent\raisebox{-0.5em}[\z@][\z@]%
     {\makebox[\textwidth]{\printloghi}}\par\bigskip}{}
   \ifdefempty{\ateneo}{}{{\centering\huge \@ateneo\par}}
    \ifdefempty{\@NomeAteneo}{}{\medskip{\centering\large
       \expandafter\MakeUppercase\expandafter{\@NomeAteneo}\par}}
    \ifdefempty{\@strutturadi}{}{\vspace{\stretch{0.1}}\par{\centering
       \Large\@struttura\par}}
   \ifdefempty{\@corsodistudi}{}{\bigskip{\centering\large
       \NomeCorsoDiStudi\ \@corsodistudi\par}}
   \ifdefempty{\@materia}{}{\medskip{\centering\large\@materia\par}}
   \vspace{\stretch{0.25}}
   {\centering\large \@monografia\par}
   \vspace{\stretch{0.1}}
   {\centering\LARGE\bfseries \@titolo\par}
   \ifdefempty{\@subtitle}{\vspace{\stretch{0.3}}}{\bigskip
   {\centering\large\@subtitle\par}}
   \ifbool{topTPTlogos}{}{\vspace{3em}\par\centering\printloghi\par}
   \vspace{\stretch{0.25}}
   
\ifdefempty{\@principaladviser}{\def\BoxRelatori{}}{%
     \def\BoxRelatori{%
            \begin{tabular}[t]{l}%
            \hbox{\unless\ifclassica\large\fi
            \ifdefempty{\@secondadviser}%
            {\let\@nomerelatore\@nomerelatoresingolare}%
            {\let\@nomerelatore\@nomerelatoreplurale}%
                  \textbf{\@nomerelatore}}\\[.6ex]
            \hbox{\large\textrm{\protect\@principaladviser}}%
            \ifdefempty{\@secondadviser}{}{%
               \ifclassica
                  \ifdefempty{\@thirdadviser}{%
                     \ifdefempty{\@secondadviser}{}{%
                           \\[1.5ex]\textbf{\Correlatore:}%
                      }
                  }{%
                     \\[1.5ex]\textbf{\Correlatori:}%
                  }
               \fi
               \\[.6ex]
               \hbox{{\large\textrm{\protect\@secondadviser}}}%
            }
            \ifdefempty{\@thirdadviser}{}{%
               \\[.6ex] 
               \hbox{{\large\textrm{\protect\@thirdadviser}}}%
            }
            \end{tabular}%
    }%
}
%
\def\print@secondocandidato{\\\relax
            \hbox{\large\tabular{@{}l@{}}\@secondauthor\endtabular}}%
\def\print@terzocandidato{\\\relax
            \hbox{\large\tabular{@{}l@{}}\@thirdauthor\endtabular}}%
            
\def\BoxCandidati{%
     \begin{tabular}[t]{l}
        \hbox{\unless\ifclassica\large\fi
           \textbf{\ifplurale
              \iffemminile\@nomecandidate\else\@nomecandidati\fi
           \else
              \iffemminile\@nomecandidata\else\@nomecandidato\fi
           \fi}}\\[.6ex]
           \hbox{\large\tabular{@{}l@{}}\@author\endtabular}%
           \ifcsvoid{@secondauthor}{}{\print@secondocandidato}%
           \ifcsvoid{@thirdauthor}{}{\print@terzocandidato}%
     \end{tabular}%
}%
\unless\ifclassica
  \ifdefempty{\BoxRelatori}{%Bachelor degree without supervisors
    \noindent\makebox[\textwidth]{\tabular[t]{@{}c@{}}
    \unless\ifclassica\large\fi
       \textbf{\ifplurale
          \iffemminile\@nomecandidate\else\@nomecandidati\fi
       \else
          \iffemminile\@nomecandidata\else\@nomecandidato\fi
       \fi}\\[.6ex]
       \@author
       \ifcsvoid{@secondauthor}{}{\\ \@secondauthor}
       \ifcsvoid{@thirdauthor}{}{\\ \@thirdauthor}
    \endtabular}%
  }{%
    \unless\ifevenboxes
         \begin{flushleft}%
            \BoxRelatori
         \end{flushleft}\par
            \vspace*{-1.5\baselineskip}
         \begin{flushright}%
            \BoxCandidati
         \end{flushright}%
    \else 
         \noindent
         \makebox[\textwidth]{\BoxRelatori\hfill\BoxCandidati}%
    \fi}
\else
     \noindent
     \makebox[\textwidth]{\BoxRelatori\hfill\BoxCandidati}%
\fi
\par\vspace*{\stretch{0.5}}
\ifdefempty{\@tutoreaziendale}{\relax}{\begin{center}
\textbf{\@tutoreaziendalename}\\[0.6ex]
\@tutoreaziendale
\end{center}}
\noindent\raisebox{-\baselineskip}[0pt][0pt]{%
   \makebox[\textwidth]{\@submitdate}}%
\end{titlepage}\newpage
% Legal/Copyright page
   \ifdefempty{\@retrofrontespizio}{}{\thispagestyle{empty}%
   \vspace*{\stretch{1}}\par
   \@retrofrontespizio\par
   \ifdefstring{\@giorno}{*}{}{\medskip
   \noindent
   \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lc@{}}
   \ifdefempty{\@luogo}{}{\@luogo, }%
   \ifdefempty{\@giorno}{\today}{\@giorno}  
            & \@@author\\[3ex]
            & \makebox[0.5\textwidth]{\dotfill}
   \end{tabular*}\par}
   \newpage}
}
%    \end{macrocode}
% This is the end of this module code.
%\iffalse
%</topmon>
%\fi
%
%\iffalse
%<*topmag>^^A               MAGISTRALE
%\fi
% \subsection{Code for \texttt{master} thesis}
% Here we document the code for the \opz{magistrale} option.
% It is a little more complicated than the code for other
% thesis types, because the title page may be typeset in different
% modes, especially for theses in the humanities domain where
% they might be typeset in more than one volume (tome).
%
% We start by providing the necessary commands, without
% duplicating those provided by the calling package |toptesi|.
% Nevertheless this module may be used as a standalone one,
% i.e.\ a package loaded by a different class; may be not
% always and not with any class, but the idea is this one.
% In facts if this module does not receive the suitable
% settings from package |toptesi|,it is possible to call it
% with the suitable options as explained below.
%    \begin{macrocode}
\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
\@ifpackageloaded{xspace}{}{\RequirePackage{xspace}}
\@ifpackageloaded{xparse}{}{\RequirePackage{xparse}}
\ifcsundef{ifclassica}{\newif\ifclassica \classicafalse}{}
\ifcsundef{if@utoretitolo}{\newif\if@utoretitolo\@utoretitolofalse}{}
\ifcsundef{if@ldstyle}{\newif\if@ldstyle\@ldstylefalse}{}
\ifcsundef{if@xivpt}{\newif\if@xivpt \@xivptfalse}{}
\ifcsundef{if@binding}{\newif\if@binding\@bindingfalse}{}
\ifcsundef{ifScuDo}{\newif\ifScuDo \ScuDofalse}{}
\ifcsundef{ifmonografia}{\newif\ifmonografia\monografiafalse}{}
\ifcsundef{iftriennale}{\newif\iftriennale\triennalefalse}{}
\ifcsundef{ifmagistrale}{\newif\ifmagistrale\magistralefalse}{}
\ifcsundef{ifdottorale}{\newif\ifdottorale\dottoralefalse}{}
\ifcsundef{ifsecondaria}{\newif\ifsecondaria\secondariafalse}{}
\ifcsundef{ifplurale}{\newif\ifplurale\pluralefalse}{}
\ifcsundef{iffemminile}{\newif\iffemminile\femminilefalse}{}

\magistraletrue

\ifcsundef{ifTOPfront}{\newif\ifTOPfront \TOPfrontfalse
\newif\ifevenboxes \evenboxesfalse}{}

%    \end{macrocode}
% We provide for the counter |tomo| and for a new definition of 
% the command |\tomo|; this new definition does not trigger
% the production of a title page as it does with the definition
% of package |topfront.sty|; it accepts an optional argument,
% the tome (arabic) number (that shall be transformed into a
% capital roman one while typesetting the title page); if this
% number is not specified the counter value is stepped up
% with the |\refstepconter| macro that renders it accessible
% to the |\label| command; otherwise a value equal to the
% given number minus one is loaded and afterwards “refstepped”
% up in the same way.
%
% Since \LaTeX\ counter settings are global, the value kept
% in the counter remains available anyhow; therefore it is
% not excluded that multiple tomes might be typeset in one 
% output \sigla{PDF} file to be split in separate files as described
% in section~\ref{sec:topmagistrale}; I did not test this
% functionality but I do not exclude it.^^A CONTROLLARE
%    \begin{macrocode}
\ifcsundef{c@tomo}{\newcounter{tomo}{\setcounter{tomo}{0}}}{}
\providecommand\tomo{}
\ifcsundef{tomo}{\renewcommand\tomo[1][]{%
  \ifstrequal{#1}{}{}{\setcounter{tomo}{\numexpr#1-1}}%
  \refstepcounter{tomo}}}{}
%    \end{macrocode}
%
% We define the options that set the same switches as those set
% by the class. If another class different from |toptesi| is used,
% it is possible that \opz{14pt} produces errors or does not
% produce the desired setting of the normal size to 14pt.
%    \begin{macrocode}
\DeclareOption{evenboxes}{\evenboxestrue}
\DeclareOption{cucitura}{\@bindingtrue}
\DeclareOption{14pt}{\@xivpttrue}
\DeclareOption{classica}{\classicatrue}
\DeclareOption{autoretitolo}{\ifclassica\@utoretitolotrue\fi}
\DeclareOption{oldstyle}{\ifclassica\@ldstyletrue\fi}
\ProcessOptions*\relax
%    \end{macrocode}
%
% We define two different page styles to be used normally
% or when the |classica| option is in force. Both redefine
% the text grid to be more or less centred on the physical
% page; since it is the first page, no binding correction
% is taken care of, because the first page does
% not suffer from the curvature and thickness of the bound
% thesis. The headings and footers in both cases are already
% filled up with suitable title page data, therefore their
% space is used instead of being “wasted”.
%    \begin{macrocode}
\def\headstrut{\vrule \@depth4\p@ \@height\z@ \@width\z@}
\def\ps@titlepage{\let\@mkboth\@gobbletwo
   \def\@oddfoot{\vbox to 0.05\paperheight{\vss
      \hbox to\hsize{\hfil{\Large{\@submitdate}}\hfil}}}%
   \let\@evenfoot\@oddfoot
   \def\@oddhead{%
      \vbox to\headheight{\vss\iftopTPTlogos
         \hbox to\textwidth{%
           \headstrut\hfil
           \raisebox{3\baselineskip}{\usebox\TPT@logobox}\hfil\null%
         }\fi
         \ifcsvoid{@ateneo}{}{\vskip\smallskipamount
         \hbox to\textwidth{\hss\LARGE\MakeUppercase{\@ateneo}\hss}}
         \vss
      }%
   }%
   \let\@evenhead\@oddhead
   \def\chaptermark##1{}\def\sectionmark##1{}%
}

\def\ps@classica{\let\@mkboth\markboth
  \def\@oddhead{\vbox{%
  \setbox256=\hbox{\LARGE\MakeUppercase{\@ateneo}}
  \unless\ifdim\wd256<\textwidth
     \setbox256=\hbox{\resizebox{\textwidth}{!}{\box256}}%
   \fi
  \hbox to \hsize{\hss\box256\hss}%
  \ifclassica
        \hbox to \hsize{\hfil\vrule\@width\z@
    \@height2ex\vrule\@height1.4\p@\@depth-\p@\@width50mm\hfil}%
  \fi
  }}%
  \def\@oddfoot{\vbox to \dimexpr\paperheight/20\relax{\vss
 \ifclassica
    \hbox to \hsize{\hfil\raisebox{-.3ex}[\z@][\z@]{%
    \vrule\@height-2.6\p@\@depth3\p@\@width
        \dimexpr\textwidth/3}\hfil}%
  \fi
  \hbox to\hsize{\hfill{\Large{\@submitdate}}\hfill}}%
  }%
  \let\@evenhead\@oddhead
  \let\@evenfoot\@oddfoot
}%
%    \end{macrocode}
%
% Some redefinitions to handle both the heading label of
% the authors block and the proper gender of such names.
%    \begin{macrocode}
\newif\iffemminile

\def\Candidato{\ifclassica Laureando\else Candidato\fi}
\def\Candidata{\ifclassica Laureanda\else Candidata\fi}
\def\Candidati{\ifclassica Laureandi\else Candidati\fi}
\def\Candidate{\ifclassica Laureande\else Candidate\fi}
\newcommand\TitoloListaCandidati[1]{\CandidateNames#1,,,,!}
\def\CandidateNames#1,#2,#3,#4,!{%
    \gdef\Candidato{#1}% Masc/neutr-sing
    \gdef\Candidati{#2}% Masc/neutr-plur
    \gdef\Candidata{#3}% Fem-sing
    \gdef\Candidate{#4}% Fem-plur
}

%    \end{macrocode}
%
% We prepare the |titolo| command. Such command accepts
% a \emph{short title} string, no more, no less than the \LaTeX\ 
% sectioning commands. It is always advisable to use short
% titles; nevertheless when the |classica| |autoretitolo|
% option is in force, long titles don't fit into the page
% headings, therefore an alternative short title is desirable.
% Long titles may be also shortened by transferring part of
% their information to a subtitle; but this must be an
% author's decision, it cannot be automated. Therefore
% a |\sottotitolo| command is also provided.
%    \begin{macrocode}
\let\@stitle\empty % default short title string

\newcommand*{\titolo}[2][]{%
\ifstrequal{#1}{}%
     {\gdef\@stitle{#2}}{\gdef\@stitle{#1}}%
     \gdef\@titolo{#2}%
}%
\def\sottotitolo#1{\gdef\@subtitle{#1}}

%    \end{macrocode}
%
% The defining commands for both the preset fixed strings
% and the variable data strings are defined; somewhere
% these strings receive also the preset values; some of the
% following strings are used to modify such preset values,
% very useful to localise these strings for a particular language.
%    \begin{macrocode}
\let\@materia\empty
\def\Materia#1{\def\@materia{#1}}\let\materia\Materia
\def\relatore#1{\gdef\@principaladviser{#1}}
\def\secondorelatore#1{\gdef\@secondadviser{#1}}
\def\terzorelatore#1{\gdef\@thirdadviser{#1}}
\def\sedutadilaurea#1{\getseduta#1 !}
\def\getseduta#1 #2!{%
  \ifstrequal{#2}{}%
    {\def\@submitdate{#1}}%
    {\unless\ifclassica
      \def\@submitdate{#1 #2}%
     \else
      \s@dutaclassica#1 #2!%
     \fi}
}%
\def\s@dutaclassica#1 #2!{%
  \if@ldstyle
    \s@paranumeri#2-!%
    \ifx\2\empty
       \edef\@submitdate{\noexpand#1 \noexpand\oldstylenums{#2}}%
    \else
       \s@paranumeri#2!%
       \edef\@submitdate{\noexpand#1
       \noexpand\oldstylenums{\1} -- \noexpand\oldstylenums{\2}}%
    \fi
    \let\1\undefined
    \let\2\undefined
  \else
    \def\@submitdate{#1 #2}%
  \fi
}
\def\s@paranumeri#1-#2!{\def\1{#1}\def\2{#2}}%

\newcommand*\NomeAnnoAccademico[1]{\gdef\AnnoAccademico{#1}}
\@ifundefined{AnnoAccademico}{\gdef\AnnoAccademico{Anno accademico}}{}
\def\annoaccademico#1{%
\ifclassica
  \def\@submitdate{{\large\textsc{\AnnoAccademico}}%
    {\Large\s@tanno#1!}}
\else
  \PackageWarning{toptesi}{\string\annoaccademico\space
    is usable only when the\MessageBreak
   `classica' option is in force}%
  \def\@submitdate{\AnnoAccademico\ #1 --- 
      Needs the `classica' option}
\fi}
\def\s@tanno#1-#2!{\oldstylenums{#1}\EnDash\oldstylenums{#2}}

\def\EnDash{{\settowidth{\dimen@}{\large\scshape I}%
\setbox\tw@\hbox{2}\dimen\tw@.5\ht\tw@\advance\dimen\tw@-.5\dp\tw@
\dimen4\dimen\tw@\advance\dimen4by.0385ex\relax
\advance\dimen\tw@-.0385ex\relax
\makebox[1.5\dimen@]{%
    \vrule\@width\dimen@\@height\dimen4\@depth-\dimen\tw@}}}
\def\corsodilaurea#1{\gdef\@corso{#1}}
\def\ateneo#1{\gdef\@ateneo{#1}}
\def\nomeateneo#1{\gdef\@nomeat{\expandafter\uppercase{\expandafter #1}}}
\newcommand\facolta[2][]{\gdef\@facname{#2}\gdef\@facnumber{#1}}
\let\struttura\facolta

%    \end{macrocode}
%
% Here we define the necessary commands to fill up a comma
% separated list of logo graphic-file names; we define
% everything up to the |\printlogos| command that provides
% to printing a list of images, duly separated by adequate
% space, all scaled to the same height, and, possibly, even
% the whole logo string duly scaled to fit in the title page
% width. The |\logosede| command, that can be used several
% times with different logo file names, accepts an optional
% argument consisting in a dimension; it is used to scale the
% height of the logo image to the desired value, so that the
% whole string of images does not have unusual different
% logo heights. This dimension is preset to one seventh of
% the |\textwidth| and on the average it is well suited. With
% the standard |toptesi| class printed on A4 paper, such height
% equals 25\,mm; of course on smaller paper it is proportionally
% smaller; on American sized sheets it may be a little larger,
% but in general it is adequate to the page size.
%    \begin{macrocode}
\newlength{\TPT@logospace}\TPT@logospace=3em\relax
\newsavebox{\TPT@logobox}
\newdimen\TPT@logoheight
\newcommand*\setlogodistance[1]{\TPT@logospace=#1}
\providecommand*{\@logosede}{}

\ifcsundef{T@Tlogoheight}{%\
    \newlength\T@Tlogoheight
    \setlength\T@Tlogoheight{0.8\dimexpr(\paperwidth-\textwidth)/2}}{}
    
\newcommand\logosede[2][\T@Tlogoheight]{\def\@logosede{#2}\TPT@logoheight=#1\relax
\ifcsvoid{@logosede}{\sbox{\TPT@logobox}{}}{\begin{lrbox}{\TPT@logobox}%
\expandafter\fillup@TCP@logobox\@logosede,!}}

\def\fillup@TCP@logobox#1,#2!{%
\ifblank{#1}{\end{lrbox}\ifdim\wd\TPT@logobox>\textwidth
\sbox\TPT@logobox{\resizebox{\textwidth}{!}{\box\TPT@logobox}}\fi}%
{\def\@logosede{#2}%
\includegraphics[height=\TPT@logoheight]{#1}\hskip\TPT@logospace
   \expandafter\fillup@TCP@logobox\@logosede,!}}

\newcommand\printloghi{\unless\ifvoid\TPT@logobox\usebox{\TPT@logobox}\fi}
%    \end{macrocode}
%
% Still more commands to define the necessary string data.
% For the ID number label the same remarks made in 
% section~\ref{sec:topfront} hold true.
%    \begin{macrocode}
\def\tutoreaziendale#1{\gdef\@tutoreaziendale{#1}}
\newcommand\retrofrontespizio[1]{\long\gdef\@retrofrontespizio{#1}}
\newcommand\FacoltaDi[1]{\gdef\@faculty{#1}}
\let\StrutturaDidattica\FacoltaDi
\newcommand\CorsoDiLaureaIn[1]{\gdef\@laureaname{#1}}
\newcommand\TesiDiLaurea[1]{\gdef\@TesiDiLaurea{#1}}
\newcommand\InName[1]{\gdef\@InName{#1}}
\newcommand\CandidateName[1]{\gdef\@nomecandidato{#1}}
\newcommand\AdvisorName[1]{\gdef\Relatore{#1}\gdef\Relatori{#1}}
\newcommand\CoAdvisorName[1]{\gdef\Correlatore{#1}\gdef\Correlatori{#1}}
\newcommand\TutorName[1]{\gdef\Tutore{#1}}
\newcommand\NomeTutoreAziendale[1]{\gdef\@tutoreaziendalename{#1}}
\newcommand\NomePrimoTomo[1]{\gdef\PrimoTomo{#1}}
\newcommand\NomeSecondoTomo[1]{\gdef\SecondoTomo{#1}}
\newcommand\NomeTerzoTomo[1]{\gdef\TerzoTomo{#1}}
\newcommand\NomeQuartoTomo[1]{\gdef\QuartoTomo{#1}}
\newcommand\IDlabel{\\\quad matricola:\xspace}
\IfFileExists{\jobname.cfg}{\input{\jobname.cfg}}%
    {\IfFileExists{toptesi.cfg}{\input{toptesi.cfg}}{}}
%    \end{macrocode}
%
% Here we define the preset strings; most of them are empty
% strings, but some are real words; the setting commands
% listed before can easily be used to localise such string
% in different languages.
%    \begin{macrocode}
\@ifundefined{@titolo}{\def\@titolo{}}{}

\providecommand\@author{}\providecommand\@@author{}
\NewDocumentCommand\candidato{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}
\femminilefalse\pluralefalse}
\NewDocumentCommand\candidata{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}
\femminiletrue\pluralefalse}
\providecommand\@secondauthor{}
\NewDocumentCommand\secondocandidato{m o}{%
\IfNoValueTF{#2}{\gdef\@secondauthor{#1}}%
                {\gdef\@secondauthor{#1\IDlabel#2}}%
\femminilefalse\pluraletrue}
\NewDocumentCommand\secondacandidata{m o}{%
\IfNoValueTF{#2}{\gdef\@secondauthor{#1}}%
                {\gdef\@secondauthor{#1\IDlabel#2}}%
\pluraletrue}
\providecommand\@thirdauthor{}
\NewDocumentCommand\terzocandidato{m o}{%
\IfNoValueTF{#2}{\gdef\@thirdauthor{#1}}%
                {\gdef\@thirdauthor{#1\IDlabel#2}}%
\femminilefalse\pluraletrue}
\NewDocumentCommand\terzacandidata{m o}{%
\IfNoValueTF{#2}{\gdef\@thirdauthor{#1}}%
                {\gdef\@thirdauthor{#1\IDlabel#2}}%
\pluraletrue}
\providecommand\IDlabel{\\\quad matricola\ }
\@ifundefined{@principaladviser}{\def\@principaladviser{}}{}
\@ifundefined{@secondadviser}{\def\@secondadviser{}}{}
\@ifundefined{@thirdadviser}{\def\@thirdadviser{}}{}
\@ifundefined{@tutore}{\def\@tutore{}}{}
\@ifundefined{@nomerelatore}{\def\@nomerelatore{}}{}
\@ifundefined{@nomecandidato}{\def\@nomecandidato{}}{}
\@ifundefined{Candidato}{\def\Candidato{Candidato}}{}
\@ifundefined{Candidata}{\def\Candidata{Candidata}}{}
\@ifundefined{Candidati}{\def\Candidati{Candidati}}{}
\@ifundefined{Candidate}{\def\Candidate{Candidate}}{}
\@ifundefined{Relatore}{\def\Relatore{Relatore}}{}
\@ifundefined{Relatori}{\def\Relatori{Relatori}}{}
\@ifundefined{Correlatore}{\def\Correlatore{Correlatore}}{}
\@ifundefined{Correlatori}{\def\Correlatori{Correlatori}}{}
\@ifundefined{Tutore}{\def\Tutore{Tutore}}{}
\@ifundefined{@tutoreaziendale}{\def\@tutoreaziendale{}}{}
\@ifundefined{@tutoreaziendalename}%
        {\def\@tutoreaziendalename{Supervisore Aziendale}}{}
\@ifundefined{@retrofrontespizio}{\def\@retrofrontespizio{}}{}
\@ifundefined{@subtitle}{\def\@subtitle{}}{}
\@ifundefined{@corso}{\def\@corso{}}{}
\@ifundefined{@ateneo}{\def\@ateneo{POLITECNICO DI TORINO}}{}
\@ifundefined{@nomeat}{\def\@nomeat{}}{}% Nome proprio dell'ateneo
\@ifundefined{@facolta}{\def\@facname{}}{}
\@ifundefined{@facnumber}{\def\@facnumber{}}{}
\@ifundefined{@faculty}{\def\@faculty{}}{}
\@ifundefined{PrimoTomo}{\def\PrimoTomo{Tomo primo}}{}
\@ifundefined{SecondoTomo}{\def\SecondoTomo{Tomo secondo}}{}
\@ifundefined{TerzoTomo}{\def\TerzoTomo{Tomo terzo}}{}
\@ifundefined{QuartoTomo}{\def\QuartoTomo{Tomo quarto}}{}
\ifclassica
\def\Candidato{Laureando}
\def\Candidata{Laureanda}
\def\Candidati{Laureandi}
\def\Candidate{Laureande}
\fi
\@ifundefined{@submitdate}{\def\@submitdate{\ifcase\the\month\or%
  Gennaio\or Febbraio\or Marzo\or Aprile\or Maggio\or Giugno\or
  Luglio\or Agosto\or Settembre\or Ottobre\or Novembre\or Dicembre\fi
  \space \the\year}}{}
\@ifundefined{@TesiDiLaurea}{\def\@TesiDiLaurea{Tesi di Laurea}}{}
\@ifundefined{@laureaname}{\def\@laureaname{Corso di Laurea in }}{}
\@ifundefined{@InName}{\def\@InName{in}}{}
\newbool{topTPTlogos} \booltrue{topTPTlogos}
%    \end{macrocode}
%
% Here the real differences take place; the environments
% |frontespizio| and |frontespizio*| are still usable, but
% we discourage them. Even the commands |\frontespizio| and
% |\frontespizio*| are still usable but for even more reasons
% we discourage their usage; they remain available for a sort
% of backwards compatibility.
%
% A new environment |ThesisTitlePage| is defined that actually
% resorts to the core command that stands behind the above
% discouraged environments and commands. This new environment
% uses the |xparse| commands to define it; therefore the
% asterisk that differentiates the four old environments and
% commands is not any more part of the environment name, but,
% if used, must be the first token after the environment
% opening statement, and should not be repeated with the
% closing statement; therefore
%\begin{verbatim}
%% Correct usage
%\begin{ThesisTitlePage}*
%...
%\end{ThesisTitlePage}
%\end{verbatim}
% is correct, while
%\begin{verbatim}
%% Wrong usage
%\begin{ThesisTitlePage*}
%...
%\end{ThesisTitlePage*}
%\end{verbatim}
% is wrong.
%
% This choice was made because its programming is simpler,
% but in view of the end user it is simpler to use: for
% example, if the user does not use the asterisk for typesetting
% the logos at the top of the page, and in a second time
% s/he decides that the title page should be typeset with
% the logos in the title page lower part, s/he has to add
% just one asterisk to the opening statement avoiding the
% possibility to forget its addition to the closing statement.
%    \begin{macrocode}
\newenvironment{frontespizio*}{\boolfalse{topTPTlogos}}{\fr@ntespizio}

\newenvironment{frontespizio}{%
    \ifdefstring{\@currenvir}{frontespizio}
           {\booltrue{topTPTlogos}}{\TPTmaybestar}
 }{%
     \fr@ntespizio
 }

\DeclareDocumentEnvironment{ThesisTitlePage}{s}{%
\IfBooleanTF{#1}{\boolfalse{topTPTlogos}}{\booltrue{topTPTlogos}}%
\InputIfFileExists{\jobname.cfg}{}{%
   \PackageInfo{toptesi-magistrale}{No configuration file found}}
}{\fr@ntespizio}
%    \end{macrocode}
%
% The following code is substantially identical to that of the
% |topfront| package; just the statements concerning the
% bachelor degree and the Ph.D.~degree theses have been deleted.
%    \begin{macrocode}
\newbool{AteneoInHead}\boolfalse{AteneoInHead}
\newcommand\TPTmaybestar[1]{\def\@tempA{#1}%
\ifdefstring{\@tempA}{*}%
  {\boolfalse{topTPTlogos}\booltrue{AteneoInHead}\fr@ntespizio}
  {\booltrue{topTPTlogos}\fr@ntespizio\@tempA}
}
\def\fr@ntespizio{%
\begingroup\par
   \oddsidemargin=\dimexpr(\oddsidemargin+\evensidemargin)/2\relax
   \evensidemargin \oddsidemargin
\null
\setcounter{page}{1}%
\normalfont
\ifclassica
   \boolfalse{topTPTlogos}
   \thispagestyle{classica}
   \ifcsvoid{@ateneo}{\def\@ateneo{Manca il nome dell'ateneo}
   }{}
\else
   \thispagestyle{titlepage}
\fi
\ifcsvoid{@ateneo}{}{\booltrue{AteneoInHead}}
\ifcsvoid{@ateneo}{%
    \ifbool{topTPTlogos}
    {}{\booltrue{AteneoInHead}\def\@ateneo{Manca il nome dell'ateneo}}%
}{%
    \booltrue{AteneoInHead}%
}

   \ifbool{AteneoInHead}{}{%
      {{\centering\LARGE \@ateneo\par}}
   }
   \ifcsvoid{@nomeat}{}
      {\ifbool{topTPTlogos}{\vspace*{\dimexpr \headsep+2.5ex}}%
      {\vspace*{-3ex}}%
  {\centering\@nomeat\par}\vfill}

  \begin{center}
  {\rmfamily\mdseries
  \ifdottorato
        \large \@phdschool\par\medskip
  \else
        \ifcsvoid{@faculty}{}{%
         \LARGE\ifx\@facnumber\empty\else\@facnumber\space\fi
         \@faculty\unskip\xspace\@facname\par\medskip
        }
  \fi
  }%
  \ifcsvoid{@corso}{}{{\large
        \ifdottorato
             \@PhDname\unskip\xspace
                  \@corso\ifx\@ciclo\empty\else~--~\@ciclo\fi
        \else
              \@laureaname\unskip\xspace\@corso
        \fi
        \par}}
  \end{center}
  \vspace{\stretch{0.2}}
  \begin{center}
    \LARGE\@TesiDiLaurea%
    \unless\ifx\empty\@materia
        \\\@InName\\\@materia
    \fi
  \end{center}
  \vspace{\stretch{0.2}}
  \begin{center}
    {\huge\bfseries \baselineskip=0.95em plus 1pt
            \@titolo \par}
  \end{center}
  \unless\ifx\@subtitle\empty
        \begin{center}%
          \large\textrm{\@subtitle}\par
        \end{center}%
  \fi
  \ifclassica
    \ifnum\value{tomo}>\z@
      \par\bigskip
      \noindent\makebox[\textwidth]{%
      \large\textbf{%
      \ifcase\c@tomo%
        \or \PrimoTomo%
        \or \SecondoTomo%
        \or \TerzoTomo%
        \or \QuartoTomo%
        \else
          \PackageWarning{toptesi}{%
          Counter tomo equals \the\c@tomo\MessageBreak
          We never considered a thesis might get\MessageeBreak
          divided in more than four volumes}%
        \fi}}%
    \fi
    \vspace{1em}
  \fi
  \par
 \unless\iftopTPTlogos
  {\vfill\centering \printloghi\par}\fi
  \vfill
    \iffemminile
          \def\@nomecandidato{\Candidata}%
    \else
          \def\@nomecandidato{\Candidato}%
    \fi
    \ifcsvoid{@secondauthor}{}{%
          \iffemminile
                \def\@nomecandidato{\Candidate}%
          \else
                \def\@nomecandidato{\Candidati}%
          \fi}
  \unless\iftriennale
     \def\BoxRelatori{%
     
        \begin{tabular}[t]{l}%
        \ifclassica
           \hbox{\textbf{\Relatore}}%
         \else
           \hbox{\large\bfseries
                 \ifcsvoid{@secondadviser}{\Relatore}{\Relatori}}
         \fi\\[.6ex]
        \hbox{\large\textrm{\protect\@principaladviser}}%
        \ifx\@secondadviser\empty \else
           \ifclassica
              \ifx\@thirdadviser\empty
                 \ifx\@secondadviser\empty\else
                       \\[1.5ex]\textbf{\Correlatore:}%
                 \fi
              \else
                 \\[1.5ex]\textbf{\Correlatori:}%
              \fi
           \fi
           \\[.6ex]\hbox{{\large\textrm{\protect\@secondadviser}}}%
            \fi
            \ifx\@thirdadviser\empty \else
               \\[.6ex]
               \hbox{{\large\textrm{\protect\@thirdadviser}}}%
            \fi
            \end{tabular}%
         }%
      \def\print@secondocandidato{\\\relax
                  \hbox{\large\tabular{@{}l@{}}%
                  \@secondauthor\endtabular}}
      \def\print@terzocandidato{\\\relax
                  \hbox{\large\tabular{@{}l@{}}%
                  \@thirdauthor\endtabular}}
      \def\BoxCandidati{%
         \begin{tabular}[t]{l}%
            \hbox{\unless\ifclassica\large\fi
               \textbf{\protect\@nomecandidato}}\\[.6ex]
               \hbox{\large\tabular{@{}l@{}}\@author\endtabular}%
               \ifcsvoid{@secondauthor}{}{\print@secondocandidato}%
               \ifcsvoid{@thirdauthor}{}{\print@terzocandidato}%
         \end{tabular}%
      }%
         \unless\ifdottorato
           \unless\ifclassica
             \unless\ifevenboxes
             \begin{flushleft}%
                \BoxRelatori
             \end{flushleft}\par\vspace*{-1.5\baselineskip}
             \begin{flushright}%
                \BoxCandidati
             \end{flushright}%
             \else
                \makebox[\textwidth]{\BoxRelatori\hfill\BoxCandidati}
             \fi
           \else
               \noindent
               \makebox[\textwidth]{%
               \BoxRelatori\hfill\BoxCandidati}\par
           \fi
         \fi
  \fi
   \ifcsvoid{@tutoreaziendale}{}{%
      \vfill\vfill
      {\centering \textbf{\@tutoreaziendalename}\\[.6ex]
         \@tutoreaziendale\par}%
      }
   \par\clearpage
%    \end{macrocode}
%
% It is useful to remind that the legal page in general is not
% compulsory, but it is becoming frequently requested by more
% and more universities. The user can fill up the
% |\retrofrontespizio| argument with as many paragraphs  as are 
% necessary by his/her university requirements.
%
% In general there is a statement claiming the intellectual
% property of the thesis contents; very often it makes reference
% to the Creative Commons licence that is internationally well
% known; other international licences may me used. At the same
% time very often a statement is needed where the thesis author
% assumes the necessary liability for any violation of other
% people intellectual property and/or copyright. Plagiarism and
% lack od attribution of other people rights are the most common
% illegal actions done by students writing their theses, and it
% is very important that the student responsibility is underlined
% by asking him/her to fulfil the legal obligations.
%    \begin{macrocode}
\ifcsvoid{@retrofrontespizio}{}%
      {\null\vfill\thispagestyle{empty}\@retrofrontespizio\par\clearpage}%
\endgroup}
%    \end{macrocode}
%\iffalse
%</topmag>
%\fi
%
%
%\iffalse
%<*topdoc>^^A               DOTTORALE
%\fi
% \subsection{The \texttt{toptesi-dottorale} module}
% What follows is mainly a replica of the |topfront| module
% where useless commands have been eliminated; “useless”
% in view of creating a title page for a Ph.D.~thesis.
%
% First we load the necessary packages.
%    \begin{macrocode}
\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
\@ifpackageloaded{xspace}{}{\RequirePackage{xspace}}
\@ifpackageloaded{xparse}{}{\RequirePackage{xparse}}
%    \end{macrocode}
% Then we define, if they are not already defined, some boolean
% switches related to the possible options. The above packages,
% and the following switches are necessary in case this module
% is used by itself with a different class. The module accepts
% some options, that are declared just after these preliminary
% definitions.
%    \begin{macrocode}
\ifcsundef{ifclassica}{\newif\ifclassica \classicafalse}{}
\ifcsundef{if@utoretitolo}{\newif\if@utoretitolo\@utoretitolofalse}{}
\ifcsundef{if@ldstyle}{\newif\if@ldstyle\@ldstylefalse}{}
\ifcsundef{if@xivpt}{\newif\if@xivpt \@xivptfalse}{}
\ifcsundef{if@binding}{\newif\if@binding\@bindingfalse}{}
\ifcsundef{ifdottorale}{\newif\ifdottorale\dottoralefalse}{}
\ifcsundef{ifevenboxes}{\newif\ifevenboxes \evenboxesfalse}{}
%    \end{macrocode}
% Using this module implies that some switches used in the
% following commands should be set to false.
%    \begin{macrocode}
\ifcsundef{ifTOPfront}{\newif\ifTOPfront \TOPfrontfalse}{}
\ifcsundef{ifT@Pfrontespizio}{\newif\ifT@Pfrontespiziofalse}{}
\ifcsundef{c@tomo}{\newcounter{tomo}\setcounter{tomo}{0}}{}
\newif\iffemminile\newif\ifplurale
\newif\iftriennale\triennalefalse
\newif\ifdottorato \dottoratotrue

%    \end{macrocode}
%
% Here are the option declarations and their processing. Notice
% that the |14pt| option implies that the calling class loads
% some package that can set a normal size to 14pt or 14.4pt,
% otherwise this option may produce an error or a warning;
% in the best case it does not do anything. The |toptesi|
% class loads such a suitable package and allows to set any
% integer or fractional size; this package is |scrextend| and
% the user who wants to use a normal size larger than 12pt
% or smaller than 10pt, can resort to that package; possibly
% that is not the only package suited for such acrobatic
% settings, but the important point is to avoid “acrobatics”;
% scientific books, reports, theses, and other such documents
% are supposed to be read by adults, not by children while
% normal sizes from 14pt on are more suited for elementary
% school pupils. On the opposite, normal sizes smaller than
% 10pt are difficult to read and should be avoided for
% documents to be read continuously; it is possible to use
% such small font sizes in footnotes, or in dictionaries,
% but both footnotes and dictionary entries do not generally
% occupy dozens of pages.
%    \begin{macrocode}
\DeclareOption{evenboxes}{\evenboxestrue}
\DeclareOption{cucitura}{\@bindingtrue}
\DeclareOption{14pt}{\@xivpttrue}
\DeclareOption{classica}{\classicatrue}
\DeclareOption{autoretitolo}{\ifclassica\@utoretitolotrue\fi}
\DeclareOption{oldstyle}{\ifclassica\@ldstyletrue\fi}
\ProcessOptions*\relax
%    \end{macrocode}
%
% We now define two specific page styles, one for “normal”
% title pages, and one for theses typeset with the |classica|
% option in force: they are |\ps@titlepge| and |\ps@classica|.
%    \begin{macrocode}
\def\headstrut{\vrule \@depth4\p@ \@height\z@ \@width\z@}
\def\ps@titlepage{\let\@mkboth\@gobbletwo
   \def\@oddfoot{\vbox to 0.05\paperheight{\vss
      \hbox to\hsize{\hfil{\Large{\@submitdate}}\hfil}}}%
   \let\@evenfoot\@oddfoot
   \def\@oddhead{%
      \vbox to\headheight{\vss\iftopTPTlogos
         \hbox to\textwidth{%
           \headstrut\hfil
           \raisebox{3\baselineskip}{\usebox\TPT@logobox}\hfil\null%
         }\fi
         \ifcsvoid{@ateneo}{}{\vskip\smallskipamount
         \hbox to\textwidth{\hss\LARGE\MakeUppercase{\@ateneo}\hss}}
         \vss
      }%
   }%
   \let\@evenhead\@oddhead
   \def\chaptermark##1{}\def\sectionmark##1{}%
}

  \def\ps@classica{\let\@mkboth\markboth
  \def\@oddhead{\vbox{%
  \setbox256=\hbox{\LARGE\MakeUppercase{\@ateneo}}
  \unless\ifdim\wd256<\textwidth
     \setbox256=\hbox{\resizebox{\textwidth}{!}{\box256}}%
   \fi
  \hbox to \hsize{\hss\box256\hss}%
  \ifclassica
        \hbox to \hsize{\hfil\vrule\@width\z@
    \@height2ex\vrule\@height1.4\p@\@depth-\p@\@width50mm\hfil}%
  \fi
  }}%
  \def\@oddfoot{\vbox to \dimexpr\paperheight/20\relax{\vss
 \ifclassica
    \hbox to \hsize{\hfil\raisebox{-.3ex}[\z@][\z@]{%
    \vrule\@height-2.6\p@\@depth3\p@\@width
        \dimexpr\textwidth/3}\hfil}%
  \fi
  \hbox to\hsize{\hfill{\Large{\@submitdate}}\hfill}}%
  }%
  \let\@evenhead\@oddhead
  \let\@evenfoot\@oddfoot
  }%
%    \end{macrocode}
%
% We provide also the variant settings for when the |classica|
% option is in force together with the |autoretitolo| one.
%    \begin{macrocode}
\if@utoretitolo
   \if@twoside
%
       \renewcommand*{\ps@headings}{\let\@mkboth\markboth%
       \def\@oddfoot{\null \hfill \textbf{\lapagina} \hfill \null}%
       \let\@evenfoot\@oddfoot
       \def\@evenhead{%
           \setbox\@intesta\hbox{\ifPDFTeX\latintext\fi
           \footnotesize\strut\textsc{%
           \@@author\ifcsvoid{@secondauthor}{\ et al.}: \@stitle}%
           }%
       \ifdim\wd\@intesta>\textwidth\headwrn{\titolo}\fi
       \underline{\makebox[\textwidth]{\box\@intesta}}}%
       \def\@oddhead{\ifPDFTeX\latintext\fi
           \setbox\@intesta\hbox{%
               \footnotesize\strut\textsl{\rightmark}}%
       \ifdim\wd\@intesta>\textwidth \headWarn{\section}\fi%
       \underline{\makebox[\textwidth]{\box\@intesta}}}%
       \def\chaptermark##1{\markright{\thechapter\ -- ##1}}%
       \def\sectionmark##1{}}%
   \else
       \renewcommand*{\ps@headings}{\let\@mkboth\markboth
           \def\@oddfoot{\null \hfill \textbf{\lapagina}\hfill \null}%
           \let\@evenfoot\empty\let\@evenhead\empty
           \def\@oddhead{{\setbox\z@\hbox{\ifPDFTeX\latintext\fi
           \footnotesize\textsc{%
           \@@author\ifcsvoid{@secondauthor}{}{\ et al.}: \@stitle}}%
           \setbox\tw@\hbox{\ifPDFTeX\latintext\fi
           \footnotesize\textsl{\rightmark}}%
           \dimen@=\dimexpr2em + \wd\z@ + \wd\tw@\relax
           \ifdim\dimen@<\textwidth \relax
           \else
             \setbox\z@\vbox{\hsize.48\textwidth\parindent\z@
             \raggedright
             \ifPDFTeX\latintext\fi\footnotesize\textsc{%
             \@@author\ifcsvoid{@secondauthor}{}{\ et al.}: \@stitle
             }}%
             \setbox\tw@\vbox{\hsize.48\textwidth\parindent\z@
             \raggedleft
             \ifPDFTeX\latintext\fi\footnotesize
                 \textsl{\rightmark}}%
             \fi
           \setbox\@intesta\vbox to\z@{%
                \vss\hbox to\textwidth{\strut\box\z@\hfill\box\tw@}}%
           \underline{\box\@intesta}}}%
           \def\chaptermark##1{\markright{\thechapter\ -- ##1}}}
   \fi
\fi
%    \end{macrocode}
% Now we define the title setting  commands for both
% title (|\titolo|) and subtitle (|\sottotitolo|) and
% all the other commands for setting the fixed strings.
%    \begin{macrocode}
\let\@stitle\empty

\newcommand*{\titolo}[2][]{%
\def\@tempA{#1}\ifdefempty{\@tempA}%
 {\gdef\@stitle{#2}}{\gdef\@stitle{#1}}%
 \gdef\@titolo{#2}%
}%

\def\sottotitolo#1{\gdef\@subtitle{#1}}
\let\@materia\empty
\def\Materia#1{\def\@materia{#1}}\let\materia\Materia
\newif\ifDirettore \Direttorefalse
\def\tutore#1{\gdef\@tutore{#1}}
\def\direttore{\Direttoretrue\relatore}%
\def\coordinatore{\Direttorefalse\relatore}%
\def\QualificaDirettore#1{\gdef\@PhDdirector{#1}}%
\def\relatore#1{\gdef\@principaladviser{#1}}
\def\secondorelatore#1{\gdef\@secondadviser{#1}}
\def\terzorelatore#1{\gdef\@thirdadviser{#1}}
\def\esamedidottorato#1{\getseduta#1 !}
\def\getseduta#1 #2!{%
    \def\@tempA{#2}%
    \ifx\@tempA\empty
        \def\@submitdate{#1}%
    \else
        \unless\ifclassica
            \def\@submitdate{#1 #2}%
        \else
            \s@dutaclassica#1 #2!%
        \fi
    \fi
}%
\def\s@dutaclassica#1 #2!{%
  \if@ldstyle
    \s@paranumeri#2-!%
    \ifx\2\empty
      \edef\@submitdate{\noexpand#1 \noexpand\oldstylenums{#2}}%
    \else
      \s@paranumeri#2!%
      \edef\@submitdate{\noexpand#1
      \noexpand\oldstylenums{\1} -- \noexpand\oldstylenums{\2}}%
    \fi
      \let\1\undefined
      \let\2\undefined
  \else
    \def\@submitdate{#1 #2}%
  \fi
}
\def\s@paranumeri#1-#2!{\def\1{#1}\def\2{#2}}%

\newcommand*\NomeAnnoAccademico[1]{\gdef\AnnoAccademico{#1}}
\@ifundefined{AnnoAccademico}{\gdef\AnnoAccademico{Anno accademico}}{}
\def\annoaccademico#1{\ifclassica
  \def\@submitdate{{\large\textsc{\AnnoAccademico}} {\Large\s@tanno#1!}}
  \else
  \PackageWarning{toptesi}{\string\annoaccademico\space
            is usable only when the\MessageBreak
   `classica' option is in force}%
  \def\@submitdate{\AnnoAccademico\ #1 --- Needs the `classica' option}
  \fi}
\def\s@tanno#1-#2!{\oldstylenums{#1}\EnDash\oldstylenums{#2}}

\def\EnDash{{\settowidth{\dimen@}{\large\scshape I}%
\setbox\tw@\hbox{2}\dimen\tw@.5\ht\tw@\advance\dimen\tw@-.5\dp\tw@
\dimen4\dimen\tw@\advance\dimen4by.0385ex\relax
\advance\dimen\tw@-.0385ex\relax
\makebox[1.5\dimen@]{%
    \vrule\@width\dimen@\@height\dimen4\@depth-\dimen\tw@}}}
\def\ciclodidottorato#1{\gdef\@ciclo{#1 \@cyclename}}%
\def\corsodidottorato#1{\global\dottoratotrue
  \global\gdef\@corso{#1}}
\def\scuoladidottorato#1{\global\dottoratotrue
  \gdef\@phdschool{#1}}
\def\ateneo#1{\gdef\@ateneo{#1}}
\def\nomeateneo#1{\gdef\@nomeat{\expandafter\uppercase{\expandafter #1}}}
\newcommand\facolta[2][]{\gdef\@facname{#2}\gdef\@facnumber{#1}}
\let\struttura\facolta
%    \end{macrocode}
%
% next we define how to handle one or more logos; even in
% PH.D. schools there might be situations where the Ph.D.~program
% has been carried on in several universities; it might be
% required to set the logos of the universities where the research
% program leading to the Ph.D. has been developed. The user commands
% are |\logosede| and |\printloghi|; the latter does what
% its name suggests, i.e. it prints the string of logos;
% the former command accepts one logo file name, and queues
% it into a logo list; this command may be used multiple times;
% of course if there are several logos, their “string”
% may become larger than the text width, and in this case
% |\printloghi| shrinks the whole string (maintaining the
% aspect ratio) so as to fit it within the measure. If the
% logos are too many and/or they are too wide, this
% shrinking may reduce them too much; there is no work
% around to avoid this problem except refraining from using too
% many and/or too wide logos.
%    \begin{macrocode}
\newlength{\TPT@logospace}\TPT@logospace=3em\relax
\newsavebox{\TPT@logobox}
\newdimen\TPT@logoheight
\newcommand*\setlogodistance[1]{\TPT@logospace=#1}
\providecommand*{\@logosede}{}

\ifcsundef{T@Tlogoheight}{%\
    \newlength\T@Tlogoheight
    \setlength\T@Tlogoheight{0.8\dimexpr(\paperwidth-\textwidth)/2}}{}
    
\newcommand\logosede[2][\T@Tlogoheight]{\def\@logosede{#2}\TPT@logoheight=#1\relax
\ifcsvoid{@logosede}{\sbox{\TPT@logobox}{}}{\begin{lrbox}{\TPT@logobox}%
\expandafter\fillup@TCP@logobox\@logosede,!}}

\def\fillup@TCP@logobox#1,#2!{%
\ifblank{#1}{\end{lrbox}\ifdim\wd\TPT@logobox>\textwidth
\sbox\TPT@logobox{\resizebox{\textwidth}{!}{\box\TPT@logobox}}\fi}%
{\def\@logosede{#2}%
\includegraphics[height=\TPT@logoheight]{#1}\hskip\TPT@logospace
   \expandafter\fillup@TCP@logobox\@logosede,!}}

\newcommand\printloghi{\unless\ifvoid\TPT@logobox\usebox{\TPT@logobox}\fi}
%    \end{macrocode}
%
% We keep defining macros to set fixed strings and/or variable data.
%    \begin{macrocode}
\def\tutoreaziendale#1{\gdef\@tutoreaziendale{#1}}
\newcommand\retrofrontespizio[1]{\long\gdef\@retrofrontespizio{#1}}
\newcommand\FacoltaDi[1]{\gdef\@faculty{#1}}
\let\StrutturaDidattica\FacoltaDi
\newcommand\DottoratoIn[1]{\gdef\@PhDname{#1}}
\newcommand\CorsoDiLaureaIn[1]{\gdef\@laureaname{#1}}
\newcommand\TesiDiLaurea[1]{\gdef\@TesiDiLaurea{#1}}
\newcommand\NomeMonografia[1]{\gdef\@monografia{#1}}
\newcommand\NomeDissertazione[1]{\gdef\@dissertazione{#1}}
\newcommand\InName[1]{\gdef\@InName{#1}}
\newcommand\CandidateName[1]{\gdef\@nomecandidato{#1}}
\newcommand\AdvisorName[1]{\gdef\Relatore{#1}\gdef\Relatori{#1}}
\newcommand\CoAdvisorName[1]{\gdef\Correlatore{#1}\gdef\Correlatori{#1}}
\newcommand\TutorName[1]{\gdef\Tutore{#1}}
\newcommand\NomeTutoreAziendale[1]{\gdef\@tutoreaziendalename{#1}}
\newcommand\CycleName[1]{\gdef\@cyclename{#1}}
\newcommand\NomePrimoTomo[1]{\gdef\PrimoTomo{#1}}
\newcommand\NomeSecondoTomo[1]{\gdef\SecondoTomo{#1}}
\newcommand\NomeTerzoTomo[1]{\gdef\TerzoTomo{#1}}
\newcommand\NomeQuartoTomo[1]{\gdef\QuartoTomo{#1}}
\newcommand\IDlabel{\\matricola:\xspace}
\IfFileExists{\jobname.cfg}{\input{\jobname.cfg}}%
    {\IfFileExists{toptesi.cfg}{\input{toptesi.cfg}}{}}
\@ifundefined{@cyclename}{\def\@cyclename{ciclo}}{}
\@ifundefined{@titolo}{\def\@titolo{}}{}
\NewDocumentCommand\candidato{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}
\femminilefalse\pluralefalse}
\NewDocumentCommand\candidata{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}
\femminiletrue\pluralefalse}
\providecommand\@secondauthor{}
\NewDocumentCommand\secondocandidato{m o}{%
\IfNoValueTF{#2}{\gdef\@secondauthor{#1}}%
                {\gdef\@secondauthor{#1\IDlabel#2}}%
\femminilefalse\pluraletrue}
\NewDocumentCommand\secondacandidata{m o}{%
\IfNoValueTF{#2}{\gdef\@secondauthor{#1}}%
                {\gdef\@secondauthor{#1\IDlabel#2}}%
\pluraletrue}
\providecommand\@thirdauthor{}
\NewDocumentCommand\terzocandidato{m o}{%
\IfNoValueTF{#2}{\gdef\@thirdauthor{#1}}%
                {\gdef\@thirdauthor{#1\IDlabel#2}}%
\femminilefalse\pluraletrue}
\NewDocumentCommand\terzacandidata{m o}{%
\IfNoValueTF{#2}{\gdef\@thirdauthor{#1}}%
                {\gdef\@thirdauthor{#1\IDlabel#2}}%
\pluraletrue}

\@ifundefined{@principaladviser}{\def\@principaladviser{}}{}
\@ifundefined{@secondadviser}{\def\@secondadviser{}}{}
\@ifundefined{@thirdadviser}{\def\@thirdadviser{}}{}
\ifcsundef{@PhDdirector}{%
   \ifDirettore\def\@PhDdirector{Direttore del corso di dottorato}\else
    \def\@PhDdirector{Coordinatore del corso di dottorato}\fi}{}
\@ifundefined{@tutore}{\def\@tutore{}}{}
\@ifundefined{@nomerelatore}{\def\@nomerelatore{}}{}
\@ifundefined{@nomecandidato}{\def\@nomecandidato{}}{}
\@ifundefined{Candidato}{\def\Candidato{Candidato}}{}
\@ifundefined{Candidata}{\def\Candidata{Candidata}}{}
\@ifundefined{Candidati}{\def\Candidati{Candidati}}{}
\@ifundefined{Candidate}{\def\Candidate{Candidate}}{}
\@ifundefined{Relatore}{\def\Relatore{Relatore}}{}
\@ifundefined{Relatori}{\def\Relatori{Relatori}}{}
\@ifundefined{Correlatore}{\def\Correlatore{Correlatore}}{}
\@ifundefined{Correlatori}{\def\Correlatori{Correlatori}}{}
\@ifundefined{Tutore}{\def\Tutore{Tutore}}{}
\@ifundefined{@tutoreaziendale}{\def\@tutoreaziendale{}}{}
\@ifundefined{@tutoreaziendalename}%
        {\def\@tutoreaziendalename{Supervisore Aziendale}}{}
\@ifundefined{@retrofrontespizio}{\def\@retrofrontespizio{}}{}
\@ifundefined{@subtitle}{\def\@subtitle{}}{}
\@ifundefined{@corso}{\def\@corso{}}{}
\@ifundefined{@ciclo}{\def\@ciclo{}}{}
\@ifundefined{@ateneo}{\def\@ateneo{POLITECNICO DI TORINO}}{}
\@ifundefined{@nomeat}{\def\@nomeat{}}{}% Nome proprio dell'ateneo
\@ifundefined{@facolta}{\def\@facname{}}{}
\@ifundefined{@facnumber}{\def\@facnumber{}}{}
\@ifundefined{@faculty}{\def\@faculty{}}{}
\@ifundefined{PrimoTomo}{\def\PrimoTomo{Tomo primo}}{}
\@ifundefined{SecondoTomo}{\def\SecondoTomo{Tomo secondo}}{}
\@ifundefined{TerzoTomo}{\def\TerzoTomo{Tomo terzo}}{}
\@ifundefined{QuartoTomo}{\def\QuartoTomo{Tomo quarto}}{}
\@ifundefined{@submitdate}{\def\@submitdate{\ifcase\the\month\or%
  Gennaio\or Febbraio\or Marzo\or Aprile\or Maggio\or Giugno\or
  Luglio\or Agosto\or Settembre\or Ottobre\or Novembre\or Dicembre\fi
  \space \the\year}}{}
\@ifundefined{@TesiDiLaurea}{\def\@TesiDiLaurea{Tesi di Laurea}}{}
\@ifundefined{@phdschool}{\def\@phdschool{SCUOLA DI DOTTORATO}}{}
\@ifundefined{@PhDname}{\def\@PhDname{Dottorato in }}{}
\@ifundefined{@laureaname}{\def\@laureaname{Corso di Laurea in }}{}
\@ifundefined{@dissertazione}{\def\@dissertazione{Tesi di Dottorato}}{}
\@ifundefined{@monografia}{\def\@monografia{Monografia di Laurea}}{}
\@ifundefined{@InName}{\def\@InName{in}}{}
%    \end{macrocode}
%
% We now start setting the |ThesisTitlePage| environment;
% we use the |xparse| functionality to define it; the
% environment accepts an optional asterisk as its first
% and only argument, that is a single token may be entered
% without brackets as the very first token after the
% environment opening statement. If the user wants to use
% this optional argument,  s/he must enter
% |\begin{ThesisTitlePage}*| with the asterisk after the
% closing brace. The presence of the asterisk sets the
% logo position to the title page lower half, while its
% absence sets such position to the title page top.
%
% The opening commands provide also to read a configuration
% file, if it exists in the same folder as the thesis main
% file; such configuration file must be named \meta{thesis
% main file name}|.cfg|. The environment body, besides the
% possible data already retrieved from the configuration file,
% accepts other setting commands for the title page necessary
% and optional data; if some commands are repeated with
% different data, the last ones prevail on the previous ones.
% The actual title page typesetting is done by the closing
% environment command.
%
% Among the setting commands there might be also the legal
% page rendered with the  |\retrofrontespizio| command; it 
% closes the recto title page, and on the verso, if the command 
% argument is void, nothing is printed except the blank verso page,
% but if it contains something, the legal notice is printed
% at the verso page bottom.
%    \begin{macrocode}
\newbool{topTPTlogos}\newbool{AteneoInHead}

\DeclareDocumentEnvironment{ThesisTitlePage}{s}{%
  \IfBooleanTF{#1}{\boolfalse{topTPTlogos}\booltrue{AteneoInHead}}%
               {\booltrue{topTPTlogos}\boolfalse{AteneoInHead}}%
  \IfFileExists{\jobname.cfg}{\input{\jobname.cfg}}{%
    \PackageWarning{toptesi-dottorale}{%
       No configuration file found\MessageBreak}}
}{%
  \fr@ntespizio  
}
%    \end{macrocode}
% Next we define the actual typesetting of the title page.
% The code is substantially that of the generic module
% |topfront| where we deleted the commands and the settings
% related to thesis kinds that have nothing to do with
% a generic doctoral thesis. 
%    \begin{macrocode}
\def\fr@ntespizio{%
\begingroup\par
   \oddsidemargin=\dimexpr(\oddsidemargin+\evensidemargin)/2\relax
   \evensidemargin \oddsidemargin
\null
\setcounter{page}{1}%
\normalfont
\ifclassica
   \boolfalse{topTPTlogos}
   \thispagestyle{classica}
   \ifcsvoid{@ateneo}{\def\@ateneo{Manca il nome dell'ateneo}
   }{}
\else
   \thispagestyle{titlepage}
\fi
\ifcsvoid{@ateneo}{}{\booltrue{AteneoInHead}}
\ifcsvoid{@ateneo}{%
    \ifbool{topTPTlogos}
    {}{\booltrue{AteneoInHead}\def\@ateneo{Manca il nome dell'ateneo}}%
}{%
    \booltrue{AteneoInHead}%
}
   \ifbool{AteneoInHead}{}{%
      {{\centering\LARGE \@ateneo\par}}
   }
   \ifcsvoid{@nomeat}{}
      {\ifbool{topTPTlogos}{\vspace*{\dimexpr \headsep+2.5ex}}{\vspace*{-3ex}}%
      {\centering\@nomeat\par}\vfill}

      \begin{center}
      {\rmfamily\mdseries
      \ifdottorato
            \large \@phdschool\par\medskip
      \else
            \ifcsvoid{@faculty}{}{%
             \LARGE\ifx\@facnumber\empty\else\@facnumber\space\fi
             \@faculty\unskip\xspace\@facname\par\medskip
            }
      \fi
      }%
      \ifcsvoid{@corso}{}{{\large
            \ifdottorato
                 \@PhDname\unskip\xspace
                      \@corso\ifx\@ciclo\empty\else~--~\@ciclo\fi
            \else
                  \@laureaname\unskip\xspace\@corso
            \fi
            \par}}
      \end{center}
      \vspace{\stretch{0.2}}
      \begin{center}
        \LARGE\@dissertazione%
        \unless\ifx\empty\@materia
            \\\@InName\\\@materia
        \fi
      \end{center}
      \vspace{\stretch{0.2}}
      \begin{center}
        {\huge\bfseries \baselineskip=0.95em plus 1pt
                \@titolo \par}
      \end{center}
      \unless\ifx\@subtitle\empty
            \begin{center}%
              \large\textrm{\@subtitle}\par
            \end{center}%
      \fi
      \ifclassica
            \ifnum\value{tomo}>\z@
                  \par\bigskip
                  \noindent\makebox[\textwidth]{%
                  \large\textbf{%
                  \ifcase\c@tomo%
                        \or \PrimoTomo%
                        \or \SecondoTomo%
                        \or \TerzoTomo%
                        \or \QuartoTomo%
                        \else
                            \PackageWarning{toptesi}{%
                            Counter tomo equals \the\c@tomo\MessageBreak
                            We never considered a thesis might get
                            divided in more than four volumes}%
                        \fi}}%
            \fi
            \vspace{1em}
      \fi
      \par
     \unless\iftopTPTlogos
      {\vfill\centering \printloghi\par}\fi
      \vfill
      \iftriennale
            \let\@nomerelatore\empty
      \else
            \ifdottorato
                  \edef\@nomerelatore{\@PhDdirector}%
            \else
                  \ifcsvoid{@principaladviser}{}{%
                        \def\@nomerelatore{\Relatore}}
                  \unless\ifclassica
                        \ifcsvoid{@secondadviser}{}{%
                              \def\@nomerelatore{\Relatori}}%
                  \fi
            \fi
      \fi
      \ifdottorato
            \let\@nomecandidato\empty
      \else
        \iflanguage{italian}{%
            \iffemminile
                  \def\@nomecandidato{\Candidata}%
            \else
                  \def\@nomecandidato{\Candidato}%
            \fi
            \ifcsvoid{@secondauthor}{}{%
                  \iffemminile
                        \def\@nomecandidato{\Candidate}%
                  \else
                        \def\@nomecandidato{\Candidati}%
                  \fi}
         }{}%
     \fi
      \iftriennale
            \begin{center}%
                  \large\mdseries\textsc{\@author}
            \end{center}%
      \else
         \def\BoxRelatori{%
            \begin{tabular}[t]{l}%
            \hbox{\ifclassica\else\large\fi
                  \textbf{\protect\@nomerelatore}}\\[.6ex]
            \hbox{\large\textrm{\protect\@principaladviser}}%
            \ifx\@secondadviser\empty \else
               \ifclassica
                  \ifx\@thirdadviser\empty
                     \ifx\@secondadviser\empty\else
                           \\[1.5ex]\textbf{\Correlatore:}%
                     \fi
                  \else
                     \\[1.5ex]\textbf{\Correlatori:}%
                  \fi
               \fi
               \\[.6ex]\hbox{{\large\textrm{\protect\@secondadviser}}}%
            \fi
            \ifx\@thirdadviser\empty \else
               \\[.6ex] \hbox{{\large\textrm{\protect\@thirdadviser}}}%
            \fi
            \end{tabular}%
         }%
      \def\print@secondocandidato{\\\relax
                  \hbox{\large\tabular{@{}l@{}}\@secondauthor\endtabular}}
      \def\print@terzocandidato{\\\relax
                  \hbox{\large\tabular{@{}l@{}}\@thirdauthor\endtabular}}
      \def\BoxCandidati{%
         \begin{tabular}[t]{l}%
            \hbox{\unless\ifclassica\large\fi
               \textbf{\protect\@nomecandidato}}\\[.6ex]
               \hbox{\large\tabular{@{}l@{}}\@author\endtabular}%
               \ifcsvoid{@secondauthor}{}{\print@secondocandidato}%
               \ifcsvoid{@thirdauthor}{}{\print@terzocandidato}%
         \end{tabular}%
      }%
         \ifdottorato
            \begin{center}\large
               \textbf{\@author}\\[3em]
               {\normalsize
                 \begin {tabular*}{\hsize}{@{\extracolsep{\fill}}ccc}
                     \ifcsvoid{@tutore}{}{\textbf{\Tutore}}
                 &\relax&
                     \ifcsvoid{@principaladviser}{}{\textbf{\@nomerelatore}}
                 \\
                     \ifcsvoid{@tutore}{}{\@tutore}
                 &\relax&
                     \ifcsvoid{@principaladviser}{}{\@principaladviser}
                 \end{tabular*}
               }%
            \end{center}
         \else
           \unless\ifclassica
             \unless\ifevenboxes
             \begin{flushleft}%
                \BoxRelatori
             \end{flushleft}\par\vspace*{-1.5\baselineskip}
             \begin{flushright}%
                \BoxCandidati
             \end{flushright}%
             \else
                \makebox[\textwidth]{\BoxRelatori\hfill\BoxCandidati}
             \fi
             \else
               \noindent
               \makebox[\textwidth]{%
               \BoxRelatori\hfill\BoxCandidati}\par
             \fi
          \fi
      \fi
\ifcsvoid{@tutoreaziendale}{}{%
    \vfill\vfill
    {\centering \textbf{\@tutoreaziendalename}\\[.6ex]
    \@tutoreaziendale\par}}
      \par\clearpage
% Legal page
      \ifcsvoid{@retrofrontespizio}{}%
      {\null\vfill\thispagestyle{empty}\@retrofrontespizio\par\clearpage}%
\endgroup}
%    \end{macrocode}
%\iffalse
%</topdoc>
%\fi
%
% \subsection{The \texttt{toptesi-sss} module code}
% The module for typesetting the high-school final-work
% title-page starts here. We avoid using a |.def| file and put
% all necessary commands in one file.
% 
% First we load the described packages using different loading
% schemes for \pdfLaTeX\ vs. \LuaLaTeX\ or \XeLaTeX.
%
%\iffalse
%<*topsss>^^A               SECONDARIA
%\fi
%    \begin{macrocode}
%% 
%%%% Math fonts and AMS extensions (|fontspec| is already loaded)
\secondariatrue
\ifPDFTeX
   \@ifpackageloaded{newtxmath}{}%
     {\@ifpackageloaded{newpxmath}{}%
       {%
         \RequirePackage{amsmath,amssymb,amsthm}%
       }%
     }%
\else
   \RequirePackage{amsmath,amsthm}
   \RequirePackage{unicode-math}
\fi
\RequirePackage{xcolor}   % Intelligent colors
\RequirePackage{xspace}   % Intelligent space
\RequirePackage{xparse}   % Command and environment advanced definitions
\RequirePackage{calc}     % Calculation macros
\RequirePackage{ifthen}   % Conditional statements
\RequirePackage{booktabs} % professional rules in tables
\RequirePackage{multirow} % Multirow table cells are not professional
\RequirePackage[autostyle]{csquotes} % necessary for biblatex
\ifPDFTeX \RequirePackage{indentfirst}\fi
\raggedbottom
%    \end{macrocode}
%
% We initialise the internal macros to the default values; most
% of them are just empty strings.
%    \begin{macrocode}
\providecommand*\@SSSLogo{}
\providecommand*\@tiposcuola{}
\providecommand*\@indirizzomiur{}
\providecommand*\@opzionemiur{}
\providecommand*\@nomescuola{}
\providecommand*\@sedescuola{}
\providecommand*\@annoscolastico{}

\providecommand*\@Ntesina{Tesina di maturit\`a}
\providecommand*\@title{}
\providecommand*\@subtitle{}

\ifcsundef{ifemminile}{\newif\iffemminile\femminilefalse}{}
\providecommand*\@Ncandidato{\iffemminile Studentessa\else
                             Studente\fi}
\providecommand*\@author{}
\providecommand*\@Npresidente{Presidente di commissione}
\providecommand*\@presidente{}
\providecommand*\@numerocommissione{}

\newcommand*\SSSLogo[1]{\gdef\@SSSLogo{#1}}
\newcommand*\NomeTesina[1]{\gdef\@Ntesina{#1}}
\newcommand*\IndirizzoMiur[1]{\gdef\@indirizzomiur{#1}}
\newcommand*\OpzioneMiur[1]{\gdef\@opzionemiur{#1}}
\newcommand*\TipoScuola[1]{\gdef\@tiposcuola{#1}}
\newcommand*\SedeScuola[1]{\gdef\@sedescuola{#1}}
\newcommand*\NomeScuola[1]{\gdef\@nomescuola{#1}}
\newcommand*\AnnoScolastico[1]{\gdef\@annoscolastico{#1}}
\newcommand*\NomeCandidato[1]{\gdef\@Ncandidato{#1}}

\newcommand*\titolo[1]{\gdef\@title{#1}}
\newcommand*\sottotitolo[1]{\gdef\@subtitle{\ifblank{#1}{}%
   {\medskip\par{\Large #1\par}}%
   \vspace{\stretch{1}}}}
   
\NewDocumentCommand\studente{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}\femminilefalse}
\NewDocumentCommand\studentessa{m o}{\gdef\@@author{#1}%
\IfNoValueTF{#2}{\gdef\@author{#1}}%
               {\gdef\@author{#1\IDlabel#2}}\femminiletrue}
\newcommand*\IDlabel{\\\normalfont Classe\ }
\newcommand*\Presidente[1]{\gdef\@presidente{#1}}
\newcommand*\NumeroCommissione[1]{\gdef\@numerocommissione{#1}}
%    \end{macrocode}
%
% The following code certainly does not hurt, but it was
% necessary during the preliminary testing.
%    \begin{macrocode}
\newcommand*\ifBlank{\expandafter\ifblank\expandafter}
%    \end{macrocode}
% The environment |FrontespizioTesina| is being defined here.
% No optional arguments are requested, therefore it is not
% necessary to use the defining commands of package |xparse|.
% The environment starts by reading the configuration file
% |jobname.cfg| if it exists. Nothing is done if such file
% does not exist, not even an info message; after all the
% configuration file is optional.
%    \begin{macrocode}
\newenvironment{FrontespizioTesina}{%
\InputIfFileExists{\jobname.cfg}{\relax}{\relax}
}{%
%    \end{macrocode}
%
% After this preliminary test the |titlepage| environment is
% opened and the layout assembly starts. First the information
% on the school; if the school generic name has been omitted
% among the mandatory user commands, the string “Manca il tipo
% di scuola”  is printed in its place, so that the user is
% directly reminded of the mandatory nature of this piece of
% data. On the opposite if the Ministry of education data are
% missing, nothing is done. After these mandatory and optional
% data are printed, a couple of horizontal lines are typed so
% as to mark the end of the title page heading.
%    \begin{macrocode}
\begin{titlepage}\parindent=0pt
\centering
\raisebox{0.025\textheight}[0pt][0pt]{\parbox[b]{\textwidth}{%
\centering
\ifBlank{\@tiposcuola}{Manca il tipo di scuola}{\@tiposcuola}%
\ifBlank{\@indirizzomiur}{\relax}{\space--\space\@indirizzomiur}%
\ifBlank{\@opzionemiur}{\relax}{\space--\space\@opzionemiur}\par
\vspace{-1ex}
\makebox[0.5\textwidth]{\rule{0.50\textwidth}{0.4\p@}}\par
\vspace{-1.5ex}
\makebox[0.25\textwidth]{\rule{0.25\textwidth}{0.8\p@}}\par
%    \end{macrocode}
%
% After this heading the proper name of the school is printed,
% possibly with its real address.
%    \begin{macrocode}
\medskip

\textsc{\@nomescuola}}}\par
\null\hfill\ifBlank{\@sedescuola}{\relax}{%
\raisebox{0.5\baselineskip}[0pt][0pt]{%
\parbox{0.4\textwidth}{\raggedleft\@sedescuola}}}\par
\vspace{\stretch{1}}
%    \end{macrocode}
%
% Next the name of the document and its title and subtitle
% are set: the title  in |\Large| boldface font, while the subtitle 
% in normal size.
%    \begin{macrocode}
{\large \@Ntesina\par}
\vspace{\stretch{0.5}}

{\Large\textbf{\@title}\par}
{\vspace{0.5\baselineskip}

\normalsize\@subtitle\par}
%    \end{macrocode}
%
% If a file name is specified for the graphic file that
% contains the school logo, such image is inserted in the
% title page.
%    \begin{macrocode}
\ifBlank{\@SSSLogo}%
  {\vspace{\stretch{1}}}%
  {\includegraphics[height=30mm]{\@SSSLogo}}\par\vspace{\stretch{1}}
%    \end{macrocode}
%
% The examining committee chairperson name and the Ministry
% of education committee ID number are typeset within a
% |minipage|. Another |minipage| contains the student's name.
% Pay attention: the names of the student and of the president
% are typeset in bold face small caps if the default fonts have
% this typeface; if the chosen fonts do not have this typeface
% the actual used typeface is bold roman.
%    \begin{macrocode}
\begin{minipage}[t]{0.45\textwidth}\flushleft
\ifBlank{\@presidente}{}{\@Npresidente\\
{\bfseries\scshape\@presidente}\par
\vspace{\baselineskip}}

\ifBlank{\@numerocommissione}{}{Commissione numero\\
\textbf{\@numerocommissione}}
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\textwidth}\flushright
\@Ncandidato\\
{\bfseries\scshape\@author}
\end{minipage}

\vspace{\stretch{1}}

%    \end{macrocode}
%
% Eventually the school year is printed with an initial string
% `Anno scolastico'. This terminates the title page; the
% environment is closed and the page ejected.
%    \begin{macrocode}
\raisebox{-0.05\textheight}[0pt][0pt]{%
\parbox[t]{\textwidth}{\centering
\makebox[0.25\textwidth]{\hrulefill}\\[\medskipamount]
Anno scolastico \@annoscolastico}}
\end{titlepage}
\clearpage}%% 
%% 
\endinput
%    \end{macrocode}
% This is the end of this module code.
%\iffalse
%</topsss>
%\fi
%
% \Finale
% \endinput
%
\endinput
%%%%%% Recent progress
%%% (version 6.2.04 2018-05-05) With TeXLive 2018 diagnostic messages
%   on errors in the LaTeX kernel are more efficient and some of them
%   were notified, while until 2017 no notice was issued. The source
%   code was revised in order to eliminate those little nasty bugs.
%
%%% (version 6.2.01 2018-04-30) The main structure introduced with
%   previous versions and their minor versions remains untouched, 
%   but a new option has been added in order to modify the bibliography
%   style when typesetting theses for the PoliTO Doctoral School ScuDo.
%   The specific module was developed having in mind theses in the
%   scientific domains covered by the IEEE Transactions; of course
%   not all doctoral theses deal with those domains, therefore the
%   bibliography style should be changeable according to the styles
%   used in other scientific domains.
%
%%% (version 6.1.8 -- 2017-10-15) Extended version 5.92.xx in order 
%    to modularise the whole bundle; this requires the key=value options 
%    in order to smoothly handle the various new options, especially those 
%    that offer the user the new environment ThesisTitlePage 
%    (FrontespizioTesi for high school tesina); a new environment SDbox 
%    to produce figures and tables and any other possible floating body, 
%    defined through package float, with their captions on a side, 
%    possibly protruding into the external margin; in any case the SD 
%    box can be used by itself without using the corresponding floating 
%    environment. Modules available for different thesis types include 
%    high school tesina, bachelor, master, doctoral theses, the doctoral 
%    thesis title page for the Doctorate School of Politecnico di Torino; 
%    custom and frontespizio key-value options are available for a totally 
%    hand made title page, and a title page typeset by means of the 
%    external package frontespizio by Enrico Gregorio; backwards 
%    compatibility with the previous version is almost always maintained 
%    for both title pages; even the ID number of the candidates is 
%    maintained, although with a slightly different modern interface, 
%    since the xparse package facilities are used to define some of the 
%    new commands and environments. The a4paper paper size is 
%    maintained as the default one, although alla paper sizes available
%    to the report/book/article class can be used (this required a loto
%    of thought, because the xkeyval package documentations require
%    thoughtful interpretation.
%%%% (version 6.2.07 of 2018/11/12) Added checks in order to avoid loading
%    an older toptesi.sty package compared to the toptesi.cls. It avoids
%    any possible conflict with hacked toptesi.sty files, or even with
%    obsolete versions, still going around in Internet, that date back
%    to the old times when the toptesi.cls file did not yet exist (versions
%    2.xxxx or older).
%%%% (version 6.2.09 of 2018/11/20) Loaded the filecontents package in oder
%    to allow overwriting of the metadata file needed for PDF/A compliance.
%%%% (version 6.2.10 of 2018/12/30) Adjusted information about PDF/A color
%    profile compliance after the |pdfx| package has been upgraded to
%    version 1.6.1 on 2018/12/22.
%%%% (version 6.3.00 of 2019-03-09) Modified the toptesi-magistrale.sty 
%    module in order to have a working set of commands to set 
%    the candidates' list heading in a proper way with any number (<4) 
%    of candidates of any sex; previous to this version this module did not
%    accept the commands \CandidateNames and \TitoloListaCandidati.
%%%% (version 6.3.05 of 2019-07-01) redefined the \chapter command, 
%    and adapted the corresponding declarations and commands, to exploit 
%    the new functionalities. Such new functionalities depend on the 
%    package xparse new (may be not that new, but new for me) syntax 
%    that allows to declare the optional argument descriptors so as to 
%    inherit the values of other arguments.Such syntax avoids a lot of 
%    fragile tests, and is very handy.