summaryrefslogtreecommitdiff
path: root/macros/xetex/latex/hfutthesis/hfutthesis.cls
blob: 62da841bc3e2b5fcd7513dffbb955425a38b25a6 (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
%
% Copyright (C) 2015-2021 by USTC TeX Users Group <https://github.com/ustctug>
%
% hfutthesis developed by HFUT TeX Users Group <https://github.com/HFUTTUG> on the 
% base of ustcthesis <https://github.com/usthtug/ustcthesis>.
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%

\NeedsTeXFormat{LaTeX2e}[2017/04/15]
\newcommand\hfutthesisversion{v1.0.4}
\ProvidesClass{hfutthesis}[2022/04/09 {\hfutthesisversion} hfut thesis template]

% 报错和警告
\newcommand\hfut@error[1]{%
  \ClassError{hfutthesis}{#1}{}%
}
\newcommand\hfut@warning[1]{%
  \ClassWarning{hfutthesis}{#1}%
}

% 检查 \LaTeXe{} kernel 版本
\@ifl@t@r\fmtversion{2017/04/15}{}{
  \hfut@error{%
    TeX Live 2017 or later version is required to compile this document%
  }
}

% 检查编译引擎,要求使用 XeLaTeX。
\RequirePackage{iftex}
\ifXeTeX\else
  \hfut@error{XeLaTeX is required to compile this document}
\fi


% \subsection{处理选项}

\RequirePackage{kvdefinekeys}
\RequirePackage{kvsetkeys}
\RequirePackage{kvoptions}

% 提供一个 \cs{hfutsetup} 命令支持 \emph{key-value} 的方式来设置。
\let\hfut@setup@hook\@empty
\newcommand\hfutsetup[1]{%
  \let\hfut@setup@hook\@empty
  \kvsetkeys{hfut}{#1}%
  \hfut@setup@hook
}

% 同时用 \emph{key-value} 的方式来定义这些接口:
% \begin{latex}
%   \hfut@define@key{
%     <key> = {
%       name = <name>,
%       choices = {
%         <choice1>,
%         <choice2>,
%       },
%       default = <default>,
%       code = <code>,
%     },
%   }
% \end{latex}

% 其中 |choices| 设置允许使用的值,默认为第一个(或者 \meta{default});
% \meta{code} 是相应的内容被设置时执行的代码。

\newcommand\hfut@define@key[1]{%
  \kvsetkeys{hfut@key}{#1}%
}
\kv@set@family@handler{hfut@key}{%
%
% \cs{hfutsetup} 会将 \meta{value} 存到 \cs{hfut@\meta{key}},
% 但是宏的名字包含 “-” 这样的特殊字符时不方便直接调用,比如 |key = math-style|,
% 这时可以用 |name| 设置 \meta{key} 的别称,比如 |key = math@style|,
% 这样就可以通过 \cs{hfut@math@style} 来引用。
% |default| 是定义该 \meta{key} 时默认的值,缺省为空。
%
  \@namedef{hfut@#1@@name}{#1}%
  \def\hfut@@default{}%
  \def\hfut@@choices{}%
  \kv@define@key{hfut@value}{name}{%
    \@namedef{hfut@#1@@name}{##1}%
  }%
  %
  % 由于在定义接口时,\cs{hfut@\meta{key}@@code} 不一定有定义,
  % 而且在文档类/宏包中还有可能对该 |key| 的 |code| 进行添加。
  % 所以 \cs{hfut@\meta{key}@@code} 会检查如果在定义文档类/宏包时则推迟执行,否则立即执行。
  %
  \@namedef{hfut@#1@@check}{}%
  \@namedef{hfut@#1@@code}{}%
  %
  % 保存下 |choices = {}| 定义的内容,在定义 \cs{hfut@\meta{name}} 后再执行。
  %
  \kv@define@key{hfut@value}{choices}{%
    \def\hfut@@choices{##1}%
    \@namedef{hfut@#1@@reset}{}%
    %
    % \cs{hfut@\meta{key}@check} 检查 |value| 是否有效,
    % 并设置 \cs{ifhfut@\meta{name}@\meta{value}}。
    %
    \@namedef{hfut@#1@@check}{%
      \@ifundefined{%
        ifhfut@\@nameuse{hfut@#1@@name}@\@nameuse{hfut@\@nameuse{hfut@#1@@name}}%
      }{%
        \hfut@error{Invalid value "#1 = \@nameuse{hfut@\@nameuse{hfut@#1@@name}}"}%
      }%
      \@nameuse{hfut@#1@@reset}%
      \@nameuse{hfut@\@nameuse{hfut@#1@@name}@\@nameuse{hfut@\@nameuse{hfut@#1@@name}}true}%
    }%
  }%
  \kv@define@key{hfut@value}{default}{%
    \def\hfut@@default{##1}%
  }%
  \kvsetkeys{hfut@value}{#2}%
  \@namedef{hfut@\@nameuse{hfut@#1@@name}}{}%
  %
  % 第一个 \meta{choice} 设为 \meta{default},
  % 并且对每个 \meta{choice} 定义 \cs{ifhfut@\meta{name}@\meta{choice}}。
  %
  \kv@set@family@handler{hfut@choice}{%
    \ifx\hfut@@default\@empty
      \def\hfut@@default{##1}%
    \fi
    \expandafter\newif\csname ifhfut@\@nameuse{hfut@#1@@name}@##1\endcsname
    \expandafter\g@addto@macro\csname hfut@#1@@reset\endcsname{%
      \@nameuse{hfut@\@nameuse{hfut@#1@@name}@##1false}%
    }%
  }%
  \kvsetkeys@expandafter{hfut@choice}{\hfut@@choices}%
  %
  % 将 \meta{default} 赋值到 \cs{hfut@\meta{name}},如果非空则执行相应的代码。
  %
  \expandafter\let\csname hfut@\@nameuse{hfut@#1@@name}\endcsname\hfut@@default
  \expandafter\ifx\csname hfut@\@nameuse{hfut@#1@@name}\endcsname\@empty\else
    \@nameuse{hfut@#1@@check}%
  \fi
  %
  % 定义 \cs{hfutsetup} 接口。
  %
  \kv@define@key{hfut}{#1}{%
    \@namedef{hfut@\@nameuse{hfut@#1@@name}}{##1}%
    \@nameuse{hfut@#1@@check}%
    \@nameuse{hfut@#1@@code}%
  }%
}

% 定义接口向 |key| 添加 |code|:

\newcommand\hfut@option@hook[2]{%
  \expandafter\g@addto@macro\csname hfut@#1@@code\endcsname{#2}%
}

\hfut@define@key{
  degree = {
    choices = {
      doctor,
      master,
      bachelor,
    },
    default = bachelor,
  },
  degree-type = {
    name = degree@type,
    choices = {
      academic,
      professional,
    },
    default = academic,
  },
  main-language = {
    name = main@language,
    choices = {
      chinese,
      english,
    },
    default = chinese,
  },
  language = {
    choices = {
      chinese,
      english,
    },
    default = chinese,
  },
  system = {
    choices = {
      auto,
      mac,
      unix,
      windows,
    },
    default = auto,
  },
  fontset = {
    choices = {
      auto,
      windows,
      mac,
      ubuntu,
      fandol,
      none,
    },
    default = auto,
  },
  font = {
    choices = {
      auto,
      times,
      termes,
      stix,
      xits,
      libertinus,
      newcm,
      lm,
      newtx,
      none,
    },
    default = auto,
  },
  cjk-font = {
    name = cjk@font,
    choices = {
      auto,
      windows,
      mac,
      noto,
      fandol,
      none,
    },
    default = auto,
  },
  math-font = {
    name = math@font,
    choices = {
      auto,
      stix,
      xits,
      libertinus,
      newcm,
      cm,
      lm,
      newtx,
      none,
    },
    default = auto,
  },
  math-style = {
    name = math@style,
    choices = {
      GB,
      ISO,
      TeX,
    },
  },
  uppercase-greek = {
    name = uppercase@greek,
    choices = {
      italic,
      upright,
    },
  },
  less-than-or-equal = {
    name = leq,
    choices = {
      slanted,
      horizontal,
    },
  },
  integral = {
    choices = {
      upright,
      slanted,
    },
  },
  integral-limits = {
    name = integral@limits,
    choices = {
      true,
      false,
    },
  },
  partial = {
    choices = {
      upright,
      italic,
    },
  },
  math-ellipsis = {
    name = math@ellipsis,
    choices = {
      centered,
      lower,
      AMS,
    },
  },
  real-part = {
    name = real@part,
    choices = {
      roman,
      fraktur,
    },
  },
  cite-style = {
    name = cite@style,
    choices = {
      super,
      inline,
      authoryear,
    },
    default = super,
  },
  output = {
    choices = {
      print,
      electronic,
    },
    default = print,
  },
  section-style = {
    name = section@style,
    choices = {
      chinese,
      arabic,
    },
    default = chinese,
  },
  badge-color = {
    name = badge@color,
    choices = {
      red,
      black,
    },
    default = red,
  },
}

\newif\ifhfut@degree@graduate
\newcommand\hfut@set@graduate{%
  \ifhfut@degree@bachelor
    \hfut@degree@graduatefalse
  \else
    \hfut@degree@graduatetrue
  \fi
}
\hfut@set@graduate
\hfut@option@hook{degree}{%
  \hfut@set@graduate
}

% 使用 \pkg{kvoptions} 提供的 key-value 接口,
\SetupKeyvalOptions{
  family  = hfut,
  prefix  = hfut@,
  setkeys = \kvsetkeys,
}

% 设置默认 \option{openany}。
\DeclareBoolOption[false]{openright}
\DeclareComplementaryOption{openany}{openright}

% 兼容旧版本的文档类选项。
% Reserved for compatibility until 2020-07-01.
\DeclareVoidOption{doctor}{\hfutsetup{degree=doctor}}
\DeclareVoidOption{master}{\hfutsetup{degree=master}}
\DeclareVoidOption{bachelor}{\hfutsetup{degree=bachelor}}
\DeclareVoidOption{chinese}{\hfutsetup{language=chinese}}
\DeclareVoidOption{english}{\hfutsetup{language=english}}
\DeclareVoidOption{academic}{\hfutsetup{degree-type=academic}}
\DeclareVoidOption{professional}{\hfutsetup{degree-type=professional}}
\DeclareVoidOption{print}{\hfutsetup{output=print}}
\DeclareVoidOption{pdf}{\hfutsetup{output=electronic}}
\newif\ifhfut@legacy@cite@style
\DeclareVoidOption{super}{\hfutsetup{cite-style=super}\hfut@legacy@cite@styletrue}
\DeclareVoidOption{numbers}{\hfutsetup{cite-style=inline}\hfut@legacy@cite@styletrue}
\DeclareVoidOption{authoryear}{\hfutsetup{cite-style=authoryear}\hfut@legacy@cite@styletrue}
\DeclareVoidOption{arabic}{\hfutsetup{section-style=arabic}}
\DeclareVoidOption{colorlogo}{\hfutsetup{badge-color=red}}
\DeclareVoidOption{bwlogo}{\hfutsetup{badge-color=black}}

% 载入 \cls{ctexbook}。
\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ProcessKeyvalOptions*


% \subsection{加载文档类和宏包}

\ifhfut@openright
  \PassOptionsToClass{openright}{book}
\else
  \PassOptionsToClass{openany}{book}
\fi

\ifhfut@output@electronic
  \PassOptionsToClass{oneside}{book}
\fi
\PassOptionsToPackage{no-math}{fontspec}

% 载入 \cls{ctexbook} 文档类,注意要求为 2.4.9 或更高的版本。
\LoadClass[UTF8,a4paper,scheme=plain,zihao=-4,fontset=none]{ctexbook}[2017/04/01]

% 建议在模板开始处载入全部宏包,不要轻易改变加载顺序。
% \pkg{hyperref} 一般在最后加载。
\RequirePackage{etoolbox}
\RequirePackage{amsmath}
\RequirePackage{fontspec}[2017/03/31]
\RequirePackage[driver=xetex]{geometry}
\RequirePackage{graphicx}
\RequirePackage{fancyhdr}
\RequirePackage{color}
\RequirePackage{titletoc}
\RequirePackage{caption}
\RequirePackage[perpage]{footmisc}
\RequirePackage{url}
\RequirePackage{calc}
\RequirePackage[normalem]{ulem} % 提供排版可断行下划线的命令\uline
\RequirePackage{multirow} % 纵向合并单元格
\RequirePackage{enumitem} % enumberate
\RequirePackage[list=off]{bicaption} % 图表中英文标题

% 如果用户在导言区未调用 \pkg{biblatex},则自动调用 \pkg{natbib}。
\AtEndPreamble{
  \@ifpackageloaded{biblatex}{}{
    \RequirePackage{natbib}
  }
}

% 对冲突的宏包报错。
\RequirePackage{filehook}
\newcommand\hfut@package@conflict[2]{
  \AtEndOfPackageFile*{#1}{%
    \AtBeginOfPackageFile*{#2}{%
      \hfut@error{The "#2" package is incompatible with "#1"}%
    }%
  }%
}

\hfut@package@conflict{biblatex}{bibunits}
\hfut@package@conflict{biblatex}{chapterbib}
\hfut@package@conflict{biblatex}{cite}
\hfut@package@conflict{biblatex}{multibib}
\hfut@package@conflict{biblatex}{natbib}

\hfut@package@conflict{bibunits}{biblatex}
\hfut@package@conflict{bibunits}{chapterbib}
\hfut@package@conflict{bibunits}{multibib}

\hfut@package@conflict{unicode-math}{amscd}
\hfut@package@conflict{unicode-math}{amsfonts}
\hfut@package@conflict{unicode-math}{amssymb}
\hfut@package@conflict{unicode-math}{bbm}
\hfut@package@conflict{unicode-math}{bm}
\hfut@package@conflict{unicode-math}{eucal}
\hfut@package@conflict{unicode-math}{eufrak}
\hfut@package@conflict{unicode-math}{mathrsfs}
\hfut@package@conflict{unicode-math}{newtxmath}
\hfut@package@conflict{unicode-math}{upgreek}

\hfut@package@conflict{natbib}{biblatex}
\hfut@package@conflict{natbib}{cite}

\hfut@package@conflict{newtxmath}{amsfonts}
\hfut@package@conflict{newtxmath}{amssymb}
\hfut@package@conflict{newtxmath}{unicode-math}
\hfut@package@conflict{newtxmath}{upgreek}


% \pkg{mathtools} 需要在 \pkg{unicode-math} 前载入,
% 参考 \url{https://tex.stackexchange.com/q/521394/82731}。
\AtBeginOfPackageFile*{mathtools}{
  \@ifpackageloaded{unicode-math}{
    \hfut@error{The "mathtools" package should be loaded before setting "math-font"}
  }{}
}%

% \pkg{amsthm} 需要在 \pkg{newtx} 前载入,参考 \pkg{newtx} 的文档。
\AtBeginOfPackageFile*{amsthm}{
  \@ifpackageloaded{newtxmath}{
    \hfut@error{The "amsthm" package should be loaded before setting "newtxmath"}
  }{}
}%



% \subsection{处理语言}

% 定义 \cs{hfut@main@language},当在导言区修改 \option{language} 时,
% 保存为论文的主要语言;
% \cs{hfut@reset@main@language} 则用于正文中恢复为主要语言。
%    \begin{macrocode}
\hfutsetup{main-language=\hfut@language}%
\let\hfut@main@language\hfut@language

\hfut@option@hook{language}{%
  \ifx\@begindocumenthook\@undefined\else
    \hfutsetup{main-language=\hfut@language}%
    \let\hfut@main@language\hfut@language
  \fi
}
\newcommand\hfut@reset@main@language{%
  \hfutsetup{language = \hfut@main@language}%
  \let\hfut@language\hfut@main@language
}

% 带圈数字和星号使用中文字体。
\xeCJKDeclareCharClass{CJK}{"2460 -> "2473}
\xeCJKDeclareCharClass{CJK}{"2605}

% 由于 Unicode 的一些标点符号是中西文混用的:
% U+00B7、U+2013、U+2014、U+2018、U+2019、
% U+201C、U+201D、U+2025、U+2026、U+2E3A,
% 所以要根据语言设置正确的字体。
% https://github.com/CTeX-org/ctex-kit/issues/389
\newcommand\hfut@set@punctuations{%
  \ifhfut@language@chinese
    \xeCJKDeclareCharClass{FullLeft}{"2018, "201C}%
    \xeCJKDeclareCharClass{FullRight}{
      "00B7, "2019, "201D, "2013, "2014, "2025, "2026, "2E3A,
    }%
  \else
    \xeCJKDeclareCharClass{HalfLeft}{"2018, "201C}%
    \xeCJKDeclareCharClass{HalfRight}{
      "00B7, "2019, "201D, "2013, "2014, "2025, "2026, "2E3A,
    }%
  \fi
}
\hfut@set@punctuations
\hfut@option@hook{language}{\hfut@set@punctuations}

% 根据语言设置各章节的名称,只有在导言区设置 \option{language} 时会修改,
% 而在正文局部切换语言时则不变。

% 由于《撰写手册》中的“speciality”一词使用的是英式拼法,
% 所以“acknowledgements”也保持一致。
\newcommand\hfut@set@chapter@names{%
  \ifhfut@main@language@chinese
    \def\contentsname{目\hspace{\ccwd}录}%
    \def\listfigurename{插图清单}%
    \def\listtablename{表格清单}%
    \ctexset{
      chapter/name   = {第,章},
    }%
    \def\bibname{参考文献}%
    \def\appendixname{附录}%
    \ifhfut@degree@bachelor
      \def\hfut@acknowledgements@name{致谢}%
    \else
      \def\hfut@acknowledgements@name{致\hspace{\ccwd}谢}%
    \fi
    \ifhfut@degree@bachelor
      \def\hfut@publication@name{攻读学士学位期间的学术活动及成果情况}%
    \else
      \ifhfut@degree@master
        \def\hfut@publication@name{攻读硕士学位期间的学术活动及成果情况}%
      \else
        \def\hfut@publication@name{攻读博士学位期间的学术活动及成果情况}%
      \fi
    \fi
    \newcommand\hfut@notation@name{符号说明}%
  \else
    \def\contentsname{Contents}%
    \def\listfigurename{List of Figures}%
    \def\listtablename{List of Tables}%
    \ctexset{
      chapter/name   = {\chaptername\space},
    }%
    \def\bibname{Bibliography}%
    \def\appendixname{Appendix}%
    \def\hfut@acknowledgements@name{Acknowledgements}%
    \def\hfut@publication@name{Publications}%
    \def\hfut@notation@name{Notation}%
  \fi
}
\hfut@set@chapter@names
\hfut@option@hook{main-language}{\hfut@set@chapter@names}

% 这部分名称在正文中局部地修改语言时会发生变化。
\newcommand\hfut@set@names{%
  \ifhfut@language@chinese
    \def\figurename{图}%
    \def\tablename{表}%
  \else
    \def\figurename{Fig}%
    \def\tablename{Tab}%
  \fi
}
\hfut@set@names
\hfut@option@hook{language}{\hfut@set@names}


% \subsection{字体}

% 字号

% 正文字号12bp,研究生行距20bp,本科生行距22bp;
% 其他命令的行距按照相同的的比例设置,如表~\ref{tab:fontsize}。
% \begin{table}[htb]
%   \centering
%   \caption{标准字体命令与字号、行距的对应}
%   \label{tab:fontsize}
%   \begin{tabular}{lllll}
%     \toprule
%     字体命令          & 字号 & bp   & 研究生行距 & 本科生行距 \\
%     \midrule
%     \cs{tiny}         & 小六 & 6.5  & 10.83      & 11.92      \\
%     \cs{scriptsize}   & 六号 & 7.5  & 12.5       & 13.75      \\
%     \cs{footnotesize} & 小五 & 9    & 15         & 16.5       \\
%     \cs{small}        & 五号 & 10.5 & 17.5       & 19.25      \\
%     \cs{normalsize}   & 小四 & 12   & 20         & 22         \\
%     \cs{large}        & 小三 & 15   & 25         & 27.5       \\
%     \cs{Large}        & 小二 & 18   & 30         & 33         \\
%     \cs{LARGE}        & 二号 & 22   & 36.67      & 40.33      \\
%     \cs{huge}         & 小一 & 24   & 40         & 44         \\
%     \cs{Huge}         & 一号 & 26   & 43.33      & 47.67      \\
%     \bottomrule
%   \end{tabular}
% \end{table}
%
% 注意重定义 \normalsize 应在 \pkg{unicode-math} 的 \cs{setmathfont} 前。
\newcommand\hfut@set@font@size{%
  \ifhfut@degree@graduate
    \renewcommand\normalsize{%
      \@setfontsize\normalsize{12bp}{20bp}%
      \abovedisplayskip 12bp \@plus3bp \@minus7bp%
      \abovedisplayshortskip \z@ \@plus3bp%
      \belowdisplayshortskip 6.5bp \@plus3.5bp \@minus3bp%
      \belowdisplayskip \abovedisplayskip
      \let\@listi\@listI}%
    %
    % 注意第~\ref{sec:list} 节去掉了列表的间距,所以不再修改 \cs{@listi}。
  \else
    \renewcommand\normalsize{%
      \@setfontsize\normalsize{12bp}{22bp}%
      \abovedisplayskip 12bp \@plus3bp \@minus7bp%
      \abovedisplayshortskip \z@ \@plus3bp%
      \belowdisplayshortskip 6.5bp \@plus3.5bp \@minus3bp%
      \belowdisplayskip \abovedisplayskip
      \let\@listi\@listI}%
  \fi
  \normalsize
  \ifx\MakeRobust\@undefined \else
      \MakeRobust\normalsize
  \fi
}
\hfut@set@font@size
\hfut@option@hook{degree}{\hfut@set@font@size}

% 设置行距的倍数为 1。
\linespread{1}\selectfont


% 检测系统
\ifhfut@system@auto
  \IfFileExists{/System/Library/Fonts/Menlo.ttc}{
    \hfutsetup{system = mac}
  }{
    \IfFileExists{/dev/null}{
      \IfFileExists{null:}{
        \hfutsetup{system = windows}
      }{
        \hfutsetup{system = unix}
      }
    }{
      \hfutsetup{system = windows}
    }
  }
\fi

% 处理 \opt{fontset}
\ifhfut@fontset@auto
  \ifhfut@system@windows
    \hfutsetup{fontset = windows}
  \else
    \ifhfut@system@mac
      \hfutsetup{fontset = mac}
    \else
      \IfFontExistsTF{Noto Serif CJK SC}{
        \hfutsetup{fontset = ubuntu}
      }{
        \hfutsetup{fontset = fandol}
      }
    \fi
  \fi
\fi

% 《撰写手册》要求西文字体使用 Times New Roman 和 Arial,
% 但是在 Linux 下没有这两个字体,所以使用它们的克隆版 TeX Gyre Termes 和
% TeX Gyre Heros。
\ifhfut@font@auto
  \ifhfut@fontset@windows
    \hfutsetup{font=times}
  \else
    \ifhfut@fontset@mac
      \hfutsetup{font=times}
    \else
      \hfutsetup{font=termes}
    \fi
  \fi
\fi

% Times New Roman + Arial
\newcommand\hfut@set@font@times{%
  \setmainfont{Times New Roman}%
  \setsansfont{Arial}%
  \ifhfut@system@mac
    \setmonofont{Menlo}[Scale = MatchLowercase]%
  \else
    \setmonofont{Courier New}[Scale = MatchLowercase]%
  \fi
}

% TeX Gyre Termes
\newcommand\hfut@set@font@termes{%
  \setmainfont{texgyretermes}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-italic,
    BoldItalicFont = *-bolditalic,
  ]%
  \hfut@set@texgyre@sans@mono
}

\newcommand\hfut@set@texgyre@sans@mono{%
  \setsansfont{texgyreheros}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-italic,
    BoldItalicFont = *-bolditalic,
  ]%
  \setmonofont{texgyrecursor}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-italic,
    BoldItalicFont = *-bolditalic,
    Scale          = MatchLowercase,
    Ligatures      = CommonOff,
  ]%
}

% STIX Two 字体。
% STIX 文件名在 v2.10 2020-12-19 从
% \file{STIX2Text-Regular.otf}、\file{STIX2Math.otf} 分别改为
% \file{STIXTwoText-Regular.otf}、\file{STIXTwoMath-Regular.otf}。
\let\hfut@font@family@stix\@empty
\newcommand\hfut@set@stix@names{%
  \ifx\hfut@font@family@stix\@empty
    \IfFontExistsTF{STIXTwoText-Regular.otf}{%
      \gdef\hfut@font@family@stix{STIXTwoText}%
      \gdef\hfut@font@name@stix@math{STIXTwoMath-Regular}%
    }{%
      \gdef\hfut@font@family@stix{STIX2Text}%
      \gdef\hfut@font@name@stix@math{STIX2Math}%
    }%
  \fi
}

\newcommand\hfut@set@font@stix{%
  \hfut@set@stix@names
  \setmainfont{\hfut@font@family@stix}[
    Extension      = .otf,
    UprightFont    = *-Regular,
    BoldFont       = *-Bold,
    ItalicFont     = *-Italic,
    BoldItalicFont = *-BoldItalic,
  ]%
  \hfut@set@texgyre@sans@mono
}

% XITS 字体。
% XITS 的文件名在 v1.109 2018-09-30
% 从 \file{xits-regular.otf}、\file{xits-math.otf} 分别改为
% \file{XITS-Regular.otf}、\file{XITSMath-Regular.otf}。
\let\hfut@font@family@xits\@empty
\newcommand\hfut@set@xits@names{%
  \ifx\hfut@font@family@xits\@empty
    \IfFontExistsTF{XITSMath-Regular.otf}{%
      \gdef\hfut@font@family@xits{XITS}%
      \gdef\hfut@font@style@xits@rm{Regular}%
      \gdef\hfut@font@style@xits@bf{Bold}%
      \gdef\hfut@font@style@xits@it{Italic}%
      \gdef\hfut@font@style@xits@bfit{BoldItalic}%
      \gdef\hfut@font@name@xits@math{XITSMath-Regular}%
    }{%
      \gdef\hfut@font@family@xits{xits}%
      \gdef\hfut@font@style@xits@rm{regular}%
      \gdef\hfut@font@style@xits@bf{bold}%
      \gdef\hfut@font@style@xits@it{italic}%
      \gdef\hfut@font@style@xits@bfit{bolditalic}%
      \gdef\hfut@font@name@xits@math{xits-math}%
    }%
  \fi
}

\newcommand\hfut@set@font@xits{%
  \hfut@set@xits@names
  \setmainfont{\hfut@font@family@xits}[
    Extension      = .otf,
    UprightFont    = *-\hfut@font@style@xits@rm,
    BoldFont       = *-\hfut@font@style@xits@bf,
    ItalicFont     = *-\hfut@font@style@xits@it,
    BoldItalicFont = *-\hfut@font@style@xits@bfit,
  ]%
  \hfut@set@texgyre@sans@mono
}

% Libertinus 的文件名在 v6.7 2019-04-03 从小写改为驼峰式,
% 在大小写敏感的平台上需要进行判断。
\let\hfut@font@family@libertinus\@empty
\newcommand\hfut@set@libertinus@names{%
  \ifx\hfut@font@family@libertinus\@empty
    \IfFontExistsTF{LibertinusSerif-Regular.otf}{%
      \gdef\hfut@font@family@libertinus@serif{LibertinusSerif}%
      \gdef\hfut@font@family@libertinus@sans{LibertinusSans}%
      \gdef\hfut@font@name@libertinus@math{LibertinusMath-Regular}%
      \gdef\hfut@font@style@libertinus@rm{Regular}%
      \gdef\hfut@font@style@libertinus@bf{Bold}%
      \gdef\hfut@font@style@libertinus@it{Italic}%
      \gdef\hfut@font@style@libertinus@bfit{BoldItalic}%
    }{%
      \gdef\hfut@font@family@libertinus@serif{libertinusserif}%
      \gdef\hfut@font@family@libertinus@sans{libertinussans}%
      \gdef\hfut@font@name@libertinus@math{libertinusmath-regular}%
      \gdef\hfut@font@style@libertinus@rm{regular}%
      \gdef\hfut@font@style@libertinus@bf{bold}%
      \gdef\hfut@font@style@libertinus@it{italic}%
      \gdef\hfut@font@style@libertinus@bfit{bolditalic}%
    }%
  \fi
}

\newcommand\hfut@set@font@libertinus{%
  \hfut@set@libertinus@names
  \setmainfont{\hfut@font@family@libertinus@serif}[
    Extension      = .otf,
    UprightFont    = *-\hfut@font@style@libertinus@rm,
    BoldFont       = *-\hfut@font@style@libertinus@bf,
    ItalicFont     = *-\hfut@font@style@libertinus@it,
    BoldItalicFont = *-\hfut@font@style@libertinus@bfit,
  ]%
  \setsansfont{\hfut@font@family@libertinus@sans}[
    Extension      = .otf,
    UprightFont    = *-\hfut@font@style@libertinus@rm,
    BoldFont       = *-\hfut@font@style@libertinus@bf,
    ItalicFont     = *-\hfut@font@style@libertinus@it,
  ]%
  \setmonofont{lmmonolt10}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-oblique,
    BoldItalicFont = *-boldoblique,
  ]%
}

% New Computer Modern
\newcommand\hfut@set@font@newcm{%
  \setmainfont{NewCM10}[
    Extension      = .otf,
    UprightFont    = *-Book,
    BoldFont       = *-Bold,
    ItalicFont     = *-BookItalic,
    BoldItalicFont = *-BoldItalic,
  ]%
  \setsansfont{NewCMSans10}[
    Extension         = .otf,
    UprightFont       = *-Book,
    BoldFont          = *-Bold,
    ItalicFont        = *-BookOblique,
    BoldItalicFont    = *-BoldOblique,
  ]%
  \setmonofont{NewCMMono10}[
    Extension           = .otf,
    UprightFont         = *-Book,
    ItalicFont          = *-BookItalic,
    BoldFont            = *-Bold,
    BoldItalicFont      = *-BoldOblique,
  ]%
}

% Latin Modern
\newcommand\hfut@set@font@lm{%
  \setmainfont{lmroman10}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-italic,
    BoldItalicFont = *-bolditalic,
  ]%
  \setsansfont{lmsans10}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-oblique,
    BoldItalicFont = *-boldoblique,
  ]%
  \setmonofont{lmmonolt10}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-oblique,
    BoldItalicFont = *-boldoblique,
  ]%
}

\newcommand\hfut@set@font@newtx{%
  \RequirePackage{newtxtext}%
}

\newcommand\hfut@set@font{%
  \@nameuse{hfut@set@font@\hfut@font}%
}
\hfut@set@font
\hfut@option@hook{font}{\hfut@set@font}

% 中文字体
\ifhfut@cjk@font@auto
  \ifhfut@fontset@mac
    \hfutsetup{cjk-font = mac}
  \else
    \ifhfut@fontset@windows
      \hfutsetup{cjk-font = windows}
    \else
      \ifhfut@fontset@ubuntu
        \hfutsetup{cjk-font = noto}
      \else
        \hfutsetup{cjk-font = fandol}
      \fi
    \fi
  \fi
\fi

% Windows 的中易字体。
\newcommand\hfut@set@cjk@font@windows{%
  \xeCJKsetup{EmboldenFactor=2}
  \setCJKmainfont{SimSun}[
    AutoFakeBold = true,
    ItalicFont   = KaiTi,
  ]%
  \setCJKsansfont{SimHei}[AutoFakeBold]%
  \setCJKmonofont{FangSong}%
  \setCJKfamilyfont{zhsong}{SimSun}[AutoFakeBold]%
  \setCJKfamilyfont{zhhei}{SimHei}[AutoFakeBold]%
  \setCJKfamilyfont{zhkai}{KaiTi}%
  \setCJKfamilyfont{zhfs}{FangSong}%
}

% macOS 的华文字体。
\newcommand\hfut@set@cjk@font@mac{%
  \defaultCJKfontfeatures{}%
  \setCJKmainfont{Songti SC}[
    UprightFont    = * Light,
    BoldFont       = * Bold,
    ItalicFont     = Kaiti SC Regular,
    BoldItalicFont = Kaiti SC Bold,
  ]%
  \setCJKsansfont{Heiti SC}[
    UprightFont    = * Light,
    BoldFont       = * Medium,
  ]%
  \setCJKmonofont{STFangsong}
  \setCJKfamilyfont{zhsong}{Songti SC}[
    UprightFont    = * Light,
    BoldFont       = * Bold,
  ]%
  \setCJKfamilyfont{zhhei}{Heiti SC}[
    UprightFont    = * Light,
    BoldFont       = * Medium,
  ]%
  \setCJKfamilyfont{zhfs}{STFangsong}%
  \setCJKfamilyfont{zhkai}{Kaiti SC}[
    UprightFont    = * Regular,
    BoldFont       = * Bold,
  ]%
  \setCJKfamilyfont{zhli}{Baoli SC}%
  \setCJKfamilyfont{zhyuan}{Yuanyi SC}[
    UprightFont    = * Light,
    BoldFont       = * Bold,
  ]%
}

% 思源字体。
% 注意 Noto CJK 的 regular 字重名字不带“Regular”。
\newcommand\hfut@set@cjk@font@noto{%
  \defaultCJKfontfeatures{}%
  \setCJKmainfont{Noto Serif CJK SC}[
    UprightFont    = * Light,
    BoldFont       = * Bold,
    ItalicFont     = FandolKai-Regular,
    ItalicFeatures = {Extension = .otf},
    Script         = CJK,
  ]%
  \setCJKsansfont{Noto Sans CJK SC}[
    BoldFont       = * Medium,
    Script         = CJK,
  ]%
  \setCJKmonofont{Noto Sans Mono CJK SC}[
    Script         = CJK,
  ]%
  \setCJKfamilyfont{zhsong}{Noto Serif CJK SC}[
    UprightFont    = * Light,
    UprightFont    = * Bold,
    Script         = CJK,
  ]%
  \setCJKfamilyfont{zhhei}{Noto Sans CJK SC}[
    BoldFont       = * Medium,
    Script         = CJK,
  ]%
  \setCJKfamilyfont{zhfs}{FandolFang}[
    Extension      = .otf,
    UprightFont    = *-Regular,
  ]%
  \setCJKfamilyfont{zhkai}{FandolKai}[
    Extension      = .otf,
    UprightFont    = *-Regular,
  ]%
}

% Fandol 字体。
\newcommand\hfut@set@cjk@font@fandol{%
  \defaultCJKfontfeatures{}%
  \setCJKmainfont{FandolSong}[
    Extension   = .otf,
    UprightFont = *-Regular,
    BoldFont    = *-Bold,
    ItalicFont  = FandolKai-Regular,
    ItalicFeatures = {Extension = .otf},
  ]%
  \setCJKsansfont{FandolHei}[
    Extension   = .otf,
    UprightFont = *-Regular,
    BoldFont    = *-Bold,
  ]%
  \setCJKmonofont{FandolFang}[
    Extension   = .otf,
    UprightFont = *-Regular,
  ]%
  \setCJKfamilyfont{zhsong}{FandolSong}[
    Extension   = .otf,
    UprightFont = *-Regular,
    BoldFont    = *-Bold,
  ]%
  \setCJKfamilyfont{zhhei}{FandolHei}[
    Extension   = .otf,
    UprightFont = *-Regular,
    BoldFont    = *-Bold,
  ]%
  \setCJKfamilyfont{zhfs}{FandolFang}[
    Extension   = .otf,
    UprightFont = *-Regular,
  ]%
  \setCJKfamilyfont{zhkai}{FandolKai}[
    Extension   = .otf,
    UprightFont = *-Regular,
  ]%
}

\ifhfut@cjk@font@none\else
  \providecommand\songti{\CJKfamily{zhsong}}
  \providecommand\heiti{\CJKfamily{zhhei}}
  \providecommand\fangsong{\CJKfamily{zhfs}}
  \providecommand\kaishu{\CJKfamily{zhkai}}
\fi

\newcommand\hfut@set@cjk@font{%
  \@nameuse{hfut@set@cjk@font@\hfut@cjk@font}%
}
\hfut@set@cjk@font
\hfut@option@hook{cjk-font}{\hfut@set@cjk@font}

% 数学字体

% 设置数学符号风格。
\newcommand\hfut@set@math@style{%
  \ifhfut@math@style@TeX
    \hfutsetup{
      uppercase-greek    = upright,
      less-than-or-equal = horizontal,
      integral           = slanted,
      integral-limits    = false,
      partial            = italic,
      math-ellipsis      = AMS,
      real-part          = fraktur,
    }%
  \else
    \hfutsetup{
      uppercase-greek = italic,
      integral        = upright,
      integral-limits = true,
      partial         = upright,
      real-part       = roman,
    }%
    \ifhfut@math@style@ISO
      \hfutsetup{
        less-than-or-equal = horizontal,
        math-ellipsis      = lower,
      }%
    \else
      \ifhfut@math@style@GB
        \hfutsetup{
          less-than-or-equal = slanted,
          math-ellipsis      = centered,
        }%
      \fi
    \fi
  \fi
}

\ifhfut@main@language@chinese
  \hfutsetup{math-style = GB}%
\else
  \hfutsetup{math-style = TeX}%
\fi

\hfut@set@math@style
\hfut@option@hook{math-style}{\hfut@set@math@style}
\hfut@option@hook{main-language}{%
  \ifhfut@main@language@chinese
    \hfutsetup{math-style = GB}%
  \else
    \hfutsetup{math-style = TeX}%
  \fi
}

% 针对 \pkg{unicode-math} 逐项配置数学符号。

\newcommand\hfut@set@unimath@leq{%
  \ifhfut@leq@horizontal
    \ifx\@begindocumenthook\@undefined
      \let\le\hfut@save@leq
      \let\ge\hfut@save@geq
      \let\leq\hfut@save@leq
      \let\geq\hfut@save@geq
    \else
      \AtBeginDocument{%
        \let\le\hfut@save@leq
        \let\ge\hfut@save@geq
        \let\leq\hfut@save@leq
        \let\geq\hfut@save@geq
      }%
    \fi
  \else
    \ifhfut@leq@slanted
      \ifx\@begindocumenthook\@undefined
        \let\le\leqslant
        \let\ge\geqslant
        \let\leq\leqslant
        \let\geq\geqslant
      \else
        \AtBeginDocument{%
          \let\le\leqslant
          \let\ge\geqslant
          \let\leq\leqslant
          \let\geq\geqslant
        }%
      \fi
    \fi
  \fi
}
\newcommand\hfut@set@unimath@integral@limits{%
  \ifhfut@integral@limits@true
    \removenolimits{%
      \int\iint\iiint\iiiint\oint\oiint\oiiint
      \intclockwise\varointclockwise\ointctrclockwise\sumint
      \intbar\intBar\fint\cirfnint\awint\rppolint
      \scpolint\npolint\pointint\sqint\intlarhk\intx
      \intcap\intcup\upint\lowint
    }%
  \else
    \addnolimits{%
      \int\iint\iiint\iiiint\oint\oiint\oiiint
      \intclockwise\varointclockwise\ointctrclockwise\sumint
      \intbar\intBar\fint\cirfnint\awint\rppolint
      \scpolint\npolint\pointint\sqint\intlarhk\intx
      \intcap\intcup\upint\lowint
    }%
  \fi
}
\newcommand\hfut@set@unimath@ellipsis{%
  \ifhfut@math@ellipsis@centered
    \DeclareRobustCommand\mathellipsis{\mathinner{\unicodecdots}}%
  \else
    \DeclareRobustCommand\mathellipsis{\mathinner{\unicodeellipsis}}%
  \fi
}
\newcommand\hfut@set@unimath@real@part{%
  \ifhfut@real@part@roman
    \AtBeginDocument{%
      \def\Re{\operatorname{Re}}%
      \def\Im{\operatorname{Im}}%
    }%
  \else
    \AtBeginDocument{%
      \let\Re\hfut@save@Re
      \let\Im\hfut@save@Im
    }%
  \fi
}

\newcommand\hfut@set@unimath@style{%
  \ifhfut@uppercase@greek@upright
    \unimathsetup{math-style = TeX}%
  \else
    \ifhfut@uppercase@greek@italic
      \unimathsetup{math-style = ISO}%
    \fi
  \fi
  \ifhfut@math@style@TeX
    \unimathsetup{bold-style = TeX}%
  \else
    \unimathsetup{bold-style = ISO}%
  \fi
  \hfut@set@unimath@leq
  \hfut@set@unimath@integral@limits
  \ifhfut@partial@upright
    \unimathsetup{partial = upright}%
  \else
    \ifhfut@partial@italic
      \unimathsetup{partial = italic}%
    \fi
  \fi
  \hfut@set@unimath@ellipsis
  \hfut@set@unimath@real@part
}

\newcommand\hfut@qed{\rule{1ex}{1ex}}
\newcommand\hfut@load@unimath{%
  \@ifpackageloaded{unicode-math}{}{%
    \RequirePackage{unicode-math}%
    \AtBeginDocument{%
      \let\hfut@save@leq\leq
      \let\hfut@save@geq\geq
      \let\hfut@save@Re\Re
      \let\hfut@save@Im\Im
    }%
    %
    % 兼容旧的粗体命令:\pkg{bm} 的 \cs{bm} 和 \pkg{amsmath} 的 \cs{boldsymbol}。
    \DeclareRobustCommand\bm[1]{{\symbfit{##1}}}%
    \DeclareRobustCommand\boldsymbol[1]{{\symbfit{##1}}}%
    %
    % 兼容 \pkg{amsfonts} 和 \pkg{amssymb} 中的一些命令。
    \newcommand\square{\mdlgwhtsquare}%
    \newcommand\blacksquare{\mdlgblksquare}%
    \AtBeginDocument{%
      \renewcommand\checkmark{\ensuremath{✓}}%
    }%
    %
    % 兼容 \pkg{amsthm} 的 \cs{qedsymbol}。
    \renewcommand\hfut@qed{\ensuremath{\QED}}%
  }%
}

% STIX Two Math
\newcommand\hfut@set@math@font@stix{%
  \hfut@load@unimath
  \hfut@set@unimath@style
  \hfut@set@stix@names
  \setmathfont{\hfut@font@name@stix@math}[
    Extension    = .otf,
    StylisticSet = \hfut@xits@integral@stylistic@set,
  ]%
  \setmathfont{\hfut@font@name@stix@math}[
    Extension    = .otf,
    StylisticSet = 1,
    range        = {scr,bfscr},
  ]%
}

% XITS Math
\newcommand\hfut@xits@integral@stylistic@set{%
  \ifhfut@integral@upright
    8%
  \fi
}
\newcommand\hfut@set@math@font@xits{%
  \hfut@load@unimath
  \hfut@set@unimath@style
  \hfut@set@xits@names
  \setmathfont{\hfut@font@name@xits@math}[
    Extension    = .otf,
    StylisticSet = \hfut@xits@integral@stylistic@set,
  ]%
  \setmathfont{\hfut@font@name@xits@math}[
    Extension    = .otf,
    StylisticSet = 1,
    range        = {cal,bfcal},
  ]%
}

% Libertinus Math
\newcommand\hfut@libertinus@integral@stylistic@set{%
  \ifhfut@integral@slanted
    8%
  \fi
}
\newcommand\hfut@set@math@font@libertinus{%
  \hfut@load@unimath
  \hfut@set@unimath@style
  \hfut@set@libertinus@names
  \hfut@set@xits@names
  \setmathfont{\hfut@font@name@libertinus@math}[
    Extension    = .otf,
    StylisticSet = \hfut@libertinus@integral@stylistic@set,
  ]%
  \setmathfont{\hfut@font@name@xits@math}[
    Extension    = .otf,
    range        = {\checkmark},
  ]%
}

% New Computer Modern Math
\newcommand\hfut@newcm@integral@stylistic@set{%
  \ifhfut@integral@upright
    2%
  \fi
}
\newcommand\hfut@set@math@font@newcm{%
  \hfut@load@unimath
  \hfut@set@unimath@style
  \setmathfont{NewCMMath-Book}[
    Extension    = .otf,
    StylisticSet = \hfut@newcm@integral@stylistic@set,
  ]%
  \setmathfont{NewCMMath-Book}[
    Extension    = .otf,
    StylisticSet = 1,
    range        = {scr,bfscr},
  ]%
  \setmathrm{NewCM10}[
    Extension      = .otf,
    UprightFont    = *-Book,
    BoldFont       = *-Bold,
    ItalicFont     = *-BookItalic,
    BoldItalicFont = *-BoldItalic,
  ]%
  \setmathsf{NewCMSans10}[
    Extension         = .otf,
    UprightFont       = *-Book,
    BoldFont          = *-Bold,
    ItalicFont        = *-BookOblique,
    BoldItalicFont    = *-BoldOblique,
  ]%
  \setmathtt{NewCMMono10}[
    Extension           = .otf,
    UprightFont         = *-Book,
    ItalicFont          = *-BookItalic,
    BoldFont            = *-Bold,
    BoldItalicFont      = *-BoldOblique,
  ]%
}

% Latin Modern Math
\newcommand\hfut@set@math@font@lm{%
  \hfut@load@unimath
  \hfut@set@unimath@style
  \setmathfont{latinmodern-math}[Extension=.otf]%
  \setmathrm{lmroman10}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-italic,
    BoldItalicFont = *-bolditalic,
  ]%
  \setmathsf{lmsans10}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-oblique,
    BoldItalicFont = *-boldoblique,
  ]%
  \setmathtt{lmmonolt10}[
    Extension      = .otf,
    UprightFont    = *-regular,
    BoldFont       = *-bold,
    ItalicFont     = *-oblique,
    BoldItalicFont = *-boldoblique,
  ]%
}

% NewTX Math
% 注意 NewTX Math 是 Type 1 字体,如果正文西文使用了 OpenType 字体时需要小心处理。
\newcommand\hfut@set@math@font@newtx{%
  \ifhfut@font@newtx\else
    \let\hfut@save@encodingdefault\encodingdefault
    \let\hfut@save@rmdefault\rmdefault
    \let\hfut@save@sfdefault\sfdefault
    \let\hfut@save@ttdefault\ttdefault
    \RequirePackage[T1]{fontenc}%
    \renewcommand{\rmdefault}{ntxtlf}%
    \renewcommand{\sfdefault}{qhv}%
    \renewcommand{\ttdefault}{ntxtt}%
  \fi
  \ifhfut@uppercase@greek@italic
    \PassOptionsToPackage{slantedGreek}{newtxmath}%
  \fi
  \ifhfut@integral@upright
    \PassOptionsToPackage{upint}{newtxmath}%
  \fi
  \RequirePackage{newtxmath}
  \let\hfut@save@leq\leq
  \let\hfut@save@geq\geq
  \ifhfut@leq@slanted
    \let\le\leqslant
    \let\ge\geqslant
    \let\leq\leqslant
    \let\geq\geqslant
  \fi
  \ifhfut@integral@limits@true
    \let\ilimits@\displaylimits
  \fi
  \let\hfut@save@partial\partial
  \ifhfut@partial@upright
    \let\partial\uppartial
  \fi
  \ifhfut@math@ellipsis@centered
    \DeclareRobustCommand\mathellipsis{\mathinner{\cdotp\cdotp\cdotp}}%
  \else
    \DeclareRobustCommand\mathellipsis{\mathinner{\ldotp\ldotp\ldotp}}%
  \fi
  \let\hfut@save@Re\Re
  \let\hfut@save@Im\Im
  \ifhfut@real@part@roman
    \def\Re{\operatorname{Re}}%
    \def\Im{\operatorname{Im}}%
  \fi
  \RequirePackage{bm}%
  \ifhfut@font@newtx\else
    \let\encodingdefault\hfut@save@encodingdefault
    \let\rmdefault\hfut@save@rmdefault
    \let\sfdefault\hfut@save@sfdefault
    \let\ttdefault\hfut@save@ttdefault
  \fi
  \DeclareRobustCommand\symup[1]{{\mathrm{##1}}}%
  \DeclareRobustCommand\symbf[1]{{\bm{##1}}}%
  \DeclareRobustCommand\symbfsf[1]{{\bm{##1}}}%
  \let\increment\upDelta%
  \renewcommand\hfut@qed{\openbox}%
}

% Computer Modern
% 使用 LaTeX 默认的 cm 字体
\newcommand\hfut@set@math@font@cm{%
  \RequirePackage{amssymb}
  \let\hfut@save@leq\leq
  \let\hfut@save@geq\geq
  \ifhfut@leq@slanted
    \let\le\leqslant
    \let\ge\geqslant
    \let\leq\leqslant
    \let\geq\geqslant
  \fi
  \ifhfut@integral@limits@true
    \let\ilimits@\displaylimits
  \fi
  \ifhfut@math@ellipsis@centered
    \DeclareRobustCommand\mathellipsis{\mathinner{\cdotp\cdotp\cdotp}}%
  \else
    \DeclareRobustCommand\mathellipsis{\mathinner{\ldotp\ldotp\ldotp}}%
  \fi
  \let\hfut@save@Re\Re
  \let\hfut@save@Im\Im
  \ifhfut@real@part@roman
    \def\Re{\operatorname{Re}}%
    \def\Im{\operatorname{Im}}%
  \fi
  \RequirePackage{bm}%
  \DeclareRobustCommand\symup[1]{{\mathrm{##1}}}%
  \DeclareRobustCommand\symbf[1]{{\bm{##1}}}%
  \DeclareRobustCommand\symbfsf[1]{{\bm{##1}}}%
  \let\increment\Delta
  \renewcommand\hfut@qed{\openbox}%
  \let\uppi\pi
}

% 不设置数学字体,仅提供兼容支持。
\newcommand\hfut@set@math@font@none{%
  \RequirePackage{amssymb}
  \RequirePackage{bm}%
  \DeclareRobustCommand\symup[1]{{\mathrm{##1}}}%
  \DeclareRobustCommand\symbf[1]{{\bm{##1}}}%
  \DeclareRobustCommand\symbfsf[1]{{\bm{##1}}}%
  \let\increment\Delta
  \renewcommand\hfut@qed{\openbox}%
  \let\uppi\pi
}

\newcommand\hfut@set@math@font{%
  \@nameuse{hfut@set@math@font@\hfut@math@font}%
}
\hfut@option@hook{math-font}{\g@addto@macro\hfut@setup@hook{\hfut@set@math@font}}
\newcommand\hfut@set@math@font@auto{%
  \ifhfut@math@font@auto
    \hfutsetup{math-font=xits}%
  \fi
}
\AtBeginOfPackageFile*{siunitx}{\hfut@set@math@font@auto}
\AtEndPreamble{%
  \hfut@set@math@font@auto
  \ifx\square\@undefined
    \RequirePackage{amssymb}%
  \fi
}



% \subsection{纸张和页面}
% 使用 \pkg{geometry} 宏包设置纸张和页面。

% 纸张:A4;

% 页面设置:上、下 2.54 cm,左、右 3 cm,页眉 1.5 cm,页脚 1.5 cm。

% 注意这里指的是页眉顶部到纸张顶部的距离为 1.5 cm,
% 所以应该是 2.54cm - 0.75cm - 0.29cm = 1.5cm
% 页脚 同理 2.54cm - 1.04cm = 1.5cm

\geometry{
  paper      = a4paper,
  vmargin    = 2.54cm,
  hmargin    = 3cm,
  headheight = 0.75cm,
  headsep    = 0.29cm,
  footskip   = 1.04cm,
}

% 使用 \pkg{fancy} 需要先调用 |\pagestyle{fancy}| 再修改 \cs{chaptermark} 和
% \cs{sectionmark}。
\pagestyle{fancy}
\let\sectionmark\@gobble
\renewcommand\headrulewidth{0.4\p@}
% 重定义默认的 |myheadings| page style,会显示页眉和页脚。
\fancypagestyle{myheadings}{%
  \fancyhf{}%
  %
  % 页眉与该部分的章标题相同,宋体 10.5 磅(五号)居中、1.5倍行距。
  % 页码:宋体 10.5 磅、页面下脚居中。
  % 页眉上下页边距1.5 cm
  \def\hfut@hf@font{\fontsize{10.5bp}{20.475bp}\selectfont}
  \renewcommand\headrulewidth{0.4\p@}
  \ifhfut@degree@graduate
    
    \fancyhead[OC]{\hfut@hf@font\leftmark}%
    \ifhfut@degree@doctor
      \fancyhead[EC]{\hfut@hf@font 合肥工业大学博士研究生学位论文}%
    \else
      \fancyhead[EC]{\hfut@hf@font 合肥工业大学\hfut@degreetype@name 研究生学位论文}%
    \fi
    \fancyfoot[C]{\hfut@hf@font\thepage}%
    \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markboth{\CTEXifname{\CTEXthechapter\quad}{}\hfut@spacetitle{##1}}{}%
    }%
    \let\sectionmark\@gobble
  \else
    %
    % 本科生要求在正文每面上部加页眉,
    % 用五号字(10.5 bp)标注“合肥工业大学毕业设计(论文)”,居中;
    % 从正文页开始在每面底部居中用小五宋体(10.5 bp)连续编页码。
    \fancyhead[C]{\hfut@hf@font 合肥工业大学毕业设计(论文)}%
    \fancyfoot[C]{\hfut@hf@font\thepage}%
    \let\@mkboth\@gobbletwo
    \let\chaptermark\@gobble
    \let\sectionmark\@gobble
  \fi
}
\pagestyle{myheadings}

% |headings| 只有页眉,没有页脚,用于研究生的符号说明和本科生的 front matter。
\fancypagestyle{headings}{
  \fancyfoot{}
}

% 重定义|plain|字体大小
\fancypagestyle{plain}{%
  \fancyhf{}
  \fancyhead{}
  \renewcommand\headrulewidth{0pt}
  \def\hfut@hf@font{\fontsize{10.5bp}{20.475bp}\selectfont}
  \fancyfoot[C]{\hfut@hf@font\thepage}%
}

% 设置特殊的 page style 不改变任何内容,用于每章首页。
\def\ps@chapter{}
\ctexset{chapter/pagestyle=chapter}

% 空白页不加页眉和页码。
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
  \hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
  %
  % 研究生要求从“中文摘要”开始页码用大写罗马数字,
  % 而本科生的 frontmatter不编页码,从正文开始页码用阿拉伯数字。
\renewcommand\frontmatter{%
  \cleardoublepage
  \@mainmatterfalse
  \pagestyle{plain}%
  \pagenumbering{Roman}%
}

% 研究生要求“第 1 章”要另页起,但是本科生要求另面起。
\renewcommand\mainmatter{%
  \ifhfut@degree@graduate
    \cleardoublepage
    \pagenumbering{arabic}%
  \else
    \clearpage
    \pagenumbering{arabic}%
  \fi
  \pagestyle{myheadings}%
  \@mainmattertrue
}

% 研究生要求"参考文献"起 无页眉,但是本科生仍然有页眉。
\renewcommand\backmatter{%
  \ifhfut@degree@graduate
    \clearpage
    \pagestyle{plain}%
  \else
    \clearpage
  \fi
  \hfut@appendixfalse
}

\g@addto@macro\appendix{
  \renewcommand\thechapter{\@arabic\c@chapter}
  \@mainmattertrue
  \hfut@appendixtrue
}%
% \subsection{附录}
% fakeTODO 处理附录编号问题
% 研究生附录按照附录1、附录2编号;[数学学院本科生附录不编号,请将以下`\renewcommand\appendix` 取消注释]
% \renewcommand\appendix{%
%   \ifhfut@degree@bachelor
%     \ctexset{
%       chapter/numbering=false,
%       chapter/format = \centering\rmfamily\bfseries\fontsize{18bp}{18bp}\selectfont,
%       chapter/beforeskip  = 9bp,
%       chapter/afterskip   = 27bp,
%     }
%     \setcounter{chapter}{1}
%   \else
%     \ctexset{appendix/number=\arabic{chapter}}
%   \fi
% }
\ctexset{appendix/number=\arabic{chapter}}

% \subsection{封面}

% 定义用户接口:
\hfut@define@key{
  ugtype = {
    default = {论文},
  },
  title = {
    default = {论文题目},
  },
  title* = {
    default = {Title},
    name    = title@en,
  },
  author = {
    default = {作者姓名},
  },
  stuID = {
    default = {学号},
  },
  clc  = {
    default = {分类号},
  },
  author* = {
    default = {Author Name},
    name    = author@en,
  },
  speciality = {
    default = {专业},
  },
  hfuteryear = {
    default = {2017级},
  },
  research = {
    default = {研究方向},
  },
  supervisor = {
    default = {导师姓名},
  },
  department = {
    default = {学院名称},
  },
  advisor = {
    default = {},
  },
  advisor* = {
    default = {},
    name    = advisor@en,
  },
  applydegree = {
    default = {理学博士},
  },
  school = {
    default = {合肥工业大学},
  },
  phdchairman = {
    default = {},
    name    = phd@chairman,
  },
  phdmember = {
    default = {},
    name    = phd@member,
  },
  date = {
    default = {\the\year-\two@digits{\month}},
  },
  defensedate = {
    default = {},
  },
  professional-type = {
    name = professional@type,
  },
  professional-type* = {
    name = professional@type@en,
  },
  secret-level = {
    default = {},
    name    = secret@level,
  },
  secret-level* = {
    name    = secret@level@en,
  },
  secret-year = {
    name    = secret@year,
  },
  signchairman = {
    default = {},
    name    = sign@chairman,
  },
  signmember = {
    default = {},
    name    = sign@member,
  },
  signsupervisor = {
    default = {},
    name    = sign@supervisor,
  },
  keywords,
  keywords* = {
    name    = keywords@en,
  },
}

% 导师一栏可能有多个姓名,所以用 \opt{supervisor} 进行收集,
% 然后使用本命令来输出要求的格式,
% 类似于 \LaTeX3 的 \cs{clist\_use:Nn}。
\newcommand\hfut@clist@count[1]{%
  \csname clist_count:N\endcsname{#1}%
}
\newcommand\hfut@clist@use[2]{%
  \csname clist_use:Nn\endcsname{#1}{#2}%
}
\newcommand\hfut@supervisor@names{%
  \hfut@clist@use{\hfut@supervisor}{\quad}
}
\newcommand\hfut@advisor@names{%
  \hfut@clist@use{\hfut@advisor}{\quad}
}

% 输出日期的给定格式:\cs{hfut@format@date}\marg{format}\marg{date},
% 其中格式 \meta{format} 接受三个参数分别对应年、月、日,
% \meta{date} 是 (yyyy-m)。
\newcommand\hfut@format@date[2]{%
  \edef\hfut@@date{#2}%
  \def\hfut@@process@date##1-##2\@nil{%
    #1{##1}{##2}%
  }%
  \expandafter\hfut@@process@date\hfut@@date\@nil
}
\newcommand\hfut@date@format@zh[2]{#1 年 \number#2 月}
\newcommand\hfut@date@month[1]{%
  \ifcase\number#1\or
    January\or February\or March\or April\or May\or June\or
    July\or August\or September\or October\or November\or December%
  \fi
}
\newcommand\hfut@date@format@en[2]{\hfut@date@month{#2}, #1}
\newcommand\hfut@date@zh{\hfut@format@date{\hfut@date@format@zh}{\hfut@date}}
\newcommand\hfut@date@en{\hfut@format@date{\hfut@date@format@en}{\hfut@date}}

% 版本 v3.2 开始使用 \cs{hfutsetup} 设置接口,
% 兼容旧版本的命令式设置。
% Reserved for compatibility until 2020-07-01.
\def\hfut@define@term#1#2{%
  \expandafter\gdef\csname #1\endcsname##1{%
    \hfutsetup{#2 = {##1}}%
  }%
}
\hfut@define@term{title}{title}
\hfut@define@term{entitle}{title*}
\hfut@define@term{author}{author}
\hfut@define@term{enauthor}{author*}
\hfut@define@term{major}{speciality}
\hfut@define@term{supervisor}{supervisor}
\gdef\cosupervisor#1{%
  \g@addto@macro\hfut@supervisor{, #1}%
}
\gdef\date#1{\renewcommand\hfut@date@zh{#1}}
\gdef\endate#1{\renewcommand\hfut@date@en{#1}}
\hfut@define@term{professionaltype}{professional-type}
\hfut@define@term{enprofessionaltype}{professional-type*}
\hfut@define@term{secretlevel}{secret-level}
\hfut@define@term{ensecretlevel}{secret-level*}
\hfut@define@term{secretyear}{secret-year}
\gdef\keywords#1{\renewcommand\hfut@keywords@text{#1}}
\gdef\enkeywords#1{\renewcommand\hfut@keywords@en@text{#1}}

% 定义一些常量。
\ifhfut@degree@doctor
  \newcommand\hfut@thesis@name{博士学位论文}
  \newcommand\hfut@degreetype@name{博士}
  \newcommand\hfut@thesis@name@en{A Dissertation Submitted to \par
  Hefei University of Technology \par
  in accordmance with the requirement \par
  for the Degree of Doctor of Philosophy}
  \newcommand\hfut@thesis@name@encover{DOCTORAL DISSERTATION}
\else
  \ifhfut@degree@master
    \newcommand\hfut@thesis@name{硕士学位论文}
    \newcommand\hfut@thesis@name@en{A Dissertation Submitted for the Degree of Master}
    \newcommand\hfut@thesis@name@encover{MASTER'S DISSERTATION}
  \else
    \newcommand\hfut@thesis@name{本科毕业设计(论文)}
    \newcommand\hfut@thesis@name@en{A Dissertation Submitted for the Degree of Bachelor}
    \newcommand\hfut@thesis@name@encover{UNDERGRADUATE THESIS}
  \fi
\fi

\ifhfut@degree@master
  \ifhfut@degree@type@academic
    \newcommand\hfut@degreetype@name{学历硕士}
  \else
    \newcommand\hfut@degreetype@name{专业硕士}
  \fi
\fi

\ifhfut@degree@type@academic
  \ifhfut@degree@doctor
    \newcommand\hfut@speciality@name{学科专业}
  \else
    \newcommand\hfut@speciality@name{专业名称}
  \fi
\else
  \ifhfut@cjk@font@mac
    \providecommand\lishu{\CJKfamily{zhli}}
  \else
    \ifhfut@cjk@font@windows
      \setCJKfamilyfont{zhli}{LiSu}
      \providecommand\lishu{\CJKfamily{zhli}}
    \else
      \hfut@warning{LiShu font is required}
      \providecommand\lishu{\sffamily}
    \fi
  \fi
  \newcommand\hfut@speciality@name{专业名称}
\fi

% 定义校徽颜色
\definecolor{hfutred}{cmyk}{0.3,1,0.95,0.05}

% 添加 PDF 书签,在 \pkg{hyperref} 载入后才有效。
\newcommand\hfut@pdfbookmark{\@gobble}

% 重定义 \env{titlepage} 环境,不修改页码。
\renewenvironment{titlepage}{%
  \cleardoublepage
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse\newpage
  \fi
  \thispagestyle{empty}%
}{%
  \if@restonecol\twocolumn \else \newpage \fi
}

% TODO: 做一些定义用以实现:不定长, 自动换行且有定长下划线的“论文标题”
% from:
% https://github.com/CTeX-org/forum/issues/208
% https://syvshc.github.io/2021-08-04-thesis-title/
% https://zhuanlan.zhihu.com/p/51494365

% inner temp length
\newlength\@tempTitleHt
\newlength\@tempTitleMaxWd

% length used as parameters, "Wd" is a shorthand for "Width"
\newlength\titleSingleLineMaxWd
\newlength\titleMultiLineMaxWd
\newlength\titleLRExtraWd
\newlength\titleSepWd

\setlength\titleSingleLineMaxWd{8.5cm}
\setlength\titleMultiLineMaxWd{7cm}
\setlength\titleLRExtraWd{0em}
\setlength\titleSepWd{.5em}

% main macro, using a simple table
% \newcommand{\multilingualTitles}[2]{%
%   \par
%   {\noindent\centering
%   \begin{tabular}{r @{\hspace{\titleSepWd}} p{\titleSingleLineMaxWd}}
%   	中文标题           & \titleBox{#1} \\
%   	                 &               \\[-10pt]
%   	Title in English & \titleBox{#2}
%   \end{tabular}\par}%
% }

% draw a fixed-width underline
\newcommand{\titleUnderline}{%
  \rule[-.3em]{\titleSingleLineMaxWd + 2\titleLRExtraWd}{.5pt}}

% title content typesetter
\newcommand\titleBox[1]{%
  \setlength\@tempTitleMaxWd\titleSingleLineMaxWd
  % Measure the total height of #1 subject to \titleSingleLineMaxWd.
  % Here \@titleBox is necessary when #1 contains "\\".
  \settototalheight\@tempTitleHt{\@titleBox{#1}}%
  \ifdim\@tempTitleHt=0pt%
    % case 1: #1 causes empty output
    \titleUnderline
  \else
    % Change to LR mode, for inserting a zero-width box right after.
    \leavevmode
    % note: Use \normalbaseineskip instead of \baselineskip, 
    %       since the latter is set to 0pt inside tabular env.
    \ifdim\@tempTitleHt>\normalbaselineskip
      % case 2: #1 is fit for multilines, or contains `\\`, hence
      %         \titleMultiLineMaxWd is used instead, and the total 
      %         height of #1 subject to new max width is re-measured.
      \setlength\@tempTitleMaxWd\titleMultiLineMaxWd
      \settototalheight\@tempTitleHt{\@titleBox{#1}}%
      % \rlap{\smash{...}} typesets content of its argument normally 
      % but sets it into a zero sized box. Here \@titleBox set 
      % (possiblly) multi-line text into a single box, since \smash 
      % only takes in argument spreading one line.
      %
      % Every line of title content needs an underline, hense we do
      % a loop to typeset one underline for every line the title 
      % content actually spreads.
      \rlap{\smash{\@titleBox{%
        \@whiledim\@tempTitleHt>0pt%
        \leavevmode
        % 
        \do{%
          \rlap{\titleUnderline}\\%
          \addtolength\@tempTitleHt{-\normalbaselineskip}%
        }%
      }}}%
      % Insert h-offset to manually center the title content.
      \hspace{\dimexpr\titleLRExtraWd + .5\titleSingleLineMaxWd - .5\titleMultiLineMaxWd\relax}%
      \@titleBox{\centering #1}%
    \else
      % case 3: #1 is fit for one line
      \rlap{\titleUnderline}%
      \hspace{\titleLRExtraWd}%
      \@titleBox{\centering #1}%
    \fi
  \fi
}

% common operations on every title content
\newcommand{\@titleBox}[1]{%
  \parbox[t]{\@tempTitleMaxWd}{#1}}

\newlength{\lwtm}
\setlength{\lwtm}{\widthof{论文题目 :}}

% 中文封面:
% 抬头黑体 12 磅;
% 论文类型:研究生黑体 48 磅,本科生黑体42磅;
% 论文类型英文 Times New Roman 22 磅;
% 封面信息 宋体 16 磅
% 论文题目黑体 26 磅加粗居中,单倍行距;
% 作者姓名宋体 16 磅,单倍行距;
% 注意这里的“单倍行距”的地方开启了“对齐到网格”,所以实际行距有所偏差,
% 所以只能使用直尺测量。
\newcommand\hfut@speciality@sse{软件工程}
% 生成空的下划线
\newcommand\hfut@underline[2][3.4cm]{\underline{\hb@xt@ #1{\hss#2\hss}}}
\newcommand\hfut@makecover{%
  \hfutsetup{language=chinese}%
  \begin{titlepage}%
    \hfut@pdfbookmark{封面}%
    \centering
    \ifhfut@degree@bachelor
      \ifx\hfut@secret@level\@empty
        {\sffamily\bfseries\fontsize{12bp}{19.5bp}\selectfont
        学\hspace{2\ccwd}号:\hfut@underline{\hfut@stuID} \hfill
        密\hspace{1em}级:\hfut@underline{公开} \par}
      \else
        {\sffamily\bfseries\fontsize{12bp}{19.5bp}\selectfont
        学\hspace{2\ccwd}号:\hfut@underline{\hfut@stuID} \hfill
        密\hspace{1em}级:\hfut@underline{\hfut@secret@level\bigstar\hfut@secret@year} \par}
      \fi
      \vskip 1.15cm%
    \else
      \ifx\hfut@secret@level\@empty
        {\sffamily\bfseries\fontsize{12bp}{19.5bp}\selectfont
        单位代码:\hfut@underline{10359} \hfill
        密\hspace{1em}级:\hfut@underline{公开} \par
        学\hspace{2\ccwd}号:\hfut@underline{\hfut@stuID} \hfill
        分类号:\hfut@underline{\hfut@clc} \par}
      \else
        {\sffamily\bfseries\fontsize{12bp}{19.5bp}\selectfont
        单位代码:\hfut@underline{10359} \hfill
        密\hspace{1em}级:\hfut@underline{\hfut@secret@level\bigstar\hfut@secret@year} \par
        学\hspace{2\ccwd}号:\hfut@underline{\hfut@stuID} \hfill
        分类号:\hfut@underline{\hfut@clc} \par}
      \fi
      \vskip 1.8cm%
    \fi

    \includegraphics[height=1.4cm]{hfut-figures/hfut-name.pdf}\par
    \vskip 0.3cm
    {\bfseries\fontsize{22bp}{22bp}\selectfont Hefei University of Technology\par}
    \ifhfut@degree@bachelor
      \vskip 1.1cm%
      {\sffamily\bfseries\fontsize{42bp}{42bp}\selectfont
      \hfut@thesis@name\par}%
      \vskip 0.6cm
    \else
      \vskip 1.0cm%
      {\sffamily\bfseries\fontsize{48bp}{48bp}\selectfont
      \hfut@thesis@name\par}%
      \vskip 0.5cm
    \fi
    {\bfseries\fontsize{22bp}{22bp}\selectfont
    \hfut@thesis@name@encover \par}%
    \ifhfut@degree@master
      \vskip 3.5cm
    \else
      \vskip 0.9cm%
      \includegraphics[height=3.6cm]{hfut-figures/hfut-badge.pdf}%
    \fi
    \ifhfut@degree@bachelor
      \vskip 1.5cm
    \else
      \vskip 2.3cm
    \fi
    \renewcommand\arraystretch{1.5}
    \ifhfut@degree@bachelor
      {\fontsize{16bp}{20bp}\selectfont
      \begin{tabular}{>{\fontsize{16bp}{20bp}\rmfamily\bfseries\selectfont}l>{\rmfamily\fontsize{16bp}{20bp}\selectfont}c}%
        类\hspace{2\ccwd}型:& \hfut@ugtype \\
        \cline{2-2}
        题\hspace{2\ccwd}目:& \hfut@title \\
        \cline{2-2}
        \hfut@speciality@name:& \hfut@speciality\\
        \cline{2-2}
        入学年份:& \hfut@hfuteryear \\
        \cline{2-2}
        学生姓名:& \hfut@author \\
        \cline{2-2}
        指导教师:& \hfut@supervisor@names \\
        \cline{2-2}
        学院名称:& \hfut@department \\
        \cline{2-2}
        完成时间:& \hfut@date@zh \\
        \cline{2-2}
      \end{tabular}\par}%
    \else
      \begin{tabular}{>{\rmfamily\bfseries\fontsize{16bp}{20bp}\selectfont}lp{8.5cm}}%
        论文题目:& \multirow[t]{2}{8.5cm}{
          \centering\linespread{1.5}\fontsize{16bp}{20bp}\selectfont
          \hfut@title} \\
          \cline{2-2}
                & \\
        \cline{2-2}
      \end{tabular}
      \renewcommand\arraystretch{1.5}
      \begin{tabular}{>{\bfseries\fontsize{16bp}{20bp}\selectfont}l>{\centering\arraybackslash\fontsize{16bp}{20bp}\selectfont}p{8.5cm}}
        \ifhfut@degree@master
          学位类别:& \hfut@degreetype@name\\
          \cline{2-2}
        \fi
        \hfut@speciality@name:& \hfut@speciality\\
        \cline{2-2}
        作者姓名:& \hfut@author \\
        \cline{2-2}
        导师姓名:& \hfut@supervisor@names \\
        \cline{2-2}
        完成时间:& \hfut@date@zh \\
        \cline{2-2}
      \end{tabular}\par%
      \fi
      \renewcommand\arraystretch{1}
  \end{titlepage}%
  \hfut@reset@main@language
}

\newcommand{\underlineFixlen}[2][4.85cm]{\underline{\makebox[#1][c]{#2}}}

% 博士学位论文 题名页
\newcommand\hfut@makephdtitle{%
  \hfutsetup{language=chinese}%
  \begin{titlepage}%
    \hfut@pdfbookmark{题名页}%
    \centering
    \ifx\hfut@secret@level\@empty
      {\sffamily\bfseries\fontsize{12bp}{20bp}\selectfont
      单位代码:\hfut@underline{10359} \hfill
      密\hspace{1em}级:\hfut@underline{公开} \par
      学\hspace{2\ccwd}号:\hfut@underline{\hfut@stuID} \hfill
      分类号:\hfut@underline{\hfut@clc} \par}
    \else
      {\sffamily\bfseries\fontsize{12bp}{20bp}\selectfont
      单位代码:\hfut@underline{10359} \hfill
      密\hspace{1em}级:\hfut@underline{\hfut@secret@level\bigstar\hfut@secret@year} \par
      学\hspace{2\ccwd}号:\hfut@underline{\hfut@stuID} \hfill
      分类号:\hfut@underline{\hfut@clc} \par}
    \fi
    
    \vskip 2.1cm
    {\sffamily\bfseries\fontsize{22bp}{27.5bp}\selectfont
    博\hspace{0.5\ccwd}士\hspace{0.5\ccwd}学\hspace{0.5\ccwd}位\hspace{0.5\ccwd}论\hspace{0.5\ccwd}文\par}%
    \vskip 1.3cm
    \renewcommand\arraystretch{1.5}
    \begin{tabular}{@{}p{11.4cm}@{}}%
        \multirow[t]{2}{11.4cm}{
        \centering\linespread{1.5}\bfseries\fontsize{16bp}{24bp}\selectfont
        \hfut@title} \\
      \cline{1-1}
              \\
      \cline{1-1}
    \end{tabular}
    \vskip 1.5cm%
    {\linespread{1.25}
    \bfseries\fontsize{16bp}{16bp}\selectfont
    \uline{\hfut@title@en}\par}%
    \vskip 3.5cm%
    {\linespread{1.5}\fontsize{15bp}{15bp}\selectfont
      \textbf{作者姓名:}\underlineFixlen{\hfut@author} \hfill \textbf{导师姓名:}\underlineFixlen{\hfut@supervisor@names} \par
      \textbf{申请学位:}\underlineFixlen{\hfut@applydegree} \hfill \textbf{培养单位:}\underlineFixlen{\hfut@school} \par
      \textbf{学科专业:}\underlineFixlen{\hfut@speciality} \hfill \textbf{研究方向:}\underlineFixlen{\hfut@research} \par
      \textbf{提交日期:}\underlineFixlen{\hfut@date@zh} \hfill \textbf{答辩日期:}\underlineFixlen{\hfut@defensedate} \par
    }
    \vskip 1.3cm
    \renewcommand\arraystretch{1.5}
    \begin{tabular}{@{}>{\fontsize{15bp}{22.5bp}\selectfont}p{15.9cm}@{}}%
      \textbf{答辩委员会主席:} \hfut@phd@chairman \\
      \cline{1-1}
      \textbf{评\hspace{2\ccwd}阅\hspace{2\ccwd}人:} \hfut@phd@member  \\
      \cline{1-1}
    \end{tabular}
    \renewcommand\arraystretch{1}
    \vfill

    {\fontsize{15bp}{15bp}\selectfont\hfut@date@zh}

  \end{titlepage}%
}


\newcommand\hfut@makezhtitle{%
  \hfutsetup{language=chinese}%
  \begin{titlepage}%
    \hfut@pdfbookmark{中文内封页}%
    \centering
    {\sffamily\fontsize{22bp}{40bp}\selectfont
      合\hspace{1.5\ccwd}肥\hspace{1.5\ccwd}工\hspace{1.5\ccwd}业\hspace{1.5\ccwd}大\hspace{1.5\ccwd}学\par}%
    \vskip 1.8cm%
    \ifhfut@degree@master
      {\sffamily\bfseries\fontsize{22bp}{30bp}\selectfont
      \hfut@degreetype@name 学位论文\par}% 空格不可忽略
    \else
      {\sffamily\bfseries\fontsize{22bp}{30bp}\selectfont
      \hfut@thesis@name\par}%
    \fi
    \vskip 1.8cm%
    {\bfseries\fontsize{22bp}{30bp}\selectfont
    \hfut@title\par}%
    \ifhfut@degree@bachelor
      \vskip 6.5cm
    \else
      \vskip 8cm%
    \fi
      \begin{tabular}{>{\fontsize{16bp}{16bp}\rmfamily\bfseries\selectfont}l>{\centering\arraybackslash\fontsize{16bp}{16bp}\rmfamily\selectfont}p{8.4cm}}%
        \ifhfut@degree@bachelor
          学生姓名:& \hfut@author \\
          \cline{2-2}\\
          学生学号:& \hfut@stuID \\
          \cline{2-2}\\
          指导教师:& \hfut@supervisor@names \\
          \cline{2-2}\\
          \hfut@speciality@name:& \hfut@speciality\\
          \cline{2-2}\\
          学院名称:& \hfut@department \\
          \cline{2-2}
        \else
          \ifhfut@degree@doctor
            作者姓名:& \hfut@author\\
            \cline{2-2}\\
            申请学位:& \hfut@applydegree \\
            \cline{2-2}\\
            研究方向:& \hfut@research \\
            \cline{2-2}\\
            \hfut@speciality@name:& \hfut@speciality\\
            \cline{2-2}\\
            指导教师:& \hfut@supervisor@names \\
            \cline{2-2}
          \else
            \ifx\hfut@advisor\@empty
              作者姓名:& \hfut@author \\
              \cline{2-2}\\
              指导教师:& \hfut@supervisor@names \\
              \cline{2-2}\\
              学科专业:& \hfut@speciality \\
              \cline{2-2}\\
              研究方向:& \hfut@research \\
              \cline{2-2}
            \else
              作者姓名:& \hfut@author \\
              \cline{2-2}\\
              指导教师:& \hfut@supervisor@names \\
              \cline{2-2}\\
                & \hfut@advisor@names \\
              \cline{2-2}\\
              专业名称:& \hfut@speciality \\
              \cline{2-2}\\
              研究方向:& \hfut@research \\
              \cline{2-2}
            \fi
          \fi
        \fi
    \end{tabular}\par%
    \vfill
    {\fontsize{15bp}{15bp}\selectfont\hfut@date@zh}
  \end{titlepage}%
  \hfut@reset@main@language
}

% 英文内封页
\newcommand\hfut@makeentitle{%
  \hfutsetup{language=english}%
  \begin{titlepage}%
    \hfut@pdfbookmark{English inner cover}%
    \centering
    \vspace*{0.5cm}%
    {\fontsize{16bp}{30bp}\selectfont
    \hfut@thesis@name@en\par}%
    \vskip 2.0cm%
    {\bfseries\fontsize{18bp}{30bp}\selectfont
    \hfut@title@en\par}%
    \vskip 1.2cm%
    {\fontsize{16bp}{30bp}\selectfont
    By\par
    \hfut@author@en\par}%
    \ifhfut@degree@doctor
      \vskip 7.0cm
    \else
      \vskip 10.0cm
    \fi
    {\fontsize{16bp}{31bp}\selectfont
    Hefei University of Technology\par
    Hefei, Anhui, P.R.China\par
    \hfut@date@en\par}%
  \end{titlepage}%
  \hfut@reset@main@language
}

% 重新定义 \cs{maketitle},调用 \cs{hfut@makezhtitle}, \cs{hfut@makeentitle}
% 分别生成封面,中、英文标题页。
\renewcommand\maketitle{%
  \newgeometry{margin=2.54cm}%
  \pagenumbering{Alph}%
  \pagestyle{empty}%
  \hfut@makecover
  \ifhfut@degree@doctor
    \hfut@makephdtitle
  \fi
  \hfut@makezhtitle
  \hfut@makeentitle
  \restoregeometry
  \pagestyle{plain}%
}

\newcommand\signaturepage{%
  \begin{titlepage}%
    \hfut@pdfbookmark{答辩委员签名页}%
    \null
    {\centering\sffamily\bfseries\fontsize{22bp}{33bp}\selectfont
    合\hspace{0.5\ccwd}肥\hspace{0.5\ccwd}工\hspace{0.5\ccwd}业\hspace{0.5\ccwd}大\hspace{0.5\ccwd}学\par}
    \vskip 0.8cm
    {\fontsize{16bp}{30bp}\selectfont
    本论文经答辩委员会全体委员审查,确认符合合肥工业大学\hfut@degreetype@name 学位论文质量要求。\par}
    \vskip 2.5cm
    {\centering\fontsize{16bp}{24bp}\selectfont
    \textbf{答辩委员会签名(工作单位、职称、姓名)}\par}
    \vskip 1.0cm
    {\fontsize{16bp}{16bp}\selectfont
    主席:\hfut@sign@chairman \par}
    \vskip 1.0cm
    {\fontsize{16bp}{16bp}\selectfont
    委员:\parbox[t]{10.5cm}{\linespread{2.0}\selectfont\hfut@sign@member} \par}
    \vfill
    {\fontsize{16bp}{16bp}\selectfont
    导师:\hfut@sign@supervisor }
  \end{titlepage}%
}

\ifhfut@degree@bachelor
  \let\signaturepage\relax
\fi
% Reserved for compatibility until 2020-07-01.
\let\makestatement\signaturepage


% \subsection{原创性声明}

% 定义原创性声明
\newcommand\hfut@originality@master{%
  本人郑重声明:所呈交的学位论文是本人在导师指导下进行独立研究
  工作所取得的成果。据我所知,除了文中特别加以标注和致谢的内容
  外,论文中不包含其他人已经发表或撰写过的研究成果,也不包含为
  获得\underline{\hspace{0.5\ccwd}合肥工业大学\hspace{0.5\ccwd}}或
  其他教育机构的学位或证书而使用过的材料。对本文成果做出贡献的
  个人和集体,本人已在论文中作了明确的说明,并表示谢意。\par%
  学位论文中表达的观点纯属作者本人观点,与合肥工业大学无关。}
\newcommand\hfut@authorization@master{%
  本学位论文作者完全了解\underline{\hspace{0.5\ccwd}合肥工业大学\hspace{0.5\ccwd}}有关保留、使用学位论文%
  的规定,即:除保密期内的涉密学位论文外,学校有权保存并向国家%
  有关部门或机构送交论文的复印件和电子光盘,允许论文被查阅或借%
  阅。本人授权\underline{\hspace{0.5\ccwd}合肥工业大学\hspace{0.5\ccwd}}可以将本学位论文的全部或部分内容%
  编入有关数据库,允许采用影印、缩印或扫描等复制手段保存、汇编%
  学位论文。\par%
  (保密的学位论文在解密后适用本授权书)}

\newcommand\hfut@originality@bachelor{%
  本人郑重声明:所呈交的毕业设计(论文)是本人在指导教师指导下
  进行独立研究工作所取得的成果。据我所知,除了文中特别加以标注
  和致谢的内容外,设计(论文)中不包含其他人已经发表或撰写过的
  研究成果,也不包含为获得\underline{\hspace{0.5\ccwd}合肥工业大学\hspace{0.5\ccwd}}或
  其他教育机构的学位或证书而使用过的材料。对本文成果做出贡献的
  个人和集体,本人已在设计(论文)中作了明确的说明,并表示谢意。\par%
  毕业设计(论文)中表达的观点纯属作者本人观点,与合肥工业大学无关。}
\newcommand\hfut@authorization@bachelor{%
  本学位论文作者完全了解\underline{\hspace{0.5\ccwd}合肥工业大学\hspace{0.5\ccwd}}有关保留、使用毕业设计(论文)的规定,即:除保密期内的涉密设计(论文)外,学校有权
  保存并向国家有关部门或机构送交设计(论文)的复印件和电子光盘,
  允许设计(论文)被查阅或借阅。本人授权\underline{\hspace{0.5\ccwd}合肥工业大学\hspace{0.5\ccwd}}可以将本毕业设计(论文)的全部或部分内容编入有关数据库,允许采用影
  印、缩印或扫描等复制手段保存、汇编毕业设计(论文)。\par%
  (保密的毕业设计(论文)在解密后适用本授权书)}
  %
  

\newcommand\copyrightpage{%
  \begin{titlepage}%
    \hfut@pdfbookmark{原创性和授权使用声明}%
    \null
    \renewcommand\arraystretch{1.5}
    \ifhfut@degree@bachelor
      {\centering\sffamily\fontsize{18bp}{18bp}\selectfont
      \textbf{毕业设计(论文)独创性声明}\par}%
      \vskip 1.0cm%
      \hfut@originality@bachelor\par
      \vskip 0.9cm%
      毕业设计(论文)作者签名:\hfill%
      签字日期:\hspace{3\ccwd}年\hspace{2\ccwd}月\hspace{2\ccwd}日\par
      \vskip 2.33cm%
      {\centering\sffamily\fontsize{18bp}{18bp}\selectfont
      \textbf{毕业设计(论文)版权使用授权书}\par}%
      \vskip 1.0cm%
      \hfut@authorization@bachelor\par
      \vskip 1.0cm%
      \begin{tabular}{@{}p{6.5cm}p{6.5cm}@{}}%
        学位论文作者签名:& 指导教师签名:\\
        签名日期:\hspace{3\ccwd}年\hspace{2\ccwd}月\hspace{2\ccwd}日 & 签名日期:\hspace{3\ccwd}年\hspace{2\ccwd}月\hspace{2\ccwd}日
      \end{tabular}\par
    \else
      {\centering\sffamily\fontsize{18bp}{18bp}\selectfont
      \textbf{学位论文独创性声明}\par}%
      \vskip 1.25cm%
      \hfut@originality@master\par
      \vskip 1.1cm%
      学位论文作者签名:\hfill%
      签字日期:\hspace{3\ccwd}年\hspace{2\ccwd}月\hspace{2\ccwd}日\par
      \vskip 2.8cm%
      {\centering\sffamily\fontsize{18bp}{18bp}\selectfont
      \textbf{学位论文版权使用授权书}\par}%
      \vskip 1.25cm%
      \hfut@authorization@master\par
      \vskip 1.2cm%
      \begin{tabular}{@{}p{6.5cm}p{6.5cm}@{}}%
        学位论文作者签名:& 指导教师签名:\\
        签名日期:\hspace{3\ccwd}年\hspace{2\ccwd}月\hspace{2\ccwd}日 & 签名日期:\hspace{3\ccwd}年\hspace{2\ccwd}月\hspace{2\ccwd}日\\
      \end{tabular}\par
      \vskip 0.6cm
      \renewcommand\arraystretch{1.1}
      \begin{tabular}{@{}p{6.5cm}p{6.5cm}@{}}%
        论文作者毕业去向 & \\
        工作单位:& \\
        联系电话:& E-mail:\\
        通讯地址:& 邮政编码:
      \end{tabular}\par
      \renewcommand\arraystretch{1}
    \fi
  \end{titlepage}%
}

% Reserved for compatibility until 2020-07-01.
\let\makestatement\copyrightpage


% \subsection{章节标题}

% 标题最多允许使用五级。
\setcounter{secnumdepth}{5}

% 研究生规定章题为两字时中间空两字,三字时空一字,四字时空半字,四字以上不空。
% 这里用 \LaTeX3 的 \cs{str\_count:N} 判断字数。
% 注意,\pkg{stringstrings} 宏包会导致范数命令 \verb+\|+ 被修改。
\newcount\hfut@titlelength
\DeclareRobustCommand\hfut@spacetitle[1]{%
  \hfut@titlelength=\csname str_count:N\endcsname{#1}%
  \begingroup
    \ifhfut@degree@graduate
      \ifcase\hfut@titlelength
      \or\or
        \ziju{2}%
      \or
        \ziju{1}%
      \or
        \ziju{0.5}%
      \fi
    \else
      \if@mainmatter\else
        \ifcase\hfut@titlelength
        \or\or
          \ziju{1}%
        \or\or
          \ziju{0.5}%
        \fi
      \fi
    \fi
    #1%
  \endgroup
}

% 五级节标题和脚注需要使用带圈的数字,这里使用 \cs{hfut@circlefont} :
\newcommand\hfut@textcircled[1]{%
  \ifnum\value{#1}<21\relax
    {\symbol{\numexpr\value{#1} + "245F\relax}}%
  \else
    \hfut@error{Cannot display more than 20 footnotes}%
  \fi
}

% 用 \pkg{ctex} 的接口设置全部章节标题格式。

% 各章标题:黑体 16 磅加粗居中,行距为单倍行距,段前 1 行,段后 1 行,
% 章序号与章名间空一字。

% 由于 Word 模板中使用“单倍行距”,还“对齐到网格”,这在 TeX 中不容易实现。
% 所以目前按照默认的行距。

% 注意 \pkg{ctex} v2.4.3 以下版本的bug会导致章节标题前后的距离的实际值偏大。
% 另外 \pkg{ctex} v2.2 前的beforeskip的符号有特殊意义。
    
\ctexset{
  chapter = {
    format = {
        \centering
        \if@mainmatter
          \fontsize{16bp}{16bp}\sffamily\bfseries\selectfont
        \else
          \fontsize{18bp}{16bp}\rmfamily\bfseries\selectfont
        \fi
    },
    nameformat  = {},
    name        = {第,章},
    titleformat = {},
    number      = \chinese{chapter},
    aftername   = \hspace{0.5\ccwd},
    beforeskip  = {
      \if@mainmatter
        16bp
      \else
        9bp
      \fi
    },
    %tocline     = {
    %  \if@mainmatter
    %    %\if \@chapapp \appendixname
    %    \ifhfut@appendix
    %      {附录~\arabic{chapter}~~#2}
    %    \else
    %      {第\chinese{chapter}章~#2}
    %    \fi
    %  \else
    %    \CTEXnumberline{#1}#2
    %  \fi
    %},
    afterskip   = {
      \if@mainmatter
        16bp
      \else
        24bp
      \fi
    },
    fixskip     = true,
  },
}

% 一级节标题:黑体,小四号,左对齐
% 序号与题名间空一字。
\ctexset{
  section = {
    format     = \sffamily\fontsize{12bp}{15.6bp}\selectfont,
    aftername  = \hspace{0.5\ccwd},
    beforeskip = 7.8bp,
    afterskip  = 7.8bp,
  },
  %
  % 二级节标题:宋体,加黑,小四号,左对齐
  % 序号与题名间空一字。
  subsection = {
    format     = \rmfamily\bfseries\fontsize{12bp}{15.6bp}\selectfont,
    aftername  = \hspace{0.5\ccwd},
    beforeskip = 7.8bp,
    afterskip  = 7.8bp,
  },
  %
  % 三级及以下节标题的格式没有具体规定,按照数学学院推荐的方案:
  % 使用宋体 12 磅,左缩进两字,行距 20 磅,段前段后 0 磅,序号(n)与题名间空半字宽。
  subsubsection = {
    format     = \rmfamily\fontsize{12bp}{15.6bp}\selectfont,
    number     = (\arabic{subsubsection}),
    aftername  = \hspace{0.5\ccwd},
    beforeskip = \z@,
    afterskip  = \z@,
    indent     = 2\ccwd,
  },
  %
  % 采用西文式段标题,runin=true
  paragraph = {
    format     = \rmfamily\bfseries\fontsize{12bp}{20bp}\selectfont,
    number     = {},
    name       = {},
    aftername  = {},
    beforeskip = \z@,
    afterskip  = \ccwd, 
    indent     = 2\ccwd,
    runin      = true,
  },
  %
  % 采用西文式子段标题,runin=true
  subparagraph = {
    format     = \rmfamily\fontsize{12bp}{20bp}\selectfont,
    number     = {},
    name       = {},
    aftername  = {},
    beforeskip = \z@,
    afterskip  = \ccwd, 
    indent     = 2\ccwd,
    runin      = true,
  },
}

\ifhfut@degree@bachelor
  \ifhfut@main@language@english
    \hfutsetup{section-style = arabic}
  \fi
\fi
\hfut@option@hook{main-language}{%
  \ifhfut@degree@bachelor
    \ifhfut@main@language@english
      \hfutsetup{section-style = arabic}%
    \fi
  \fi
}

% 在研究生格式的基础上再设置本科生的章节标题格式。
\ifhfut@degree@bachelor
  \setcounter{secnumdepth}{4}
  \ctexset{
  %
  % 论文的致谢、目录、摘要和参考文献等标题用小二号(18 bp)黑体字,居中,
  % 这通过 \cs{if@mainmatter} 区分。
  % 正文中的标题分章、节、段三级;章、节标题居中,段标题居左,
  % 分别用三号(16 bp)黑体、小四(12 bp)黑体、小四(12 bp)黑体。
    chapter = {
      name = {},
      format = {
        \centering
        \if@mainmatter
          \fontsize{16bp}{22bp}\sffamily\bfseries\selectfont
        \else
          \fontsize{18bp}{22bp}\rmfamily\bfseries\selectfont
        \fi
      },
      nameformat  = \rmfamily\bfseries,
      number      = \thechapter,
      aftername   = \hspace{\ccwd},
      beforeskip  = {
        \if@mainmatter
          22bp
        \else
          11bp
        \fi
      },
      afterskip   = {
        \if@mainmatter
          22bp
        \else
          33bp
        \fi
      },
      fixskip     = true,
    },
    section = {
      format = \sffamily\fontsize{12bp}{22bp}\selectfont,
      beforeskip = 11bp,
      afterskip  = 11bp, 
      nameformat = \rmfamily\bfseries,
    },
    subsection = {
      format     = \rmfamily\bfseries\fontsize{12bp}{22bp}\selectfont,
      beforeskip = 11bp,
      afterskip  = 11bp, 
      nameformat = \rmfamily\bfseries\selectfont,
      indent     = \z@,
    },
    subsubsection = {
      format     = \rmfamily\fontsize{12bp}{22bp}\selectfont,
      number     = (\arabic{subsubsection}),
      aftername  = \hspace{0.5\ccwd},
      beforeskip = \z@,
      afterskip  = \z@,
      indent     = 2\ccwd,
    },
    paragraph = {
      format     = \rmfamily\bfseries\fontsize{12bp}{22bp}\selectfont,
      number     = {},
      name       = {},
      aftername  = {},
      beforeskip = \z@,
      afterskip  = \ccwd, 
      indent     = 2\ccwd,
      runin      = true,
    },
    subparagraph = {
      format     = \rmfamily\fontsize{12bp}{22bp}\selectfont,
      number     = {},
      name       = {},
      aftername  = {},
      beforeskip = \z@,
      afterskip  = \ccwd, 
      indent     = 2\ccwd,
      runin      = true,
    },
  }
  %
  % 本科生的阿拉伯数字式标题的格式与研究生几乎一致,只有中文数字式需要修改。
  \ifhfut@section@style@arabic\else
    \ctexset{
      chapter = {
        name = {},
        %number = \chinese{chapter}
      },
      section = {
        %name   = {第,节},
        %number = \chinese{section},
      },
      subsection = {
        %number    = \chinese{subsection},
        %aftername = {、},
      },
    }
  \fi
\fi

% 默认的 \cs{chapter*} 生成的章标题没有编号、不更改页眉,
% 也不添加进目录或 PDF 书签。
% 然而像摘要、目录、符号说明这样的章节,它们不需要编号、不加入目录,
% 但是需要修改页眉,并且加入 PDF 标签。
% 所以我们新定义 \cs{hfut@chapter} 用于处理这些章节。%
\NewDocumentCommand\hfut@chapter{o m}{%
  \if@openright\cleardoublepage\else\clearpage\fi
  \IfValueTF{#1}{%
    \hfut@pdfbookmark{#1}%
    \chaptermark{#1}%
  }{%
    \hfut@pdfbookmark{#2}%
    \chaptermark{#2}%
  }%
  \chapter*{#2}}
  %
  %
  % \subsection{摘要}
  %
  % 中文摘要环境。
  % 判断 \cs{hfut@tocloaded} 是为了防止本科生未调整摘要位置时的目录页码缺失。
\newcommand\hfut@keywords@text{%
  \hfut@clist@use{\hfut@keywords}{;}%
}
\newcommand\hfut@keywords@en@text{%
  \hfut@clist@use{\hfut@keywords@en}{; }%
}
\newenvironment{abstract}{%
  \hfutsetup{language=chinese}%
  \ifhfut@degree@graduate
    \pagestyle{plain}
    \ctexset{chapter/format=\centering\Large\selectfont\bfseries}%
    \hfut@chapter[摘要]{摘\hspace{\ccwd}要}%
  \else
    \pagestyle{plain}
    \hfut@chapter[摘要]{摘\hspace{\ccwd}要}%
    % \ifhfut@tocloaded\else
    %   本科生需要手动将摘要置于目录后。\par
    % \fi
  \fi
}{
  \pagestyle{plain}
  \par\null\par\noindent
  \textbf{关键词:}\hfut@keywords@text\par
  \hfut@reset@main@language
}

% 英文摘要环境
\newenvironment{abstract*}{%
  \hfutsetup{language=english}%
  \ctexset{chapter/format=\centering\Large\selectfont\bfseries}%
  \setlength{\parindent}{1em}
  \ifhfut@degree@graduate
    \hfut@chapter[Abstract]{ABSTRACT}%
    \pagestyle{plain}
  \else
    \begingroup
      \pagestyle{plain}%
      \hfut@chapter[Abstract]{ABSTRACT}%
    \endgroup
  \fi
}{
  %\pagestyle{plain}
  \par\null\par\noindent
  \textbf{KEYWORDS:} \hfut@keywords@en@text\par
  \ifhfut@degree@graduate
    \cleardoublepage
  \fi
  \hfut@reset@main@language
}

% Reserved for compatibility until 2020-07-01.
\newenvironment{enabstract}{%
  \begin{abstract*}%
}{%
  \end{abstract*}%
}


% \subsection{目录}

% 判断是否已经加载目录,用于提醒本科生更改摘要和致谢的顺序。
\newif\ifhfut@tocloaded

% 判断是否在附录中
\newif\ifhfut@appendix

% 研究生规定目录另面起;
% 本科生规定从正文起标页码。
\renewcommand\tableofcontents{%
  \ifhfut@degree@bachelor
    \cleardoublepage
    %\pagenumbering{arabic}%
    \pagestyle{plain}%
    \hfut@tocloadedtrue
  \else
    \pagestyle{plain}%
  \fi
  \hfut@chapter{\contentsname}%
  \@starttoc{toc}%
}

% 下面用 \pkg{titletoc} 宏包设置目录内容的格式。
% 先定义目录线:
\newcommand\hfut@leaders{\titlerule*[9bp]{\textperiodcentered}}

% 各章目录要求宋体 12 磅,单倍行距,段前 6 磅,段后 0 磅,两端对齐,
% 页码右对齐,章序号与章名间空一字。
% 但是 Word 模板中实际是行距 20 磅。
\ifhfut@degree@graduate
  \titlecontents{chapter}
    [\z@]{\bfseries\normalsize}
    {\contentspush{\thecontentslabel\hspace{0.5\ccwd}}}{}
    {\normalsize\hfut@leaders\contentspage}
    %
    % 一级节标题目录要求宋体 12 磅,单倍行距,左缩进一字,段前 6 磅,段后 0 磅,
    % 两端对齐,页码右对齐,序号与题名间空一字。
    % Word 模板中实际是行距 20 磅,段前 0 磅。
  \titlecontents{section}
    [2\ccwd]{\normalsize}
    {\contentspush{\thecontentslabel\hspace{0.5\ccwd}}}{}
    {\normalsize\hfut@leaders\contentspage}
    %
    % 二级节标题目录要求宋体 12 磅,单倍行距,左缩进两字,段前 6 磅,段后 0 磅,
    % 两端对齐,页码右对齐,序号与题名间空一字。
    % Word 模板中实际是行距 20 磅,段前 0 磅。
  \titlecontents{subsection}
    [4\ccwd]{\normalsize}
    {\contentspush{\thecontentslabel\hspace{0.5\ccwd}}}{}
    {\normalsize\hfut@leaders\contentspage}
    %
    % 本科生的目录使用小四宋体(同正文字体),其他同研究生的格式相近。
\else
  \titlecontents{chapter}
    [\z@]{\bfseries\normalsize}
    {\contentspush{\thecontentslabel\unskip\hspace{0.5\ccwd}}}{}
    {\hfut@leaders\contentspage}
  \titlecontents{section}
    [2\ccwd]{\normalsize}
    {\contentspush{\thecontentslabel\hspace{0.5\ccwd}}}{}
    {\hfut@leaders\contentspage}
  \titlecontents{subsection}
    [4\ccwd]{\normalsize}
    {\contentspush{\thecontentslabel\hspace{0.5\ccwd}}}{}
      %\ifhfut@section@style@arabic\hspace{\ccwd}\else 、\fi}}{}
    {\hfut@leaders\contentspage}
\fi

% 本科生要求目录中正文每章前多空一行,而目录、附录等章则不需要空行,
% 所以不能简单判断 \cs{if@mainmatter},需要重新定义 \cs{mainmatter} 等命令。
% \newif\ifhfut@addtocspace
% \ifhfut@degree@bachelor
%   \hfut@addtocspacetrue
%   \g@addto@macro\frontmatter{\hfut@addtocspacefalse}%
%   \g@addto@macro\mainmatter{\hfut@addtocspacetrue}%
%   \g@addto@macro\backmatter{\hfut@addtocspacefalse}%
%   \g@addto@macro\appendix{\hfut@addtocspacefalse}%
% \fi

% 处理本科生在目录中添加空行。
% \renewcommand\chapter{%
%   \if@openright\cleardoublepage\else\clearpage\fi
%   \thispagestyle{\CTEX@chapter@pagestyle}%
%   \global\@topnum\z@
%   \@afterindenttrue
%   \ifhfut@degree@bachelor
%     \ifhfut@addtocspace
%       \addtocontents{toc}{\protect\addvspace{12bp}}%
%     \fi
%   \fi
%   \secdef\@chapter\@schapter
% }

% 研究生要求图、表的清单须另页起。
\newlength{\hfut@lof@label@width}
\newcommand\hfut@set@lof@format{%
  \settowidth{\hfut@lof@label@width}{\figurename~9.99}%
  \addtolength{\hfut@lof@label@width}{0.5\ccwd}%
  \titlecontents{figure}%
    [\hfut@lof@label@width]{\normalsize}%
    {\contentslabel[\figurename~\thecontentslabel]{\hfut@lof@label@width}}{}%
    {\hfut@leaders\contentspage}%
  \titlecontents{table}%
    [\hfut@lof@label@width]{\normalsize}%
    {\contentslabel[\tablename~\thecontentslabel]{\hfut@lof@label@width}}{}%
    {\hfut@leaders\contentspage}%
}
\hfut@set@lof@format
\hfut@option@hook{main-language}{\hfut@set@lof@format}
\renewcommand\listoffigures{%
  \ifhfut@degree@graduate
    \cleardoublepage
  \fi
  \hfut@chapter{\listfigurename}%
  \@starttoc{lof}%
}
\renewcommand\listoftables{%
  \ifhfut@degree@graduate
    \cleardoublepage
  \fi
  \hfut@chapter{\listtablename}%
  \@starttoc{lot}%
}


% \subsection{符号说明}

% 研究生规定符号说明另页起,标题字体字号等同论文正文,
\newenvironment{notation}{%
  \ifhfut@degree@graduate
    \cleardoublepage
    \pagestyle{plain}%
  \fi
  \hfut@chapter{\hfut@notation@name}%
}{%
  \ifhfut@degree@graduate
    \clearpage
    \pagestyle{plain}%
  \fi
}%
\newcommand*\notationlabel[1]{#1\hfil}%
\newenvironment{notationlist}[1]{%
  \list{}{%
    \itemsep 3bp%
    \labelwidth #1\relax%
    \labelsep 1em%
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \advance\leftmargin 3em%
    \rightmargin 3em%
    \let\makelabel\notationlabel
  }%
}{%
  \endlist
}


% \subsection{正文}

% \cs{sloppy} 可以减少“overfull boxes”。
\sloppy

% 禁止扩大段间距。(\href{https://github.com/ustctug/ustcthesis/issues/209}{
%   ustctug/ustcthesis\#209})
\raggedbottom

% 段间距 0 磅。
\setlength{\parskip}{\z@}

% 首段缩进。
\ctexset{autoindent=2}

% 首段缩进。
\let\@afterindentfalse\@afterindenttrue
\@afterindenttrue

% URL 的字体设为保持原样。
\urlstyle{same}

% 使用 \pkg{xurl} 宏包的方法,增加 URL 可断行的位置。
\def\UrlBreaks{%
  \do\/%
  \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j\do\k\do\l%
     \do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w\do\x\do\y\do\z%
  \do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L%
     \do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X\do\Y\do\Z%
  \do0\do1\do2\do3\do4\do5\do6\do7\do8\do9\do=\do/\do.\do:%
  \do\*\do\-\do\~\do\'\do\"\do\-}
\Urlmuskip=0mu plus 0.1mu

% 脚注用带圈的数字:
\renewcommand\thefootnote{\hfut@textcircled{footnote}}

% LaTeX 默认脚注按章计数,即每章的开始才重置脚注计数器;我们修改为按页计数。
% 简单的|\@addtoreset{footnote}{page}|并不可靠,
% \footnote{\url{https://texfaq.org/FAQ-footnpp.html}}
% 所以我们使用 \pkg{footmisc} 宏包。

% 脚注线长为版心宽度的四分之一:
\renewcommand\footnoterule{%
  \kern-3\p@
  \hrule\@width.25\textwidth
  \kern2.6\p@}
  %
  % 注文缩进两字:
\renewcommand\@makefntext[1]{%
  \parindent 2\ccwd\relax
  \noindent
  \hb@xt@2\ccwd{\hss\@makefnmark}#1}


% \subsection{列表}
% \label{sec:list}

% 调整列表中各项之间过大的间距。
\setlength\partopsep{\z@}
\newcommand\hfut@nolistsep{%
  \parsep 0\p@ \@plus.2\p@
  \topsep 0\p@ \@plus.2\p@
  \itemsep0\p@ \@plus.2\p@
}
\def\@listi{\leftmargin\leftmargini
            \hfut@nolistsep}
\let\@listI\@listi
\@listi
\def\@listii {\leftmargin\leftmarginii
              \labelwidth\leftmarginii
              \advance\labelwidth-\labelsep
              \hfut@nolistsep}
\def\@listiii{\leftmargin\leftmarginiii
              \labelwidth\leftmarginiii
              \advance\labelwidth-\labelsep
              \hfut@nolistsep}


% \subsection{浮动体}

% \LaTeX{} 对放置浮动体的要求比较强,这里按照 UK TeX FAQ 的建议
% \footnote{\url{https://texfaq.org/FAQ-floats}} 对其适当放宽。
\renewcommand\topfraction{.85}
\renewcommand\bottomfraction{.7}
\renewcommand\textfraction{.15}
\renewcommand\floatpagefraction{.66}
\renewcommand\dbltopfraction{.66}
\renewcommand\dblfloatpagefraction{.66}
\setcounter{topnumber}{9}
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20}
\setcounter{dbltopnumber}{9}

% 修改默认的浮动体描述符为 |htb|。
\def\fps@figure{h}
\def\fps@table{h}

% 用 \pkg{caption} 宏包设置图、表的格式:

% 图号、图题置于图的下方,宋体 10.5 磅居中,单倍行距,段前 6 磅,段后 12 磅,
% 图号与图题文字之间空一字,图号、图题加粗。
% 图注位于图的下方,左缩进两字,续行悬挂缩进左对齐,两端对齐。

% 表号、表题置于表的上方,黑体 10.5 磅居中,单倍行距,段前 6 磅,段后 6 磅,
% 表号与表题文字之间空一字,表号、表题加粗。
% 表注左缩进两字,续行悬挂缩进左对齐,两端对齐。
\setlength{\floatsep}{6bp}
\setlength{\textfloatsep}{6bp}
\setlength{\intextsep}{12bp}

% 由于 LaTeX2e kernel 的问题,图表等浮动体与文字前后的距离不一致,需要进行 patch。
% 参考 \href{https://github.com/tuna/thuthesis/issues/614}{tuna/thuthesis/issues\#614}、
% \url{https://www.zhihu.com/question/46618031} 和
% \url{https://tex.stackexchange.com/a/40363/82731}。
%    \begin{macrocode}
\patchcmd{\@addtocurcol}%
  {\vskip \intextsep}%
  {\edef\save@first@penalty{\the\lastpenalty}\unpenalty
   \ifnum \lastpenalty = \@M  % hopefully the OR penalty
     \unpenalty
   \else
     \penalty \save@first@penalty \relax % put it back
   \fi
   \ifnum\outputpenalty <-\@Mii
     \addvspace\intextsep
     \vskip\parskip
   \else
     \addvspace\intextsep
   \fi}%
  {}{\hfut@patch@error{\@addtocurcol}}
\patchcmd{\@addtocurcol}%
  {\vskip\intextsep \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi}%
  {\ifnum\outputpenalty <-\@Mii
     \aftergroup\vskip\aftergroup\intextsep
     \aftergroup\nointerlineskip
   \else
     \vskip\intextsep
   \fi}%
  {}{\hfut@patch@error{\@addtocurcol}}
\patchcmd{\@getpen}{\@M}{\@Mi}
  {}{\hfut@patch@error{\@getpen}}

\DeclareCaptionFont{hfut}{%
  \ifhfut@language@chinese
    \fontsize{10.5bp}{13.65bp}\selectfont
  \else
    \fontsize{10.5bp}{12.075bp}\selectfont
  \fi
}

\captionsetup{
  font           = hfut,
  labelsep       = quad,
  skip           = 6bp,
  figureposition = bottom,
  tableposition  = top,
}
% graduate的图表标题不需要加粗
% \ifhfut@degree@graduate
%   \captionsetup{font+=bf}
%   \captionsetup[table]{font+=sf}
% \fi

% 硕博需要中英文双标题
\captionsetup[figure][bi-second]{name=Fig} %设置图的英文编号前缀
\captionsetup[table][bi-second]{name=Tab} %设置表的英文编号前缀

% 新定义了 \cs{note} 来生成图表的附注。
% 如果用 \cs{caption} 生成图表的附注会导致图表的序号有误;
% 如果用 \cs{bicaption} 会导致表注无法置于表后,而且对齐方式不对。
\newcommand\note[1]{%
  \begingroup
    \captionsetup{
      font          = hfut,
      margin        = 2\ccwd,
      position      = bottom,
    }%
    \caption*{#1}%
  \endgroup
}

% 表格默认字号略小
\patchcmd\@floatboxreset{%
  \normalsize
}{%
  \small
}{}{\hfut@patch@error{\@floatboxreset}}

% 对 \pkg{longtable} 跨页表格进行相同的设置。
%
% 在 Word 模板中按照正确的设置(需要去掉文档网格),
% 中文模板每页能装下 1 行标题、1 行表头、30 行表身,
% 英文模板每页能装下 1 行标题、1 行表头、33 行表身。
%    \begin{macrocode}
\AtEndOfPackageFile*{longtable}{
  \AtBeginEnvironment{longtable}{%
    \small
  }
}


% \subsection{参考文献}

\PassOptionsToPackage{compress}{natbib}

\AtEndOfPackageFile*{natbib}{
  % 定义几种引用文献的标注样式。
  \newcommand\bibstyle@super{\bibpunct{[}{]}{,}{s}{,}{\textsuperscript{,}}}
  \newcommand\bibstyle@inline{\bibpunct{[}{]}{,}{n}{,}{,}}
  \newcommand\bibstyle@authoryear{\bibpunct{(}{)}{;}{a}{,}{,}}
  \@namedef{bibstyle@author-year}{\bibstyle@authoryear}
  %
  % 几种种引用样式,与 \file{bst} 文件名保持一致,
  % 这样在使用 \cs{bibliographystyle} 选择参考文献表的样式时也会设置对应的引用样式。
  \@namedef{bibstyle@hfutthesis-numerical}{\bibstyle@super}
  \@namedef{bibstyle@hfutthesis-authoryear}{\bibstyle@authoryear}
  \@namedef{bibstyle@hfutthesis-graduate}{\bibstyle@super}
  %
  % 如果载入 `natbib` 前设置了 `cite-style`,这里先进行配置。
  % https://github.com/ustctug/ustcthesis/issues/327
  \ifx\hfut@cite@style\@empty\else
    \citestyle{\hfut@cite@style}%
  \fi
  %
  % 定义接口 cite-style 切换引用样式。
  \hfut@option@hook{cite-style}{%
    \ifx\@begindocumenthook\@undefined
    \citestyle{\hfut@cite@style}%
    \fi
  }
  %
  % 如果文献序号作为叙述文字的一部分,需要临时将文献序号与正文平排
  \DeclareRobustCommand\inlinecite{\@inlinecite}
  \def\@inlinecite#1{\begingroup\let\@cite\NAT@citenum\citep{#1}\endgroup}
  %
  % 修改引用的样式。
  % 这里在 filehook 中无法使用 \cs{patchcmd},所以只能手动重定义。
  %
  % 将 super 式 \cs{citep} 引用的页码置于括号外。
  \renewcommand\NAT@citesuper[3]{\ifNAT@swa
    \if*#2*\else#2\NAT@spacechar\fi
    % \unskip\kern\p@\textsuperscript{\NAT@@open#1\NAT@@close}%
    %  \if*#3*\else\NAT@spacechar#3\fi\else #1\fi\endgroup}
    \unskip\kern\p@\textsuperscript{\NAT@@open#1\NAT@@close\if*#3*\else#3\fi}%
    \else #1\fi\endgroup}
  %
  % 将 numbers 式 \cs{citep} 引用的页码置于括号外并改为上标。
  \renewcommand\NAT@citenum%
      [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\NAT@spacechar\fi
          % #1\if*#3*\else\NAT@cmt#3\fi\NAT@@close\else#1\fi\endgroup}
          #1\NAT@@close\textsuperscript{\if*#3*\else#3\fi}\else#1\fi\endgroup}
  %
  % 在 filehook 中无法使用 \cs{patchcmd},所以只能手动重定义。
  \def\NAT@citexnum[#1][#2]#3{%
    \NAT@reset@parser
    \NAT@sort@cites{#3}%
    \NAT@reset@citea
    \@cite{\def\NAT@num{-1}\let\NAT@last@yr\relax\let\NAT@nm\@empty
      \@for\@citeb:=\NAT@cite@list\do
      {\@safe@activestrue
      \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
      \@safe@activesfalse
      \@ifundefined{b@\@citeb\@extra@b@citeb}{%
        {\reset@font\bfseries?}
          \NAT@citeundefined\PackageWarning{natbib}%
        {Citation `\@citeb' on page \thepage \space undefined}}%
      {\let\NAT@last@num\NAT@num\let\NAT@last@nm\NAT@nm
        \NAT@parse{\@citeb}%
        \ifNAT@longnames\@ifundefined{bv@\@citeb\@extra@b@citeb}{%
          \let\NAT@name=\NAT@all@names
          \global\@namedef{bv@\@citeb\@extra@b@citeb}{}}{}%
        \fi
        \ifNAT@full\let\NAT@nm\NAT@all@names\else
          \let\NAT@nm\NAT@name\fi
        \ifNAT@swa
        \@ifnum{\NAT@ctype>\@ne}{%
          \@citea
          \NAT@hyper@{\@ifnum{\NAT@ctype=\tw@}{\NAT@test{\NAT@ctype}}{\NAT@alias}}%
        }{%
          \@ifnum{\NAT@cmprs>\z@}{%
          \NAT@ifcat@num\NAT@num
            {\let\NAT@nm=\NAT@num}%
            {\def\NAT@nm{-2}}%
          \NAT@ifcat@num\NAT@last@num
            {\@tempcnta=\NAT@last@num\relax}%
            {\@tempcnta\m@ne}%
          \@ifnum{\NAT@nm=\@tempcnta}{%
            \@ifnum{\NAT@merge>\@ne}{}{\NAT@last@yr@mbox}%
          }{%
            \advance\@tempcnta by\@ne
            \@ifnum{\NAT@nm=\@tempcnta}{%
              % 在顺序编码制下,\pkg{natbib} 只有在三个以上连续文献引用才会使用连接号,
              % 这里修改为允许两个引用使用连接号。
              % 参考 https://tex.stackexchange.com/a/86991/82731 。
              %
              % \ifx\NAT@last@yr\relax
              %   \def@NAT@last@yr{\@citea}%
              % \else
              %   \def@NAT@last@yr{--\NAT@penalty}%
              % \fi
              \def@NAT@last@yr{-\NAT@penalty}%
            }{%
              \NAT@last@yr@mbox
            }%
          }%
          }{%
          \@tempswatrue
          \@ifnum{\NAT@merge>\@ne}{\@ifnum{\NAT@last@num=\NAT@num\relax}{\@tempswafalse}{}}{}%
          \if@tempswa\NAT@citea@mbox\fi
          }%
        }%
        \NAT@def@citea
        \else
          \ifcase\NAT@ctype
            \ifx\NAT@last@nm\NAT@nm \NAT@yrsep\NAT@penalty\NAT@space\else
              \@citea \NAT@test{\@ne}\NAT@spacechar\NAT@mbox{\NAT@super@kern\NAT@@open}%
            \fi
            \if*#1*\else#1\NAT@spacechar\fi
            \NAT@mbox{\NAT@hyper@{{\citenumfont{\NAT@num}}}}%
            \NAT@def@citea@box
          \or
            \NAT@hyper@citea@space{\NAT@test{\NAT@ctype}}%
          \or
            \NAT@hyper@citea@space{\NAT@test{\NAT@ctype}}%
          \or
            \NAT@hyper@citea@space\NAT@alias
          \fi
        \fi
      }%
      }%
        \@ifnum{\NAT@cmprs>\z@}{\NAT@last@yr}{}%
        \ifNAT@swa\else
          % 将 numerical 式 \cs{citet} 引用的页码置于括号外并改为上标。
          %
          % \@ifnum{\NAT@ctype=\z@}{%
          %   \if*#2*\else\NAT@cmt#2\fi
          % }{}%
          \NAT@mbox{\NAT@@close}%
          \@ifnum{\NAT@ctype=\z@}{%
            \if*#2*\else\textsuperscript{#2}\fi
          }{}%
        \fi
    }{#1}{#2}%
  }%
  %
  % 将 author-year 式 \cs{citep} 引用的页码置于括号外并改为上标:
  \renewcommand\NAT@cite%
      [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\NAT@spacechar\fi
          % #1\if*#3*\else\NAT@cmt#3\fi\NAT@@close\else#1\fi\endgroup}
          #1\NAT@@close\if*#3*\else\textsuperscript{#3}\fi\else#1\fi\endgroup}
  %
  % 调整 author-year 式 \cs{citet} 引用的页码。
  \def\NAT@citex%
    [#1][#2]#3{%
    \NAT@reset@parser
    \NAT@sort@cites{#3}%
    \NAT@reset@citea
    \@cite{\let\NAT@nm\@empty\let\NAT@year\@empty
      \@for\@citeb:=\NAT@cite@list\do
      {\@safe@activestrue
      \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
      \@safe@activesfalse
      \@ifundefined{b@\@citeb\@extra@b@citeb}{\@citea%
        {\reset@font\bfseries ?}\NAT@citeundefined
                  \PackageWarning{natbib}%
        {Citation `\@citeb' on page \thepage \space undefined}\def\NAT@date{}}%
      {\let\NAT@last@nm=\NAT@nm\let\NAT@last@yr=\NAT@year
        \NAT@parse{\@citeb}%
        \ifNAT@longnames\@ifundefined{bv@\@citeb\@extra@b@citeb}{%
          \let\NAT@name=\NAT@all@names
          \global\@namedef{bv@\@citeb\@extra@b@citeb}{}}{}%
        \fi
      \ifNAT@full\let\NAT@nm\NAT@all@names\else
        \let\NAT@nm\NAT@name\fi
      \ifNAT@swa\ifcase\NAT@ctype
        \if\relax\NAT@date\relax
          \@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}\NAT@date}%
        \else
          \ifx\NAT@last@nm\NAT@nm\NAT@yrsep
              \ifx\NAT@last@yr\NAT@year
                \def\NAT@temp{{?}}%
                \ifx\NAT@temp\NAT@exlab\PackageWarningNoLine{natbib}%
                {Multiple citation on page \thepage: same authors and
                year\MessageBreak without distinguishing extra
                letter,\MessageBreak appears as question mark}\fi
                \NAT@hyper@{\NAT@exlab}%
              \else\unskip\NAT@spacechar
                \NAT@hyper@{\NAT@date}%
              \fi
          \else
            \@citea\NAT@hyper@{%
              \NAT@nmfmt{\NAT@nm}%
              \hyper@natlinkbreak{%
                \NAT@aysep\NAT@spacechar}{\@citeb\@extra@b@citeb
              }%
              \NAT@date
            }%
          \fi
        \fi
      \or\@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}%
      \or\@citea\NAT@hyper@{\NAT@date}%
      \or\@citea\NAT@hyper@{\NAT@alias}%
      \fi \NAT@def@citea
      \else
        \ifcase\NAT@ctype
          \if\relax\NAT@date\relax
            \@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}%
          \else
          \ifx\NAT@last@nm\NAT@nm\NAT@yrsep
              \ifx\NAT@last@yr\NAT@year
                \def\NAT@temp{{?}}%
                \ifx\NAT@temp\NAT@exlab\PackageWarningNoLine{natbib}%
                {Multiple citation on page \thepage: same authors and
                year\MessageBreak without distinguishing extra
                letter,\MessageBreak appears as question mark}\fi
                \NAT@hyper@{\NAT@exlab}%
              \else
                \unskip\NAT@spacechar
                \NAT@hyper@{\NAT@date}%
              \fi
          \else
            \@citea\NAT@hyper@{%
              \NAT@nmfmt{\NAT@nm}%
              \hyper@natlinkbreak{\NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi}%
                {\@citeb\@extra@b@citeb}%
              \NAT@date
            }%
          \fi
          \fi
        \or\@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}%
        \or\@citea\NAT@hyper@{\NAT@date}%
        \or\@citea\NAT@hyper@{\NAT@alias}%
        \fi
        \if\relax\NAT@date\relax
          \NAT@def@citea
        \else
          \NAT@def@citea@close
        \fi
      \fi
      }}\ifNAT@swa\else
        % 将 author-year 式 \cs{citet} 引用的页码置于括号外并改为上标。
        %
        % \if*#2*\else\NAT@cmt#2\fi
        \if\relax\NAT@date\relax\else\NAT@@close\fi
        \if*#2*\else\textsuperscript{#2}\fi
      \fi}{#1}{#2}}
  %
  % 为了将参考文献加入目录和 pdf 书签,重新定义 \pkg{natbib} 的 \cmd{bibsection}
  % 另外如果调用了 \pkg{chapterbib} 或者使用了 \opt{sectionbib} 参数,
  % 需要使用节标题 \cs{section}。
  \newcommand\hfut@bib@chapter{%
    \@mainmatterfalse
    \ifhfut@degree@bachelor
      \ctexset{
        chapter/format = {
          \centering\fontsize{16bp}{22bp}\sffamily\bfseries\selectfont
        },
        chapter/beforeskip  = 11bp,
        chapter/afterskip   = 11bp,
      }
    \fi
    \chapter{\bibname}%
  }%
  \newcommand\hfut@bib@section{%
    \begingroup
      \ctexset{section/numbering=false}%
      \section{\bibname}%
    \endgroup
  }%
  \@ifpackagewith{chapterbib}{sectionbib}{%
    \hfut@error{The "sectionbib" option cannot be used with chaperbib if natbib loaded}%
  }{}%
  \@ifpackageloaded{chapterbib}{%
    \let\bibsection\hfut@bib@section
  }{%
    \@ifxundefined\NAT@sectionbib{%
      \let\bibsection\hfut@bib@chapter
    }{%
      \let\bibsection\hfut@bib@section
    }%
  }%
  %
  % 参考文献列表格式:宋体 10.5 磅,行距 20 磅,续行缩进2.5字符,左对齐。
  \renewcommand\bibfont{%
    \fontsize{10.5bp}{20bp}\selectfont
  }
  \setlength{\bibsep}{0\p@ \@plus.2\p@}
  \renewcommand\@biblabel[1]{[#1]\hfill}
  \setlength{\bibhang}{2.5\ccwd}
}


% biblatex 宏包的配置

\AtEndOfPackageFile*{biblatex}{
  \AtBeginDocument{
    \ifthenelse{\equal{\blx@bbxfile}{apa}}{\def\bibname{REFERENCES}}{}
    \ifthenelse{\equal{\blx@bbxfile}{apa6}}{\def\bibname{REFERENCES}}{}
    \ifthenelse{\equal{\blx@bbxfile}{mla}}{\def\bibname{WORKS CITED}}{}
    \ifthenelse{\equal{\blx@bbxfile}{mla-new}}{\def\bibname{WORKS CITED}}{}
  }
  \DeclareRobustCommand\inlinecite{\parencite}
  \defbibheading{bibliography}[\bibname]{%
    \@mainmatterfalse
    \chapter{\bibname}%
  }
  \renewcommand\bibfont{%
    \fontsize{10.5bp}{20bp}\selectfont
  }
  \setlength{\bibitemsep}{0\p@ \@plus.2\p@}
  \setlength{\bibhang}{2.5\ccwd}
}

% \subsection{附录}

% 定义了一个满足要求的致谢环境:
\newenvironment{acknowledgements}{%
  \@mainmatterfalse
  \ifhfut@degree@graduate
    \hfut@chapter[致谢]{\hfut@acknowledgements@name}%
  \else
    \chapter{致谢}%
  \fi
}{}


% 兼容旧版本中“acknowledgments”的拼法。
% Reserved for compatibility until 2020-07-01.
\newenvironment{acknowledgments}{%
  \begin{acknowledgements}%
}{%
  \end{acknowledgements}%
}

% TODO 发表成果环境格式:
\newenvironment{publications}{%
  \@mainmatterfalse
  \ctexset{
    chapter/format = \centering\sffamily\bfseries\fontsize{18bp}{18bp}\selectfont,
    chapter/beforeskip  = 9bp,
    chapter/afterskip   = 27bp,
    section/name = {,)},
    section/nameformat = {},
    section/aftername = {},
    section/format = \sffamily\bfseries\fontsize{12bp}{20bp}\selectfont\bfseries,
    section/beforeskip  = 10bp,
    section/afterskip   = 10bp,
  }
  \chapter{\hfut@publication@name}%
  \renewcommand\thesection{\arabic{section}}
  \setenumerate[1]{itemsep = 0pt, parsep = 0pt, label = (\arabic*)}
  \setcounter{tocdepth}{0}
  \setcounter{section}{0}
}{}


% \subsection{其他宏包的设置}

% 这些宏包并非格式要求,但是为了方便同学们使用,在这里进行简单设置。


% \subsubsection{\pkg{hyperref} 宏包}

\AtEndOfPackageFile*{hyperref}{
  \hypersetup{
    bookmarksnumbered  = true,
    bookmarksopen      = true,
    bookmarksopenlevel = 1,
    linktoc            = all,
    unicode            = true,
    psdextra           = true,
  }
  %
  % 如果为 \opt{pdf} 样式,设置 hyperlink 颜色
  \ifhfut@output@electronic
    \hypersetup{
      colorlinks = true,
      allcolors  = red,
    }
  \else
    \hypersetup{hidelinks}
  \fi
  %
  % 填写 PDF 元信息。
  \AtBeginDocument{%
    \ifhfut@main@language@chinese
      \hypersetup{
        pdftitle  = \hfut@title,
        pdfauthor = \hfut@author,
      }%
    \else
      \hypersetup{
        pdftitle  = \hfut@title@en,
        pdfauthor = \hfut@author@en,
      }%
    \fi
  }
  %
  % 添加 PDF 书签
  %
  \newcounter{hfut@bookmarknumber}
  \renewcommand\hfut@pdfbookmark[1]{%
    \phantomsection
    \stepcounter{hfut@bookmarknumber}%
    \pdfbookmark[0]{#1}{hfutchapter.\thehfut@bookmarknumber}%
  }
  %
  % 在 PDF 字符串中去掉换行,以减少 \pkg{hyperref} 的警告信息。
  \pdfstringdefDisableCommands{
    \let\\\@empty
    \let\hspace\@gobble
  }
  %
  % \pkg{hyperref} 与 \pkg{unicode-math} 存在一些兼容性问题,见
  % \href{https://github.com/ustctug/ustcthesis/issues/223}{%
  %   ustctug/ustcthesis\#223},
  % \href{https://github.com/ho-tex/hyperref/pull/90}{ho-tex/hyperref\#90} 和
  % \href{https://github.com/ustctug/ustcthesis/issues/235}{%
  %   ustctug/ustcthesis/\#235}。
  \@ifpackagelater{hyperref}{2019/04/27}{}{%
    \g@addto@macro\psdmapshortnames{\let\mu\textmu}%
  }
  %
  % 设置中文的 \cs{autoref}。
  % \footnote{\url{https://tex.stackexchange.com/a/66150/82731}}
  \ifhfut@language@chinese
    \def\equationautorefname~#1\null{公式~(#1)\null}
    \def\footnoteautorefname{脚注}
    \def\itemautorefname~#1\null{第~#1~项\null}
    \def\figureautorefname{图}
    \def\tableautorefname{表}
    \def\partautorefname~#1\null{第~#1~部分\null}
    \def\appendixautorefname{附录}
    \def\chapterautorefname~#1\null{第~#1~章\null}
    \def\sectionautorefname~#1\null{第~#1~节\null}
    \def\subsectionautorefname~#1\null{第~#1~小节\null}
    \def\subsubsectionautorefname~#1\null{第~#1~小小节\null}
    \def\paragraphautorefname~#1\null{第~#1~段\null}
    \def\subparagraphautorefname~#1\null{第~#1~小段\null}
    \def\theoremautorefname{定理}
    \def\HyRef@autopageref#1{\hyperref[{#1}]{第~\pageref*{#1} 页}}
  \fi
}


% \subsubsection{\pkg{amsthm} 宏包}

\AtEndOfPackageFile*{amsthm}{
  \newtheoremstyle{hfutplain}
    {}{}
    {}{2\ccwd}
    {\bfseries}{}
    {\ccwd}{}
  \theoremstyle{hfutplain}
  % 定义新的定理
  \ifhfut@language@chinese
    \newcommand\hfut@assertion@name{断言}
    \newcommand\hfut@assumption@name{假设}
    \newcommand\hfut@axiom@name{公理}
    \newcommand\hfut@corollary@name{推论}
    \newcommand\hfut@definition@name{定义}
    \newcommand\hfut@example@name{例}
    \newcommand\hfut@lemma@name{引理}
    \newcommand\hfut@proof@name{证明}
    \newcommand\hfut@proposition@name{命题}
    \newcommand\hfut@remark@name{注}
    \newcommand\hfut@theorem@name{定理}
  \else
    \newcommand\hfut@assertion@name{Assertion}
    \newcommand\hfut@assumption@name{Assumption}
    \newcommand\hfut@axiom@name{Axiom}
    \newcommand\hfut@corollary@name{Corollary}
    \newcommand\hfut@definition@name{Definition}
    \newcommand\hfut@example@name{Example}
    \newcommand\hfut@lemma@name{Lemma}
    \newcommand\hfut@proof@name{Proof}
    \newcommand\hfut@proposition@name{Proposition}
    \newcommand\hfut@remark@name{Remark}
    \newcommand\hfut@theorem@name{Theorem}
  \fi
  \newtheorem{theorem}             {\hfut@theorem@name}    [chapter]
  \newtheorem{assertion}  [theorem]{\hfut@assertion@name}
  \newtheorem{axiom}      [theorem]{\hfut@axiom@name}
  \newtheorem{corollary}  [theorem]{\hfut@corollary@name}
  \newtheorem{lemma}      [theorem]{\hfut@lemma@name}
  \newtheorem{proposition}[theorem]{\hfut@proposition@name}
  \newtheorem{assumption}          {\hfut@assumption@name} [chapter]
  \newtheorem{definition}          {\hfut@definition@name} [chapter]
  \newtheorem{example}             {\hfut@example@name}    [chapter]
  \newtheorem*{remark}             {\hfut@remark@name}
  % \pkg{amsthm} 单独定义了 proof 环境,这里重新定义以满足格式要求。
  % 原本模仿 \pkg{amsthm} 写成 |\item[\hskip\labelsep\hskip2\ccwd #1\hskip\ccwd]|,
  % 但是却会多出一些间隙。
  \renewenvironment{proof}[1][\hfut@proof@name]{\par
    \pushQED{\qed}%
    \normalfont \topsep6\p@\@plus6\p@\relax
    \trivlist
      \item\relax\hskip2\ccwd
      \textbf{#1}
      \hskip\ccwd\ignorespaces
    }{%
    \popQED\endtrivlist\@endpefalse
  }
  \renewcommand\qedsymbol{\hfut@qed}
}


% \subsubsection{\pkg{algorithm2e} 宏包}

% 按章节编号。
\PassOptionsToPackage{algochapter}{algorithm2e}

\AtEndOfPackageFile*{algorithm2e}{
  \ifhfut@language@chinese
    \SetAlgorithmName{算法}{算法}{算法清单}
  \else
    \SetAlgorithmName{Algorithm}{Algorithm}{List of Algorithms}
  \fi
  %
  % 设置算法环境的格式。
  \SetAlCapSkip{6bp}
  \SetAlCapFnt{\small}
  \SetAlCapNameFnt{\small}
  \ifhfut@degree@graduate
    \SetAlCapNameSty{textbf}
  \fi
  \SetAlgoCaptionSeparator{\unskip\hspace*{\ccwd}}
  %
  % 设置算法清单的格式
  \renewcommand\listofalgocfs{%
    \ifhfut@degree@graduate
      \cleardoublepage
    \fi
    \hfut@chapter{\listalgorithmcfname}%
    \@starttoc{loa}%
  }
  \titlecontents{algocf}
    [2.3em]{\normalsize}
    {\contentslabel{2.3em}}{}
    {\hfut@leaders\contentspage}
  \contentsuse{algocf}{loa}
}


% \subsubsection{\pkg{nomencl} 宏包}

\AtEndOfPackageFile*{nomencl}{
  \let\nomname\hfut@notation@name
  \def\thenomenclature{%
    \ifhfut@degree@graduate
      \cleardoublepage
      \pagestyle{headings}%
    \fi
    \hfut@chapter{\hfut@notation@name}%
    \nompreamble
    \list{}{%
      \labelwidth\nom@tempdim
      \leftmargin\labelwidth
      \advance\leftmargin\labelsep
      \itemsep\nomitemsep
      \let\makelabel\nomlabel}}
  \def\endthenomenclature{%
    \endlist
    \nompostamble
    \ifhfut@degree@graduate
      \clearpage
      \pagestyle{plain}%
    \fi
  }
}


% \subsubsection{\pkg{siunitx} 宏包}

\AtEndOfPackageFile*{siunitx}{
  \sisetup{
    group-minimum-digits = 4,
    separate-uncertainty = true,
    inter-unit-product   = \ensuremath{{}\cdot{}},
  }
  \newcommand\hfut@set@siunitx@language{%
  \ifhfut@language@chinese
    \sisetup{
      list-final-separator = { 和 },
      list-pair-separator  = { 和 },
      range-phrase         = {~},
        }%
      \else
        \sisetup{
          list-final-separator = {, and },
          list-pair-separator  = { and },
          range-phrase         = { to },
        }%
  \fi
  }
  \hfut@set@siunitx@language
  \hfut@option@hook{language}{\hfut@set@siunitx@language}
}

% \subsubsection{\pkg{chapterbib} 宏包}

\AtEndOfPackageFile*{chapterbib}{
  \@ifpackageloaded{natbib}{%
    \@ifpackagewith{chapterbib}{sectionbib}{%
      \hfut@error{The "sectionbib" option cannot be used with chaperbib if natbib loaded}%
    }{}%
    \renewcommand\bibsection{%
      \begingroup
        \ctexset{section/numbering=false}%
        \section{\bibname}%
      \endgroup
    }
  }{}
}