summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/easybook/easybook.dtx
blob: 3206e3da325a6f852f8a078e0ed2724883362472 (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
% \iffalse meta-comment
%
% Copyright (C) 2021 by Qu Yi <quee123@foxmail.com>
%
% This work may be distributed and/or modified under the
% conditions of the CC-BY 4.0 License.
% The latest version of this license is in
%   https://creativecommons.org/licenses/by/4.0/legalcode
%<*driver>
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%<*install>
\input ctxdocstrip
\keepsilent
\askforoverwritefalse
%
\preamble
Copyright (C) 2021 by Qu Yi <quee123@foxmail.com>

This work may be distributed and/or modified under the
conditions of the CC-BY 4.0 License.
The latest version of this license is in
  https://creativecommons.org/licenses/by/4.0/legalcode
\endpreamble
%
\generate
  {
    \usedir{tex/latex/\jobname}
    \file{\jobname.cls}{\from{\jobname.dtx}{class}}
  }
%</install>
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</driver>
%<*driver>
\documentclass{ctxdoc}
\OnlyDescription
\begin{document}
  \DocInput{\jobname.dtx}
  \IndexLayout
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \changes{v1.20}{2021/01/09}{修改和完善用户文档。}
% \changes{v1.20}{2021/01/09}{模板更改为使用 CC-BY 许可协议。}
% \changes{v1.23x}{2021/03/19}{修复在 \pkg{ctex} v2.5.6 更新后 \cls{easybook} 与 \pkg{hyperref} 冲突问题。}
%
% \CheckSum{0}
%
% \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         \~}
%
% \title{\sffamily easybook书籍文档类}
% \author{瞿毅}
% \date{2021/03/21\hskip\ccwd\relax v1.23x\thanks{\url{https://gitee.com/texl3/easybook}}}
% \maketitle
% \begin{abstract}
%   \cls{easybook} 是基于 \cls{ctexbook} 书籍文档类创建以极简为风格的模板,可以看作对 \cls{ctexbook} 的进一步包装。虽然\CTeX 文档类提供了较好的中文支持,但想实现个性化功能一般需要在其基础上载入更多宏包来定制。\cls{easybook} 考虑了一些细节并载入一些常用宏包实现一般的排版需求,它适用于排版中英文书籍或笔记,甚至可稍加调整成为学位论文模板。
% \end{abstract}
% \tableofcontents
%
% \begin{documentation}
% \section{编译方式}
% 模板含有一个使用示例文件 \opt{easybook-demo.tex},编译前建议满足以下的条件
% \begin{itemize}
%   \item 使用 \hologo{XeLaTeX}(推荐)或 \hologo{LuaLaTeX} 两种编译方式。
%   \item 由于用到了一些宏包较新的功能,建议安装最新的\TeX 发行版并将所有宏包升级为最新,目前在 \hologo{MiKTeX} 21.2和 \TeX Live 2020可以正常编译。
% \end{itemize}
%
% \subsection{编译步骤}
% \begin{frameverb}
%   xelatex -shell-escape easybook-demo
%   bibtex easybook-demo
%   makeindex easybook-demo
%   xelatex -shell-escape easybook-demo
%   xelatex -shell-escape easybook-demo
% \end{frameverb}
%
% 需注意,正确\textbf{编译索引}需要增加 \opt{-shell-escape} 命令行选项。若不需要索引和参考文献,可以在正文中注释掉命令。若出现以下警告,再编译一次即可。
% \begin{frameverb}
%   LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
% \end{frameverb}
%
% \subsection{字体设置}
% \label{subsec:font settings}
% 默认使用\CTeX 预置中文字库,当开启 \opt{font = noto} 选项时需要安装开源字体,中文使用方正系列的{\songti 方正书宋}、{\heiti 方正黑体}、{\kaishu 方正楷体}和{\fangsong 方正仿宋},英文使用思源系列的{\rmfamily Noto Serif}、{\sffamily Noto Sans}和{\ttfamily Noto Sans Mono},数学字体使用 \pkg{notomath}。相关选项可以见节 \ref{sec:document class options} 中的 \opt{font} 选项,字体点击此处下载\href{https://wws.lanzous.com/b01ns361i}{下载地址}。
%
% 如果您不想使用\CTeX 默认字体和方正、思源字体,\textbf{自定义字体}需启用选项 \opt{font = none},并可在导言区设置中文字体,粗体与斜体不设置会产生警告。
% \begin{ctexexam}
%   \setCJKmainfont{SimSun}[BoldFont = SimHei,ItalicFont = KaiTi]
%   \setCJKsansfont{SimHei}
%   \setCJKmonofont{FangSong}
% \end{ctexexam}
%
% \section{文档类选项}
% \label{sec:document class options}
% 标准 \cls{book} 文类与 \cls{ctexbook} 文类的选项同样适用于本文档。除此之外选项分为两类
% \begin{itemize}
%   \item 带有 \rexptarget\rexpstar{} 号的选项,需要在引入文档类的时候设定。
%   \item 带有 \exptarget\expstar{} 号的选项,需要通过\CTeX 宏集提供的用户接口命令 \tn{ctexset} 设定。
% \end{itemize}
%
% \begin{function}[rEXP,added = 2021-01-05]{draft}
% 开启草稿模式会加快编译速度,表现有显示页面边框、行溢出的地方显示黑色方块、图片变成占位方框、显示当前日期和关闭超链接渲染。不载入 \pkg{tcolorbox} 宏包支持盒子环境也会提高编译速度,详情见小节 \ref{subsec:box}。
% \end{function}
%
% \begin{function}[rEXP,added = 2021-01-05]{newline}
% 章标题风格为另起一行,英文模式使用较为常见。类似下面的效果
% \begin{flushleft}\sffamily\LARGE
%   Chapter 1\vskip 1.3pc
%   This is a title
% \end{flushleft}
% \end{function}
%
% \begin{function}[rEXP,added = 2021-01-05]{entitle}
% 部分标题编号由中文数字变为大写罗马数字,章标题编号由中文数字变为阿拉伯数字。比如\textbf{第一部分}变为\textbf{第I部分},\textbf{第一章}变为\textbf{第1章}。
% \end{function}
% \begin{function}[rEXP,added = 2021-01-05]{english}
% 使各类标题变为英文形式。包括章节标题、图表标题和定理标题等。如\textbf{第一章}变为\textbf{Chapter 1},\textbf{图1.1} 变为 \textbf{Table 1.1}。
% \end{function}
% \begin{function}[rEXP,added = 2021-01-05]{enstyle}
% 同时开启 \opt{newline}、\opt{entitle} 和 \opt{english} 三个选项以符合英文原生风格。
% \end{function}
%
% \begin{function}[rEXP,added = 2021-01-05,updated = 2021-02-02]{font}
% \begin{syntax}
%   font = <adobe|founder|mac|windows|linux|(overleaf)|noto|none>
% \end{syntax}
% 传递给 \cls{ctexbook} 设置字体,最好不要使用原有的 \opt{fontset} 选项,默认情况下使用自定义字体而不开启这个选项,可根据安装的字体及电脑系统选取。\opt{noto} 与 \opt{none} 选项的相关描述见小节 \ref{subsec:font settings},\opt{overleaf} 是一个各系统通用选项,会检测系统环境选取对应字体。
% \changes{v1.21}{2021/01/12}{默认字体与\CTeX 一致,不再是自定义字体。}
% \end{function}
%
% \begin{function}[rEXP,added = 2021-01-05,updated = 2021-01-13]{paper}
% \begin{syntax}
%   paper = <(a4paper)|b5paper|letterpaper|...>
% \end{syntax}
% 设置页面大小,交给 \pkg{geometry} 宏包处理,可使用它支持的所有规格。建议选项 \opt{b5paper} 和 \opt{zihao = 5},选项 \opt{a4paper} 和 \opt{zihao = -4} 配合。
% \end{function}
%
% \subsection{article 模式}
% \begin{function}[rEXP,added = 2021-03-16]{class}
% \begin{syntax}
%   class = <(book)|article>
% \end{syntax}
% 设置文类风格,默认为 \opt{book} 文档类。选用 \opt{article} 使文档编号、结构等与 \cls{article} 文档类的特性相似,可用于短篇幅的文章,不要再使用 \tn{chapter} 命令,此时设置双栏目录的 \opt{style/multoc} 选项、小节 \ref{subsec:document command} 中打印目录命令的 \opt{multoc} 及 \opt{book} 选项均会失效,会以 \opt{section} 标题级别输出目录。
% \changes{v1.23x}{2021/03/16}{增加 article 文章模式,可用于短篇幅的文章。}
% \end{function}
%
% \subsection{文档命令}
% \label{subsec:document command}
% \begin{function}[added = 2021-02-20,updated = 2021-03-15]{\frontmatter,\mainmatter,\backmatter,\tableofcontents,\listoffigures,\listoftables,\listoflistings}
% \begin{syntax}
%   \tn{frontmatter*}\oarg{编号格式|(Roman)}
%   \tn{mainmatter*}
%   \tn{backmatter}
%   \tn{tableofcontents}\oarg{键值列表}
%   \tn{listoffigures*}\oarg{键值列表}
%   \tn{listoftables*}\oarg{键值列表}
%   \tn{listoflistings*}\oarg{键值列表}
% \end{syntax}
% \tn{frontmatter} 为前言区命令,章标题不编号,页码可设置为例如 \opt{roman}、\opt{Alph} 等格式,带有星号的命令 \tn{frontmatter*} 不使用 \tn{cleardoublepage}。\tn{mainmatter} 为主文区命令,章标题正常编号且页码为从1开始计数的阿拉伯数字,\tn{mainmatter*} 命令不使用 \tn{cleardoublepage}。\tn{backmatter} 为后记区命令,页码格式与编号保持不变,章标题不编号。\tn{listoffigures} 命令输出图片目录,\tn{listoftables} 命令输出表格目录,\tn{listoflistings} 命令输出代码目录。带有星号的目录命令不会添加进主文档目录中,目录的键值列表选项如下
% \changes{v1.23x}{2021/02/20}{重新定义文档结构划分命令。}
% \end{function}
%
% \begin{function}{multoc,book,article}
% \begin{syntax}
%   multoc = <true|(false)>
% \end{syntax}
% \opt{multoc} 与 \opt{style/multoc} 选项具有相同的效果,但是具有优先性且可单独设置不同目录是否双栏排版。\opt{book} 选项使目录标题按照 \opt{chapter} 级别输出,\opt{article} 选项使目录标题按照 \opt{article} 级别输出,默认为 \opt{chapter} 级别。
% \changes{v1.23x}{2021/03/15}{为几个目录增加键值列表的选项,可设置标题输出级别以及是否加入主目录。}
% \end{function}
%
% \section{接口选项}
% \begin{function}[added = 2021-01-05]{\ctexset}
% \begin{syntax}
%   \tn{ctexset}\marg{键值列表}
% \end{syntax}
% \cls{easybook} 扩展了\CTeX 宏集\LaTeX 3风格键值的通用控制命令 \tn{ctexset},接口选项同样用它设置, 原有的键值列表仍然可用。
% \end{function}
%
% \begin{function}[EXP,added = 2021-01-08]{config}
% \begin{syntax}
%   config = <配置文件名>
% \end{syntax}
% \opt{config}为载入用户配置选项,配置文件名不需加括号但需带有后缀名如 \opt{tex}、\opt{def} 和 \opt{cfg}。
% \changes{v1.10}{2021/01/08}{加入载入用户配置选项。}
% \end{function}
%
% \subsection{风格}
% \begin{function}[EXP,added = 2021-01-05,updated = 2021-03-18]{color,multoc,withpart,footwith,notomath,rulewidth,uppercase,figure-sep,table-sep,listing-sep,equation-sep,number-sep}
% \begin{syntax}
%   color = <(none)|seaside|energy|cyberpunk>
%   multoc = <true|(false)>
%   withpart = <true|(false)>
%   footwith = <part|(chapter)|page>
%   notomath = <(true)|false>
%   rulewidth = <(0.75pt)>
%   uppercase = <(true)|false>
%   figure-sep = <(.)>
%   table-sep = <(.)>
%   listing-sep = <(.)>
%   equation-sep = <(.)>
%   number-sep = <(.)>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{style/...}
% \changes{v1.10}{2021/01/08}{更改颜色实现方式与选项名。}
% \changes{v1.23x}{2021/02/02}{noto风格的数学字体独立出来,可自定义设置。}
% \changes{v1.23x}{2021/02/09}{增加控制页面横线粗细的选项。}
% \changes{v1.23x}{2021/03/15}{增加控制编号连接符的选项。}
% \end{function}
%
% \begin{optdesc}
%   \item[color] 主题颜色,包括标题、页眉颜色等,选项 \opt{none} 为黑白页面,但不包括超链接。
%     \begin{function}{ctex@frame,ctex@emph,ctex@verb}
%     \begin{syntax}
%       \tn{definecolor}\oarg{类型}\marg{名称}\marg{模式列表}\marg{参数列表}
%     \end{syntax}
%     主题颜色用到这三个颜色,可以使用 \tn{definecolor} 命令进行更改,类似地更改超链接颜色见小节 \ref{subsec:hyperlinks}。
%     \changes{v1.10}{2021/01/08}{可以自定义主题颜色。}
%     \end{function}
%   \item[multoc] 开启双栏目录,可与 \opt{onecolumn} 和 \opt{twocolumn} 选项配合出单栏正文、单栏目录,双栏正文、单栏目录,单栏正文、双栏目录和双栏正文、双栏目录四种方式。
%   \item[withpart] 使章跟随每一部分编号,默认不跟随。
%   \item[footwith] 使脚注跟随编号的计数器,默认跟随章,当开启新的一章时脚注编号从1开始。
%   \item[notomath] 使用 \opt{noto} 风格的数学字体,将会加载 \pkg{newtxmath} 宏包。
%   \item[rulewidth] 调整页眉、定理盒子以及代码框线条的粗细。
%   \item[uppercase] 使用 \tn{rightmark} 及 \tn{leftmark} 获取标题内容设置页眉页脚时英文是否大小写。
%   \item[figure-sep] 图片标题编号的连接符。
%   \item[table-sep] 表格标题编号的连接符。
%   \item[listing-sep] 代码标题编号的连接符。
%   \item[equation-sep] 公式编号的连接符。
%   \item[number-sep] 统一设置所有编号的连接符。
% \end{optdesc}
%
% \subsection{超链接}
% \label{subsec:hyperlinks}
% \begin{function}[EXP,added = 2021-01-05,updated = 2021-01-08]{hyperlink,linkcolor,linktopage}
% \begin{syntax}
%   hyperlink = <(edge)|various|none>
%   linkcolor = <(fresh)|cutepink|skyblue|crimson>
%   linktopage = <true|(false)>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{link/...}
% \changes{v1.10}{2021/01/08}{修复了 \opt{linktopage} 选项关闭时目录中标题编号无超链接的问题。}
% \end{function}
%
% \begin{optdesc}
%   \item[hyperlink] \opt{edge} 使超链接为边框形式,\opt{various} 使超链接为彩色字体,有四种颜色风格。\opt{none} 关闭超链接边框与颜色,此时 \opt{linkcolor} 选项无效。
%   \item[linkcolor] 超链接颜色样式。
%     \begin{function}{ctex@link,ctex@url,ctex@cite}
%     \begin{syntax}
%       \tn{definecolor}\oarg{类型}\marg{名称}\marg{模式列表}\marg{参数列表}
%     \end{syntax}
%     超链接颜色用到这三个颜色,可以使用 \tn{definecolor} 命令进行更改。
%     \changes{v1.10}{2021/01/08}{可以自定义超链接颜色。}
%     \end{function}
%   \item[linktopage] 将目录中的超链接置于页码上,默认是置于标题上。
% \end{optdesc}
%
% \subsection{行距}
% \begin{function}[EXP,added = 2021-01-05,updated = 2021-02-13]{line,table,math,caption,footnote}
% \begin{syntax}
%   line = <(1.3)>
%   table = <(1.05)>
%   math = <(1.05)>
%   caption = <(1)>
%   footnote = <(1)>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{spread/...} \\
% 行距因子用于设置各种行距倍数,只能是浮点数,不能带有长度单位。\tn{ctexset} 原有的行距选项 \opt{linespread} 失效。各行距既可在导言区全局设置也可正文中设置对后面生效,行距的意义为
% \changes{v1.21}{2021/01/12}{增加脚注线间的距离选项。}
% \changes{v1.23x}{2021/02/09}{取消使用 \pkg{zhlineskip} 宏包设置数学间距。}
% \end{function}
%
% \begin{optdesc}
%   \item[line] 正文行距。
%   \item[table] 表格行距。
%   \item[math] 数学环境行距,包括 \pkg{amsmath} 和 \pkg{mathtools} 宏包附带的环境,但并未加载 \pkg{mathtools} 宏包。
%   \item[caption] 图表代码标题行距。
%   \item[footnote] 脚注行距。
% \end{optdesc}
%
% \subsection{其它字体}
% \begin{function}[EXP,added = 2021-01-08,updated = 2021-02-13]{table-cap,figure-cap,listing-cap,footnote,marginpar}
% \begin{syntax}
%   table-cap = <\tn{sffamily}\tn{small}>
%   figure-cap = <\tn{sffamily}\tn{small}>
%   listing-cap = <\tn{sffamily}\tn{small}>
%   footnote = <\tn{rmfamily}>
%   marginpar = <\tn{rmfamily}\tn{footnotesize}>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{elsefont/...}
% \changes{v1.10}{2021/01/08}{加入自定义非正文字体选项。}
% \changes{v1.23x}{2021/02/08}{修复使用 \tn{zihao} 命令设置字体失效的问题。}
% \end{function}
%
% \begin{optdesc}
%   \item[table-cap] 表格标题的字体设置。
%   \item[figure-cap] 图片标题的字体设置。
%   \item[listing-cap] 代码标题的字体设置。
%   \item[footnote] 脚注的字体设置,请不要使用字号命令。
%   \item[marginpar] 边注的字体设置。
% \end{optdesc}
%
% \subsection{参考文献}
% \begin{function}[EXP,added = 2021-01-11,updated = 2021-03-15]{backend,bib-style,cite-style,bibfile}
% \begin{syntax}
%   backend = <(bibtex)|biblatex>
%   bib-style = <(numerical)|authoryear|其它格式>
%   cite-style = <标注风格>
%   bibfile = <refs.bib>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{bibset/...}
% \changes{v1.21}{2021/01/11}{增加 \opt{bibset} 选项,可以使用 \hologo{BibTeX} 或 \hologo{biber} 编译参考文献。}
% \changes{v1.23x}{2021/02/23}{使用 \opt{bibset} 选项时可设置标注风格。}
% \end{function}
%
% \begin{optdesc}
%   \item[backend] 参考文献处理后端,默认用传统的 \hologo{BibTeX} 处理参考文献。
%   \item[bib-style] 参考文献格式为中国的参考文献推荐标准GB/T 7714-2015,有顺序编码制和著者-出版年制两种风格,理工科类一般使用顺序编码制,文科类一般使用著者-出版年制。若使用其它格式,使用 \hologo{BibTeX} 处理时需确保正确的 \opt{bst} 文件,使用 \hologo{biber} 处理可使用 \pkg{biblatex} 宏包支持的参考文献风格名称。
%   \item[cite-style] 标注参考文献的风格,\opt{backend = bibtex} 选项下可使用 \opt{super}(数字上标标注,默认)或 \opt{numbers}(数字标注)等 \pkg{natbib} 宏包带有的标注风格,\opt{backend = biblatex} 选项下可使用 \pkg{biblatex} 宏包支持的标注风格名称。
%   \item[bibfile] 参考文献的数据文件,使用 \hologo{biber} 处理时要带有 \opt{bib} 后缀,默认为一个以 \opt{refs.bib} 命名的文件。
% \end{optdesc}
%
% \begin{function}[added = 2021-01-11,updated = 2021-03-15]{\printbibliography}
% \begin{syntax}
%   \tn{printbibliography}\oarg{键值列表}
% \end{syntax}
% 两种方式\textbf{均使用}此命令打印参考文献,不同处理后端此命令的键值列表不同。使用 \hologo{BibTeX} 处理时选项与小节 \ref{subsec:document command} 目录的选项相同,使用 \hologo{biber} 处理时常用的选项如下
% \end{function}
%
% \begin{function}{heading,title}
% \begin{syntax}
%   heading = <bibliography|subbibliography|(bibintoc)|subbibintoc>
%   title = <参考文献标题名>
% \end{syntax}
% \opt{heading} 为参考文献标题的处理方式,\opt{bibliography} 选项以 \opt{chapter} 级别输出参考文献,不加进目录,\opt{subbibliography} 选项以 \opt{section} 级别输出参考文献,不加进目录,\opt{bibintoc} 选项以 \opt{chapter} 级别输出参考文献,加进目录,\opt{subbibintoc} 选项以 \opt{section} 级别输出参考文献,加进目录。\opt{title} 选项覆盖由 \opt{heading} 选项提供的缺省标题名。除此之外其他支持选项可见 \pkg{biblatex} 宏包说明文档。
% \end{function}
%
% \subsection{定理样式}
% \begin{function}[EXP,added = 2021-01-12,updated = 2021-03-13]{thmbox,numberwith,headpunct,bodyfont,notefont,headfont,headindent,spaceabove,spacebelow,spacepost}
% \begin{syntax}
%   thmbox = <true|(false)>
%   numberwith = <(chapter)|section|其它环境|空置>
%   headpunct = <(未设置)>
%   bodyfont = <(未设置)>
%   notefont = <(未设置)>
%   headfont = <(\tn{color}\marg{ctex@emph}\tn{sffamily})>
%   headindent = <(0\tn{ccwd})>
%   spaceabove = <(0.75ex plus .1ex)>
%   spacebelow = <(0.75ex plus .1ex)>
%   spacepost = <(\tn{ccwd})>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{thmset/...}
% \changes{v1.21}{2021/01/12}{增加配置定理环境样式的选项。}
% \end{function}
%
% \begin{optdesc}
%   \item[thmbox] 开启定理及习题环境的盒子边框,需载入 \pkg{tcolorbox} 宏包才生效。
%   \item[numberwith] 定理编号跟随的计数器,默认跟随章的编号,也可以跟随其它定理环境的编号,当计数器增加时定理编号会从零开始,空置时不跟随其它计数器。
%   \item[headpunct] 定理标题末尾后的标记,在换行符或第一段内容的间隔之前。
%   \item[bodyfont] 定理内容部分的字体。
%   \item[notefont] 定理副标题内容的字体。
%   \item[headfont] 定理种类标题名的字体。
%   \item[headindent] 定理标题的缩进,默认无缩进,可用 \tn{parindent} 命令设置为段落缩进。
%   \item[spaceabove] 定理环境前的间距。
%   \item[spacebelow] 定理环境后的间距。
%   \item[spacepost] 定理标题后与第一段内容的间隔。
% \end{optdesc}
%
% \begin{function}[added = 2021-01-12,updated = 2021-03-13]{\newtheorem, \declaretheoremstyle}
% \begin{syntax}
%   \tn{newtheorem}\oarg{键值列表}\marg{定理环境名}
%   \tn{declaretheoremstyle}\oarg{键值列表}\marg{定理样式名}
% \end{syntax}
% 文档类已预置8个定理环境,环境名及对应的定理标题名见小节 \ref{subsec:theorem},如果需要新的定理标题名或定理样式可使用这两个命令。
% \changes{v1.23x}{2021/03/12}{重新定义了新定理环境命令 \tn{newtheorem}。}
% \end{function}
%
% \begin{optdesc}
%   \item[\tn{newtheorem}] 定义新的定理类环境,可选参数与 \pkg{thmtools} 宏包定理命令 \tn{declaretheorem} 的参数一致。常用的选项如下
%   \begin{description}
%     \item[name] 定理的标题。默认值是环境的名称,并且首字母大写(英文标题)。
%     \item[numbered] 值为 \opt{no}、\opt{yes} 或 \opt{unless unique}。定理将被编号,而不是编号,或者只有在文档中多次出现时才被编号。
%     \item[numberlike] 定理将使用此计数器进行编号,通常这是另一个定理环境的名称。
%     \item[style] 用 \tn{declaretheoremstyle} 定义的定理样式的名称,定理将使用这种样式的设置。
%   \end{description}
%   \item[\tn{declaretheoremstyle}] 定义新的定理样式,可选参数中除了包括上述定理样式选项,还包括 \tn{newtheorem} 的选项。
% \end{optdesc}
%
% \subsubsection{新的定理样式}
% 定理由 \pkg{thmtools} 设置,预置定理的样式为 \opt{mythm},上述定理样式选项将对这个定理样式生效。如果使用这个样式而只是增加新的定理名称,可以这样
% \begin{ctexexam}
%   \newtheorem[style = mythm,name = 定理名]{定理环境名}
% \end{ctexexam}
% 若要给定理环境增加边框,可以如下进行设置
% \begin{ctexexam}
%   \tcolorboxenvironment{定理环境名}{thmsty}
% \end{ctexexam}
% 定义一个新的定理样式可用于 \tn{newtheorem} 的 \opt{style} 选项。
% \begin{ctexexam}
%   \declaretheoremstyle[bodyfont = \rmfamily,spacepost = 0.5\ccwd]{定理样式名}
% \end{ctexexam}
%
% \subsection{页面边距}
% \begin{function}[EXP,added = 2021-01-13,updated = 2021-03-21]{footnotemargin,footparskip,footparindent,list-labelsep,left,top,hmargin,textwidth,includehead}
% \begin{syntax}
%   footnotemargin = <脚注首行缩进|(0.5\tn{ccwd})>
%   footparskip = <脚注段落间距|(0ex)>
%   footparindent = <脚注分段缩进|(2\tn{ccwd})>
%   list-labelsep = <索引目录编号与标题的间距|(\tn{ccwd})>
%   left = <页面左边距>
%   top = <页面上边距>
%   hmargin = \marg{左边距,右边距}
%   textwidth = <页面文本区宽度>
%   includehead = <true|(false)>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{geoset/...} \\
% \opt{geoset} 会将前4个选项以外的其它选项交给 \pkg{geometry} 宏包接口命令 \tn{geometry} 处理,并且选项的键值列表与之相同,上面的选项仅是一小部分,支持的参数可查阅宏包帮助文档。当在此设置页面大小时,会覆盖 \opt{paper} 选项的设置。
% \begin{ctexexam}
%   \ctexset
%     {
%       geoset =
%         {
%           top = 2.5cm,
%           bottom = 2.5cm,
%           left = 3.2cm,
%           right = 3.2cm,
%           list-labelsep = \hspace{0.5\ccwd}
%         }
%     }
% \end{ctexexam}
% \changes{v1.21}{2021/01/13}{增加配置页面边距的选项。}
% \end{function}
%
% \subsection{页眉页脚}
% \begin{function}[EXP,added = 2021-01-13,updated = 2021-03-14]{head-foot,chap-mark,sec-mark,headrule,footrule,footnoterule}
% \begin{syntax}
%   head-foot = <页眉页脚中的内容>
%   chap-mark = <\tn{chaptermark} 标志命令 \tn{markboth} 中的内容>
%   sec-mark = <\tn{sectionmark} 标志命令 \tn{markright} 中的内容>
%   headrule = <页眉横线格式>
%   footrule = <页脚横线格式>
%   footnoterule = <脚注横线格式>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{hdrset/...} \\
% \opt{hdrset} 设置的命令由 \pkg{fancyhdr} 宏包提供支持,\opt{headrule}、\opt{footrule} 和 \opt{footnoterule} 三个横线选项一般可以使用 \tn{hrule} width \meta{长度} height \meta{高度} 命令来绘制,脚注横线默认为空。当然,手动绘制横线时线条粗细选项 \opt{style/rulewidth} 会失效。
% \changes{v1.21}{2021/01/11}{修复单面文档时页眉横线消失的问题。}
% \changes{v1.21}{2021/01/13}{增加配置页眉页脚的选项。}
% \changes{v1.23x}{2021/03/08}{优化页眉页脚设置,增加 \opt{chap-mark} 和 \opt{sec-mark} 选项。}
% \changes{v1.23x}{2021/03/14}{可以手动绘制页眉、页脚和脚注的横线。}
% \end{function}
%
% \begin{function}[added = 2021-01-13,updated = 2021-03-14]{,\easyhead,\easyfoot}
% \begin{syntax}
%   \tn{easyhead}\oarg{位置}\marg{内容}
%   \tn{easyfoot}\oarg{位置}\marg{内容}
% \end{syntax}
% 命令 \tn{easyhead} 和 \tn{easyfoot} 的含义与 \tn{fancyhead} 和 \tn{fancyfoot} 相同,它们用于 \opt{head-foot} 选项中,设置的是一个名为 \opt{fancy} 的页面风格。\pkg{fancyhdr} 将页眉页脚分成了左中右和奇数页(odd)、偶数页(even)共12个部分,可选参数中E、O代表偶数、奇数,L、C、R代表左、中、右部分。单面打印时,含有偶数的选项无效。
% \begin{ctexexam}
%   \ctexset
%     {
%       hdrset =
%         {
%           head-foot =
%             {
%               \easyhead[ER]{\leftmark}
%               \easyhead[OL]{\rightmark}
%               \easyhead[EL,OR]{\textbf{\thepage}}
%             },
%           sec-mark = {\CTEXthesection\hspace{0.5\ccwd}},
%           headrule = {\hrule width \textwidth height 1pt}
%         }
%     }
% \end{ctexexam}
% \end{function}
%
% \subsection{目录样式}
% \begin{function}[EXP,added = 2021-01-13,updated = 2021-01-15]{format,indent,rule}
% \begin{syntax}
%   format = <目录标题格式>
%   indent = <目录标题左边缩进>
%   rule = <目录引导线样式>
% \end{syntax}
% \ding{229} 以上选项路径为 \opt{tocset/(level)/...} \\
% \opt{tocset} 将目录样式交给 \pkg{titletoc} 处理,\opt{level} 代表 \opt{part}、\opt{chapter}、\opt{section}、\opt{subsection} 和 \opt{lists} 五种级别的目录样式设置,其中 \opt{lists} 为图片、表格和代码目录样式的级别。
%
% \opt{format} 是目录中标题的格式,可以设置字体和加入垂直间距等,垂直间距最好使用无间距重合的 \tn{addvspace} 命令。\opt{indent} 是目录中标题在页面左侧的缩进距离,应该有长度单位。\opt{rule} 选项中一般应当使用 \tn{tocrule} 命令,将会在接下来介绍。
% \changes{v1.21}{2021/01/13}{增加配置目录样式的选项。}
% \end{function}
%
% \begin{function}[EXP,added = 2021-01-13,updated = 2021-01-15]{lists/lolskip,lists/belowoffset,tocset/belowoffset}
% \begin{syntax}
%   lolskip = <(0.8pc)>
%   belowoffset = <(0pc)>
%   belowoffset = <(-1pc)>
% \end{syntax}
% \opt{lolskip} 是代码目录中章之间的代码标题的距离,与\CTeX 的表格目录和图片目录中章之间的标题距离选项 \opt{lotskip} 和 \opt{lofskip} 类似,它们的值均默认0.8 pc,在 \opt{article} 模式中此选项失效。\opt{belowoffset} 选项为主目录标题 \tn{contentsname} 后的间距补偿,一般为负值,用于抵消 \opt{format} 中设置的垂直间距。\opt{lists} 中的 \opt{belowoffset} 与之意义类似,但是一般为正值,可以在 \opt{article} 模式中使用。建议 \opt{lists/lolskip(0.8pc) + lists/format/addvspace(0.2pc) + lists/belowoffset(0pc) = belowoffset(-1pc)}。
% \end{function}
%
% \begin{function}[added = 2021-01-13,updated = 2021-01-15]{\tocrule}
% \begin{syntax}
%   \tn{tocrule} = \oarg{引导点间距|(0.7pc)}\parg{引导点大小|(1.2)}\marg{引导点}\oarg{页码格式}
% \end{syntax}
% \tn{tocrule} 命令生成目录引导线,需要在 \opt{rule} 选项中使用,其中引导线间距需带有长度单位,引导点大小不带单位,为引导点符号正常大小的倍数,引导点一般为英文句号或 \tn{cdot} 中心点符号。页码格式的内容位于页码前面,可以设置页码字体、距离。
% \begin{ctexexam}
%   \ctexset
%     {
%       tocset =
%         {
%           chapter =
%             {
%               format = \addvspace{8pt}\large,
%               indent = 1.5\ccwd,
%               rule = \tocrule[0.6pc](1.1){.}[\zihao{5}]
%             }
%         }
%     }
% \end{ctexexam}
% \end{function}
%
% \section{常用环境}
%
% \subsection{公式}
% \begin{function}[added = 2021-01-05]{equation,multline,gather,align}
% \begin{syntax}
%   \tn{begin}\marg{环境名}
%   <行间公式>
%   \tn{end}\marg{环境名}
% \end{syntax}
% \pkg{amsmath} 宏包提供了一系列数学环境,它们可以排布各种对齐或不对齐的公式组。\env{multline} 环境用于一行无法放下的长公式,\env{gather} 环境用于每行居中的公式组,\env{align} 环境用于多列对齐的公式组。
% \end{function}
%
% \subsection{列表}
% \begin{function}[added = 2021-01-05]{enumerate,itemize,description}
% \begin{syntax}
%   \tn{begin}\marg{环境名}\oarg{键值列表}
%   \tn{item} <列表内容>
%   \tn{end}\marg{环境名}
% \end{syntax}
% \pkg{enumitem} 宏包为系统预置的列表环境 \env{enumerate}、\env{itemize}和 \env{description} 提供了更灵活的标签以及间距的控制,可使用 \tn{setlist} 命令设置原有的三种列表格式。已设置默认格式,若自定义标签可例如
% \begin{ctexexam}
%   \begin{enumerate}[label = \arabic*(a),leftmargin = 1cm,resume]
%   \begin{itemize}[label = \textbullet]
%   \begin{description}[font = \sffamily\bfseries,style = nextline]
% \end{ctexexam}
% \end{function}
%
% \subsubsection{排序列表}
% \label{subsec:sort list}
% 使用 \opt{enumerate} 环境可创建排序列表,使用 \env{enumerate*} 环境产生行内部列表,可以使用\textbf{A、a、I、i和1}作为可选项为 \env{enumerate} 与 \env{enumerate*} 格式化标签。若生成\textbf{Item I、Item II、Item III}格式可以这样
% \begin{ctexexam}
%   \begin{enumerate*}[(a)]
%   \begin{enumerate}[\bfseries{Item} I]
% \end{ctexexam}
%
% \subsubsection{常规列表}
% 使用 \env{itemize} 环境可创建不计数列表,列表环境中若换行不缩进,若在列表中分段后则缩进两字符。 \opt{itemize*} 为行内常规列表,也提供一个可选参数。
%
% 用$\star$取代默认的符号
% \begin{ctexexam}
%   \begin{itemize*}[$\star$]
%   \begin{itemize}[$\star$]
% \end{ctexexam}
%
% \subsubsection{主题列表}
% 使用 \env{description} 环境可创建带有主题词的列表。
% \begin{ctexexam}
%   \begin{description}
%     \item[主题一] 内容一
%     \item[主题二] 内容二
%   \end{description}
% \end{ctexexam}
%
% \subsection{定理}
% \label{subsec:theorem}
% \begin{function}[added = 2021-01-05,updated = 2021-01-08]{theorem,definition,lemma,corollary,proposition,example,remark,proof}
% \begin{syntax}
%   \tn{begin}\marg{环境名}
%   <定理内容>
%   \tn{end}\marg{环境名}
% \end{syntax}
% 这些是已预置的定理环境,定理环境除了注和证明跟随章编号并可带有边框,边框和习题标题盒子可使用 \opt{thmbox = false} 开启,证明末尾会自动添加证明结束符。环境名对应的定理标题名如下
% \begin{center}
%   \begin{tabular}{*{8}{c}}
%     \toprule
%     theorem & definition & lemma & corollary & proposition & example & remark & proof \\
%     定理 & 定义 & 引理 & 推论& 性质 & 例 & 注 & 证明 \\
%     \bottomrule
%   \end{tabular}
% \end{center}
% \end{function}
%
% \subsection{习题}
% \label{subsec:exercise}
% \begin{function}[added = 2021-01-05,updated = 2021-03-19]{exercise}
% \begin{syntax}
%   \tn{begin}\marg{exercise}\oarg{颜色名|(LightYellow)}\oarg{编号|(1.)}\parg{标题|(习题)}\oarg{配置选项}
%   \tn{item} <习题内容>
%   \tn{end}\marg{exercise}
% \end{syntax}
% 习题环境 \env{exercise} 的标题紧接上一节编号并加入目录与页眉,当使用星号环境时不进行编号。三个可选参数中颜色为自定义或 \pkg{xcolor} 包含的颜色名称,正文编号格式与小节 \ref{subsec:sort list} 排序列表相同,标题名默认为摘要。注意,环境具有相同定界符的可选参数只能\textbf{从右往左}省略,省略的参数使用默认值。
% \begin{ctexexam}
%   \begin{exercise}[LightYellow][1.](习题)
%     \item 习题内容
%     \item 习题内容
%   \end{exercise}
% \end{ctexexam}
% \changes{v1.23x}{2021/02/08}{增加准确的习题盒子标题目录锚点。}
% \end{function}
%
% \subsection{盒子}
% \label{subsec:box}
% 使用盒子以及小节 \ref{subsec:exercise} 中的 \env{exercise} 环境需要在导言区\textbf{手动载入} \pkg{tcolorbox} 宏包,它们的配置的选项同样由 \pkg{tcolorbox} 提供支持,具体选项可见宏包文档的 Option Keys 一节,可以进行边距、字体及背景颜色等各种个性化设置,一些配置会覆盖之前预置的设置。
%
% \subsubsection{摘要盒子}
% \begin{function}[added = 2021-01-05,updated = 2021-03-19]{outline}
% \begin{syntax}
%   \tn{begin}\marg{outline}\parg{标题名称}\oarg{配置选项}
%   \tn{item} <摘要内容>
%   \tn{end}\marg{outline}
% \end{syntax}
% 摘要盒子可用于章前摘要,它的标题是可选参数,默认标题是摘要。
% \begin{ctexexam}
%   \begin{outline}(标题名称)
%     \item 摘要内容
%     \item 摘要内容
%   \end{outline}
% \end{ctexexam}
% \end{function}
%
% \subsubsection{段落盒子}
% \begin{function}[added = 2021-01-05,updated = 2021-03-19]{mybox}
% \begin{syntax}
%   \tn{begin}\marg{mybox}\oarg{颜色名|(MintCream)}\parg{段落标题}\oarg{配置选项}
%   <盒子内容>
%   \tn{end}\marg{mybox}
% \end{syntax}
% 环境 \opt{mybox} 创建一个段落盒子,可以添加可选参数的标题,否则无标题框。当使用带有星号的环境时 \oarg{颜色名} 选项生效,可以自定义背景颜色,否则无背景颜色。
% \begin{ctexexam}
%   \begin{mybox}*[MintCream](段落标题)
%     盒子内容
%     \tcblower   % 盒子上下部分分界线
%     盒子内容
%   \end{mybox}
% \end{ctexexam}
% \end{function}
%
% \subsubsection{行内盒子}
% \begin{function}[added = 2021-03-13]{\concise,\fuzzy}
% \begin{syntax}
%   \tn{concise}\oarg{颜色名}\marg{内容}\oarg{配置选项}
%   \tn{fuzzy}\oarg{颜色名}\marg{内容}\oarg{配置选项}
% \end{syntax}
% 设置了两个参数选项相同的行内盒子,盒子 \opt{concise} 为抄录盒子有三个参数,行内盒子内容是必选参数其他可选。盒子 \opt{fuzzy} 也是抄录盒子,具有模糊边缘类似高亮的效果。
% \end{function}
%
% \section{其它用法}
%
% \subsection{代码}
% \begin{function}[added = 2021-01-05]{\lstinline,lstlisting,\listoflistings}
% \begin{syntax}
%   \tn{lstinline}\oarg{键值列表}\marg{行内代码}
%   \tn{begin}\marg{lstlisting}\oarg{键值列表}
%   <行间代码>
%   \tn{end}\marg{lstlisting}
% \end{syntax}
% 加载 \pkg{listings} 宏包以对代码格式进行高度定制,代码样式可使用 \tn{lstset} 命令设置,\tn{listoflistings} 命令用于输出代码目录。
% \end{function}
%
% \subsection{物理量}
% \begin{function}[added = 2021-01-05,updated = 2021-02-23]{\num,\si,\SI,\SIrange}
% \begin{syntax}
%   \tn{num}\oarg{选项}\marg{数字}
%   \tn{si}\oarg{选项}\marg{单位}
%   \tn{SI}\oarg{选项}\marg{数字}\oarg{前缀}\marg{单位}
%   \tn{SIrange}\oarg{选项}\marg{数字1}\marg{数字2}\marg{单位}
% \end{syntax}
% \pkg{siunitx} 宏包的 \tn{num} 命令可以输出科学计数法,\tn{si} 命令支持数学模式,可以代替数学行内公式输入,而 \tn{SI} 命令可用来输出带有单位的量,\tn{SIrange} 可以输出带有范围和单位的量。
% \begin{ctexexam}
%   \num{-21x.3e5}
%   \si{mL.min^{-1}}
%   \SI{5}{\mole}
%   \SIrange[unit-color = green]{1.5}{4}{kg}
% \end{ctexexam}
% \end{function}
%
% \subsection{化学式}
% \begin{function}[added = 2021-01-05]{\ch,\chemfig}
% \begin{syntax}
%   \tn{ch}\oarg{选项}\marg{输入}
%   \tn{chemfig}\oarg{键值列表}\marg{分子代码}
% \end{syntax}
% 除了以普通公式的方式,化学式还可用 \pkg{chemformula} 实现,无机化学式使用 \tn{ch} 命令书写。有机化学式推荐在导言区载入 \pkg{chemfig} 宏包,使用\tn{chemfig} 命令完成。
% \end{function}
%
% \subsection{引用}
% \begin{function}[added = 2021-01-05]{\cref}
%   \begin{syntax}
%   \tn{cref}\marg{标签}
%   \end{syntax}
% 使用 \pkg{cleveref} 宏包的 \tn{cref} 命令进行引用,将会自动检测环境并添加相应的前缀。
% \end{function}
%
% \subsubsection{索引}
% \begin{function}[added = 2021-01-05]{\index,\printindex}
% \begin{syntax}
%   \tn{index}\marg{标签}
%   \tn{printindex}\oarg{索引名}
% \end{syntax}
% 使用 \pkg{imakeidx} 生成索引,\tn{printindex} 命令用于生成索引目录。仅做了简单的设置如将索引设为双栏并加入目录,其他选项可另外配置。
% \end{function}
%
% \subsubsection{自定义脚注}
% \begin{function}[added = 2021-01-05]{\Footnote,\Footnotetext,\Footnotemark}
% \begin{syntax}
%   \tn{Footnote}\marg{标记}\marg{插入文本}
%   \tn{Footnotetext}\marg{标记}\marg{插入文本}
%   \tn{Footnotemark}\marg{标记}
% \end{syntax}
% 自定义标记且不影响正常编号的脚注命令。
% \begin{ctexexam}
%   \Footnote{*}{这是可以自定义标记的脚注。}
% \end{ctexexam}
% \end{function}
%
% \subsubsection{边注}
% \begin{function}[added = 2021-01-05]{\marginnote}
% \begin{syntax}
%   \tn{marginnote}\oarg{左文本}\marg{右文本}\oarg{垂直偏移}
% \end{syntax}
% 命令 \tn{marginnote} 可以生成简单的边注,如果只给定了 \meta{右文本},那么边注在奇偶数页文字相同。如果同时给定了 \meta{左文本},则偶数页使用 \meta{左文本} 的文字。
% \end{function}
%
% \subsection{双语标题}
% \begin{function}[added = 2021-03-19]{\bicaption,\bicaptionbox}
% \begin{syntax}
%   \tn{bicaption}\oarg{目录标题1}\marg{标题2}\oarg{目录标题1}\marg{标题2}
%   \tn{bicaptionbox}\oarg{目录标题1}\marg{标题2}\oarg{目录标题1}\marg{标题2}
%     \oarg{宽度}\oarg{内部位置}\marg{内容}
% \end{syntax}
% 可以实现中英文双语标题,使用此功能需要在导言区载入 \pkg{bicaption} 宏包,具体用法见说明文档。
% \end{function}
%
% \subsection{插入文档}
% \begin{function}[added = 2021-03-14]{\includepdf}
% \begin{syntax}
%   \tn{includepdf}\oarg{键值列表}\marg{文档名}
% \end{syntax}
% 该命令由 \pkg{pdfpages} 提供,将其他 pdf 文档插入当前文档,比如插入封面,可以指定插入页数、逻辑页和横向等,详情查看宏包文档。
% \end{function}
%
% \subsection{指定行距的段落}
% \begin{function}[added = 2021-03-14]{spacing}
% \begin{syntax}
%   \tn{begin}\marg{spacing}\marg{浮点数}
%   <段落内容>
%   \tn{end}\marg{spacing}
% \end{syntax}
% 该环境由 \pkg{setspace} 提供,可以指定环境内段落的行距,使用浮点数控制行距倍数。
% \end{function}
% \end{documentation}
%
% \StopEventually{}
%<*class>
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{l3keys2e}
\ProvidesExplClass{easybook}{2021/03/21}{1.23x}{beta}

\cs_generate_variant:Nn \keys_define:nn {nx}
\cs_generate_variant:Nn \int_to_arabic:n {v}
\cs_generate_variant:Nn \dim_add:Nn {NV}
\cs_new_protected:Npn \__ctex_define:nn #1
  {\keys_define:nn {ctex/#1}}
\cs_new_protected:Npn \__put_ctexbook:n #1
  {\PassOptionsToClass{#1}{ctexbook}}
\cs_new_protected:Npn \__patch_cmd:Nnn #1#2#3
  {\ctex_patch_cmd_once:NnnnTF #1{}{#2}{#3}{}{\ctex_patch_failure:N #1}}
\cs_new_protected:Npn \__appto_cmd:Nn #1#2
  {\ctex_appto_cmd:NnnTF #1{}{#2}{}{\ctex_patch_failure:N #1}}

\bool_set_false:N \l__draft_bool
\bool_set_false:N \l__newline_bool
\bool_set_false:N \l__font_noto_bool
\bool_set_true:N  \l__zhtitle_bool
\bool_set_true:N  \l__lang_chinese_bool
\bool_set_true:N  \l__page_twoside_bool
\bool_set_true:N  \l__class_book_bool
\clist_new:N      \g__options_clist

\keys_define:nn {easybook}
  {
    draft         .code:n = {\bool_set_true:N  \l__draft_bool},
    newline       .code:n = {\bool_set_true:N  \l__newline_bool},
    entitle       .code:n = {\bool_set_false:N \l__zhtitle_bool},
    english       .code:n = {\bool_set_false:N \l__lang_chinese_bool},
    enstyle       .meta:n = {newline,entitle,english},

    font          .choice:,
    font          .value_required:n = true,
    font/overleaf .code:n = {},
    font/adobe    .code:n = {\__put_ctexbook:n {fontset = #1}},
    font/founder  .code:n = {\__put_ctexbook:n {fontset = #1}},
    font/mac      .code:n = {\__put_ctexbook:n {fontset = #1}},
    font/windows  .code:n = {\__put_ctexbook:n {fontset = #1}},
    font/linux    .code:n = {\__put_ctexbook:n {fontset = ubuntu}},
    font/none     .code:n = {\__put_ctexbook:n {fontset = #1}},
    font/noto     .code:n =
      {
        \bool_set_true:N \l__font_noto_bool
        \__put_ctexbook:n {fontset = none}
      },
    font          .initial:n = overleaf,

    paper         .choice:,
    paper         .value_required:n = true,
    paper/unknown .code:n = {\PassOptionsToPackage{#1}{geometry}},
    paper         .initial:n = a4paper,

    oneside       .value_forbidden:n = true,
    twoside       .value_forbidden:n = true,
    oneside       .code:n =
      {
        \bool_set_false:N \l__page_twoside_bool
        \__put_ctexbook:n {oneside}
      },

    class         .choice:,
    class         .value_required:n = true,
    class/book    .code:n = {},
    class/article .code:n = {\bool_set_false:N \l__class_book_bool},
    class         .initial:n = book,

    unknown       .code:n =
      {\clist_gput_right:No \g__options_clist{\CurrentOption}}
  }

\ProcessKeysOptions{easybook}

\bool_if:NTF \l__lang_chinese_bool
  {\__put_ctexbook:n {scheme = chinese}}
  {\__put_ctexbook:n {scheme = plain}}

\clist_map_inline:nn
  {
    {svgnames}{xcolor},
    {hang,stable}{footmisc},
    {normalem}{ulem},
    {protrusion = false}{microtype},
    {shortlabels,inline}{enumitem},
    {many}{tcolorbox},
    {xindy}{imakeidx},
    {CJKmath = true}{xeCJK},
    {no-math}{fontspec},
    {noto,upint}{newtxmath}
  }{\PassOptionsToPackage#1}
\__put_ctexbook:n {\g__options_clist}
\LoadClass[UTF8]{ctexbook}

\bool_new:N \l__multoc_bool
\bool_new:N \l__notomath_bool
\bool_new:N \l__uppercase_bool
\bool_new:N \l__chap_withpart_bool
\tl_new:N   \l__foot_numberwith_tl
\tl_new:N   \g__config_tl

\ctex_define:n
  {
    style               .meta:nn = {ctex/style}{#1},
    link                .meta:nn = {ctex/link}{#1},
    spread              .meta:nn = {ctex/spread}{#1},
    elsefont            .meta:nn = {ctex/elsefont}{#1},
    bibset              .meta:nn = {ctex/bibset}{#1},
    thmset              .meta:nn = {ctex/thmset}{#1},
    geoset              .meta:nn = {ctex/geoset}{#1},
    hdrset              .meta:nn = {ctex/hdrset}{#1},
    tocset              .meta:nn = {ctex/tocset}{#1},
    config              .tl_set:N = \g__config_tl,
    lstlistlistingname  .tl_set:N = \lstlistlistingname,
    lstlistingname      .tl_set:N = \lstlistingname
  }
\__ctex_define:nn {style}
  {
    multoc            .bool_set:N = \l__multoc_bool,
    multoc            .default:n = true,
    withpart          .bool_set:N = \l__chap_withpart_bool,
    withpart          .default:n = true,
    withpart          .initial:n = false,
    notomath          .bool_set:N = \l__notomath_bool,
    notomath          .default:n = true,
    notomath          .initial:n = true,
    rulewidth         .dim_set:N = \l__rule_width_dim,
    rulewidth         .initial:n = 0.75pt,
    uppercase         .bool_set:N = \l__uppercase_bool,
    uppercase         .default:n = true,
    uppercase         .initial:n = true,

    footwith          .choice:,
    footwith          .value_required:n = true,
    footwith/part     .code:n =
      {\tl_set:Nn \l__foot_numberwith_tl{#1}},
    footwith/page     .code:n =
      {\tl_set:Nn \l__foot_numberwith_tl{#1}},
    footwith/chapter  .code:n = {},
    footwith          .initial:n = chapter,

    figure-sep        .tl_set:N = \l__figure_separator_tl,
    table-sep         .tl_set:N = \l__table_separator_tl,
    listing-sep       .tl_set:N = \l__lstlisting_separator_tl,
    equation-sep      .tl_set:N = \l__equation_separator_tl,
    number-sep        .meta:n =
      {
        figure-sep = {#1},table-sep = {#1},
        listing-sep = {#1},equation-sep = {#1}
      },
    number-sep        .initial:n = {.}
  }

\RequirePackage
  {
    xcolor,
    footmisc,setspace,
    amsmath,amsthm,thmtools,cases,
    chemformula,siunitx,ulem,
    geometry,marginnote,nccfoots,
    pdfpages,graphicx,
    fancyhdr,titletoc,
    caption-light,subcaption,
    pifont,microtype,
    tabularx,multirow,makecell,booktabs,
    tasks,enumitem,
    listings,
    imakeidx
  }
\ctex_at_end_preamble:n
  {
    \bool_if:NT \l__notomath_bool{\RequirePackage{newtxmath,bm}}
    \tl_if_empty:NF \g__config_tl{\file_input:n {\g__config_tl}}
  }

\cs_new_protected:Npn \__ifpackage_later:nn #1#2
  {
    \@ifpackagelater{#1}{#2}
      {}{\msg_warning:nnn {easybook}{package-old}{#1}}
  }
\msg_new:nnn {easybook}{package-old}
  {
    Package~#1~has~been~out~of~date. \\
    Some~problems~or~errors~may~occur \\
    if~you~continue~compiling. \\\\
    Please~update~your~macro~package~from~CTAN.
  }
\clist_map_inline:nn
  {
    {expl3}{2020/10/27},
    {xparse}{2020/10/27},
    {l3keys2e}{2020/10/27},
    {ctex}{2020/10/19},
    {thmtools}{2020/08/01},
    {caption-light}{2020/08/24}
  }{\__ifpackage_later:nn #1}

\sys_if_engine_xetex:TF
  {
    \cs_new_eq:NN \__set_family:nnn  \xeCJK_set_family:nnn
    \cs_new_eq:NN \__switch_family:n \xeCJK_switch_family:n
  }{
    \cs_new_eq:NN \__set_family:nnn  \ctex_ltj_set_family:nnn
    \cs_new_eq:NN \__switch_family:n \ctex_ltj_switch_family:n
  }

\cs_new_protected:Npn \__setmainfont:nn #1#2
  {\__fontspec_main_setmainfont:nn {#2}{#1}}
\cs_new_protected:Npn \__setsansfont:nn #1#2
  {\__fontspec_main_setsansfont:nn {#2}{#1}}
\cs_new_protected:Npn \__setmonofont:nn #1#2
  {\__fontspec_main_setmonofont:nn {#2}{#1}}
\cs_new_protected:Npn \__setCJKmainfont:nn #1#2
  {\__set_family:nnn {\CJKrmdefault}{#2}{#1}}
\cs_new_protected:Npn \__setCJKsansfont:nn #1#2
  {\__set_family:nnn {\CJKsfdefault}{#2}{#1}}
\cs_new_protected:Npn \__setCJKmonofont:nn #1#2
  {\__set_family:nnn {\CJKttdefault}{#2}{#1}}
\cs_new_protected:Npn \__set_zhfont_songti:nn #1#2
  {\__set_family:nnn {songti}{#2}{#1}}
\cs_new_protected:Npn \__set_zhfont_heiti:nn #1#2
  {\__set_family:nnn {heiti}{#2}{#1}}
\cs_new_protected:Npn \__set_zhfont_kaishu:nn #1#2
  {\__set_family:nnn {kaishu}{#2}{#1}}
\cs_new_protected:Npn \__set_zhfont_fangsong:nn #1#2
  {\__set_family:nnn {fangsong}{#2}{#1}}

\tl_const:Nn \__option_zhfont_tl
  {UprightFont = *,AutoFakeBold = 1.5,ItalicFont = *}
\cs_new_protected:Npx \__setCJKmainfont:n #1
  {\__setCJKmainfont:nn {#1}{\__option_zhfont_tl}}
\cs_new_protected:Npx \__setCJKsansfont:n #1
  {\__setCJKsansfont:nn {#1}{\__option_zhfont_tl}}
\cs_new_protected:Npx \__setCJKmonofont:n #1
  {\__setCJKmonofont:nn {#1}{\__option_zhfont_tl}}
\cs_new_protected:Npx \__set_zhfont_songti:n #1
  {\__set_zhfont_songti:nn {#1}{\__option_zhfont_tl}}
\cs_new_protected:Npx \__set_zhfont_heiti:n #1
  {\__set_zhfont_heiti:nn {#1}{\__option_zhfont_tl}}
\cs_new_protected:Npx \__set_zhfont_kaishu:n #1
  {\__set_zhfont_kaishu:nn {#1}{\__option_zhfont_tl}}
\cs_new_protected:Npx \__set_zhfont_fangsong:n #1
  {\__set_zhfont_fangsong:nn {#1}{\__option_zhfont_tl}}

\bool_if:NT \l__font_noto_bool
  {
    \__setmainfont:nn {NotoSerif}
      {
        Extension = .ttf,
        UprightFont = *-Regular,
        BoldFont = *-Bold,
        ItalicFont = *-Italic
      }
    \__setsansfont:nn {NotoSans}
      {
        Extension = .ttf,
        UprightFont = *-Regular,
        BoldFont = *-Bold,
        ItalicFont = *-Italic
      }
    \__setmonofont:nn {NotoSansMono}
      {
        Extension = .ttf,
        UprightFont = *-Regular,
        BoldFont = *-Bold
      }
    \__setCJKmainfont:nn {FZShuSong-Z01S}
      {
        UprightFont = *,
        BoldFont = FZHei-B01S,
        ItalicFont = FZKai-Z03S
      }
    \__setCJKsansfont:n {FZHei-B01S}
    \__setCJKmonofont:n {FZFangSong-Z02S}
    \__set_zhfont_songti:n {FZShuSong-Z01S}
    \__set_zhfont_heiti:n {FZHei-B01S}
    \__set_zhfont_kaishu:n {FZKai-Z03S}
    \__set_zhfont_fangsong:n {FZFangSong-Z02S}
    \cs_new_protected:Npn \songti{\__switch_family:n {songti}}
    \cs_new_protected:Npn \heiti{\__switch_family:n {heiti}}
    \cs_new_protected:Npn \kaishu{\__switch_family:n {kaishu}}
    \cs_new_protected:Npn \fangsong{\__switch_family:n {fangsong}}
  }
\cs_if_exist:NF \kaishu{\cs_gset_eq:NN \kaishu\normalfont}

\includepdfset{fitpaper = true}
\geometry
  {
    vmargin = 2.54cm,
    hmargin = 3.17cm,
    columnsep = 2\ccwd,
    headheight = 2.04cm,
    headsep = 0.5cm,
    footskip = 0.79cm,
    footnotesep = 0.5cm,
    marginparsep = 8pt,
    marginparwidth = 2.54cm
  }
\clist_new:N \g__geometry_clist
\__ctex_define:nn {geoset}
  {
    footnotemargin  .dim_set:N = \footnotemargin,
    footnotemargin  .initial:n = 0.5\ccwd,
    footparskip     .tl_set:N = \hangfootparskip,
    footparskip     .initial:n = 0ex,
    footparindent   .tl_set:N = \hangfootparindent,
    footparindent   .initial:n = 2\ccwd,
    list-labelsep   .dim_set:N = \list@labelsep,
    list-labelsep   .initial:n = \ccwd,
    unknown         .code:n =
      {
        \clist_gput_right:Nx \g__geometry_clist
          {
            \l_keys_key_str
            \tl_if_empty:NF \l_keys_value_tl{ = {#1}}
          }
      }
  }

\cs_gset:Npn \cleardoublepage
  {
    \clearpage
    \bool_if:NT \l__page_twoside_bool
      {
        \int_if_odd:nF \c@page
          {\hbox:n {}\thispagestyle{empty}\clearpage}
      }
  }
\RenewDocumentCommand{\frontmatter}{sO{Roman}}
  {
    \IfBooleanTF{#1}{\clearpage}{\cleardoublepage}
    \@mainmatterfalse
    \pagenumbering{#2}
  }
\RenewDocumentCommand{\mainmatter}{s}
  {
    \IfBooleanTF{#1}{\clearpage}{\cleardoublepage}
    \@mainmattertrue
    \pagenumbering{arabic}
  }
\cs_gset_eq:NN \easyhead\fancyhead
\cs_gset_eq:NN \easyfoot\fancyfoot
\__ctex_define:nn {hdrset}
  {
    head-foot     .tl_set:N = \l__fancyhf_content_tl,
    head-foot     .initial:n =
      {
        \easyhead[EC]{\color{ctex@frame}\kaishu\leftmark}
        \easyhead[OC]{\color{ctex@frame}\kaishu\rightmark}
        \easyhead[EL,OR]{\color{ctex@frame}\thepage}
      },
    chap-mark     .tl_set:N = \l__fancyhf_chap_mark_tl,
    chap-mark     .initial:n =
      {
        \int_compare:nT {\c@secnumdepth > -1}
          {
            \if@mainmatter
              \ifodd\CTEX@chapter@numbering
                \CTEXthechapter\hspace{\ccwd}
              \fi
            \fi
          }
      },
    sec-mark      .tl_set:N = \l__fancyhf_sec_mark_tl,
    sec-mark      .initial:n =
      {
        \int_compare:nT {\c@secnumdepth > 0}
          {
            \ifodd\CTEX@section@numbering
              \CTEXthesection\hspace{0.5\ccwd}
            \fi
          }
      },
    headrule      .tl_gset:N = \headrule,
    headrule      .initial:n =
      {
        \color{ctex@frame}\vspace{1.5pt}
        \hrule width \textwidth height \l__rule_width_dim
      },
    footrule      .tl_gset:N = \footrule,
    footrule      .initial:n = {},
    footnoterule  .tl_gset:N = \footnoterule,
    footnoterule  .initial:n =
      {
        \color{ctex@frame}
        \hrule width 0.35\columnwidth height \l__rule_width_dim
        \vspace*{2.6pt}\color{black}
      }
  }
\ctex_at_end_preamble:n
  {
    \exp_args:NV \geometry\g__geometry_clist
    \pagestyle{fancy}
    \fancyhf{}
    \bool_if:NTF \l__page_twoside_bool
      {
        \cs_gset:Npn \chaptermark#1
          {
            \markboth
              {
                \bool_if:NTF \l__uppercase_bool
                  {\text_uppercase:n {\l__fancyhf_chap_mark_tl#1}}
                  {\text_titlecase_first:n {\l__fancyhf_chap_mark_tl#1}}
              }{
                \bool_if:NTF \l__uppercase_bool
                  {\text_uppercase:n {\l__fancyhf_chap_mark_tl#1}}
                  {\text_titlecase_first:n {\l__fancyhf_chap_mark_tl#1}}
              }
          }
        \l__fancyhf_content_tl
        \cs_gset_eq:NN \ps@plain\ps@empty
      }{
        \cs_gset:Npn \chaptermark#1
          {
            \markboth
              {
                \bool_if:NTF \l__uppercase_bool
                  {\text_uppercase:n {\l__fancyhf_chap_mark_tl#1}}
                  {\text_titlecase_first:n {\l__fancyhf_chap_mark_tl#1}}
              }{}
          }
        \l__fancyhf_content_tl
        \cs_gset_eq:NN \ps@plain\ps@empty
      }
    \cs_gset:Npn \sectionmark#1
      {
        \markright
          {
            \bool_if:NTF \l__uppercase_bool
              {\text_uppercase:n {\l__fancyhf_sec_mark_tl#1}}
              {\text_titlecase_first:n {\l__fancyhf_sec_mark_tl#1}}
          }
      }
    \bool_if:NT \l__draft_bool
      {
        \bool_if:NTF \l__page_twoside_bool
          {\easyfoot[C]{\color{gray!60}\sffamily\today}}
          {\easyhead[L]{\color{gray!60}\sffamily\today}}
        \geometry{showframe}
      }
  }

\ctex_define:n
  {
    tocset/part       .meta:nn = {ctex/tocset/part}{#1},
    tocset/chapter    .meta:nn = {ctex/tocset/chapter}{#1},
    tocset/section    .meta:nn = {ctex/tocset/section}{#1},
    tocset/subsection .meta:nn = {ctex/tocset/subsection}{#1},
    tocset/list       .meta:nn = {ctex/tocset/list}{#1},
  }
\__ctex_define:nn {tocset}
  {
    part/format       .tl_set:N = \l__toc_part_format_tl,
    part/format       .initial:n = \addvspace{1pc}\sffamily\large,
    part/indent       .tl_set:N = \l__toc_part_indent_tl,
    part/indent       .initial:n = 0\ccwd,
    part/rule         .tl_set:N = \l__toc_part_rule_tl,
    part/rule         .initial:n = \tocrule{}[\bfseries],

    chapter/format    .tl_set:N = \l__toc_chapter_format_tl,
    chapter/format    .initial:n = \addvspace{1pc}\sffamily\large,
    chapter/indent    .tl_set:N = \l__toc_chapter_indent_tl,
    chapter/indent    .initial:n = 0\ccwd,
    chapter/rule      .tl_set:N = \l__toc_chapter_rule_tl,
    chapter/rule      .initial:n = \tocrule{$\cdot$}[\bfseries],

    section/format    .tl_set:N = \l__toc_section_format_tl,
    section/format    .initial:n = \addvspace{0.35pc},
    section/indent    .tl_set:N = \l__toc_section_indent_tl,
    section/indent    .initial:n = 1.5\ccwd,
    section/rule      .tl_set:N = \l__toc_section_rule_tl,
    section/rule      .initial:n = \tocrule{$\cdot$},

    subsection/format .tl_set:N = \l__toc_subsection_format_tl,
    subsection/format .initial:n = \addvspace{0.35pc},
    subsection/indent .tl_set:N = \l__toc_subsection_indent_tl,
    subsection/indent .initial:n = 3.8\ccwd,
    subsection/rule   .tl_set:N = \l__toc_subsection_rule_tl,
    subsection/rule   .initial:n = \tocrule{$\cdot$},

    lists/format      .tl_set:N = \l__toc_lists_format_tl,
    lists/format      .initial:n = \addvspace{0.2pc},
    lists/indent      .tl_set:N = \l__toc_lists_indent_tl,
    lists/indent      .initial:n = 0\ccwd,
    lists/rule        .tl_set:N = \l__toc_lists_rule_tl,
    lists/rule        .initial:n = \tocrule{$\cdot$},
    lists/lolskip     .skip_set:N = \l__toc_lolskip_skip,
    lists/lolskip     .initial:n = 0.8pc,
    lists/belowoffset .dim_set:N = \l__toc_listsoffset_dim,
    lists/belowoffset .initial:n = 0pc,

    belowoffset       .dim_set:N = \l__toc_offset_dim,
    belowoffset       .initial:n = -1pc
  }

\NewDocumentCommand{\tocrule}{O{0.7pc}D(){1.2}mO{}}
  {
    \normalsize\normalfont
    \titlerule*[#1]{\scalebox{#2}{#3}}#4\contentspage
  }
\cs_new_protected:Npn \__titlecontents_set:nn #1#2
  {
    \titlecontents{#1}
      [\use:c {l__toc_#2_indent_tl}]
      {\use:c {l__toc_#2_format_tl}}{}{}
      {\use:c {l__toc_#2_rule_tl}}
  }
\contentsuse{lstlisting}{lol}
\clist_map_inline:nn
  {
    {part}{part},
    {chapter}{chapter},
    {section}{section},
    {subsection}{subsection},
    {figure}{lists},
    {table}{lists},
    {lstlisting}{lists}
  }{\__titlecontents_set:nn #1}
\ctex_patch_cmd:Nnn \caption@@@addcontentsline
  {\addcontentsline{#1}{#2}{\protect\numberline{#3}{#4}}}
  {\addcontentsline{#1}{#2}{#3\hspace{\list@labelsep}#4}}
\ctex_patch_cmd:Nnn \lst@MakeCaption
  {
    \addcontentsline{lol}{lstlisting}
      {\protect\numberline{\thelstlisting}\lst@@caption}
  }{
    \addcontentsline{lol}{lstlisting}
      {\thelstlisting\hspace{\list@labelsep}\lst@@caption}
  }
\__appto_cmd:Nn \@chapter
  {
    \skip_if_eq:nnF {\l__toc_lolskip_skip}{\c_zero_skip}
      {
        \addtocontents{lol}
          {\protect\addvspace{\skip_use:N \l__toc_lolskip_skip}}
      }
    \bool_if:NF \l__class_book_bool
      {\msg_error:nn {easybook}{no-chapter}}
  }
\__appto_cmd:Nn \@schapter
  {
    \bool_if:NF \l__class_book_bool
      {\msg_error:nn {easybook}{no-chapter}}
  }
\msg_new:nnn {easybook}{no-chapter}
  {
    Your~document~class~is~in~article~mode. \\
    The~\string\chapter\space~command~will~not~be~used.
  }

\cs_new_protected:Npn \__markboth:n #1
  {
    \bool_if:NTF \l__page_twoside_bool
      {
        \markboth
          {
            \bool_if:NTF \l__uppercase_bool
              {\text_uppercase:n {#1}}
              {\text_titlecase_first:n {#1}}
          }{
            \bool_if:NTF \l__uppercase_bool
              {\text_uppercase:n {#1}}
              {\text_titlecase_first:n {#1}}
          }
      }{
        \markboth
          {
            \bool_if:NTF \l__uppercase_bool
              {\text_uppercase:n {#1}}
              {\text_titlecase_first:n {#1}}
          }{}
      }
  }

\tl_set:Nn \l__toc_type_tl{book}
\keys_define:nn {listoc}
  {
    article .code:n = \tl_set:Nn \l__toc_type_tl{article},
    book    .code:n = {},
    multoc  .bool_set:N = \l__multoc_bool,
    multoc  .default:n = true,
    multoc  .initial:n = false
  }

\cs_new_protected:Npn \__title_mark_intoc:n #1
  {
    \tl_if_eq:NnTF \l__toc_type_tl{book}
      {
        \chapter*{\phantomsection#1}
        \CTEX@addtocline{chapter}{#1}
      }{
        \section*{\phantomsection#1}
        \CTEX@addtocline{section}{#1}
      }
    \__markboth:n {#1}
  }
\cs_new_protected:Npn \__title_mark:n #1
  {
    \tl_if_eq:NnTF \l__toc_type_tl{book}
      {\chapter*{\phantomsection#1}}
      {\section*{\phantomsection#1}}
    \__markboth:n {#1}
  }
\cs_new_protected:Npn \__ifmultoc_pre_set:
  {
    \bool_if:NTF \l__class_book_bool
      {
        \if@twocolumn
          \@restonecoltrue
          \bool_if:NTF \l__multoc_bool{\twocolumn}{\onecolumn}
        \else
          \@restonecolfalse
          \bool_if:NT \l__multoc_bool{\twocolumn}
        \fi
      }{\tl_set:Nn \l__toc_type_tl{article}}
  }
\cs_new_protected:Npn \__ifmultoc_after_set:
  {
    \bool_if:NTF \l__class_book_bool
      {
        \if@restonecol
          \twocolumn
        \else
          \onecolumn
        \fi
      }{\tl_set:Nn \l__toc_type_tl{article}}
  }
\RenewDocumentCommand{\tableofcontents}{o}
  {
    \group_begin:
    \IfValueT{#1}{\keys_set:nn {listoc}{#1}}
    \__ifmultoc_pre_set:
    \__title_mark:n {\contentsname}
    \vspace*{\dim_use:N \l__toc_offset_dim}
    \@starttoc{toc}
    \__ifmultoc_after_set:
    \group_end:
  }
\RenewDocumentCommand{\listoffigures}{so}
  {
    \group_begin:
    \IfValueT{#2}{\keys_set:nn {listoc}{#2}}
    \__ifmultoc_pre_set:
    \IfBooleanTF{#1}
      {\__title_mark:n {\listfigurename}}
      {\__title_mark_intoc:n {\listfigurename}}
    \dim_add:NV \l__toc_offset_dim\l__toc_listsoffset_dim
    \vspace*{\dim_use:N \l__toc_offset_dim}
    \@starttoc{lof}
    \__ifmultoc_after_set:
    \group_end:
  }
\RenewDocumentCommand{\listoftables}{so}
  {
    \group_begin:
    \IfValueT{#2}{\keys_set:nn {listoc}{#2}}
    \__ifmultoc_pre_set:
    \IfBooleanTF{#1}
      {\__title_mark:n {\listtablename}}
      {\__title_mark_intoc:n {\listtablename}}
    \dim_add:NV \l__toc_offset_dim\l__toc_listsoffset_dim
    \vspace*{\dim_use:N \l__toc_offset_dim}
    \@starttoc{lot}
    \__ifmultoc_after_set:
    \group_end:
  }
\NewDocumentCommand{\listoflistings}{so}
  {
    \group_begin:
    \IfValueT{#2}{\keys_set:nn {listoc}{#2}}
    \__ifmultoc_pre_set:
    \IfBooleanTF{#1}
      {\__title_mark:n {\lstlistlistingname}}
      {\__title_mark_intoc:n {\lstlistlistingname}}
    \dim_add:NV \l__toc_offset_dim\l__toc_listsoffset_dim
    \vspace*{\dim_use:N \l__toc_offset_dim}
    \@starttoc{lol}
    \__ifmultoc_after_set:
    \group_end:
  }

\makeindex[
  intoc,
  options = -M~texindy~-C~utf8,
  program = truexindy,
  columns = 2,
  columnsep = 2\ccwd
  ]
\indexsetup
  {
    level = \bool_if:NTF \l__class_book_bool{\chapter*}{\section*},
    toclevel = \bool_if:NTF \l__class_book_bool{chapter}{section},
    firstpagestyle = \bool_if:NTF \l__class_book_bool{plain}{fancy}
  }
\__patch_cmd:Nnn \imki@indexheaders
  {\@mkboth{\MakeUppercase\indexname}{\MakeUppercase\indexname}}
  {\__markboth:n {\indexname}}

\tl_new:N \l__font_table_tl
\tl_new:N \l__font_figure_tl
\tl_new:N \l__font_listing_tl
\tl_new:N \l__font_footnote_tl

\__ctex_define:nn {elsefont}
  {
    table-cap   .tl_set:N = \l__font_table_tl,
    table-cap   .initial:n = \sffamily\small,
    figure-cap  .tl_set:N = \l__font_figure_tl,
    figure-cap  .initial:n = \sffamily\small,
    listing-cap .tl_set:N = \l__font_listing_tl,
    listing-cap .initial:n = \sffamily\small,
    footnote    .tl_set:N = \l__font_footnote_tl,
    footnote    .initial:n = \rmfamily,
    marginpar   .tl_set:N = \marginfont,
    marginpar   .initial:n = \rmfamily\footnotesize
  }

\DeclareCaptionLabelSeparator{ccwd}{\hspace{\ccwd}}
\DeclareCaptionLabelFormat{parens}{\bothIfFirst{#1}{~}(#2)}
\DeclareCaptionFont{table@font}{\l__font_table_tl}
\DeclareCaptionFont{figure@font}{\l__font_figure_tl}
\DeclareCaptionFont{listing@font}{\l__font_listing_tl}
\captionsetup
  {
    format = hang,
    % figurewithin = section,
    % tablewithin = section,
    font = {stretch = {\fp_use:N \l__spread_caption_fp}},
    labelfont = {color = ctex@frame},
    labelsep = ccwd,
    singlelinecheck = true,
    belowskip = 0pt,aboveskip = 10pt
  }
\captionsetup[table]{font += table@font}
\captionsetup[figure]{font += figure@font}
\captionsetup[lstlisting]{font += listing@font}
\captionsetup[subfigure]
  {
    labelformat = parens,
    font += figure@font,
    belowskip = 2pt,aboveskip = 6pt
  }
\ctex_at_end_package:nn {bicaption}
  {
    \captionsetup[figure][bi-second]{name = Figure}
    \captionsetup[table][bi-second]{name = Table}
  }
\cs_new:Npn \__arabic:n #1{\int_to_arabic:v {c@#1}}
\cs_new_protected:Npn \__separator_set:n #1
  {
    \cs_set:cpn {the#1}
      {
        \int_compare:nT {\c@chapter > 0}
          {
            \thechapter
            \use:c {l__#1_separator_tl}
          }
        \__arabic:n {#1}
      }
  }
\cs_gset:cpn {thesection}
  {
    \int_compare:nT {\c@chapter > 0}{\thechapter.}
    \__arabic:n {section}
  }
\clist_map_inline:nn
  {{figure},{table},{lstlisting},{equation}}
  {\__separator_set:n {#1}}
\cs_gset_protected:Npn \appendix
  {
    \int_compare:nNnTF {\c@chapter} > {0}
      {
        \setcounter{chapter}{0}
        \setcounter{section}{0}
        \gdef\thechapter{\@Alph\c@chapter}
        \gdef\CTEX@prechapter{\CTEX@preappendix}
        \gdef\CTEX@thechapter{\CTEX@appendix@number}
        \gdef\CTEX@postchapter{\CTEX@postappendix}
        \gdef\CTEX@chapter@numbering{\CTEX@appendix@numbering}
      }{
        \setcounter{section}{0}
        \setcounter{subsection}{0}
        \gdef\thesection{\@Alph\c@section}
        \gdef\CTEX@presection{\CTEX@preappendix}
        \gdef\CTEX@thesection{\CTEX@appendix@number}
        \gdef\CTEX@postsection{\CTEX@postappendix}
        \gdef\CTEX@section@numbering{\CTEX@appendix@numbering}
        \ctex_set:nn {appendix}{number = {\@Alph\c@section},name = {}}
      }
  }
\AtBeginEnvironment{tabularx}
  {
    \exp_args:Nx \linespread{\fp_use:N \l__spread_table_fp}
    \selectfont\ignorespaces
  }
\AtBeginEnvironment{tabular}
  {
    \exp_args:Nx \linespread{\fp_use:N \l__spread_table_fp}
    \selectfont\ignorespaces
  }
\ctex_after_end_preamble:n
  {
    \exp_args:Nx \linespread{\fp_use:N \l__spread_line_fp}
    \selectfont\ignorespaces
  }

\fp_new:N \l__spread_line_fp
\fp_new:N \l__spread_table_fp
\fp_new:N \l__spread_math_fp
\fp_new:N \l__spread_caption_fp
\fp_new:N \l__spread_footnote_fp

\__ctex_define:nn {spread}
  {
    line      .fp_set:N = \l__spread_line_fp,
    line      .initial:n = 1.3,
    table     .fp_set:N = \l__spread_table_fp,
    table     .initial:n = 1.05,
    math      .fp_set:N = \l__spread_math_fp,
    math      .initial:n = 1.05,
    caption   .fp_set:N = \l__spread_caption_fp,
    caption   .initial:n = 1,
    footnote  .fp_set:N = \l__spread_footnote_fp,
    footnote  .initial:n = 1
  }

\skip_set:Nn \parskip{0pt plus 2pt minus 1pt}
\skip_set:Nn \floatsep{12pt plus 2pt minus 2pt}
\skip_set:Nn \intextsep{14pt plus 2pt minus 2pt}
\skip_set:Nn \textfloatsep{16pt plus 2pt minus 4pt}
\skip_set:Nn \dbltextfloatsep{16pt plus 2pt minus 4pt}
\skip_set:Nn \@fpsep{8pt plus 2.0fil}
\setcounter{topnumber}{4}
\setcounter{bottomnumber}{4}
\setcounter{totalnumber}{8}
\cs_gset:Npn \textfraction{0.18}
\cs_gset:Npn \topfraction{0.85}
\cs_gset:Npn \bottomfraction{0.65}
\cs_gset:Npn \floatpagefraction{0.60}

\newcolumntype{L}{X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\graphicspath{{figures/}}
\DeclareGraphicsExtensions{.pdf,.png,.jpg,.eps,.tif}

\setlist
  {
    labelsep = .75\ccwd,listparindent = 2\ccwd,
    itemsep = .75ex plus .1ex,topsep = .75ex plus .1ex,
    partopsep = 0ex,parsep = 0ex
  }
\newlist{outlinelist}{itemize}{1}
\setlist[outlinelist]
  {
    label = \color{ctex@emph}\upshape\ding{111},
    itemsep = .5ex plus .1ex,leftmargin = *
  }
\setlist[itemize,1]
  {label = \color{ctex@emph}\ensuremath{\bullet},leftmargin = *}
\setlist[itemize,2]
  {label = \color{ctex@emph}\ensuremath{\circ},leftmargin = *}
\setlist[enumerate,1]
  {label = \color{ctex@emph}\arabic*.,ref = \arabic*,leftmargin = *}
\setlist[enumerate,2]
  {label = \color{ctex@emph}(\alph*),ref = \theenumi(\alph*),leftmargin = *}
\setlist[description]
  {font = \color{ctex@emph}\sf,labelwidth = *,leftmargin = 2\ccwd}

\cs_new_protected:Npn \__thmname_set:nn #1#2
  {\tl_const:cn {c__name_#1_tl}{#2}}
\bool_if:NTF \l__lang_chinese_bool
  {
    \clist_map_inline:nn
      {
        {theorem}{定理},
        {definition}{定义},
        {lemma}{引理},
        {corollary}{推论},
        {proposition}{性质},
        {example}{例},
        {remark}{注},
        {exercise}{练习}
      }{\__thmname_set:nn #1}
  }{
    \clist_map_inline:nn
      {
        {theorem}{Theorem},
        {definition}{Definition},
        {lemma}{Lemma},
        {corollary}{Corollary},
        {proposition}{Proposition},
        {example}{Example},
        {remark}{Remark},
        {exercise}{Exercise}
      }{\__thmname_set:nn #1}
  }

\bool_new:N \l__thmbox_bool
\tl_new:N \l__thm_numberwith_tl
\tl_new:N \l__thm_headpunct_tl
\tl_new:N \l__thm_bodyfont_tl
\tl_new:N \l__thm_notefont_tl
\tl_new:N \l__thm_headindent_tl
\tl_new:N \l__thm_spaceabove_tl
\tl_new:N \l__thm_spacebelow_tl

\RenewDocumentCommand{\newtheorem}{O{}m}
  {\AfterPreamble{\declaretheorem[#1]{#2}}}
\__ctex_define:nn {thmset}
  {
    thmbox      .bool_set:N = \l__thmbox_bool,
    thmbox      .default:n = true,
    thmbox      .initial:n = false,
    numberwith  .tl_set:N = \l__thm_numberwith_tl,
    numberwith  .initial:n = {chapter},
    headpunct   .tl_set:N = \l__thm_headpunct_tl,
    headpunct   .initial:n = {},
    bodyfont    .tl_set:N = \l__thm_bodyfont_tl,
    bodyfont    .initial:n = {},
    notefont    .tl_set:N = \l__thm_notefont_tl,
    notefont    .initial:n = {},
    headfont    .tl_set:N = \l__thm_headfont_tl,
    headfont    .initial:n = {\color{ctex@emph}\sffamily},
    headindent  .tl_set:N = \l__thm_headindent_tl,
    headindent  .initial:n = {0\ccwd},
    spaceabove  .tl_set:N = \l__thm_spaceabove_tl,
    spaceabove  .initial:n = {.75ex plus .1ex},
    spacebelow  .tl_set:N = \l__thm_spacebelow_tl,
    spacebelow  .initial:n = {.75ex plus .1ex},
    spacepost   .tl_set:N = \l__thm_spacepost_tl,
    spacepost   .initial:n = {\ccwd}
  }
\ctex_at_end_preamble:n
  {
    \declaretheoremstyle[
      spaceabove = \l__thm_spaceabove_tl,
      spacebelow = \l__thm_spacebelow_tl,
      headindent = \l__thm_headindent_tl,
      headfont = \l__thm_headfont_tl,
      notefont = \l__thm_notefont_tl,
      notebraces = {}{},
      bodyfont = \l__thm_bodyfont_tl,
      headpunct = \l__thm_headpunct_tl,
      postheadspace = \l__thm_spacepost_tl,
      numberwithin = \l__thm_numberwith_tl,
      headformat = \NAME\space\NUMBER\NOTE
      ]{mythm}
    \declaretheorem[style = mythm,name = \c__name_theorem_tl]{theorem}
    \declaretheorem[style = mythm,name = \c__name_definition_tl]{definition}
    \declaretheorem[style = mythm,name = \c__name_lemma_tl]{lemma}
    \declaretheorem[style = mythm,name = \c__name_corollary_tl]{corollary}
    \declaretheorem[style = mythm,name = \c__name_proposition_tl]{proposition}
    \declaretheorem[style = mythm,name = \c__name_example_tl]{example}
    \cs_gset_eq:NN \proof\relax
    \declaretheorem{remark}[
      style = mythm,
      name = \c__name_remark_tl,
      numbered = no
      ]
    \declaretheorem{proof}[
      style = mythm,
      name = \proofname,
      numbered = no,
      qed = \qedsymbol
      ]
  }

\settasks
  {
    label = (\Alph*),
    after-item-skip = 0ex plus .1ex,
    column-sep = .5\ccwd,
    item-indent = 2\ccwd,
    label-width = 1.5\ccwd
  }
\setchemformula
  {
    math-scripts = false,
    charge-hshift = 0.25\ccwd,
    subscript-vshift = -0.2ex
  }
\sisetup
  {
    detect-family,
    detect-weight,
    detect-shape,
    detect-inline-family = math,
    detect-inline-weight = math,
    detect-display-math,
    range-phrase = \ensuremath{\sim},
    range-units = single,
    table-parse-only,
    group-digits = false
  }
\allowdisplaybreaks[4]
\cs_gset:Npn \ULthickness{.75pt}
\skip_set:Nn \jot{4pt plus 1pt minus 1pt}
\cs_new_protected:Npn \l__math_restore:n #1
  {
    \AtBeginEnvironment{#1}
      {\linespread{\fp_use:N \l__spread_math_fp}\selectfont\ignorespaces}
  }
\clist_map_inline:nn
  {
    {array},{matrix},{pmatrix},{bmatrix},{Bmatrix},{vmatrix},{Vmatrix},
    {matrix*},{pmatrix*},{bmatrix*},{Bmatrix*},{vmatrix*},{Vmatrix*},
    {cases},{cases*},{dcases},{dcases*},{rcases},{rcases*},{drcases},{drcases*},
    {aligned},{alignedat},{gathered},{multlined},{lgathered},{rgathered}
  }{\l__math_restore:n {#1}}
\__patch_cmd:Nnn \start@gather
  {\collect@body}
  {\linespread{\fp_use:N \l__spread_math_fp}\selectfont\collect@body}
\__patch_cmd:Nnn \start@align
  {\collect@body}
  {\linespread{\fp_use:N \l__spread_math_fp}\selectfont\collect@body}
\__patch_cmd:Nnn \start@multline
  {\collect@body}
  {\linespread{\fp_use:N \l__spread_math_fp}\selectfont\collect@body}
\__patch_cmd:Nnn \gather@split
  {\spread@equation}
  {\linespread{\fp_use:N \l__spread_math_fp}\selectfont\spread@equation}
\ctex_after_end_preamble:n
  {
    \skip_set:Nn \abovedisplayskip{5pt plus 1pt minus 1pt}
    \skip_set:Nn \belowdisplayskip{5pt plus 1pt minus 1pt}
    \skip_set:Nn \abovedisplayshortskip{0pt}
    \skip_set:Nn \belowdisplayshortskip{5pt plus 1pt minus 1pt}
  }
\cs_gset:Npn \tagform@#1
  {\maketag@@@{\color{ctex@emph}(\ignorespaces#1\unskip\@@italiccorr)}}

\ctex_at_end_package:nn {tcolorbox}
  {
    \__ifpackage_later:nn {tcolorbox}{2020/10/09}
    \tcbset
      {
        thmsty/.style =
          {
            enhanced~jigsaw,pad~at~break* = 3pt,
            opacityback = 0,
            colframe = ctex@emph,
            left = .2pc,right = .2pc,top = .5pc,bottom = .5pc,middle= .5pc,
            arc = 0pt
          },
        outlinesty/.style =
          {
            enhanced,nofloat,
            tikznode~boxed~title,
            interior~style = white,colframe = ctex@emph,
            colbacktitle = white,coltitle = ctex@emph,
            fonttitle = \large\sffamily,fontupper = \itshape,
            boxed~title~style = {size = normal,opacityframe = 0,boxrule = 0pt},
            attach~boxed~title~to~top~center = {yshift = -\tcboxedtitleheight/2},
            arc = 3pt,
            after~skip = 3ex,
            left = 1.5pc,right = 1.5pc,top = 1pc,bottom = 0.5pc,
            boxsep = 5pt
          },
        exersty/.style =
          {
            enhanced,on~line,
            arc = 5pt,
            fontupper = \sffamily\Large,
            boxrule = 1pt,boxsep = 0pt,
            left = 6pt,right = 6pt,top = 3.5pt,bottom = 3.5pt,
            before~skip = 4ex,after~skip = 2.25ex
          },
        breakable,
        boxrule = \l__rule_width_dim
      }
    \NewDocumentEnvironment{outline}{D(){\abstractname}o+b}
      {
        \begin{tcolorbox}[outlinesty,title = #1,IfValueT = {#2}{#2}]
          \begin{outlinelist}
            #3
          \end{outlinelist}
        \end{tcolorbox}
      }{}
    \NewDocumentEnvironment{exercise}
      {sO{LightYellow}O{1.}D(){\c__name_exercise_tl}o+b}
      {
        \begin{center}
          \bool_if:NTF \l__thmbox_bool
            {
              \tcbox[
                exersty,
                colback = #2,colframe = black,
                drop~fuzzy~shadow = #2,
                IfValueT = {#5}{#5},
                phantom =
                  \IfBooleanF{#1}
                    {
                      \CTEX@ifnametrue
                      \refstepcounter{section}
                      \markright{\CTEXthesection\hspace{0.5\ccwd}#4}
                      \CTEX@addtocline{section}{#4}
                    }
                ]{\IfBooleanF{#1}{\CTEXthesection\hspace{0.5\ccwd}}#4}
            }{
              \sffamily\Large
              \IfBooleanF{#1}
                {
                  \CTEX@ifnametrue
                  \refstepcounter{section}
                  \markright{\CTEXthesection\hspace{0.5\ccwd}#4}
                  \CTEX@addtocline{section}{#4}
                  \CTEXthesection\hspace{0.5\ccwd}
                }#4
            }
        \end{center}
        \begin{enumerate}[#3,labelsep = 0.5\ccwd]
          #6
        \end{enumerate}
      }{}
    \DeclareTColorBox{mybox}{sO{MintCream}d()O{}}
      {
        enhanced~jigsaw,pad~at~break* = 3pt,
        IfBooleanTF = {#1}{colback = #2}{opacityback = 0,colframe = ctex@emph},
        IfValueT = {#3}{title = #3},
        coltitle = black,colbacktitle = white,
        fonttitle = \sffamily,
        left = .2pc,right = .2pc,top = .5pc,bottom = .5pc,middle= .5pc,
        arc = 0pt,
        toptitle = 2pt,bottomtitle = 2pt,
        beforeafter~skip=2ex,
        halign~upper = left,halign~lower = left,
        center~title,#4
      }
    \DeclareTotalTCBox{\fuzzy}{O{DarkSeaGreen}vO{}}
      {
        nobeforeafter,tcbox~raise~base,
        blank,fuzzy~halo = 2pt~with~#1,#3
      }{#2}
    \DeclareTotalTCBox{\concise}{O{Aqua}vO{}}
      {
        nobeforeafter,tcbox~raise~base,
        top = 2pt,bottom = 2.5pt,left = 2pt,right = 2pt,
        boxsep = 0pt,boxrule = 0.75pt,arc = 1pt,
        colback = #1!15!white,#3
      }{#2}
  }
\ctex_at_end_preamble:n
  {
    \bool_if:NT \l__thmbox_bool
      {
        \@ifpackageloaded{tcolorbox}
          {
            \tcolorboxenvironment{theorem}{thmsty}
            \tcolorboxenvironment{definition}{thmsty}
            \tcolorboxenvironment{lemma}{thmsty}
            \tcolorboxenvironment{corollary}{thmsty}
            \tcolorboxenvironment{proposition}{thmsty}
            \tcolorboxenvironment{example}{thmsty}
          }{}
      }
  }

\bool_set_true:N \l__backend_bibtex_bool
\tl_new:N \l__bib_style_tl
\tl_new:N \l__bib_otherstyle_tl
\tl_new:N \l__bib_citestyle_tl
\tl_new:N \l__bib_file_tl

\__ctex_define:nn {bibset}
  {
    backend               .choice:,
    backend/bibtex        .code:n = {},
    backend/biblatex      .code:n =
      {\bool_set_false:N \l__backend_bibtex_bool},

    bib-style             .choice:,
    bib-style             .value_required:n = true,
    bib-style/numerical   .code:n =
      {
        \tl_set:Nn  \l__bib_style_tl{#1}
        \tl_clear:N \l__bib_otherstyle_tl
      },
    bib-style/authoryear  .code:n =
      {
        \tl_set:Nn  \l__bib_style_tl{#1}
        \tl_clear:N \l__bib_otherstyle_tl
      },
    bib-style/unknown     .code:n =
      {\tl_set_eq:NN \l__bib_otherstyle_tl\l_keys_value_tl},
    bib-style             .initial:n = numerical,

    cite-style            .code:n =
      {\tl_set:Nn \l__bib_citestyle_tl{#1}},
    bibfile               .tl_set:N = \l__bib_file_tl,
    bibfile               .initial:n = refs.bib
  }

\cs_new_protected:Npn \__bibtex_set:
  {
    \tl_if_empty:NTF \l__bib_otherstyle_tl
      {
        \tl_if_eq:VnT \l__bib_style_tl{numerical}
          {
            \bibliographystyle{gbt7714-numerical}
            \setcitestyle{comma,square,super}
          }
        \tl_if_eq:VnT \l__bib_style_tl{authoryear}
          {\bibliographystyle{gbt7714-author-year}}
        \cs_set_eq:NN \cite\citep
      }{
        \exp_args:NV \bibliographystyle\l__bib_otherstyle_tl
      }
    \tl_if_empty:NF \l__bib_citestyle_tl
      {\exp_args:NV \setcitestyle\l__bib_citestyle_tl}
    \skip_set:Nn \bibsep{0ex}
    \NewDocumentCommand{\printbibliography}{so}
      {
        \group_begin:
        \IfValueT{##2}{\keys_set:nn {listoc}{##2}}
        \__ifmultoc_pre_set:
        \cs_set:Npn \bibsection
          {
            \IfBooleanTF{##1}
              {\__title_mark:n {\bibname}}
              {\__title_mark_intoc:n {\bibname}}
          }
        \exp_args:NV \bibliography\l__bib_file_tl
        \__ifmultoc_after_set:
        \group_end:
      }
  }
\cs_new_protected:Npn \__put_biblatex:n #1
  {\PassOptionsToPackage{#1}{biblatex}}
\cs_new_protected:Npn \__biblatex_pre_set:
  {
    \tl_if_empty:NTF \l__bib_otherstyle_tl
      {
        \tl_if_eq:VnT \l__bib_style_tl{numerical}
          {\__put_biblatex:n {style = gb7714-2015}}
        \tl_if_eq:VnT \l__bib_style_tl{authoryear}
          {\__put_biblatex:n {style = gb7714-2015ay}}
      }{
        \__put_biblatex:n {style = \l__bib_otherstyle_tl}
      }
    \tl_if_empty:NF \l__bib_citestyle_tl
      {\__put_biblatex:n {citestyle = \l__bib_citestyle_tl}}
    \__put_biblatex:n {backend = biber}
  }
\cs_new_protected:Npn \__biblatex_after_set:
  {
    \exp_args:NV \addbibresource\l__bib_file_tl
    \cs_gset:Npn \blx@default@theheading{bibintoc}
    \defbibheading{bibintoc}[\bibname]{\__title_mark_intoc:n {##1}}
    \skip_set:Nn \bibitemsep{0ex}
  }
\ctex_at_end_preamble:n
  {
    \bool_if:NTF \l__backend_bibtex_bool
      {
        \RequirePackage[sort&compress]{natbib}
        \__bibtex_set:
      }{
        \__biblatex_pre_set:
        \RequirePackage{biblatex}
        \__biblatex_after_set:
      }
  }

\ctex_at_end_preamble:n
  {
    \group_begin:
    \footnotesize
    \exp_args:Nx \linespread{\fp_use:N \l__spread_footnote_fp}\selectfont
    \skip_gset:Nn \footnotesep{\ht\strutbox}
    \group_end:
    \bool_if:NT \l__chap_withpart_bool
      {\counterwithin*{chapter}{part}}
    \tl_if_eq:NnT \l__foot_numberwith_tl{part}
      {
        \counterwithout*{footnote}{chapter}
        \counterwithin*{footnote}{part}
      }
    \tl_if_eq:NnT \l__foot_numberwith_tl{page}
      {
        \counterwithout*{footnote}{chapter}
        \counterwithin*{footnote}{page}
      }
  }
\__patch_cmd:Nnn \@footnotetext
  {\reset@font}
  {\def\baselinestretch{\fp_use:N \l__spread_footnote_fp}\l__font_footnote_tl}
\__patch_cmd:Nnn \@mpfootnotetext
  {\reset@font}
  {\def\baselinestretch{\fp_use:N \l__spread_footnote_fp}\l__font_footnote_tl}
\__patch_cmd:Nnn \@makefnmark
  {\normalfont}{\l__font_footnote_tl}

\lstdefinestyle{mystyle}
  {
    language = [LaTeX]TeX,
    texcsstyle =
      *\lst@ifdisplaystyle\bfseries\color{ctex@verb}\else\color{ctex@verb}\fi,
    basicstyle =
      \ttfamily\lst@ifdisplaystyle\small\else\color{ctex@verb}\fi,
    framexleftmargin = 0pt,
    framexrightmargin = 0pt,
    xleftmargin = 3pt,
    xrightmargin = 3pt,
    numbersep = 10pt,
    framesep = 3pt,
    frame = single,
    rulecolor = \color{ctex@frame},
    commentstyle = \color{gray},
    emphstyle = \color{ctex@emph},
    emph = {caption,makecell,subcaption,tabularx},
    keywordstyle =
      \lst@ifdisplaystyle\bfseries\color{ctex@verb}\else\color{ctex@verb}\fi,
    morekeywords =
      {
        includegraphics,setmainfont,setsansfont,setmonofont,setCJKmainfont,setCJKsansfont,setCJKmonofont,setCJKfamilyfont,RequirePackage
      }
  }
\lstset
  {
    style = mystyle,
    breaklines = true,
    resetmargins = true,
    % numbers = left,
    numberstyle = \footnotesize,
    abovecaptionskip = -1ex,
    belowcaptionskip = 1.5ex,
    aboveskip = 1.5ex plus .2ex minus .1ex,
    belowskip = 0.55ex plus .2ex minus .1ex,
    keepspaces = true,
    framerule = \l__rule_width_dim,
    columns = flexible
  }
\lstloadlanguages{C,C++,Java,Python,Matlab}
\AtBeginEnvironment{verbatim}{\microtypesetup{activate = false}}

\clist_new:N \l__hyperref_clist
\cs_new_protected:Npn \__put_hyperref:n #1
  {\clist_put_right:Nn \l__hyperref_clist{#1}}
\cs_new_protected:Npn \__define_linkcolor:nnn #1#2#3
  {\definecolorset{HTML}{ctex@}{}{link,#1;url,#2;cite,#3}}
\cs_new_protected:Npn \__define_themecolor:nnn #1#2#3
  {\definecolorset{HTML}{ctex@}{}{frame,#1;emph,#2;verb,#3}}
\cs_new:Npn \__linkcolor_set:n #1
  {
    linkcolor/\clist_item:nn {#1}{1} .code:n =
      {
        \__define_linkcolor:nnn
          {\clist_item:nn {#1}{2}}
          {\clist_item:nn {#1}{3}}
          {\clist_item:nn {#1}{4}}
        \__put_hyperref:n
          {
            linkcolor = ctex@link,linkbordercolor = ctex@link,
            urlcolor = ctex@url,urlbordercolor = ctex@url,
            citecolor = ctex@cite,citebordercolor = ctex@cite
          }
      },
  }
\cs_new:Npn \__themecolor_set:n #1
  {
    color/\clist_item:nn {#1}{1} .code:n =
      {
        \__define_themecolor:nnn
          {\clist_item:nn {#1}{2}}
          {\clist_item:nn {#1}{3}}
          {\clist_item:nn {#1}{4}}
      },
  }

\cs_new:Npn \__allow_urlbreak:
  {
    \cs_new:Npn \__add_urlbreak_points:
      {\tl_map_function:NN \c__urlbreak_points_tl\do}
    \__appto_cmd:Nn
      \UrlBreaks{\UrlOrds\__add_urlbreak_points:}
  }
\tl_const:Nn \c__urlbreak_points_tl
  {ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789}

\keys_define:nx {ctex/link}
  {
    hyperlink         .choice:,
    hyperlink/edge    .code:n = {},
    hyperlink/various .code:n = {\__put_hyperref:n {colorlinks}},
    hyperlink/none    .code:n = {\__put_hyperref:n {hidelinks}},
    hyperlink         .default:n = edge,
    hyperlink         .initial:n = edge,

    linkcolor         .choice:,
    \clist_map_function:nN
      {
        {fresh,     62d71f,0000B2,005752},
        {cutepink,  ff69b4,9d5196,57b5e5},
        {skyblue,   0000ff,004986,eb6877},
        {crimson,   dc143c,00c1c9,afcd20}
      }
      \__linkcolor_set:n
    linkcolor         .default:n = fresh,
    linkcolor         .initial:n = fresh,

    linktopage        .choice:,
    linktopage/true   .code:n = {\__put_hyperref:n {linktocpage}},
    linktopage/false  .code:n = {},
    linktopage        .default:n = true,
    linktopage        .initial:n = false
  }
\keys_define:nx {ctex/style}
  {
    color             .choice:,
    color             .value_required:n = true,
    \clist_map_function:nN
      {
        {none,      000000,000000,000000},
        {seaside,   4682B4,004986,a40000},
        {energy,    f39800,00a0e9,893895},
        {cyberpunk, 601986,eb6877,a4005b}
      }
      \__themecolor_set:n
    color             .initial:n = none
  }

\ctex_at_end_preamble:n
  {
    \RequirePackage{hyperref,cleveref}
    \urlstyle{same}
    \__allow_urlbreak:
    \ctex_hypersetup:n {pdfstartview = FitH,bookmarksnumbered}
    \exp_args:NV \hypersetup\l__hyperref_clist
    \bool_if:NTF \l__lang_chinese_bool
      {
        \keys_set_known:nn {ctex}
          {
            contentsname = {目\hspace{\ccwd}录},
            indexname = {索\hspace{\ccwd}引},
            listfigurename = {图片索引},
            listtablename = {表格索引},
            abstractname = {摘\hspace{\ccwd}要},
            lstlistlistingname = {代码索引},
            lstlistingname = {代码}
          }
        \crefformat{equation}{#2式(#1)#3}
        \crefformat{align}{#2式(#1)#3}
        \crefformat{multline}{#2式(#1)#3}
        \crefformat{gather}{#2式(#1)#3}
        \crefformat{figure}{#2图#1#3}
        \crefformat{table}{#2表#1#3}
        \crefformat{chapter}{#2第#1章#3}
        \crefformat{section}{#2节#1#3}
        \crefformat{subsection}{#2小节#1#3}
        \crefformat{theorem}{#2定理#1#3}
        \crefformat{definition}{#2定义#1#3}
        \crefformat{lemma}{#2引理#1#3}
        \crefformat{corollary}{#2推论#1#3}
        \crefformat{proposition}{#2性质#1#3}
        \crefformat{example}{#2例#1#3}
      }{
        \keys_set_known:nn {ctex}
          {
            abstractname = {Abstract},
            lstlistlistingname = {List~of~Listings},
            lstlistingname = {Code}
          }
        \crefformat{equation}{#2Equation~(#1)#3}
        \crefformat{align}{#2Equation~(#1)#3}
        \crefformat{multline}{#2Equation~(#1)#3}
        \crefformat{gather}{#2Equation~(#1)#3}
        \crefformat{figure}{#2Figure~#1#3}
        \crefformat{table}{#2Table~#1#3}
        \crefformat{chapter}{#2Chapter~#1#3}
        \crefformat{section}{#2Section~#1#3}
        \crefformat{subsection}{#2Subsection~#1#3}
        \crefformat{theorem}{#2Theorem~#1#3}
        \crefformat{definition}{#2Definition~#1#3}
        \crefformat{lemma}{#2Lemma~#1#3}
        \crefformat{corollary}{#2Corollary~#1#3}
        \crefformat{proposition}{#2Proposition~#1#3}
        \crefformat{example}{#2Example~#1#3}
      }
  }

\ctex_set:n
  {
    secnumdepth = 3,
    tocdepth = 1,
    part =
      {
        pagestyle = empty,
        number =
          {\bool_if:NTF \l__zhtitle_bool{\chinese{part}}{\thepart}},
        format = {\color{ctex@frame}\sffamily\Huge},
        aftername =
          {\bool_if:NTF \l__newline_bool{\par\nobreak}{\hspace{\ccwd}}},
        tocline = {\CTEXifname{\CTEXthepart\hspace{\ccwd}}{}#2}
      },
    chapter =
      {
        % pagestyle = fancy,
        number =
          {\bool_if:NTF \l__zhtitle_bool{\chinese{chapter}}{\thechapter}},
        format =
          {
            \color{ctex@frame}\sffamily\LARGE
            \bool_if:NF \l__newline_bool{\centering}
          },
        aftername =
          {
            \bool_if:NTF \l__newline_bool
              {\par\nobreak\vskip 1.5pc}{\hspace{\ccwd}}
          },
        beforeskip = {-1.5ex},
        afterskip = {3ex},
        lotskip = {0.8pc},
        lofskip = {0.8pc},
        tocline = {\CTEXifname{\CTEXthechapter\hspace{\ccwd}}{}#2}
      },
    section =
      {
        hang = true,
        format = {\color{ctex@frame}\sffamily\Large},
        aftername = {\hspace{0.5\ccwd}},
        beforeskip = {1.5ex plus .2ex minus .1ex},
        afterskip = {1.5ex plus .2ex minus .1ex},
        tocline = {\CTEXifname{\CTEXthesection\hspace{\ccwd}}{}#2}
      },
    subsection =
      {
        hang = true,
        format = {\color{ctex@frame}\sffamily\large},
        aftername = {\hspace{0.5\ccwd}},
        beforeskip = {1.3ex plus .2ex minus .1ex},
        afterskip = {1.3ex plus .2ex minus .1ex},
        tocline = {\CTEXifname{\CTEXthesubsection\hspace{\ccwd}}{}#2}
      },
    subsubsection =
      {
        hang = true,
        format = {\color{ctex@frame}\sffamily},
        aftername = {\hspace{0.5\ccwd}},
        beforeskip = {\parskip},
        afterskip = {\parskip}
      }
  }

\bool_if:NF \l__newline_bool
  {
    \ctex_set:n
      {
        part/hang = true,
        chapter/hang = true
      }
  }
%</class>
% \Finale
\endinput