summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hustthesis/hustthesis.dtx
blob: bd2d8d690f84f98feda874ed7420b4ab15c74853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
% \iffalse meta-comment
% !TEX program  = LuaLaTeX
%
% hustthesis.dtx
%
% Copyright (C) 2013-2014 by Xu Cheng <xucheng@me.com>
%               2014-2016 by hust-latex <https://github.com/hust-latex>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is hust-latex Organization.
%
% This work consists of the files hustthesis.bst, hustthesis.dtx,
% hustthesis.ins and the derived file hustthesis.cls
% along with its document and example files.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{hustthesis.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{hustthesis}
%<*class>
[2016/11/17 v1.4 A Thesis Template for Huazhong University of Science and Technology]
%</class>
%
%<*driver>
\documentclass[12pt,a4paper,numbered,full]{l3doc}

\usepackage{fontspec}
\setmainfont[Ligatures={Common,TeX}]{Tex Gyre Pagella}
\setsansfont[Ligatures={Common,TeX}]{Droid Sans}
\setmonofont{CMU Typewriter Text}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}

\usepackage{luatexja-fontspec}
\setmainjfont[BoldFont={AdobeHeitiStd-Regular},ItalicFont={AdobeKaitiStd-Regular}]{AdobeSongStd-Light}
\setsansjfont{AdobeKaitiStd-Regular}
\defaultjfontfeatures{JFM=kaiming}
\newjfontfamily\KAI{AdobeKaitiStd-Regular}
\newjfontfamily\FANGSONG{AdobeFangsongStd-Regular}

\linespread{1.2}\selectfont

\usepackage[top=1.2in,bottom=1.2in,left=1.5in,right=1in]{geometry}
\pagewidth=\paperwidth
\pageheight=\paperheight

\usepackage{color}
\usepackage[table]{xcolor}

\definecolor{hyperreflinkred}{RGB}{128,23,31}
\hypersetup{
  unicode,
  bookmarksnumbered=true,
  bookmarksopen=true,
  bookmarksopenlevel=0,
  breaklinks=true,
  colorlinks=true,
  allcolors=hyperreflinkred,
  linktoc=page,
  plainpages=false,
  pdfpagelabels=true,
  pdfstartview={XYZ null null 1}
}
\usepackage{indentfirst}
\setlength{\parindent}{2em}

\usepackage{titlesec,titletoc}
\usepackage[titles]{tocloft}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{3}

\usepackage{enumitem}
\setlist{noitemsep,partopsep=0pt,topsep=.8ex}
\setlist[1]{labelindent=\parindent}
\setlist[enumerate,1]{label=\arabic*.,ref=\arabic*}
\setlist[enumerate,2]{label*=\arabic*,ref=\theenumi.\arabic*}
\setlist[enumerate,3]{label=\emph{\alph*}),ref=\theenumii\emph{\alph*}}

\usepackage{listings}
\definecolor{lstgreen}{rgb}{0,0.6,0}
\definecolor{lstgray}{rgb}{0.5,0.5,0.5}
\definecolor{lstmauve}{rgb}{0.58,0,0.82}
\lstset{
  basicstyle=\footnotesize\ttfamily\FANGSONG,
  keywordstyle=\color{blue}\bfseries,
  commentstyle=\color{lstgreen}\itshape\KAI,
  stringstyle=\color{lstmauve},
  showspaces=false,
  showstringspaces=false,
  showtabs=false,
  numbers=left,
  numberstyle=\tiny\color{lstgray},
  frame=lines,
  rulecolor=\color{black},
  breaklines=true
}

\AtBeginEnvironment{verbatim}{\small}
\let\AltMacroFont\MacroFont

\usepackage{metalogo}
\usepackage{notes}
\usepackage{tabularx}

\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\setlength{\cftsecindent}{2em}
\setlength{\cftsubsecindent}{4em}
\makeatletter
\newskip\HUST@oldcftbeforepartskip
\HUST@oldcftbeforepartskip=\cftbeforepartskip
\newskip\HUST@oldcftbeforesecskip
\HUST@oldcftbeforesecskip=\cftbeforesecskip
\let\HUST@oldl@part\l@part
\let\HUST@oldl@section\l@section
\let\HUST@oldl@subsection\l@subsection
\def\l@part#1#2{\HUST@oldl@part{#1}{#2}\cftbeforepartskip=3pt}
\def\l@section#1#2{\HUST@oldl@section{#1}{#2}\cftbeforepartskip=\HUST@oldcftbeforepartskip\cftbeforesecskip=3pt}
\def\l@subsection#1#2{\HUST@oldl@subsection{#1}{#2}\cftbeforesecskip=\HUST@oldcftbeforesecskip}
\makeatother

\titleformat{\part}
  {
    \bfseries
    \centering
    \fontsize{18pt}{23.4pt}\selectfont
  }
  {\thepart}
  {1em}
  {}
\let\oldpart\part
\def\part#1{\newpage\oldpart{#1}}

\def\orvar{\textnormal{|}}

\IndexPrologue
 {
  \part{Index}
  The~italic~numbers~denote~the~pages~where~the~
  corresponding~entry~is~described,~
  numbers~underlined~point~to~the~definition,~
  all~others~indicate~the~places~where~it~is~used.
 }

\GlossaryPrologue
 {
  \part{Change History}
 }

\EnableCrossrefs
\CodelineIndex
\RecordChanges

\def\email#1{
  \href{mailto:#1}{\texttt{#1}}
}

\usepackage{xparse}
\ExplSyntaxOn
\DeclareDocumentCommand\pkgurl{o m}
{
    \IfNoValueTF{#1}
    {
        \href
        {
        http://mirrors.ctan.org/help/Catalogue/entries/
        \str_fold_case:n {#2} .html
        }
        { \textsf{#2} }
    }
    {
        \href
        {
        http://mirrors.ctan.org/help/Catalogue/entries/
        \str_fold_case:n {#1} .html
        }
        { \textsf{#2} }
    }
}
\ExplSyntaxOff

\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}

\begin{document}
\DocInput{hustthesis.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{1568}
%
% \iffalse
%<*!(example-bib)>
% \fi
%% \CharacterTable
%% {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%  Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%  Digits        \0\1\2\3\4\5\6\7\8\9
%%  Exclamation   \!     Double quote  \"     Hash (number) \#
%%  Dollar        \$     Percent       \%     Ampersand     \&
%%  Acute accent  \'     Left paren    \(     Right paren   \)
%%  Asterisk      \*     Plus          \+     Comma         \,
%%  Minus         \-     Point         \.     Solidus       \/
%%  Colon         \:     Semicolon     \;     Less than     \<
%%  Equals        \=     Greater than  \>     Question mark \?
%%  Commercial at \@     Left bracket  \[     Backslash     \\
%%  Right bracket \]     Circumflex    \^     Underscore    \_
%%  Grave accent  \`     Left brace    \{     Vertical bar  \|
%%  Right brace   \}     Tilde         \~}
% \iffalse
%</!(example-bib)>
% \fi
%
% \changes{v1.0}{2013/06/01}{Initial version}
% \changes{v1.1}{2013/07/01}{Pack template using dtx and ins file}
% \changes{v1.1}{2013/07/01}{Add language option}
% \changes{v1.2}{2016/06/01}{Fix for TeXLive 2016. Remove \texttt{interfaces} and other problematic package}
% \changes{v1.3}{2016/07/05}{Fix for \XeLaTeX}
% \changes{v1.4}{2016/11/17}{Minor update to fulfill school requirement.}
% \changes{v1.4}{2016/11/17}{Add command to custom apply name field.}
%
% \GetFileInfo{hustthesis.dtx}
%
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\,}
% \DoNotIndex{\def,\if,\else,\fi,\gdef,\long,\let}
% \DoNotIndex{\@ne,\@nil}
% \DoNotIndex{\begingroup,\endgroup,\advance}
% \DoNotIndex{\newcommand,\renewcommand}
% \DoNotIndex{\newenvironment,\renewenvironment}
% \DoNotIndex{\RequirePackage}
%
% \title{A Thesis Template for Huazhong University of Science and Technology: the \textsf{hustthesis} class
% \thanks{This document corresponds to \textsf{hustthesis.cls}~\fileversion, dated \filedate.}}
% \author{Xu Cheng \\ \email{xucheng@me.com}}
% \date{\today}
%
% \begingroup
% \hypersetup{allcolors=black}
% \maketitle
% \endgroup
% \tableofcontents
%
% \part{Introduction}
%
% This is a thesis template for \href{http://www.hust.edu.cn/}{Huazhong University of Science \& Technology}. This template is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%
% The whole project is published under LPPL v1.3 License at \href{https://github.com/hust-latex/hustthesis}{GitHub}.
%
% 中文使用说明见\autoref{part:中文使用说明}。
%
% English version instruction is in \autoref{part:English Version Instruction}.
%
% \part{中文使用说明}\label{part:中文使用说明}
%
% \section{使用必要条件}
%
% \begin{enumerate}
%     \item 安装最新版本的\href{http://www.tug.org/texlive/}{\texttt{TeXLive}}(推荐)或\href{http://miktex.org/}{\texttt{MiKTeX}}。因为未及时更新的宏包可能存在未修复的bug,请确保所有宏包都更新至最新。
%     \item 安装如下中文字体\footnote{本模板所用到的英文字体\textsf{Tex Gyre Termes},\textsf{Droid Sans}和\textsf{CMU Typewriter Text}均默认安装于\textsf{TeXLive}和\textsf{MiKTeX}中。}:
%     \begin{enumerate}[label=\emph{\alph*})]
%         \item \textsf{AdobeSongStd-Light}
%         \item \textsf{AdobeKaitiStd-Regular}
%         \item \textsf{AdobeHeitiStd-Regular}
%         \item \textsf{AdobeFangsongStd-Regular}
%     \end{enumerate}
%     \begin{informationnote}
%     如果使用\textnormal{\LuaTeX},安装字体之后需运行命令\verb+mkluatexfontdb+生成字体索引。
%     \end{informationnote}
% \end{enumerate}
%
% \section{安装}
%
% \subsection{安装到本地}
%
% 使用如下命令即可安装本模板到本地:
% \begin{verbatim}
%     make install
% \end{verbatim}
% 如需卸载,则使用如下命令:
% \begin{verbatim}
%     make uninstall
% \end{verbatim}
%
% 对于没有安装\verb+Make+的Windows系统用户,可以使用如下命令安装:
% \begin{verbatim}
%     makewin32.bat install
% \end{verbatim}
% 如需卸载,则使用如下命令:
% \begin{verbatim}
%     makewin32.bat uninstall
% \end{verbatim}
% 虽然\verb+makewin32.bat+表现与\verb+Makefile+极其相似,但是还是强烈建议你安装\verb+Make+,对于Windows用户可以在\href{http://gnuwin32.sourceforge.net/packages/make.htm}{这里}下载。
%
% \subsection{免安装使用}
%
% 如果你希望临时使用本模板,而非安装到本地供长期使用。使用如下命令解压模板文件:
% \begin{verbatim}
%     make unpack
% \end{verbatim}
% 对于没有安装\verb+Make+的Windows系统用户,则使用如下命令解压:
% \begin{verbatim}
%     makewin32.bat unpack
% \end{verbatim}
%
% 再将\verb+hustthesis+目录下的如下文件拷贝到你\TeX{}工程根目录下即可:
% \begin{itemize}
%     \item \verb+hustthesis.bst+
%     \item \verb+hustthesis.cls+
%     \item \verb+hust-title.eps+
%     \item \verb+hust-title.pdf+
% \end{itemize}
%
% \section{基本用法}
%
% \begin{importantnote}
% 本文档只能使用\textnormal{\XeLaTeX}或\textnormal{\LuaLaTeX}(推荐)编译。
% \end{importantnote}
%
% 在源文件开头处选择加载本文档类型,即可使用本模板,如下所示:
% \begin{verbatim}
%     \documentclass{hustthesis}
% \end{verbatim}
%
% \subsection{文档类型选项}
%
% 加载本文档类型时,有如下三个选项提供选择。
%
% \begin{function}{format}
%     \begin{syntax}
%         format = \meta{draft\orvar{}\textbf{final}}
%     \end{syntax}
%     提交草稿选择\verb+draft+选项,提交最终版选\verb+final+选项。其中草稿正文页包括页眉(“华中科技大学\verb+xx+学位论文”)、页眉修饰线(双线)、页脚(页码)和页脚修饰线(单线)。而最终版正文页不包括页眉、页眉修饰线和页脚修饰线,仅包含页脚(页码)。如果不指定,默认设置为\verb+final+。
% \end{function}
%
% \begin{function}{degree}
%     \begin{syntax}
%         degree = \meta{\textbf{none}\orvar{}fyp\orvar{}bachelor\orvar{}master\orvar{}phd}
%     \end{syntax}
%     指定论文种类,它将通过设置字段\verb+\HUST@zhapplyname+和\verb+\HUST@enapplyname+来影响中英文封面处的标题和正文处的页眉(如果\verb+format+设为\verb+draft+)。各个不同的选项产生的效果见表\ref{tab:optdegree-zh}。如果不指定,默认设置为\verb+none+。如有需要,这两个字段可以通过\href{doc/function//applyname}{\texttt{\textbackslash{}zhapplyname},\texttt{\textbackslash{}enapplyname},\texttt{\textbackslash{}applyname}}命令进一步修改。
% \end{function}
%
% \begin{function}[updated=2013-07-01]{language}
%     \begin{syntax}
%         language = \meta{\textbf{chinese}\orvar{}english\orvar{}english-draft}
%     \end{syntax}
%     指定论文语言。特别的,如果设定为\verb+english-draft+,将会剔除论文中的所有中文内容,这有利于在未安装中文字体的环境中使用。如果不指定,默认设置为\verb+chinese+。
% \end{function}
%
% \begin{table}[ht]
%     \centering
%     \caption{\texttt{degree}选项的作用}\label{tab:optdegree-zh}
%     \begin{tabularx}{\textwidth}{|c|X|X|}
%     \hline
%     \textbf{选项} & \tabincell{c}{\textbf{中文标题}\\(字段\verb+\HUST+\verb+@zhapplyname+)} & \tabincell{c}{\textbf{英文标题}\\(字段\verb+\HUST+\verb+@enapplyname+)} \\
%     \hline
%     \verb+none+ & 学位论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree \\ \hline
%     \verb+fyp+ & 毕业论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for Final Year Project \\ \hline
%     \verb+bachelor+ & 学士学位论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Bachelor \\ \hline
%     \verb+master+ & 硕士学位论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master \\ \hline
%     \verb+phd+ & 博士学位论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Philosophy \\ \hline
%     \end{tabularx}
% \end{table}
%
% \subsection{基本字段设置}
%
% 模板中定义一些命令用于设置文档中的字段。其中一部分命令是以\verb+\zhX{<Chinese var>}+,\verb+\enX{<English var>}+和\verb+\X{<Chinese var>}{<English var>}+的形式出现,他们分别意味着设置字段\verb+X+的中文部分,英文部分及一同设定。
%
% \begin{function}{\zhtitle,\entitle,\title}
%     \begin{syntax}
%     \cs{zhtitle}\Arg{Chinese title}
%     \cs{entitle}\Arg{English title}
%     \cs{title}\Arg{Chinese title}\Arg{English title}
%     \end{syntax}
%     这一组命令用于设定论文的中英文标题。
% \end{function}
%
% \begin{function}{\zhauthor,\enauthor,\author}
%     \begin{syntax}
%     \cs{zhauthor}\Arg{Chinese author}
%     \cs{enauthor}\Arg{English author}
%     \cs{author}\Arg{Chinese author}\Arg{English author}
%     \end{syntax}
%     这一组命令用于设定论文的中英文作者名。
% \end{function}
%
% \begin{function}{\date}
%     \begin{syntax}
%     \cs{date}\Arg{Year}\Arg{Month}\Arg{Day}
%     \end{syntax}
%     该命令用于设定论文的答辩日期。如果不设定,则会选择当前编译日期作为答辩日期。
% \end{function}
%
% \begin{function}{\zhschoolname,\enschoolname,\schoolname}
%     \begin{syntax}
%     \cs{zhschoolname}\Arg{Chinese school name}
%     \cs{enschoolname}\Arg{English school name}
%     \cs{schoolname}\Arg{Chinese school name}\Arg{English school name}
%     \end{syntax}
%     这一组命令用于设定论文的中英文学校名。该字段在模板中已默认设置为\verb+\schoolname{华中科技大学}{Huazhong University of Science \& Technology}+。所以除非需更改学校名,无需使用该命令。
% \end{function}
%
% \begin{function}{\zhaddress,\enaddress,\address}
%     \begin{syntax}
%     \cs{zhaddress}\Arg{Chinese address}
%     \cs{enaddress}\Arg{English address}
%     \cs{address}\Arg{Chinese address}\Arg{English address}
%     \end{syntax}
%     这一组命令用于设定论文的中英文学校地址。该字段在模板中已默认设置为\verb+\address{中国,武汉,430074}{Wuhan~430074, P.~R.~China}+。所以除非需更改学校地址,无需使用该命令。
% \end{function}
%
% \begin{function}[updated=2016-11-17]{\zhapplyname,\enapplyname,\applyname}
%     \begin{syntax}
%     \cs{zhapplyname}\Arg{Chinese apply name}
%     \cs{enapplyname}\Arg{English apply name}
%     \cs{applyname}\Arg{Chinese apply name}\Arg{English apply name}
%     \end{syntax}
%     这一组命令用于自定义中英文封面处的标题和正文处的页眉。详情见~\href{doc/function//degree}{\texttt{degree} 文档类型选项}。
% \end{function}
%
% \begin{function}{\zhmajor,\enmajor,\major}
%     \begin{syntax}
%     \cs{zhmajor}\Arg{Chinese major}
%     \cs{enmajor}\Arg{English major}
%     \cs{major}\Arg{Chinese major}\Arg{English major}
%     \end{syntax}
%     这一组命令用于设定论文的中英文专业名。
% \end{function}
%
% \begin{function}{\zhsupervisor,\ensupervisor,\supervisor}
%     \begin{syntax}
%     \cs{zhsupervisor}\Arg{Chinese supervisor}
%     \cs{ensupervisor}\Arg{English supervisor}
%     \cs{supervisor}\Arg{Chinese supervisor}\Arg{English supervisor}
%     \end{syntax}
%     这一组命令用于设定论文的中英文指导老师名(含职称)。
% \end{function}
%
% \begin{function}{\zhasssupervisor,\enasssupervisor,\asssupervisor}
%     \begin{syntax}
%     \cs{zhasssupervisor}\Arg{Chinese asssupervisor}
%     \cs{enasssupervisor}\Arg{English asssupervisor}
%     \cs{asssupervisor}\Arg{Chinese asssupervisor}\Arg{English asssupervisor}
%     \end{syntax}
%     这一组命令用于设定论文的中英文副指导老师名(含职称)。该命令是可选的,如果不加以设定,封面处不会显示相应项。
% \end{function}
%
% \begin{function}{\schoolcode}
%     \begin{syntax}
%     \cs{schoolcode}\Arg{school code}
%     \end{syntax}
%     用于设置学校代码。
% \end{function}
%
% \begin{function}{\stuno}
%     \begin{syntax}
%     \cs{stuno}\Arg{student number}
%     \end{syntax}
%     用于设置学号。
% \end{function}
%
% \begin{function}{\classno}
%     \begin{syntax}
%     \cs{classno}\Arg{classify number}
%     \end{syntax}
%     用于设置分类号。
% \end{function}
%
% \begin{function}{\secretlevel}
%     \begin{syntax}
%     \cs{secretlevel}\Arg{secret level}
%     \end{syntax}
%     用于设置密级。
% \end{function}
%
% \begin{function}{\zhabstract,\enabstract,\abstract}
%     \begin{syntax}
%     \cs{zhabstract}\Arg{Chinese abstract}
%     \cs{enabstract}\Arg{English abstract}
%     \cs{abstract}\Arg{Chinese abstract}\Arg{English abstract}
%     \end{syntax}
%     这一组命令用于设定论文的中英文摘要。
% \end{function}
%
% \begin{function}{\zhkeywords,\enkeywords,\keywords}
%     \begin{syntax}
%     \cs{zhkeywords}\Arg{Chinese keywords}
%     \cs{enkeywords}\Arg{English keywords}
%     \cs{keywords}\Arg{Chinese keywords}\Arg{English keywords}
%     \end{syntax}
%     这一组命令用于设定论文的中英文关键字。
% \end{function}
%
% \subsection{其它基本命令}
%
% 下面来介绍其它基本命令。
%
% \begin{function}{\frontmatter,\mainmatter,\backmatter}
%     这一组命令用于设定论文的状态、改变样式,其具体使用见\nameref{sec:简单示例}。\verb+\frontmatter+用在文档最开始,表明文档的前言部分(如封面,摘要,目录等)的开始。\verb+\mainmatter+表示论文正文的开始。\verb+\backmatter+表示论文正文的结束。
% \end{function}
%
% \begin{function}{\maketitle,\makecover}
%     \verb+\maketitle+和\verb+\makecover+作用相同,用于生成封面和版权页面。
% \end{function}
%
% \begin{function}{\makeabstract}
%     用于生成中英文摘要页面。
% \end{function}
%
% \begin{function}{\tableofcontents}
%     用于生成目录。
% \end{function}
%
% \begin{function}{\zhdateformat,\endateformat}
%     用于打印中英文日期。
% \end{function}
%
% \vskip 1ex\DescribeEnv{ack}
%     \verb+ack+环境用于致谢页面。使用方法如下:
%     \begin{verbatim}
%     \begin{ack}
%         <content>
%     \end{ack}
%     \end{verbatim}
%
% \begin{function}{\bibliography}
%     \begin{syntax}
%     \cs{bibliography}\Arg{.bib file}
%     \end{syntax}
%     用于生成参考文献。
% \end{function}
%
% \vskip 1ex\DescribeEnv{appendix}
%     \verb+appendix+环境用于附录环境。你可以将附录置于\verb+appendix+环境中,如:
%     \begin{verbatim}
%     \begin{appendix}
%         <content>
%     \end{appendix}
%     \end{verbatim}
% \begin{function}{\appendix}
%     或者使用\verb+\appendix+代表后文均为附录,如:
%     \begin{verbatim}
%     \appendix
%     <content>
%     \end{verbatim}
% \end{function}
%
% \begin{function}{\listoffigures,\listoftables}
%     这两个命令分别用于生成图片和表格索引,可以根据要求在论文前言中使用或附录中使用。
% \end{function}
%
% \vskip 1ex\DescribeEnv{publications}
%     \verb+publications+环境用于已发表论文页面。一般用于附录中。使用上同\verb+enumerate+环境。如下:
%     \begin{verbatim}
%     \begin{publications}
%         \item <thesis>
%         <...>
%     \end{publications}
%     \end{verbatim}
%
% \begin{function}{\TurnOffTabFontSetting,\TurnOnTabFontSetting}
%     因为模板中设定了表格的行距和字号,使得使用中无法临时自定义表格的行距和字号。故提供两个命令用于关闭和开启默认表格的行距和字号设置。比如你如果需要输出一个自己定义字号的表格,可以使用如下示例:
%     \begin{verbatim}
%     \begingroup
%     \TurnOffTabFontSetting
%     \footnotesize % 设置字号
%     \begin{tabular}{...}
%         <content>
%     \end{tabular}
%     \TurnOnTabFontSetting
%     \endgroup
%     \end{verbatim}
% \end{function}
%
% \begin{function}{\email}
%     \begin{syntax}
%     \cs{email}\Arg{Email Address}
%     \end{syntax}
%     用于生成邮箱地址。如\verb+\email{name@example.com}+会生成如下效果的地址:\email{name@example.com}。
% \end{function}
%
% \section{简单示例}\label{sec:简单示例}
% 如下为一个使用本模板的简单示例。更完整的例子请见\texttt{hustthesis-zh-example.tex}文件,其效果见\href{https://github.com/hust-latex/hustthesis/raw/master/hustthesis/hustthesis-zh-example.pdf}{\texttt{hustthesis-zh-example.pdf}}。
%
% \iffalse
%<*driver>
% \fi
\begin{lstlisting}[language={[LaTeX]TeX}]
\documentclass[degree=phd,language=chinese]{hustthesis}

\stuno{你的学号}
\schoolcode{10487}
\title{中文标题}{英文标题}
\author{作者名}{作者名拼音}
\major{专业中文}{专业英文}
\supervisor{指导老师中文}{指导老师英文}
\date{2013}{7}{1} % 答辩日期

\zhabstract{中文摘要}
\zhkeywords{中文关键字}
\enabstract{英文摘要}
\enkeywords{英文关键字}

\begin{document}

\frontmatter
\maketitle
\makeabstract
\tableofcontents
\listoffigures
\listoftables
\mainmatter

%% 正文

\backmatter

\begin{ack}
%% 致谢
\end{ack}
\bibliography{参考文献.bib文件}

\appendix

\begin{publications}
%% 发表过的论文列表
\end{publications}

%% 附录剩余部分

\end{document}
\end{lstlisting}
% \iffalse
%</driver>
% \fi
%
% \section{预设宏包介绍}
%
% 本模板中预设了一些宏包,下面对其进行简单介绍。
%
% \begin{itemize}
%     \item \pkgurl{algorithm2e} 算法环境。
%     \item \pkgurl{enumitem} 自定义列表环境的式样。
%     \item \pkgurl{fancynum} 用于将大数每三位断开。
%     \item \pkgurl{listings} 代码环境。如需更好的代码高亮可以使用\pkgurl{minted}宏包。
%     \item \pkgurl{longtable} 跨页的超长表格环境。
%     \item \pkgurl{ltxtable} \textsf{longtable}环境和\textsf{tabularx}环境的合并。
%     \item \pkgurl{multirow} 用于表格中合并行。
%     \item \pkgurl{overpic} 用于在图片上层叠其他内容。
%     \item \pkgurl{tabularx} 扩展到表格环境。
%     \item \pkgurl{zhnumber} 用于生成中文数字。
% \end{itemize}
%
% \section{高级设置}
%
% \subsection{切换字体}
%
% 模板正文字体为宋体(\textsf{AdobeSongStd-Light}),同时我们提供如下命令切换中文字体:
%
% \begin{function}{\HEI,\hei}
%     \begin{syntax}
%     \{\cs{HEI} \meta{content}\}
%     \cs{hei}\Arg{content}
%     \end{syntax}
%     切换字体为黑体(\textsf{AdobeHeitiStd-Regular})。
% \end{function}
%
% \begin{function}{\KAI,\kai}
%     \begin{syntax}
%     \{\cs{KAI} \meta{content}\}
%     \cs{kai}\Arg{content}
%     \end{syntax}
%     切换字体为楷体(\textsf{AdobeKaitiStd-Regular})。
% \end{function}
%
% \begin{function}{\FANGSONG,\fangsong}
%     \begin{syntax}
%     \{\cs{FANGSONG} \meta{content}\}
%     \cs{fangsong}\Arg{content}
%     \end{syntax}
%     切换字体为仿宋(\textsf{AdobeFangsongStd-Regular})。
% \end{function}
%
% 如果需要加载其他字体,请参阅宏包\pkgurl{fontspec},宏包\pkgurl{xeCJK}(对于\XeLaTeX{})和宏包\pkgurl[luatexja]{luatex-ja}(对于\LuaLaTeX{})的文档。
%
% \subsection{内部字段设置}
%
% 本模板定义了很多内部字段,其具体内容见\autoref{sec:Localization}。通过更改这些字段,可以对论文格式进行自定义。
%
% \part{English Version Instruction}\label{part:English Version Instruction}
%
% \section{Requirement}
% Install the latest version of \href{http://www.tug.org/texlive/}{\texttt{TeXLive}}(Recommend) or \href{http://miktex.org/}{\texttt{MiKTeX}}. Please ensure that all the packages are up-to-date.
%
% If you need to produce the final format of thesis (see \autoref{subsec:Option} for more details), you should also need to install following Chinese fonts:
% \begin{itemize}
%   \item \textsf{AdobeSongStd-Light}
%   \item \textsf{AdobeKaitiStd-Regular}
%   \item \textsf{AdobeHeitiStd-Regular}
%   \item \textsf{AdobeFangsongStd-Regular}
% \end{itemize}
% \begin{informationnote}
% If you use \textnormal{\LuaTeX}, you need to run the command \verb+mkluatexfontdb+ to refresh font database index after installing the fonts.
% \end{informationnote}
%
% \section{Installation}
%
% \subsection{Install into local}
%
% Use the command below to install this template into local.
% \begin{verbatim}
%    make install
% \end{verbatim}
% If you need uninstall it, use the command below.
% \begin{verbatim}
%    make uninstall
% \end{verbatim}
%
% For Windows User who don't install \texttt{Make}, use the command below to install.
% \begin{verbatim}
%     makewin32.bat install
% \end{verbatim}
% If you need uninstall it, use the command below.
% \begin{verbatim}
%     makewin32.bat uninstall
% \end{verbatim}
% Although \texttt{makewin32.bat} behaves much like \texttt{Makefile}, I still
% recommend you install \texttt{Make} into your Windows. You can download
% it from \href{http://gnuwin32.sourceforge.net/packages/make.htm}{here}.
%
% \subsection{Use without installation}
%
% If you want to use this template temporary rather than installing it into local for long term use. Run below command to unpack the package.
% \begin{verbatim}
%     make unpack
% \end{verbatim}
% For Windows User who don't install \texttt{Make}, use the command below to unpack the package.
% \begin{verbatim}
%     makewin32.bat unpack
% \end{verbatim}
% Then copy the following files from directory \texttt{hustthesis} into your \TeX{} project root directory.
% \begin{itemize}
%     \item \verb+hustthesis.bst+
%     \item \verb+hustthesis.cls+
%     \item \verb+hust-title.eps+
%     \item \verb+hust-title.pdf+
% \end{itemize}
%
% \section{Usage}
% \begin{importantnote}
% This template can only be compiled by \\
% \hskip 10pt \textnormal{\XeLaTeX} or\textnormal{\LuaLaTeX}(Recommend).
% \end{importantnote}
%
% Insert below code in the top of source code to use this template:
% \begin{verbatim}
%     \documentclass[language=english]{hustthesis}
% \end{verbatim}
%
% \subsection{Option} \label{subsec:Option}
%
% There're three options available when use this template.
%
% % \begin{function}{format}
%     \begin{syntax}
%         format = \meta{draft\orvar{}\textbf{final}}
%     \end{syntax}
%     If \verb+format+ is set to \verb+final+, the header will be removed. This option is only valid if \verb+language+ is not set to \verb+english-draft+. The default value is \verb+final+.
% \end{function}
%
% \begin{function}[updated=2013-07-01]{language}
%     \begin{syntax}
%         language = \meta{\textbf{chinese}\orvar{}english\orvar{}english-draft}
%     \end{syntax}
%     Set what language is used in the document. Specially, if it's set to \verb+english-draft+, all the Chinese characters will be removed in the document. This is extremely helpful when you don't install Chinese fonts. The default value is \verb+chinese+.
% \end{function}
%
% \begin{function}{degree}
%     \begin{syntax}
%         degree = \meta{\textbf{none}\orvar{}fyp\orvar{}bachelor\orvar{}master\orvar{}phd}
%     \end{syntax}
%     Set the category of thesis. It will influence the title of document, see Table~\ref{tab:optdegree-en}. The default value is \verb+none+. Noted that the apply name field in the title page can be further customized through \href{doc/function//applyname}{\texttt{\textbackslash{}applyname}} command.
% \end{function}
%
% \begin{table}[ht]
%     \centering
%     \caption{Title under different \texttt{degree}}\label{tab:optdegree-en}
%     \begin{tabularx}{\textwidth}{|c|X|}
%     \hline
%     \textbf{Option} & \textbf{Title}\\
%     \hline
%     \verb+none+  & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree \\ \hline
%     \verb+fyp+ & A Thesis Submitted in Partial Fulfillment of the Requirements for Final Year Project \\ \hline
%     \verb+bachelor+ & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Bachelor \\ \hline
%     \verb+master+ & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master \\ \hline
%     \verb+phd+ & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Philosophy \\ \hline
%     \end{tabularx}
% \end{table}
%
% \subsection{Variables setting}
%
% There're some commands which are used to set the variables for the thesis.
%
% \begin{function}{\title}
%     \begin{syntax}
%     \cs{title}\Arg{title}
%     \end{syntax}
%     Set title.
% \end{function}
%
% \begin{function}{\author}
%     \begin{syntax}
%     \cs{author}\Arg{author}
%     \end{syntax}
%     Set author.
% \end{function}
%
% \begin{function}{\date}
%     \begin{syntax}
%     \cs{date}\Arg{Year}\Arg{Month}\Arg{Day}
%     \end{syntax}
%     Set date. If you don't set it, template will use current date.
% \end{function}
%
% \begin{function}{\schoolname}
%     \begin{syntax}
%     \cs{schoolname}\Arg{school name}
%     \end{syntax}
%     Set the name of school which has been set as \\*\hbox{\verb+\schoolname{Huazhong University of Science \& Technology}+} by default. So unless you want to change the name, you don't need to use this command.
% \end{function}
%
% \begin{function}{\address}
%     \begin{syntax}
%     \cs{address}\Arg{address}
%     \end{syntax}
%     Set the address of school which has been set as \\*\hbox{\verb+\address{Wuhan~430074, P.~R.~China}+} by default. So unless you want to change the address, you don't need to use this command.
% \end{function}
%
% \begin{function}[updated=2016-11-17]{\applyname}
%     \begin{syntax}
%     \cs{applyname}\Arg{apply name}
%     \end{syntax}
%     Custom the apply name which affects English title page. See more detail at~\href{doc/function//degree}{\texttt{degree} option}.
% \end{function}
%
% \begin{function}{\major}
%     \begin{syntax}
%     \cs{major}\Arg{major}
%     \end{syntax}
%     Set your major.
% \end{function}
%
% \begin{function}{\supervisor}
%     \begin{syntax}
%     \cs{supervisor}\Arg{supervisor}
%     \end{syntax}
%     Set your supervisor.
% \end{function}
%
% \begin{function}{\asssupervisor}
%     \begin{syntax}
%     \cs{asssupervisor}\Arg{ass-supervisor}
%     \end{syntax}
%     Set your ass-supervisor if you have.
% \end{function}
%
% \begin{function}{\abstract}
%     \begin{syntax}
%     \cs{abstract}\Arg{abstract}
%     \end{syntax}
%     Put your abstract.
% \end{function}
%
% \begin{function}{\keywords}
%     \begin{syntax}
%     \cs{keywords}\Arg{keywords}
%     \end{syntax}
%     Put your keywords.
% \end{function}
%
% \subsection{Other commands}
%
% \begin{function}{\frontmatter,\mainmatter,\backmatter}
%     Used to determine the different part of document. You can see the example at \autoref{sec:simple-example}.
% \end{function}
%
% \begin{function}{\maketitle,\makecover}
%     \verb+\maketitle+ and \verb+\makecover+ are the same. Used to create the title page.
% \end{function}
%
% \begin{function}{\makeabstract}
%     Used to create abstract page.
% \end{function}
%
% \begin{function}{\tableofcontents}
%     Used to create table of contents.
% \end{function}
%
% \begin{function}{\endateformat}
%     Used to print the date.
% \end{function}
%
% \vskip 1ex\DescribeEnv{ack}
%     The \verb+ack+ environment is used to create acknowledge page.
%     \begin{verbatim}
%     \begin{ack}
%         <content>
%     \end{ack}
%     \end{verbatim}
%
% \begin{function}{\bibliography}
%     \begin{syntax}
%     \cs{bibliography}\Arg{.bib file}
%     \end{syntax}
%     Used to create bibliography page.
% \end{function}
%
% \vskip 1ex\DescribeEnv{appendix}
%     The \verb+appendix+ environment is for appendix of course. Used like this:
%     \begin{verbatim}
%     \begin{appendix}
%         <content>
%     \end{appendix}
%     \end{verbatim}
% \begin{function}{\appendix}
%     Or simple use \verb+\appendix+ to indicate that the rest of document are all in appendix, like this:
%     \begin{verbatim}
%     \appendix
%     <content>
%     \end{verbatim}
% \end{function}
%
% \begin{function}{\listoffigures,\listoftables}
%     Create the index for all the figures and tables separately.
% \end{function}
%
% \vskip 1ex\DescribeEnv{publications}
%     The \verb+publications+ environment is where you list all of your published thesises. It's usually putted in appendix.
%     \begin{verbatim}
%     \begin{publications}
%         \item <thesis>
%         <...>
%     \end{publications}
%     \end{verbatim}
%
% \begin{function}{\TurnOffTabFontSetting,\TurnOnTabFontSetting}
%     This template has set the font size and line spread for all the tables which makes it's impossible to change font format temporary in one table.  So it provides these to command to temporary disable or enable default font setting in table. For example, if you want to change table font size, you can use the code like this:
%     \begin{verbatim}
%     \begingroup
%     \TurnOffTabFontSetting
%     \footnotesize % Set your font format as you like.
%     \begin{tabular}{...}
%         <content>
%     \end{tabular}
%     \TurnOnTabFontSetting
%     \endgroup
%     \end{verbatim}
% \end{function}
%
% \begin{function}{\email}
%     \begin{syntax}
%     \cs{email}\Arg{Email Address}
%     \end{syntax}
%     A command to display email address. For example, \verb+\email{name@example.com}+ would look like this: \email{name@example.com}.
% \end{function}
%
% \section{Simple example}\label{sec:simple-example}
% Below is a simple example of using this template. For a complete example see \texttt{hustthesis-en-example.tex} which will generate \href{https://github.com/hust-latex/hustthesis/raw/master/hustthesis/hustthesis-en-example.pdf}{\texttt{hustthesis-en-example.pdf}}.
%
% \iffalse
%<*driver>
% \fi
\begin{lstlisting}[language={[LaTeX]TeX}]
\documentclass[degree=phd,language=english]{hustthesis}

\title{your title}
\author{your name}
\major{your major}
\supervisor{your supervisor}
\date{2013}{7}{1}

\abstract{the abstract}
\keywords{the keywords}

\begin{document}

\frontmatter
\maketitle
\makeabstract
\tableofcontents
\listoffigures
\listoftables
\mainmatter

%% main body

\backmatter

\begin{ack}
%% acknowledge
\end{ack}
\bibliography{.bib file}

\appendix

\begin{publications}
%% your publications
\end{publications}

%% rest of appendix

\end{document}
\end{lstlisting}
% \iffalse
%</driver>
% \fi
%
%
% \section{Introduction to some packages used in the template}
%
% Here's a list of some packages used in the template.
%
% \begin{itemize}
%     \item \pkgurl{algorithm2e} For display algorithm.
%     \item \pkgurl{enumitem} For set the style of enumerate, itemize and description environment.
%     \item \pkgurl{fancynum} Display the really big number.
%     \item \pkgurl{listings} For display the highlighted code. If you need better quality, use the package \pkgurl{minted}.
%     \item \pkgurl{longtable} Create a very long table.
%     \item \pkgurl{ltxtable} Combine the features of \textsf{longtable} anb \textsf{tabularx}.
%     \item \pkgurl{multirow} Combine multi-rows in table.
%     \item \pkgurl{overpic} Put something over a picture,
%     \item \pkgurl{tabularx} A better table environment.
% \end{itemize}
%
% \StopEventually{
%  \PrintIndex
%  \PrintChanges
% }
%
% \part{Implementation}\label{part:Implementation}
%
%    \begin{macrocode}
%<*class>
\RequirePackage{ifthen}
%    \end{macrocode}
%
% \section{Process Options}
% Use \pkgurl{xkeyval} to process options.
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
%
% Option |format|.
%    \begin{macrocode}
\newif\ifHUST@finalformat
\HUST@finalformattrue
\DeclareOptionX{format}[final]{
  \ifthenelse{\equal{#1}{final}}{
    \HUST@finalformattrue
  }{
    \ifthenelse{\equal{#1}{draft}}{
      \HUST@finalformatfalse
    }{
      \ClassError{hustthesis}
      {Option format can only be 'final' or 'draft'}
      {Try to remove option format^^J}
    }
  }
}
%    \end{macrocode}
%
% Option |language|.
%    \begin{macrocode}
\gdef\HUST@language{chinese}
\DeclareOptionX{language}[chinese]{
  \ifthenelse{\equal{#1}{chinese} \OR \equal{#1}{english} \OR \equal{#1}{english-draft}}{
    \gdef\HUST@language{#1}
  }{
    \ClassError{hustthesis}
    {Option language can only be 'chinese', 'english' or 'english-draft'}
    {Try to remove option language^^J}
  }
}
%    \end{macrocode}
%
% Option |degree|.
%    \begin{macrocode}
\gdef\HUST@degree{none}
\DeclareOptionX{degree}[none]{
  \ifthenelse{\equal{#1}{none} \OR \equal{#1}{fyp} \OR \equal{#1}{bachelor} \OR \equal{#1}{master} \OR \equal{#1}{phd}}{
    \gdef\HUST@degree{#1}
  }{
     \ClassError{hustthesis}
      {Option degree can only be 'none', 'fyp', 'bachelor', 'master' or 'phd'}
      {Try to remove option degree^^J}
  }
}
%    \end{macrocode}
%
% Process options and load class |book|.
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptionsX
\LoadClass[12pt, a4paper, openany]{book}
%    \end{macrocode}
%
% \section{Check Engine}
% Check engine, only \XeLaTeX{} and \LuaLaTeX{} are supported.
%    \begin{macrocode}
\RequirePackage{iftex}
\ifXeTeX\else
  \ifLuaTeX\else
    \begingroup
      \errorcontextlines=-1\relax
      \newlinechar=10\relax
      \errmessage{^^J
      *******************************************************^^J
      * XeTeX or LuaTeX is required to compile this document.^^J
      * Sorry!^^J
      *******************************************************^^J
      }%
    \endgroup
  \fi
\fi
%    \end{macrocode}
%
% \section{Font Setting}
% Set font used in document. Firstly, it's font setting for English font under |english-draft| mode. We use \pkgurl{fontspec} package to handle font. We choose \textsf{Tex Gyre Termes}, \textsf{Droid Sans} and \textsf{CMU Typewriter Text} as document main font, sans font and mono font.
%    \begin{macrocode}
\ifthenelse{\equal{\HUST@language}{english-draft}}{
    \RequirePackage{fontspec}
    \setmainfont[
      Ligatures={Common,TeX},
      Extension=.otf,
      UprightFont=*-regular,
      BoldFont=*-bold,
      ItalicFont=*-italic,
      BoldItalicFont=*-bolditalic]{texgyretermes}
    \setsansfont[Ligatures={Common,TeX}]{Droid Sans}
    \setmonofont{CMU Typewriter Text}
    \defaultfontfeatures{Mapping=tex-text}
%    \end{macrocode}
%
% Now let's set the Chinese font commands into empty, when document is under |english-draft| mode.
%    \begin{macrocode}
    \let\HEI\relax
    \let\KAI\relax
    \let\FANGSONG\relax
    \newcommand{\hei}[1]{#1}
    \newcommand{\kai}[1]{#1}
    \newcommand{\fangsong}[1]{#1}
}{}
%    \end{macrocode}
%
% Below is the font setting under |chinese| or |english| mode. We chooses the same English font as under |english-draft| mode. We use \pkgurl{xecjk} package (for \XeLaTeX) or \pkgurl[luatexja]{luatex-ja} package (for \LuaLaTeX, recommend) to handle Chinese font. We will use font: \textsf{AdobeSongStd-Light}, \textsf{AdobeKaitiStd-Regular}, \textsf{AdobeHeitiStd-Regular} and \textsf{AdobeFangsongStd-Regular}.
%    \begin{macrocode}
\ifthenelse{\equal{\HUST@language}{english-draft}}{}{
    \ifXeTeX  % XeTeX下使用fontspec + xeCJK处理字体
      % 英文字体
      \RequirePackage{fontspec}
      \RequirePackage{xunicode}
      \setmainfont[
        Ligatures={Common,TeX},
        Extension=.otf,
        UprightFont=*-regular,
        BoldFont=*-bold,
        ItalicFont=*-italic,
        BoldItalicFont=*-bolditalic]{texgyretermes}
      \setsansfont[Ligatures={Common,TeX}]{Droid Sans}
      \setmonofont{CMU Typewriter Text}
      \defaultfontfeatures{Mapping=tex-text}
      % 中文字体
      \RequirePackage[CJKmath]{xeCJK}
      \setCJKmainfont[
       BoldFont={Adobe Heiti Std},
       ItalicFont={Adobe Kaiti Std}]{Adobe Song Std}
      \setCJKsansfont{Adobe Kaiti Std}
      \setCJKmonofont{Adobe Fangsong Std}
      \xeCJKsetup{PunctStyle=kaiming}

      \newcommand\ziju[2]{{\renewcommand{\CJKglue}{\hskip #1} #2}}
%    \end{macrocode}
%
% \begin{macro}{\HEI}
%    \begin{macrocode}
      \newCJKfontfamily\HEI{Adobe Heiti Std}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\KAI}
%    \begin{macrocode}
      \newCJKfontfamily\KAI{Adobe Kaiti Std}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FANGSONG}
%    \begin{macrocode}
      \newCJKfontfamily\FANGSONG{Adobe Fangsong Std}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hei}
%    \begin{macrocode}
      \newcommand{\hei}[1]{{\HEI #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\kai}
%    \begin{macrocode}
      \newcommand{\kai}[1]{{\KAI #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fangsong}
%    \begin{macrocode}
      \newcommand{\fangsong}[1]{{\FANGSONG #1}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
    \else\fi
    \ifLuaTeX  % LuaTeX下使用luatex-ja处理字体 [推荐]
      \RequirePackage{luatexja-fontspec}
      % 英文字体
      \setmainfont[Ligatures={Common,TeX}]{Tex Gyre Termes}
      \setsansfont[Ligatures={Common,TeX}]{Droid Sans}
      \setmonofont{CMU Typewriter Text}
      \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
      % 中文字体
      \setmainjfont[
       BoldFont={AdobeHeitiStd-Regular},
       ItalicFont={AdobeKaitiStd-Regular}]{AdobeSongStd-Light}
      \setsansjfont{AdobeKaitiStd-Regular}
      \defaultjfontfeatures{JFM=kaiming}

      \newcommand\ziju[2]{\vbox{\ltjsetparameter{kanjiskip=#1} #2}}
%    \end{macrocode}
%
% \begin{macro}{\HEI}
%    \begin{macrocode}
      \newjfontfamily\HEI{AdobeHeitiStd-Regular}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\KAI}
%    \begin{macrocode}
      \newjfontfamily\KAI{AdobeKaitiStd-Regular}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FANGSONG}
%    \begin{macrocode}
      \newjfontfamily\FANGSONG{AdobeFangsongStd-Regular}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hei}
%    \begin{macrocode}
      \newcommand{\hei}[1]{{\jfontspec{AdobeHeitiStd-Regular} #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\kai}
%    \begin{macrocode}
      \newcommand{\kai}[1]{{\jfontspec{AdobeKaitiStd-Regular} #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fangsong}
%    \begin{macrocode}
      \newcommand{\fangsong}[1]{{\jfontspec{AdobeFangsongStd-Regular} #1}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
    \else\fi
%    \end{macrocode}
%
% Generate Chinese number using \pkgurl{zhnumber}.
%    \begin{macrocode}
    \RequirePackage{zhnumber}
    \def\CJKnumber#1{\zhnumber{#1}} % 兼容CJKnumb
}
%    \end{macrocode}
%
% \section{Basic Format}
% We set global line spread to 1.3.
%    \begin{macrocode}
\linespread{1.3}\selectfont
%    \end{macrocode}
%
% Use \pkgurl{geometry} package to handle paper page.
%    \begin{macrocode}
\RequirePackage{geometry}
\geometry{
  top=1.77in,
  bottom=0.8in,
  left=1.1in,
  right=1.1in,
  includefoot
}
\ifthenelse{\isundefined{\pagewidth}}{
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight
}{
  \pagewidth=\paperwidth
  \pageheight=\paperheight
}
%    \end{macrocode}
%
% Indent of paragraph and skip between paragraphs.
%    \begin{macrocode}
\RequirePackage{indentfirst}
\setlength{\parindent}{2em}
\setlength{\parskip}{0pt plus 2pt minus 1pt}
%    \end{macrocode}
%
% Packages to handle color.
%    \begin{macrocode}
\RequirePackage{color}
\RequirePackage[table]{xcolor}
%    \end{macrocode}
%
% Use \pkgurl{hyperref} package to generate cross-reference link.
%    \begin{macrocode}
\RequirePackage[unicode]{hyperref}
\hypersetup{
  bookmarksnumbered=true,
  bookmarksopen=true,
  bookmarksopenlevel=1,
  breaklinks=true,
  colorlinks=true,
  allcolors=black,
  linktoc=all,
  plainpages=false,
  pdfpagelabels=true,
  pdfstartview={XYZ null null 1},
  pdfinfo={Template.Info={hustthesis.cls v1.1 2013/07/01, Copyright (C) 2013-2014 by Xu Cheng 2014 by hust-latex, https://github.com/hust-latex/hustthesis}}
}
%    \end{macrocode}
%
% \section{Load Packages}
% Load packages for math.
%    \begin{macrocode}
\RequirePackage{amsmath,amssymb,amsfonts}
\RequirePackage[amsmath,amsthm,thmmarks,hyperref,thref]{ntheorem}
\RequirePackage{fancynum}
\setfnumgsym{\,}
\RequirePackage[lined,boxed,linesnumbered,ruled,vlined,algochapter]{algorithm2e}
%    \end{macrocode}
%
% Load packages for picture.
%    \begin{macrocode}
\RequirePackage{overpic}
\RequirePackage{graphicx,caption,subcaption}
%    \end{macrocode}
%
% Load packages for table.
%    \begin{macrocode}
\RequirePackage{array}
\RequirePackage{multirow,tabularx,ltxtable}
%    \end{macrocode}
%
% Load package for code highlight. Here we use \pkgurl{listings} to highlight the code. But if you need more features, use \pkgurl{minted}.
%    \begin{macrocode}
\RequirePackage{listings}
%    \end{macrocode}
%
% Load package for bibliography cite style.
%    \begin{macrocode}
\RequirePackage[numbers,square,comma,super,sort&compress]{natbib}
%    \end{macrocode}
%
% Other packages for style setting.
%    \begin{macrocode}
\RequirePackage{titlesec}
\RequirePackage{titletoc}
\RequirePackage{tocvsec2}
\RequirePackage[inline]{enumitem}
\RequirePackage{fancyhdr}
\RequirePackage{afterpage}
\RequirePackage{datenumber}
\RequirePackage{etoolbox}
\RequirePackage{appendix}
\RequirePackage[titles]{tocloft}
\RequirePackage{xstring}
\RequirePackage{perpage}
%    \end{macrocode}
%
% \section{Variables Setting}
% \begin{macro}{\zhtitle,\entitle,\title}
% Commands to set the title.
%    \begin{macrocode}
\def\zhtitle#1{\gdef\HUST@zhtitle{#1}\hypersetup{pdftitle={#1}}}
\def\entitle#1{\gdef\HUST@entitle{#1}}
\DeclareDocumentCommand\title{m g}
{
  \IfNoValueTF{#2}{
    \zhtitle{#1}\entitle{#1}
  }{
    \zhtitle{#1}\entitle{#2}
  }
}
\title{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhauthor,\enauthor,\author}
% Commands to set the author.
%    \begin{macrocode}
\def\zhauthor#1{\gdef\HUST@zhauthor{#1}\hypersetup{pdfauthor={#1}}}
\def\enauthor#1{\gdef\HUST@enauthor{#1}}
\DeclareDocumentCommand\author{m g}
{
  \IfNoValueTF{#2}{
    \zhauthor{#1}\enauthor{#1}
  }{
    \zhauthor{#1}\enauthor{#2}
  }
}
\author{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\date,\zhdateformat,\endateformat,\dateformat}
% A command to set the date and several commands to display date.
%    \begin{macrocode}
\def\date#1#2#3{
  \setdate{#1}{#2}{#3}
}
\setdatetoday
\def\zhdateformat{~\thedateyear~年~\thedatemonth~月~\thedateday~日}
\def\endateformat{\datedate}
\ifthenelse{\equal{\HUST@language}{chinese}}{
  \let\dateformat\zhdateformat
}{
  \let\dateformat\endateformat
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhschoolname,\enschoolname,\schoolname}
% Commands to set the school name.
%    \begin{macrocode}
\def\zhschoolname#1{\gdef\HUST@zhschoolname{#1}}
\def\enschoolname#1{\gdef\HUST@enschoolname{#1}}
\DeclareDocumentCommand\schoolname{m g}
{
  \IfNoValueTF{#2}{
    \zhschoolname{#1}\enschoolname{#1}
  }{
    \zhschoolname{#1}\enschoolname{#2}
  }
}
\schoolname{华中科技大学}{Huazhong University of Science~\char38~Technology}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhaddress,\enaddress,\address}
% Commands to set the address.
%    \begin{macrocode}
\def\zhaddress#1{\gdef\HUST@zhaddress{#1}}
\def\enaddress#1{\gdef\HUST@enaddress{#1}}
\DeclareDocumentCommand\address{m g}
{
  \IfNoValueTF{#2}{
    \zhaddress{#1}\enaddress{#1}
  }{
    \zhaddress{#1}\enaddress{#2}
  }
}
\address{中国,武汉,430074}{Wuhan~430074, P.~R.~China}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhapplyname,\enapplyname,\applyname}
% Commands to custom apply name.
%    \begin{macrocode}
\def\zhapplyname#1{\def\HUST@zhapplyname{#1}}
\def\enapplyname#1{\def\HUST@enapplyname{#1}}
\DeclareDocumentCommand\applyname{m g}
{
  \IfNoValueTF{#2}{
    \enapplyname{#1}
  }{
    \zhapplyname{#1}\enapplyname{#2}
  }
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhmajor,\enmajor,\major}
% Commands to set the major.
%    \begin{macrocode}
\def\zhmajor#1{\gdef\HUST@zhmajor{#1}}
\def\enmajor#1{\gdef\HUST@enmajor{#1}}
\DeclareDocumentCommand\major{m g}
{
  \IfNoValueTF{#2}{
    \zhmajor{#1}\enmajor{#1}
  }{
    \zhmajor{#1}\enmajor{#2}
  }
}
\major{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhsupervisor,\ensupervisor,\supervisor}
% Commands to set the supervisor.
%    \begin{macrocode}
\def\zhsupervisor#1{\gdef\HUST@zhsupervisor{#1}}
\def\ensupervisor#1{\gdef\HUST@ensupervisor{#1}}
\DeclareDocumentCommand\supervisor{m g}
{
  \IfNoValueTF{#2}{
    \zhsupervisor{#1}\ensupervisor{#1}
  }{
    \zhsupervisor{#1}\ensupervisor{#2}
  }
}
\supervisor{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhasssupervisor,\enasssupervisor,\asssupervisor}
% Commands to set the asssupervisor.
%    \begin{macrocode}
\def\zhasssupervisor#1{\gdef\HUST@zhasssupervisor{#1}}
\def\enasssupervisor#1{\gdef\HUST@enasssupervisor{#1}}
\DeclareDocumentCommand\asssupervisor{m g}
{
  \IfNoValueTF{#2}{
    \zhasssupervisor{#1}\enasssupervisor{#1}
  }{
    \zhasssupervisor{#1}\enasssupervisor{#2}
  }
}
\asssupervisor{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\schoolcode}
% A command to set school code.
%    \begin{macrocode}
\def\schoolcode#1{\gdef\HUST@schoolcode{#1}}
\schoolcode{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\stuno}
% A command to set student number.
%    \begin{macrocode}
\def\stuno#1{\gdef\HUST@stuno{#1}}
\stuno{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\classno}
% A command to set classification number.
%    \begin{macrocode}
\def\classno#1{\gdef\HUST@classno{#1}}
\classno{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\secretlevel}
% A command to set secret level.
%    \begin{macrocode}
\def\secretlevel#1{\gdef\HUST@secretlevel{#1}}
\secretlevel{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhabstract,\enabstract,\abstract}
% Commands to set the abstract.
%    \begin{macrocode}
\long\def\zhabstract#1{\long\gdef\HUST@zhabstract{#1}}
\long\def\enabstract#1{\long\gdef\HUST@enabstract{#1}}
\DeclareDocumentCommand\abstract{+m +g}
{
  \IfNoValueTF{#2}{
    \zhabstract{#1}\enabstract{#1}
  }{
    \zhabstract{#1}\enabstract{#2}
  }
}
\abstract{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhkeywords,\enkeywords,\keywords}
% Commands to set the keywords.
%    \begin{macrocode}
\def\zhkeywords#1{\gdef\HUST@zhkeywords{#1}\hypersetup{pdfkeywords={#1}}}
\def\enkeywords#1{\gdef\HUST@enkeywords{#1}}
\DeclareDocumentCommand\keywords{m g}
{
  \IfNoValueTF{#2}{
    \zhkeywords{#1}\enkeywords{#1}
  }{
    \zhkeywords{#1}\enkeywords{#2}
  }
}
\keywords{}{}
%    \end{macrocode}
% \end{macro}
%
% \section{Localization}\label{sec:Localization}
% Chinese localization.
% \footnote{The |autorefname| Reference:\url{http://tex.stackexchange.com/questions/52410/how-to-use-the-command-autoref-to-implement-the-same-effect-when-use-the-comman}}
%    \begin{macrocode}
\ifthenelse{\equal{\HUST@language}{chinese}}{
    \def\indexname{索引}
    \def\figurename{图}
    \def\tablename{表}
    \AtBeginDocument{\def\listingscaption{代码}}
    \def\bibname{参考文献}
    \def\contentsname{目\hspace{1em}录}
    \def\contentsnamenospace{目录}
    \def\appendixname{附录}
    \def\HUST@listfigurename{插图索引}
    \def\HUST@listtablename{表格索引}
    \def\equationautorefname{公式}
    \def\footnoteautorefname{脚注}
    \def\itemautorefname~#1\null{第~#1~项\null}
    \def\figureautorefname{图}
    \def\tableautorefname{表}
    \def\appendixautorefname{附录}
    \expandafter\def\csname\appendixname autorefname\endcsname{\appendixname}
    \def\chapterautorefname~#1\null{第\zhnumber{#1}章\null}
    \def\sectionautorefname~#1\null{#1~小节\null}
    \def\subsectionautorefname~#1\null{#1~小节\null}
    \def\subsubsectionautorefname~#1\null{#1~小节\null}
    \def\FancyVerbLineautorefname~#1\null{第~#1~行\null}
    \def\pageautorefname~#1\null{第~#1~页\null}
    \def\lstlistingautorefname{代码}
    \def\definitionautorefname{定义}
    \def\propositionautorefname{命题}
    \def\lemmaautorefname{引理}
    \def\theoremautorefname{定理}
    \def\axiomautorefname{公理}
    \def\corollaryautorefname{推论}
    \def\exerciseautorefname{练习}
    \def\exampleautorefname{例}
    \def\proofautorefname{证明}
    \SetAlgorithmName{算法}{算法}{算法索引}
    \SetAlgoProcName{过程}{过程}
    \SetAlgoFuncName{函数}{函数}
    \def\AlgoLineautorefname~#1\null{第~#1~行\null}
}{}
%    \end{macrocode}
%
% English localization.
%    \begin{macrocode}
\ifthenelse{\equal{\HUST@language}{chinese}}{}{
    \def\HUST@listfigurename{List of Figures}
    \def\HUST@listtablename{List of Tables}
    \def\equationautorefname{Equation}
    \def\footnoteautorefname{Footnote}
    \def\itemautorefname{Item}
    \def\figureautorefname{Figure}
    \def\tableautorefname{Table}
    \def\appendixautorefname{Appendix}
    \expandafter\def\csname\appendixname autorefname\endcsname{\appendixname}
    \def\chapterautorefname{Chapter}
    \def\sectionautorefname{Section}
    \def\subsectionautorefname{Subsection}
    \def\subsubsectionautorefname{Sub-subsection}
    \def\FancyVerbLineautorefname{Line}
    \def\pageautorefname{Page}
    \def\lstlistingautorefname{Code Fragment}
    \def\definitionautorefname{Definition}
    \def\propositionautorefname{Proposition}
    \def\lemmaautorefname{Lemma}
    \def\theoremautorefname{Theorem}
    \def\axiomautorefname{Axiom}
    \def\corollaryautorefname{Corollary}
    \def\exerciseautorefname{Exercise}
    \def\exampleautorefname{Example}
    \def\proofautorefname{Proof}
    \SetAlgorithmName{Algorithm}{Algorithm}{List of Algorithms}
    \SetAlgoProcName{Procedure}{Procedure}
    \SetAlgoFuncName{Function}{Function}
    \def\AlgoLineautorefname{Line}
}
%    \end{macrocode}
%
% Internal variables.
%    \begin{macrocode}
\def\HUST@classnotitle{{分}\hfill{类}\hfill{号}}
\def\HUST@stunotitle{学号}
\def\HUST@schoolcodetitle{学校代码}
\def\HUST@secrettile{密级}
\def\HUST@zhauthortitle{{学}\hfill{位}\hfill{申}\hfill{请}\hfill{人}}
\def\HUST@zhmajortitle{{学}\hfill{科}\hfill{专}\hfill{业}}
\def\HUST@zhsupervisortitle{{指}\hfill{导}\hfill{教}\hfill{师}}
\def\HUST@zhasssupervisortitle{{副}\hfill{指}\hfill{导}\hfill{教}\hfill{师}}
\def\HUST@zhdatetitle{{答}\hfill{辩}\hfill{日}\hfill{期}}

\def\HUST@enauthortitle{Student}
\def\HUST@enmajortitle{Major}
\def\HUST@ensupervisortitle{Supervisor}
\def\HUST@enasssupervisortitle{Co-Supervisor}

\def\HUST@originaldeclare{独创性声明}
\long\def\HUST@originaldeclaretext{
  本人声明所呈交的学位论文是我个人在导师的指导下进行的研究工作及取得的研究成果。尽我所知,除文中已标明引用的内容外,本论文不包含任何其他人或集体已经发表或撰写过的研究成果。对本文的研究做出贡献的个人和集体,均已在文中以明确方式标明。本人完全意识到本声明的法律结果由本人承担。
}
\def\HUST@zhauthorsig{学位论文作者签名:}
\def\HUST@zhdatefield{日期:\hspace{2em}年\hspace{2em}月\hspace{2em}日}

\def\HUST@authtitle{学位论文版权使用授权书}
\long\def\HUST@authorizationtext{
  本学位论文作者完全了解学校有关保留、使用学位论文的规定,即:学校有权保留并向国家有关部门或机构送交论文的复印件和电子版,允许论文被查阅和借阅。本人授权华中科技大学可以将本学位论文的全部或部分内容编入有关数据库进行检索,可以采用影印、缩印或扫描等复制手段保存和汇编本学位论文。
}
\long\def\HUST@authorizationaddon{
 本论文属于
 \tabincell{l}{
  保密$\square$,在~\makebox[2em]{\hrulefill} 年解密后适用本授权书。\\
  不保密~$\square$。
 }
}
\def\HUST@authorizationcheck{(请在以上方框内打“$\surd$”)}
\def\HUST@zhteachersig{指导教师签名:}

\def\HUST@zhabstractname{摘\hspace{1em}要}
\def\HUST@zhabstractnamenospace{摘要}
\def\HUST@zhkeywordstitle{关键词:}
\def\HUST@enabstractname{Abstract}
\def\HUST@enkeywordstitle{Key words:}

\ifthenelse{\equal{\HUST@language}{chinese}}{
  \def\HUST@ackname{致\hspace{1em}谢}
  \def\HUST@acknamenospace{致谢}
  \def\HUST@publicationtitle{攻读学位期间发表的学术论文}
}{
  \def\HUST@ackname{Acknowledge}
  \def\HUST@acknamenospace{Acknowledge}
  \def\HUST@publicationtitle{Publication}
}

\ifthenelse{\equal{\HUST@degree}{none}}{
  \def\HUST@zhapplyname{学位论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree}
}{}

\ifthenelse{\equal{\HUST@degree}{fyp}}{
  \def\HUST@zhapplyname{毕业设计论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for Final Year Project}
}{}

\ifthenelse{\equal{\HUST@degree}{bachelor}}{
  \def\HUST@zhapplyname{学士学位论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Bachelor}
}{}

\ifthenelse{\equal{\HUST@degree}{master}}{
  \def\HUST@zhapplyname{硕士学位论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master}
}{}

\ifthenelse{\equal{\HUST@degree}{phd}}{
  \def\HUST@zhapplyname{博士学位论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Philosophy}
}{}

\ifthenelse{\equal{\HUST@language}{chinese}}{
  \hypersetup{pdfsubject={\HUST@zhschoolname\HUST@zhapplyname}}
}{
  \hypersetup{pdfsubject={\HUST@enapplyname}}
}
%    \end{macrocode}
%
% Set |\listfigurename| and |\listtablename|.
%    \begin{macrocode}
\def\listfigurename{\HUST@listfigurename}
\def\listtablename{\HUST@listtablename}
%    \end{macrocode}
%
% \section{Style Setting}
% \subsection{Equation Style}
% Allow long equation breaking between lines or pages.
%    \begin{macrocode}
\allowdisplaybreaks[4]
%    \end{macrocode}
%
% Set skip between equation and context.
%    \begin{macrocode}
\abovedisplayskip=10bp plus 2bp minus 2bp
\abovedisplayshortskip=10bp plus 2bp minus 2bp
\belowdisplayskip=\abovedisplayskip
\belowdisplayshortskip=\abovedisplayshortskip
%    \end{macrocode}
%
% Set equation numbering style.
%    \begin{macrocode}
\numberwithin{equation}{chapter}
%    \end{macrocode}
%
% \subsection{Theorem Style}
% We use \pkgurl{amsthm} to handle the proof environment and use \pkgurl{ntheorem} to handle other theorem environments.
%    \begin{macrocode}
\theoremnumbering{arabic}
\ifthenelse{\equal{\HUST@language}{chinese}}{
  \theoremseparator{:}
}{
  \theoremseparator{:}
}
\theorempreskip{1.2ex plus 0ex minus 1ex}
\theorempostskip{1.2ex plus 0ex minus 1ex}
\theoremheaderfont{\normalfont\bfseries\HEI}
\theoremsymbol{}

\theoremstyle{definition}
\theorembodyfont{\normalfont}
\ifthenelse{\equal{\HUST@language}{chinese}}{
  \newtheorem{definition}{定义}[chapter]
}{
  \newtheorem{definition}{Definition}[chapter]
}

\theoremstyle{plain}
\theorembodyfont{\itshape}
\ifthenelse{\equal{\HUST@language}{chinese}}{
  \newtheorem{proposition}{命题}[chapter]
  \newtheorem{lemma}{引理}[chapter]
  \newtheorem{theorem}{定理}[chapter]
  \newtheorem{axiom}{公理}[chapter]
  \newtheorem{corollary}{推论}[chapter]
  \newtheorem{exercise}{练习}[chapter]
  \newtheorem{example}{例}[chapter]
  \def\proofname{\hei{证明}}
}{
  \newtheorem{proposition}{Proposition}[chapter]
  \newtheorem{lemma}{Lemma}[chapter]
  \newtheorem{theorem}{Theorem}[chapter]
  \newtheorem{axiom}{Axiom}[chapter]
  \newtheorem{corollary}{Corollary}[chapter]
  \newtheorem{exercise}{Exercise}[chapter]
  \newtheorem{example}{Example}[chapter]
  \def\proofname{\textbf{Proof}}
}
%    \end{macrocode}
%
% \subsection{Floating Objects Style}
% Set the skip to the context for floating object with argument `h'.
%    \begin{macrocode}
\setlength{\intextsep}{0.7\baselineskip plus 0.1\baselineskip minus 0.1\baselineskip}
%    \end{macrocode}
%
% Set the skip to the context for top or bottom floating object.
%    \begin{macrocode}
\setlength{\textfloatsep}{0.8\baselineskip plus 0.1\baselineskip minus 0.2\baselineskip}
%    \end{macrocode}
%
% Set the fraction of floating object. Make the fraction less crowded than default value to prevent floating object occupying too much space.
%    \begin{macrocode}
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.60}
%    \end{macrocode}
%
% \subsection{Table Style}
%
% \begin{macro}{\tabincell}
% A command make it easier to insert a new table into an existing cell.
%    \begin{macrocode}
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
%    \end{macrocode}
% \end{macro}
%
% To prevent |\cline| breaking page in \pkgurl{longtable} environment, use in this way:
% \meta{table content} |\\* \nopagebreak \cline{i-j}|
% \footnote{Reference:\url{http://tex.stackexchange.com/questions/52100/longtable-multirow-problem-with-cline-and-nopagebreak}}
%    \begin{macrocode}
\def\@cline#1-#2\@nil{%
  \omit
  \@multicnt#1%
  \advance\@multispan\m@ne
  \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
  \@multicnt#2%
  \advance\@multicnt-#1%
  \advance\@multispan\@ne
  \leaders\hrule\@height\arrayrulewidth\hfill
  \cr
  \noalign{\nobreak\vskip-\arrayrulewidth}}
%    \end{macrocode}
%
% Here we set the global font setting (font size: 11pt and line spread: 1.4) for tables. But first we will declare a variable to determine whether table global font setting is activated.
%    \begin{macrocode}
\newif\ifHUST@useoldtabular
\HUST@useoldtabularfalse
%    \end{macrocode}
%
% \begin{macro}{\TurnOffTabFontSetting}
% Use |\TurnOffTabFontSetting| to deactivate global font setting.
%    \begin{macrocode}
\def\TurnOffTabFontSetting{\HUST@useoldtabulartrue}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TurnOnTabFontSetting}
% Use |\TurnOnTabFontSetting| to activate global font setting.
%    \begin{macrocode}
\def\TurnOnTabFontSetting{\HUST@useoldtabularfalse}
%    \end{macrocode}
% \end{macro}
%
% Hook the \pkgurl{tabular}, \pkgurl{tabularx} and \pkgurl{longtable} environment to imply the global font setting.
%    \begin{macrocode}
\AtBeginEnvironment{tabular}{
  \ifHUST@useoldtabular\else
    \fontsize{11pt}{15.4pt}\selectfont
  \fi
}
\AtBeginEnvironment{tabularx}{
  \ifHUST@useoldtabular\else
    \fontsize{11pt}{15.4pt}\selectfont
  \fi
}
\AtBeginEnvironment{longtable}{
  \ifHUST@useoldtabular\else
    \fontsize{11pt}{15.4pt}\selectfont
  \fi
}
%    \end{macrocode}
%
% \subsection{Caption Style}
% Set caption font size as 11pt, use hang format, remove `:' after number and set the skip between context as 12pt.
%    \begin{macrocode}
\DeclareCaptionFont{HUST@captionfont}{\fontsize{11pt}{14.3pt}\selectfont}
\DeclareCaptionLabelFormat{HUST@caplabel}{#1~#2}
\captionsetup{
  font=HUST@captionfont,
  labelformat=HUST@caplabel,
  format=hang,
  labelsep=quad,
  skip=12pt
}
%    \end{macrocode}
%
% Set figure and table numbering style.
%    \begin{macrocode}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{chapter}-\arabic{figure}}
%    \end{macrocode}
%
% \subsection{Code Highlight Style}
%    \begin{macrocode}
\definecolor{HUST@lstgreen}{rgb}{0,0.6,0}
\definecolor{HUST@lstmauve}{rgb}{0.58,0,0.82}

\lstset{
  basicstyle=\footnotesize\ttfamily\linespread{1}\selectfont\FANGSONG,
  keywordstyle=\color{blue}\bfseries,
  commentstyle=\color{HUST@lstgreen}\itshape\KAI,
  stringstyle=\color{HUST@lstmauve},
  showspaces=false,
  showstringspaces=false,
  showtabs=false,
  numbers=left,
  numberstyle=\tiny\color{black},
  frame=lines,
  rulecolor=\color{black},
  breaklines=true
}
%    \end{macrocode}
%
% \subsection{Section Title Style}
% Set the numbering depth for section.
%    \begin{macrocode}
\setcounter{secnumdepth}{3}
%    \end{macrocode}
%
% Chapter tilte format and spacing setting.
%    \begin{macrocode}
\titleformat{\chapter}
  {
    \bfseries
    \HEI
    \centering
    \fontsize{18pt}{23.4pt}\selectfont
  }
  {
    \ifthenelse{\equal{\HUST@language}{chinese}}
    {\zhnumber{\thechapter}}
    {Chapter~\thechapter}
  }
  {1em}
  {}
\titlespacing*{\chapter}{0pt}{0pt}{20pt}
%    \end{macrocode}
%
% Section tilte format and spacing setting.
%    \begin{macrocode}
\titleformat*{\section}{\bfseries\HEI\fontsize{16pt}{20.8pt}\selectfont}
\titlespacing*{\section}{0pt}{18pt}{6pt}
%    \end{macrocode}
%
% Subsection tilte format and spacing setting.
%    \begin{macrocode}
\titleformat*{\subsection}{\bfseries\HEI\fontsize{14pt}{18.2pt}\selectfont}
\titlespacing*{\subsection}{0pt}{12pt}{6pt}
%    \end{macrocode}
%
% Subsubsection tilte format and spacing setting.
%    \begin{macrocode}
\titleformat*{\subsubsection}{\bfseries\HEI\fontsize{13pt}{16.9pt}\selectfont}
\titlespacing*{\subsubsection}{0pt}{12pt}{6pt}
%    \end{macrocode}
%
% \subsection{TOC Style}
% TOC depth.
%    \begin{macrocode}
\setcounter{tocdepth}{1}
%    \end{macrocode}
%
% TOC right margin.
%    \begin{macrocode}
\contentsmargin{2.0em}
%    \end{macrocode}
%
% Remove vertical space between two continues chapter entries.
% \footnote{Reference:\url{http://tex.stackexchange.com/questions/89103/remove-vertical-space-between-two-chapters-in-table-of-contents-in-latex}}
%    \begin{macrocode}
\newskip\HUST@oldcftbeforechapskip
\HUST@oldcftbeforechapskip=\cftbeforechapskip
\newskip\HUST@oldcftbeforesecskip
\HUST@oldcftbeforesecskip=\cftbeforesecskip
\let\HUST@oldl@chapter\l@chapter
\let\HUST@oldl@section\l@section
\let\HUST@oldl@subsection\l@subsection
\def\l@chapter#1#2{\HUST@oldl@chapter{#1}{#2}\cftbeforechapskip=3pt}
\def\l@section#1#2{\HUST@oldl@section{#1}{#2}\cftbeforechapskip=\HUST@oldcftbeforechapskip\cftbeforesecskip=3pt}
\def\l@subsection#1#2{\HUST@oldl@subsection{#1}{#2}\cftbeforesecskip=\HUST@oldcftbeforesecskip}
%    \end{macrocode}
%
% Set LOF LOT style.
% \footnote{Reference:\url{http://www.latex-community.org/viewtopic.php?f=5&t=1838}}
%    \begin{macrocode}
\renewcommand*\cftfigpresnum{\figurename~}
\newlength{\HUST@cftfignumwidth@tmp}
\settowidth{\HUST@cftfignumwidth@tmp}{\cftfigpresnum}
\addtolength{\cftfignumwidth}{\HUST@cftfignumwidth@tmp}
\renewcommand{\cftfigaftersnumb}{\quad~}
\renewcommand*\cfttabpresnum{\tablename~}
\newlength{\HUST@cfttabnumwidth@tmp}
\settowidth{\HUST@cfttabnumwidth@tmp}{\cfttabpresnum}
\addtolength{\cfttabnumwidth}{\HUST@cfttabnumwidth@tmp}
\renewcommand{\cfttabaftersnumb}{\quad~}
%    \end{macrocode}
%
% \subsection{Head \& Foot Style}
%    \begin{macrocode}
\let\ps@plain\ps@fancy
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\ifthenelse{\equal{\HUST@degree}{fyp}}{
  \fancyfoot[R]{\thepage}
}{
  \fancyfoot[C]{\thepage}
}

\ifthenelse{\equal{\HUST@language}{english-draft}}{}{
  \ifHUST@finalformat\else
    \fancyhead[C]{
      \ziju{1em}{\kai{\fontsize{14pt}{18.2pt}\selectfont\HUST@zhschoolname\HUST@zhapplyname}}
      \vskip -5pt
      \vbox{
        \hrule width \textwidth height 2pt
      }
    }
  \fi
}
%    \end{macrocode}
%
% \subsection{List Environment Style}
%    \begin{macrocode}
\setlist{noitemsep,partopsep=0pt,topsep=.8ex}
\setlist[1]{labelindent=\parindent}
\setlist[enumerate,1]{label=\arabic*.,ref=\arabic*}
\setlist[enumerate,2]{label*=\arabic*,ref=\theenumi.\arabic*}
\setlist[enumerate,3]{label=\emph{\alph*}),ref=\theenumii\emph{\alph*}}
\setlist[description]{font=\bfseries\HEI}
%    \end{macrocode}
%
% \subsection{Footnote Style}
%    \begin{macrocode}
\MakePerPage{footnote}
%    \end{macrocode}
%
% \section{Specical Page}
% \begin{macro}{\frontmatter,\mainmatter,\backmatter}
%    \begin{macrocode}
\def\frontmatter{
  \clearpage
  \@mainmatterfalse
  \pagenumbering{Roman}
}
\def\mainmatter{
  \clearpage
  \@mainmattertrue
  \pagenumbering{arabic}
}
\def\backmatter{
  \clearpage
  \@mainmatterfalse
  \settocdepth{chapter}
  \hypersetup{bookmarksopenlevel=0}
}
%    \end{macrocode}
% \end{macro}
%
% Chinese title page.
%    \begin{macrocode}
\def\HUST@zhtitlepage{
  \begin{center}
  \vspace*{-1.0cm}
  \parbox[t][2.2cm][t]{\textwidth}{
    \begin{center}
      \setlength{\tabcolsep}{0pt}
      \setlength{\extrarowheight}{12pt}
      \TurnOffTabFontSetting
      \fontsize{14pt}{16.8pt}\selectfont
      \begin{tabularx}{\textwidth}{p{4em}p{5em}Xp{2em}p{12em}}
        \HUST@classnotitle    & \makebox[5em][l]{\rule[-2.0pt]{5em}{1pt}\hspace{-5em}\hfill\texttt{\HUST@classno}\hfill} & &
        \HUST@stunotitle      & \makebox[12em][l]{\rule[-2.0pt]{12em}{1pt}\hspace{-12em}\hfill\texttt{\HUST@stuno}\hfill} \\
        \HUST@schoolcodetitle & \makebox[5em][l]{\rule[-2.0pt]{5em}{1pt}\hspace{-5em}\hfill\texttt{\HUST@schoolcode}\hfill} & &
        \HUST@secrettile      & \makebox[12em][l]{\rule[-2.0pt]{12em}{1pt}\hspace{-12em}\hfill\texttt{\HUST@secretlevel}\hfill}
      \end{tabularx}
      \TurnOnTabFontSetting
    \end{center}
    }
  \parbox[t][6cm][t]{\textwidth}{
    \vspace{1.0cm}
    \begin{center}
    \includegraphics[scale=1.1]{hust-title.pdf}\\[0.8cm]
    \ziju{10bp}{\fontsize{42pt}{54.6pt}\selectfont\HEI\HUST@zhapplyname}
    \end{center}
  }
  \parbox[t][4.8cm][t]{.8\textwidth}{
    \vspace{1.4cm}
    \begin{center}
    \fontsize{22pt}{35.2pt}\selectfont\hei{\HUST@zhtitle}
    \end{center}
  }
  \parbox[t][7.4cm][t]{\textwidth}{
    \vspace{1.2cm}
    \begin{center}
    \fontsize{18pt}{27.0pt}\selectfont
    \setlength{\extrarowheight}{0pt}
    \TurnOffTabFontSetting
    \begin{tabular}{p{5em}@{{:\hspace{1em}}}l}
    \HUST@zhauthortitle       & {\HUST@zhauthor} \\
    \HUST@zhmajortitle      & {\HUST@zhmajor} \\
    \HUST@zhsupervisortitle & {\HUST@zhsupervisor} \\
    \ifthenelse{\equal{\HUST@zhasssupervisor}{}}{}{
      \HUST@zhasssupervisortitle & {\HUST@zhasssupervisor} \\
    }
    \HUST@zhdatetitle & \zhdateformat
    \end{tabular}
    \TurnOnTabFontSetting
    \end{center}
  }
  \end{center}
}
%    \end{macrocode}
%
% English title page.
%    \begin{macrocode}
\def\HUST@entitlepage{
  \begin{center}
    \parbox[t][4.5cm][t]{.9\textwidth}{
      \begin{center}
        \fontsize{16pt}{17.6pt}\selectfont
        \HUST@enapplyname
      \end{center}
    }
    \parbox[t][5.7cm][t]{\textwidth}{
      \begin{center}
        \fontsize{18pt}{23.4pt}\selectfont
        \textbf{\textsf{\HUST@entitle}}
      \end{center}
    }
    \parbox[t][5cm][t]{.8\textwidth}{
      \begin{center}
      \setlength{\extrarowheight}{5pt}
      \fontsize{16pt}{24.0pt}\selectfont
      \TurnOffTabFontSetting
      \begin{tabular}{l@{~:~}p{18em}}
        \HUST@enauthortitle     & {\HUST@enauthor} \\
        \HUST@enmajortitle      & {\HUST@enmajor} \\
        \HUST@ensupervisortitle & {\HUST@ensupervisor}
        \ifthenelse{\equal{\HUST@enasssupervisor}{}}{}{
          \\ \HUST@enasssupervisortitle & {\HUST@enasssupervisor}
        }
      \end{tabular}
      \TurnOnTabFontSetting
      \end{center}
    }
    \parbox[t][7cm][b]{.8\textwidth}{
      \begin{center}
      \bfseries
      \fontsize{14pt}{28.0pt}\selectfont
      \HUST@enschoolname \\
      \HUST@enaddress \\
      \endateformat
    \end{center}
    }
  \end{center}
}
%    \end{macrocode}
%
% Copyright page.
%    \begin{macrocode}
\def\HUST@authorization{
  \centerline{\fontsize{16pt}{20.8pt}\selectfont \HEI \HUST@originaldeclare}
  \vspace{1cm}
  {
    \fontsize{12pt}{24.0pt}\selectfont
    \indent\HUST@originaldeclaretext
  }
  \\[1.9cm]
  \parbox[t]{\textwidth}{
    \fontsize{12pt}{18.0pt}\selectfont
    \TurnOffTabFontSetting
    \hfill\begin{tabular}{ll}
        \HUST@zhauthorsig & \hspace{2em}\\
        \HUST@zhdatefield & \hspace{2em}\\
    \end{tabular}
    \TurnOnTabFontSetting
  }
  \\[1.9cm]
  \centerline{\fontsize{16pt}{20.8pt}\selectfont \HEI \HUST@authtitle}
  \\[1cm]
  {
    \fontsize{12pt}{24.0pt}\selectfont
    \indent\HUST@authorizationtext \\
    \indent\HUST@authorizationaddon \\
    \indent\HUST@authorizationcheck
  }
  \\[1.9cm]
  \hspace{2em}\parbox[t]{.9\textwidth}{
    \fontsize{12pt}{18.0pt}\selectfont
    \TurnOffTabFontSetting
    \begin{tabular}{ll}
        \HUST@zhauthorsig & \hspace{2em}\\
        \HUST@zhdatefield & \hspace{2em}\\
    \end{tabular}
    \hfill
    \begin{tabular}{ll}
        \HUST@zhteachersig & \hspace{2em}\\
        \HUST@zhdatefield & \hspace{2em}\\
    \end{tabular}
    \TurnOnTabFontSetting
  }
  \vfill
}
%    \end{macrocode}
%
% \begin{macro}{\maketitle,\makecover}
% Commands to generate title page.
%    \begin{macrocode}
\def\maketitle{
  \newgeometry{
    top=1.2in,
    bottom=1.2in,
    left=1in,
    right=1in,
  }
  \let\HUST@oldthepage\thepage
  \ifthenelse{\equal{\HUST@language}{english-draft}}
  {\def\thepage{Titlepage}}
  {\def\thepage{封面}}
  \begin{titlepage}
    \ifthenelse{\equal{\HUST@language}{english-draft}}{}{
      \thispagestyle{empty}
      \HUST@zhtitlepage
      \clearpage
    }
    \thispagestyle{empty}
    \HUST@entitlepage
  \end{titlepage}
  \ifthenelse{\equal{\HUST@language}{english-draft}}{}{
    \def\thepage{版权页}
    \thispagestyle{empty}
    \HUST@authorization
    \clearpage
  }
  \restoregeometry
  \let\thepage\HUST@oldthepage
  \setcounter{page}{1}
}
\let\makecover\maketitle
%    \end{macrocode}
% \end{macro}
%
% Chinese abstract page.
%    \begin{macrocode}
\def\HUST@zhabstractpage{
  \chapter*{\HUST@zhabstractname}
  \begingroup
  \fontsize{10.5pt}{13.7pt}\selectfont
  \HUST@zhabstract \par
  \vskip 1.2ex
  \noindent\hei{\HUST@zhkeywordstitle}\hspace{.8em} \HUST@zhkeywords
  \endgroup
}
%    \end{macrocode}
%
% English abstract page.
%    \begin{macrocode}
\def\HUST@enabstractpage{
  \chapter*{\textsf{\HUST@enabstractname}}
  \begingroup
  \fontsize{10.5pt}{13.7pt}\selectfont
  \HUST@enabstract \par
  \vskip 1.2ex
  \noindent\textbf{\HUST@enkeywordstitle}\hspace{.8em} \HUST@enkeywords
  \endgroup
}
%    \end{macrocode}
%
% \begin{macro}{\makeabstract}
% A command to generate abstract page.
%    \begin{macrocode}
\def\makeabstract{
  \phantomsection
  \ifthenelse{\equal{\HUST@language}{chinese}}{
    \addcontentsline{toc}{chapter}{\HUST@zhabstractnamenospace}
  }{
    \addcontentsline{toc}{chapter}{\HUST@enabstractname}
  }
  \ifthenelse{\equal{\HUST@language}{english-draft}}{}{
    \HUST@zhabstractpage
    \clearpage
  }
  \HUST@enabstractpage
  \clearpage
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tableofcontents}
% A command to generate table of contents.
%    \begin{macrocode}
\let\HUST@tableofcontents\tableofcontents
\def\tableofcontents{
  \ifthenelse{\equal{\HUST@language}{chinese}}{
    \pdfbookmark{\contentsnamenospace}{\contentsnamenospace}
  }{
    \pdfbookmark{\contentsname}{\contentsname}
  }
  \HUST@tableofcontents
  \clearpage
}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{ack}
% A command to generate acknowledge page.
%    \begin{macrocode}
\newenvironment{ack}{
  \clearpage
  \phantomsection
  \addcontentsline{toc}{chapter}{\HUST@acknamenospace}
  \chapter*{\HUST@ackname}
  \begingroup
  \fontsize{10.5pt}{13.7pt}\selectfont
}{
  \endgroup
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{publications}
% A command to generate publications page.
%    \begin{macrocode}
\newenvironment{publications}{
  \clearpage
  \ifHUST@inappendix
    \chapter{\HUST@publicationtitle}
  \else
    \phantomsection
    \addcontentsline{toc}{chapter}{\HUST@publicationtitle}
    \chapter*{\HUST@publicationtitle}
  \fi
  \begin{enumerate}[labelindent=0pt,label={[\arabic*]},itemsep=0.5ex]
  \fontsize{10.5pt}{10.5pt}\selectfont
}{
  \end{enumerate}
}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\bibliography}
% A command to generate bibliography page.
%    \begin{macrocode}
\bibliographystyle{hustthesis}
\let\HUST@bibliography\bibliography
\def\bibliography#1{
  \clearpage
  \phantomsection
  \addcontentsline{toc}{chapter}{\bibname}
  \begingroup
  \fontsize{10.5pt}{10.5pt}\selectfont
  \setlength\bibsep{0.5ex}
  \HUST@bibliography{#1}
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{appendix}
% The appendix environment.
%    \begin{macrocode}
\newif\ifHUST@inappendix
\HUST@inappendixfalse
\newif\ifHUST@appendix@resetmainmatter
\HUST@appendix@resetmainmatterfalse
\renewenvironment{appendix}{
  \if@mainmatter
    \HUST@appendix@resetmainmatterfalse
  \else
    \HUST@appendix@resetmainmattertrue
    \@mainmattertrue
  \fi
  \appendixtitletocon
  \appendices
  \titleformat{\chapter}
  {
    \bfseries\HEI
    \centering
    \fontsize{18pt}{23.4pt}\selectfont
  }
  {\appendixname\,\thechapter}
  {1em}
  {}
  \HUST@inappendixtrue
}{
  \endappendices
  \HUST@inappendixfalse
  \ifHUST@appendix@resetmainmatter
    \HUST@appendix@resetmainmatterfalse
    \@mainmatterfalse
  \else\fi
}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\listoffigures}
% A command to generate list of figures.
%    \begin{macrocode}
\let\HUST@listoffigures\listoffigures
\def\listoffigures{
  \clearpage
  \ifHUST@inappendix
    \addtocounter{chapter}{1}
    \def\listfigurename{\appendixname\,\thechapter\hspace{1em}\HUST@listfigurename}
  \else
    \def\listfigurename{\HUST@listfigurename}
  \fi
  \phantomsection
  \ifHUST@inappendix
    \addcontentsline{toc}{chapter}{\thechapter\hspace{1em}\HUST@listfigurename}
  \else
    \addcontentsline{toc}{chapter}{\listfigurename}
  \fi
  \HUST@listoffigures
  \def\listfigurename{\HUST@listfigurename}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listoftables}
% A command to generate list of tables.
%    \begin{macrocode}
\let\HUST@listoftables\listoftables
\def\listoftables{
  \clearpage
  \ifHUST@inappendix
    \addtocounter{chapter}{1}
    \def\listtablename{\appendixname\,\thechapter\hspace{1em}\HUST@listtablename}
  \else
    \def\listtablename{\HUST@listtablename}
  \fi
  \phantomsection
  \ifHUST@inappendix
    \addcontentsline{toc}{chapter}{\thechapter\hspace{1em}\HUST@listtablename}
  \else
    \addcontentsline{toc}{chapter}{\listtablename}
  \fi
  \HUST@listoftables
  \def\listtablename{\HUST@listtablename}
}
%    \end{macrocode}
% \end{macro}
%
% \section{Other Command}
% \begin{macro}{\email}
%    \begin{macrocode}
\def\email#1{
  \href{mailto:#1}{\texttt{#1}}
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%
% \Finale
%
% ^^A Other files
% \iffalse
%
%<*example-zh|example-en>
%<example-zh>\documentclass[format=draft,language=chinese,degree=bachelor]{hustthesis}
%<example-en>\documentclass[format=draft,language=english,degree=bachelor]{hustthesis}

\stuno{U2009xxxxx}
\schoolcode{10487}
%<example-zh>\title{\LaTeX 模板使用示例}{An Example of Using hustthesis \LaTeX{} Template}
%<example-en>\title{An Example of Using hustthesis \LaTeX{} Template}
\author
%<example-zh>{许铖}{Xu Cheng}
%<example-en>{}
\major
%<example-zh>{电子信息工程}{Electronic and Information Engineering}
%<example-en>{}
\supervisor
%<example-zh>{黑晓军\hspace{1em}副教授}{Ass. Prof. Xiaojun Hei}
%<example-en>{}
\date{2013}{7}{1}

%<*example-zh>
\zhabstract{
    这这是一个\LaTeX{}模板使用实例文件,该模板用于华中科技大学毕业设计、学士论文、硕士论文和博士论文写作中。

    该模板基于LPPL v1.3发行。

}
\zhkeywords{\LaTeX{},华中科技大学,论文,模板}
%</example-zh>

%<example-zh>\enabstract
%<example-en>\abstract
{
    This is a \LaTeX{} template example file. This template is used in written thesis for Huazhong Univ. of Sci. \& Tech.

    This template is published under LPPL v1.3 License.

}
%<example-zh>\enkeywords
%<example-en>\keywords
{\LaTeX{}, Huazhong Univ. of Sci. \& Tech., Thesis, Template}

\begin{document}

\frontmatter
\maketitle
\makeabstract
\tableofcontents
\listoffigures
\listoftables
\mainmatter

%<*example-zh>
\chapter{基本格式测试}\label{chapter:1}

\section{第一层}\label{sec:1}
\subsection{第二层}\label{sec:2}
\subsubsection{第三层}\label{sec:3}
测试测试测试测试测试测试测试测试测试测试测试测试。
\footnote{\label{footnote:1}脚注}

\section{字体}

普通\textbf{粗体}\emph{斜体}

\hei{黑体}\kai{楷体}\fangsong{仿宋}

\section{公式}

单个公式,公式引用:\autoref{eq:1}。
\begin{equation}
 c^2 = a^2 + b^2 \label{eq:1}
\end{equation}

多个公式,公式引用:\autoref{eq:2},\autoref{eq:3}。

\begin{subequations}
\begin{equation}
  F = ma \label{eq:2}
\end{equation}
\begin{equation}
  E = mc^2 \label{eq:3}
\end{equation}
\end{subequations}

\section{罗列环境}

\begin{enumerate}
    \item 第一层\label{item:1}
    \item 第一层
    \begin{enumerate}
        \item 第二层\label{item:2}
        \item 第二层
        \begin{enumerate}
            \item 第三层\label{item:3}
            \item 第三层
        \end{enumerate}
    \end{enumerate}
\end{enumerate}

\begin{description}
    \item[解释环境]  解释内容
\end{description}

\chapter{其他格式测试}

\section{代码环境}

\begin{lstlisting}[language=python]
import os

def main():
    '''
    doc here
    '''
    print 'hello, world' # Abc
    print 'hello, 中文' # 中文
\end{lstlisting}

\section{定律证明环境}

\begin{definition}\label{def:1}
这是一个定义。
\end{definition}
\begin{proposition}\label{proposition:1}
这是一个命题。
\end{proposition}
\begin{axiom}\label{axiom:1}
这是一个公理。
\end{axiom}
\begin{lemma}\label{lemma:1}
这是一个引理。
\end{lemma}
\begin{theorem}\label{theorem:1}
这是一个定理。
\end{theorem}
\begin{proof}\label{proof:1}
这是一个证明。
\end{proof}

\section{算法环境}

\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;\label{alg_line:1}
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}\label{alg:1}
\end{algorithm}

\section{表格}
表格见\autoref{tab:1}。

\begin{table}[!h]
\centering
\caption{一个表格}\label{tab:1}
\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d \\
\hline
\end{tabular}
\end{table}
\section{图片}
图片见\autoref{fig:1}。图片格式支持eps,png,pdf等。多个图片见\autoref{fig:2},分开引用:\autoref{fig:2-1},\autoref{fig:2-2}。

\begin{figure}[!h]
\centering
\includegraphics[width=.4\textwidth]{fig-example.pdf}
\caption{一个图片}\label{fig:1}
\end{figure}

\begin{figure}[!h]
\centering
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{fig-example.pdf}
  \caption{图片1}\label{fig:2-1}
  \end{subfigure}
  ~
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{fig-example.pdf}
  \caption{图片2}\label{fig:2-2}
  \end{subfigure}
\caption{多个图片}\label{fig:2}
\end{figure}

\section{参考文献示例}
这是一篇中文参考文献\cite{TEXGURU99};这是一篇英文参考文献\cite{knuth};同时引用\cite{TEXGURU99,knuth}。

\section[\textbackslash{}autoref 测试]{\texttt{\textbackslash{}autoref} 测试}

\begin{description}
  \item[公式] \autoref{eq:1}
  \item[脚注] \autoref{footnote:1}
  \item[项] \autoref{item:1},\autoref{item:2},\autoref{item:3}
  \item[图] \autoref{fig:1}
  \item[表] \autoref{tab:1}
  \item[附录] \autoref{appendix:1}
  \item[章] \autoref{chapter:1}
  \item[小节] \autoref{sec:1},\autoref{sec:2},\autoref{sec:3}
  \item[算法] \autoref{alg:1},\autoref{alg_line:1}
  \item[证明环境] \autoref{def:1},\autoref{proposition:1},\autoref{axiom:1},\autoref{lemma:1},\autoref{theorem:1},\autoref{proof:1}
\end{description}


\backmatter

\begin{ack}
致谢正文。
\end{ack}

\bibliography{ref-example}

\appendix

\begin{publications}
    \item 论文1
    \item 论文2
\end{publications}

\chapter{这是一个附录}\label{appendix:1}
附录正文。

%</example-zh>
%<*example-en>
\chapter{Simple Test}\label{chapter:1}

\section{Level 1}\label{sec:1}
\subsection{Level 2}\label{sec:2}
\subsubsection{Level 3}\label{sec:3}
Content
\footnote{\label{footnote:1}A footnote.}

\section{Font}

Normal \textbf{Bold} \emph{Italic} \textsf{Sans}

The quick brown fox jumps over the lazy dog.

\section{Equation}

Single equation, see \autoref{eq:1}.
\begin{equation}
  c^2 = a^2 + b^2 \label{eq:1}
\end{equation}

Multi-equations, see \autoref{eq:2} and \autoref{eq:3}.

\begin{subequations}
\begin{equation}
  F = ma \label{eq:2}
\end{equation}
\begin{equation}
  E = mc^2 \label{eq:3}
\end{equation}
\end{subequations}

\section{List Environment}

\begin{enumerate}
    \item Level 1\label{item:1}
    \item Level 1
    \begin{enumerate}
        \item Level 2\label{item:2}
        \item Level 2
        \begin{enumerate}
            \item Level 3\label{item:3}
            \item Level 3
        \end{enumerate}
    \end{enumerate}
\end{enumerate}

\begin{description}
    \item[Discription]  Content
\end{description}

\chapter{Other Test}

\section{Code Highlight}

\begin{lstlisting}[language=python]
import os

def main():
    '''
    doc here
    '''
    print 'hello, world' # Abc
\end{lstlisting}

\section{Theorem}

\begin{definition}\label{def:1}
This is a definition.
\end{definition}
\begin{proposition}\label{proposition:1}
This is a proposition.
\end{proposition}
\begin{axiom}\label{axiom:1}
This is an axiom.
\end{axiom}
\begin{lemma}\label{lemma:1}
This is a lemma.
\end{lemma}
\begin{theorem}\label{theorem:1}
This is a theorem.
\end{theorem}
\begin{proof}\label{proof:1}
This is a proof.
\end{proof}

\section{Algorithm}

\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;\label{alg_line:1}
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}\label{alg:1}
\end{algorithm}

\section{Table}
See \autoref{tab:1}.

\begin{table}[!h]
\centering
\caption{A table}\label{tab:1}
\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d \\
\hline
\end{tabular}
\end{table}

\section{Figure}
See \autoref{fig:1}.Figure supports format in eps, png, pdf and so on. Multi-figures, see \autoref{fig:2}. Reference separately: \autoref{fig:2-1}, \autoref{fig:2-2}.

\begin{figure}[!h]
\centering
\includegraphics[width=.4\textwidth]{fig-example.pdf}
\caption{A figure}\label{fig:1}
\end{figure}

\begin{figure}[!h]
\centering
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{fig-example.pdf}
  \caption{Figure A}\label{fig:2-1}
  \end{subfigure}
  ~
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{fig-example.pdf}
  \caption{Figure B}\label{fig:2-2}
  \end{subfigure}
\caption{Multi-figures}\label{fig:2}
\end{figure}

\section{Bibliography}
Cite one bib\cite{knuth}, cite two\cite{TEXGURU99,knuth}.

\section[\textbackslash{}autoref Test]{\texttt{\textbackslash{}autoref} Test}

\begin{description}
  \item[Equation] \autoref{eq:1}
  \item[Footnote] \autoref{footnote:1}
  \item[Item] \autoref{item:1},\autoref{item:2},\autoref{item:3}
  \item[Figure] \autoref{fig:1}
  \item[Table] \autoref{tab:1}
  \item[Appendix] \autoref{appendix:1}
  \item[Chapter] \autoref{chapter:1}
  \item[Section] \autoref{sec:1},\autoref{sec:2},\autoref{sec:3}
  \item[Algorithm] \autoref{alg:1},\autoref{alg_line:1}
  \item[Theorem] \autoref{def:1},\autoref{proposition:1},\autoref{axiom:1},\autoref{lemma:1},\autoref{theorem:1},\autoref{proof:1}
\end{description}

\backmatter

\begin{ack}
Acknowledge
\end{ack}

\bibliography{ref-example}

\appendix

\begin{publications}
    \item Thesis 1
    \item Thesis 2
\end{publications}

\chapter{This is an appendix}\label{appendix:1}
Content.

%</example-en>

\end{document}

%</example-zh|example-en>
%
%<*example-bib>
@BOOK{TEXGURU99,
  AUTHOR        = "{\TeX}Guru",
  TITLE         = "{\LaTeXe} Manual",
  YEAR          = "1999"
}

@BOOK{knuth,
  AUTHOR        = "{Donald E. Knuth}",
  TITLE         = "The \TeX{}book",
  publisher     = "Addison–Wesley Pub. Co.",
  address       = "MA",
  YEAR          = "1984"
}
%</example-bib>
%
%<*bst>
%<<BSTFILE

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% PREDEFINED STRING MACROS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MACRO {jan} {"January"}
MACRO {feb} {"February"}
MACRO {mar} {"March"}
MACRO {apr} {"April"}
MACRO {may} {"May"}
MACRO {jun} {"June"}
MACRO {jul} {"July"}
MACRO {aug} {"August"}
MACRO {sep} {"September"}
MACRO {oct} {"October"}
MACRO {nov} {"November"}
MACRO {dec} {"December"}


MACRO {IEEE_J_MTT} {"{IEEE} Trans. Microwave Theory Tech."}


%%%%%%%%%%%%%%%%%%
%% ENTRY FIELDS %%
%%%%%%%%%%%%%%%%%%

ENTRY
  { address
    author
    booktitle
    chapter
    edition
    editor
    howpublished
    institution
    journal
    key
    lang
    month
    note
    number
    organization
    pages
    publisher
    school
    series
    title
    type
    volume
    year
    url
    nationality
  }
  {}
  { label }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INTEGER VARIABLES, STRING VARIABLES and FUNCTIONS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

INTEGERS { output.state before.all mid.sentence after.sentence after.block }

INTEGERS { longest.label.width multiresult nameptr namesleft number.label numnames }



FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}

FUNCTION {and}
{   'skip$
    { pop$ #0 }
  if$
}

FUNCTION {or}
{   { pop$ #1 }
    'skip$
  if$
}

FUNCTION {is.num}
{ chr.to.int$
  duplicate$ "0" chr.to.int$ < not
  swap$ "9" chr.to.int$ > not and
}

FUNCTION {init.state.consts}
{ #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
}

STRINGS { s t }

FUNCTION {output.nonnull}
{ 's :=
  output.state mid.sentence =
    { ", " * write$ }
    { output.state after.block =
    { add.period$ write$
      newline$
      "\newblock " write$
    }
    { output.state before.all =
        'write$
        { add.period$ " " * write$ }
      if$
    }
      if$
      mid.sentence 'output.state :=
    }
  if$
  s
}

STRINGS {z}
FUNCTION {remove.dots}
{ 'z :=
  ""
  { z empty$ not}
  { z #1 #1 substring$
    z #2 global.max$ substring$ 'z :=
    duplicate$ "." = 'pop$
      { * }
    if$
  }
  while$
  %z
}

FUNCTION {bibinfo.check}
{ swap$
  duplicate$ missing$
    {
      pop$ pop$
      ""
    }
    { duplicate$ empty$
        {
          swap$ pop$
        }
        { swap$
          pop$
        }
      if$
    }
  if$
}

FUNCTION {bibinfo.warn}
{ swap$
  duplicate$ missing$
    {
      swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
      ""
    }
    { duplicate$ empty$
        {
          swap$ "empty " swap$ * " in " * cite$ * warning$
        }
        { swap$
          pop$
        }
      if$
    }
  if$
}

% IEEE separates large numbers with more than 4 digits into groups of
% three. IEEE uses a small space to separate these number groups.
% Typical applications include patent and page numbers.

% number of consecutive digits required to trigger the group separation.
FUNCTION {large.number.trigger}{ #5 }

% For numbers longer than the trigger, this is the blocksize of the groups.
% The blocksize must be less than the trigger threshold, and 2 * blocksize
% must be greater than the trigger threshold (can't do more than one
% separation on the initial trigger).
FUNCTION {large.number.blocksize}{ #3 }

% What is actually inserted between the number groups.
FUNCTION {large.number.separator}{ "\," }

% So as to save on integer variables by reusing existing ones, numnames
% holds the current number of consecutive digits read and nameptr holds
% the number that will trigger an inserted space.
FUNCTION {large.number.separate}
{ 't :=
  ""
  #0 'numnames :=
  large.number.trigger 'nameptr :=
  { t empty$ not }
  { t #-1 #1 substring$ is.num
      { numnames #1 + 'numnames := }
      { #0 'numnames :=
        large.number.trigger 'nameptr :=
      }
    if$
    t #-1 #1 substring$ swap$ *
    t #-2 global.max$ substring$ 't :=
    numnames nameptr =
      { duplicate$ #1 nameptr large.number.blocksize - substring$ swap$
        nameptr large.number.blocksize - #1 + global.max$ substring$
        large.number.separator swap$ * *
        nameptr large.number.blocksize - 'numnames :=
        large.number.blocksize #1 + 'nameptr :=
      }
      { skip$ }
    if$
  }
  while$
}

FUNCTION {format.note}
{
 note empty$
    { "" }
    { note #1 #1 substring$
      duplicate$ "{" =
        'skip$
        { output.state mid.sentence =
          { "l" }
          { "u" }
        if$
        change.case$
        }
      if$
      note #2 global.max$ substring$ * "note" bibinfo.check
    }
  if$
}

FUNCTION {output}
{ duplicate$ empty$
    'pop$
    'output.nonnull
  if$
}

FUNCTION {output.check}
{ 't :=
  duplicate$ empty$
    { pop$ "empty " t * " in " * cite$ * warning$ }
    'output.nonnull
  if$
}

FUNCTION {output.bibitem}
{ newline$
  "\bibitem{" write$
  cite$ write$
  "}" write$
  newline$
  ""
  before.all 'output.state :=
}

FUNCTION {fin.entry}
{ add.period$
  write$
  newline$
}

FUNCTION {new.block}
{ output.state before.all =
    'skip$
    { after.block 'output.state := }
  if$
}

FUNCTION {new.sentence}
{ output.state after.block =
    'skip$
    { output.state before.all =
    'skip$
    { after.sentence 'output.state := }
      if$
    }
  if$
}


FUNCTION {new.block.checka}
{ empty$
    'skip$
    'new.block
  if$
}

FUNCTION {new.block.checkb}
{ empty$
  swap$ empty$
  and
    'skip$
    'new.block
  if$
}

FUNCTION {new.sentence.checka}
{ empty$
    'skip$
    'new.sentence
  if$
}

FUNCTION {new.sentence.checkb}
{ empty$
  swap$ empty$
  and
    'skip$
    'new.sentence
  if$
}

FUNCTION {field.or.null}
{ duplicate$ empty$
    { pop$ "" }
    'skip$
  if$
}

FUNCTION {emphasize}
{ duplicate$ empty$
    { pop$ "" }
    { "{\em " swap$ * "}" * }
  if$
}

FUNCTION {bbl.etal}
{ "et~al." }

FUNCTION {bbl.cn.etal}
{ "等." }

FUNCTION {format.lang}
{ lang empty$
    'skip$
    'skip$
  if$
 }

FUNCTION {format.names}
{ 's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr
      "{ll}{ f{~}}"
      format.name$
      %remove.dots
      %bibinfo bibinfo.check
      't :=
      nameptr #1 >
        {
          nameptr #3
          #1 + =
          numnames #3
          > and
            { "others" 't :=
              #1 'namesleft := }
            'skip$
          if$
          namesleft #1 >
            { ", " * t * }
            { numnames #2 >
              { "" * }
              'skip$
              if$
              s nameptr "{ll}" format.name$ duplicate$ "others" =
                { 't := }
                { pop$ }
              if$
              t "others" =
                {
                  lang empty$
                    { ", " * bbl.etal * }
                    { lang "chinese" =
                       { ", " * bbl.cn.etal * }
                       'skip$
                      if$
                    }
                  if$
                }
                {
                  lang empty$
                    { ", " * t * }
                    { lang "chinese" =
                       { ", " * t * }
                       'skip$
                     if$
                    }
                  if$
                }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

FUNCTION {format.authors}
{ author empty$
    { "" }
    { author format.names }
  if$
}

%FUNCTION {format.editors}
%{ editor empty$
%    { "" }
%    { editor format.names
%      editor num.names$ #1 >
%    { ", editors" * }
%    { ", editor" * }
%      if$
%    }
%  if$
%}

FUNCTION {format.editors}
{ editor empty$
    { "" }
    { lang empty$
    { editor format.names
      editor num.names$ #1 >
    { ", editors" * }
    { ", editor" * }
      if$
    }
    { editor format.names * ", " }
    if$
    }
  if$
}

FUNCTION {format.title}
{ title empty$
    { "" }
    { title }
  if$
}

FUNCTION {n.dashify}
{ 't :=
  ""
    { t empty$ not }
    { t #1 #1 substring$ "-" =
    { t #1 #2 substring$ "--" = not
        { "--" *
          t #2 global.max$ substring$ 't :=
        }
        {   { t #1 #1 substring$ "-" = }
        { "-" *
          t #2 global.max$ substring$ 't :=
        }
          while$
        }
      if$
    }
    { t #1 #1 substring$ *
      t #2 global.max$ substring$ 't :=
    }
      if$
    }
  while$
}

FUNCTION {format.date}
{ year empty$
    { month empty$
    { "" }
    { "there's a month but no year in " cite$ * warning$
      month
    }
      if$
    }
    { month empty$
    'year
    { month ", " * year * }
      if$
    }
  if$
}

FUNCTION {format.btitle}
{ edition empty$
  { title }
  { title empty$
    { title }
    {
      lang empty$
        { " " title * ", " * edition * " ed." * }
        { lang "chinese" =
          { " " title * ", 第~" * edition * " 版" * }
          'skip$
          if$
        }
      if$
    }
    if$
  }
  if$
}

FUNCTION {tie.or.space.connect}
{ duplicate$ text.length$ #3 <
    { "~" }
    { " " }
  if$
  swap$ * *
}

FUNCTION {either.or.check}
{ empty$
    'pop$
    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  if$
}

FUNCTION {format.bvolume}
{ volume empty$
    { "" }
    { "volume" volume tie.or.space.connect
      series empty$
    'skip$
    { " of " * series emphasize * }
      if$
      "volume and number" number either.or.check
    }
  if$
}

FUNCTION {format.number.series}
{ volume empty$
    { number empty$
    { series field.or.null }
    { output.state mid.sentence =
        { "number" }
        { "Number" }
      if$
      number tie.or.space.connect
      series empty$
        { "there's a number but no series in " cite$ * warning$ }
        { " in " * series * }
      if$
    }
      if$
    }
    { "" }
  if$
}

FUNCTION {format.url}
{ url empty$
    { "" }
    { new.block " {\url{" url * "}}" * }
  if$
}



FUNCTION {multi.page.check}
{ 't :=
  #0 'multiresult :=
    { multiresult not
      t empty$ not
      and
    }
    { t #1 #1 substring$
      duplicate$ "-" =
      swap$ duplicate$ "," =
      swap$ "+" =
      or or
    { #1 'multiresult := }
    { t #2 global.max$ substring$ 't := }
      if$
    }
  while$
  multiresult
}

FUNCTION {format.pages}
{ pages empty$
    { "" }
    { pages multi.page.check
    {  lang empty$
         {"pages" pages n.dashify tie.or.space.connect }
         { lang "chinese" =
         { "" pages n.dashify tie.or.space.connect }
         'skip$
         if$
         }
       if$
    }
       { "page" pages tie.or.space.connect }
      if$
    }
  if$
}

FUNCTION {format.vol.num.pages}
{ volume field.or.null
  number empty$
    'skip$
    { "(" number * ")" * *
      volume empty$
    { "there's a number but no volume in " cite$ * warning$ }
    'skip$
      if$
    }
  if$
  pages empty$
    'skip$
    { duplicate$ empty$
    { pop$ format.pages }
    { ":" * pages n.dashify * }
      if$
    }
  if$
}

FUNCTION {format.chapter.pages}
{ chapter empty$
    'format.pages
    { type empty$
    { "chapter" }
    { type "l" change.case$ }
      if$
      chapter tie.or.space.connect
      pages empty$
    'skip$
    { ", " * format.pages * }
      if$
    }
  if$
}

FUNCTION {format.in.ed.booktitle}
{ booktitle empty$
    { "" }
    { editor empty$
    { lang empty$
        { "in: Proceedings of " booktitle * }
        { "见: " booktitle * }
      if$
    }
    { lang empty$
        { "in: " format.editors * ", Proceedings of " * booktitle * }
        { ". 见: " * format.editors * booktitle * }
      if$
    }
      if$
    }
  if$
}

FUNCTION {empty.misc.check}
{ author empty$ title empty$ howpublished empty$
  month empty$ year empty$ note empty$
  and and and and and
    { "all relevant fields are empty in " cite$ * warning$ }
    'skip$
  if$
}

FUNCTION {format.thesis.type}
{ type empty$
    'skip$
    { pop$
      type "t" change.case$
    }
  if$
}

FUNCTION {format.tr.number}
{ type empty$
    { "Technical Report" }
    'type
  if$
  number empty$
    { "t" change.case$ }
    { number tie.or.space.connect }
  if$
}

FUNCTION {format.article.crossref}
{ key empty$
    { journal empty$
    { "need key or journal for " cite$ * " to crossref " * crossref *
      warning$
      ""
    }
    { "In {\em " journal * "\/}" * }
      if$
    }
    { "In " key * }
  if$
  " \cite{" * crossref * "}" *
}

FUNCTION {format.crossref.editor}
{ editor #1 "{ll }{f{~}}" format.name$
  editor num.names$ duplicate$
  #2 >
    { pop$ " et~al." * }
    { #2 <
    'skip$
    { editor #2 "{ll }{f{~}}" format.name$ "others" =
        { " et~al." * }
        { " and " * editor #2 "{ll }{f{~}}" format.name$ * }
      if$
    }
      if$
    }
  if$
}

FUNCTION {format.book.crossref}
{ volume empty$
    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
      "In "
    }
    { "Volume" volume tie.or.space.connect
      " of " *
    }
  if$
  editor empty$
  editor field.or.null author field.or.null =
  or
    { key empty$
    { series empty$
        { "need editor, key, or series for " cite$ * " to crossref " *
          crossref * warning$
          "" *
        }
        { "{\em " * series * "\/}" * }
      if$
    }
    { key * }
      if$
    }
    { format.crossref.editor * }
  if$
  " \cite{" * crossref * "}" *
}

FUNCTION {format.incoll.inproc.crossref}
{ editor empty$
  editor field.or.null author field.or.null =
  or
    { key empty$
    { booktitle empty$
        { "need editor, key, or booktitle for " cite$ * " to crossref " *
          crossref * warning$
          ""
        }
        { "In {\em " booktitle * "\/}" * }
      if$
    }
    { "In " key * }
      if$
    }
    { "In " format.crossref.editor * }
  if$
  " \cite{" * crossref * "}" *
}

FUNCTION {format.patent.nationality.type.number}
{
  nationality duplicate$ empty$
    { "nationality" bibinfo.warn pop$ "" }
    { "nationality" bibinfo.check
      duplicate$ "l" change.case$ "china" =
        { pop$ "中国" }
        { skip$ }
      if$
      " " *
    }
  if$
  type empty$
    { "Patent" "type" bibinfo.check }
    { type "type" bibinfo.check }
  if$
  *
  number duplicate$ empty$
    { "number" bibinfo.warn pop$ }
    { "number" bibinfo.check
      large.number.separate
      swap$ " " * swap$ *
    }
  if$
}

FUNCTION {format.address.publisher}
{ address empty$
    { publisher empty$
    { "" }
    { "there's a publisher but no address in " cite$ * warning$
      publisher
    }
      if$
    }
    { publisher empty$
    'address
    { address ": " * publisher * }
      if$
    }
  if$
}

FUNCTION {format.address.school}
{ address empty$
    { school empty$
    { "" }
    { "there's a school but no address in " cite$ * warning$
      school
    }
      if$
    }
    { school empty$
    'address
    { address ": " * school * }
      if$
    }
  if$
}


FUNCTION {format.title.type}
{ title empty$
    { type empty$
        { "" }
        { "there's a type but no title in " cite$ * warning$
          type
        }
      if$
    }
    { type empty$
        'title
        { title ": " * type * }
      if$
    }
  if$
}

FUNCTION {book} { output.bibitem
  author empty$
    { format.editors "author and editor" output.check }
    { format.authors output.nonnull
      crossref missing$
    { "author and editor" editor either.or.check }
    'skip$
      if$
    }
  if$
  new.block
  format.btitle
  "title" output.check
  crossref missing$
    { format.bvolume output
      new.block
      format.number.series output
      new.sentence
    }
    { new.block
      format.book.crossref output.nonnull
    }
  if$
  %format.edition output
  format.address.publisher output
  format.date "year" output.check
  new.block
  note output
  fin.entry
}

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { %journal emphasize "journal" output.check
      journal "journal" output.check
      %format.date "year" output.check
      %new.block
      year output
      format.vol.num.pages output
    }
    { format.article.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  format.note output
  fin.entry
}

FUNCTION {booklet}
{ output.bibitem
  format.authors output
  new.block
  format.title "title" output.check
  howpublished address new.block.checkb
  howpublished output
  address output
  format.date output
  new.block
  note output
  fin.entry
}

FUNCTION {inbook} { output.bibitem
  author empty$
    { format.editors "author and editor" output.check }
    { format.authors output.nonnull
      crossref missing$
    { "author and editor" editor either.or.check }
    'skip$
      if$
    }
  if$
  new.block
  format.btitle "title" output.check
  crossref missing$
    { format.bvolume output
      new.block
      format.number.series output
      new.sentence
    }
    { new.block
      format.book.crossref output.nonnull
    }
  if$
  %format.edition output
  format.address.publisher output
  format.date "year" output.check
  format.chapter.pages "chapter and pages" output.check
  new.block
  note output
  fin.entry
}

FUNCTION {incollection}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { format.in.ed.booktitle "booktitle" output.check
      format.bvolume output
      format.number.series output
      format.chapter.pages output
      new.sentence
      publisher "publisher" output.check
      address output
      %format.edition output
      format.date "year" output.check
    }
    { format.incoll.inproc.crossref output.nonnull
      format.chapter.pages output
    }
  if$
  new.block
  note output
  fin.entry
}

FUNCTION {inproceedings}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { format.in.ed.booktitle "booktitle" output.check
      %format.bvolume output
      %format.number.series output
      %format.pages output
      address empty$
    { organization publisher new.sentence.checkb
      organization output
      publisher output
      format.date "year" output.check
      %year output
    }
    { %address output.nonnull
      format.address.publisher output
      format.date "year" output.check
      %year output
      %new.sentence
      organization output
    }
      if$
      %new.block
      pages output
      %remove.dots
    }
    { format.incoll.inproc.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  note output
  fin.entry
}

FUNCTION {conference} { inproceedings }

FUNCTION {manual}
{ output.bibitem
  author empty$
    { organization empty$
    'skip$
    { organization output.nonnull
      address output
    }
      if$
    }
    { format.authors output.nonnull }
  if$
  new.block
  format.btitle "title" output.check
  author empty$
    { organization empty$
    { address new.block.checka
      address output
    }
    'skip$
      if$
    }
    { organization address new.block.checkb
      organization output
      address output
    }
  if$
  %format.edition output
  format.date output
  new.block
  note output
  fin.entry
}

FUNCTION {masterthesis.type}
{ lang empty$
    { "[Master Thesis]" }
    { "[硕士学位论文]" }
  if$
}

FUNCTION {mastersthesis}
{ output.bibitem
  format.authors "author" add.period$ output.check
  new.block
  format.title remove.dots ": " * masterthesis.type * output
  new.block
  format.address.school output
  %format.madd "address" output.check
  %school "school" output.check
  format.date "year" output.check
  new.block
  note output
  fin.entry
}

FUNCTION {misc}
{ output.bibitem
  format.authors output
  title howpublished new.block.checkb
  format.title output
  howpublished new.block.checka
  howpublished output
  format.date output
  format.url output
  new.block
  note output
  fin.entry
  empty.misc.check
}

FUNCTION {phdthesis.type}
{ lang empty$
    { "[PhD Dissertation]" }
    { "[博士学位论文]" }
  if$
}

FUNCTION {phdthesis}
{ output.bibitem
  format.authors "author" add.period$ output.check
  new.block
  format.title remove.dots ": " * phdthesis.type * output
  new.block
  format.address.school output
  %address output
  %school "school" output.check
  format.date "year" output.check
  new.block
  note output
  fin.entry
}

FUNCTION {proceedings}
{ output.bibitem
  editor empty$
    { organization output }
    { format.editors output.nonnull }
  if$
  new.block
  format.btitle "title" output.check
  format.bvolume output
  format.number.series output
  address empty$
    { editor empty$
    { publisher new.sentence.checka }
    { organization publisher new.sentence.checkb
      organization output
    }
      if$
      publisher output
      format.date "year" output.check
    }
    { address output.nonnull
      format.date "year" output.check
      new.sentence
      editor empty$
    'skip$
    { organization output }
      if$
      publisher output
    }
  if$
  new.block
  note output
  fin.entry
}

FUNCTION {techreport}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  format.tr.number output.nonnull
  institution "institution" output.check
  address output
  format.date "year" output.check
  format.url output
  new.block
  note output
  fin.entry
}

FUNCTION {patent} { output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  format.patent.nationality.type.number output
  format.date "year" output.check
  format.pages output
  new.block
  note output
  fin.entry
}

FUNCTION {unpublished}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  note "note" output.check
  format.date output
  fin.entry
}

FUNCTION {default.type} { misc }


%%%%%%%%%%%%%%%%%%
%% MAIN PROGRAM %%
%%%%%%%%%%%%%%%%%%

READ

STRINGS { longest.label }

FUNCTION {initialize.longest.label}
{ "" 'longest.label :=
  #1 'number.label :=
  #0 'longest.label.width :=
}

FUNCTION {longest.label.pass}
{ number.label int.to.str$ 'label :=
  number.label #1 + 'number.label :=
  label width$ longest.label.width >
    { label 'longest.label :=
      label width$ 'longest.label.width :=
    }
    'skip$
  if$
}

EXECUTE {initialize.longest.label}

ITERATE {longest.label.pass}

FUNCTION {begin.bib}
{ preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
  "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
}

EXECUTE {begin.bib}

EXECUTE {init.state.consts}

ITERATE {call.type$}

FUNCTION {end.bib}
{ newline$
  "\end{thebibliography}" write$ newline$
}

EXECUTE {end.bib}

%BSTFILE
%<\bst>
%
% \fi
%
\endinput