-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheasybook.tex
1616 lines (1554 loc) · 113 KB
/
easybook.tex
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
\PassOptionsToPackage{svgnames}{xcolor}
\documentclass[load-preamble+]{cnltx-doc}
\usepackage[fontset = fandol]{ctex}
\usepackage
{
enumitem,indentfirst,tabularray,
fancyvrb,geometry,hologo,changelog,calc
}
\definecolorscheme{blue}
{
cs => violet,
option => DarkGreen,
cnltx => DarkBlue,
link => DeepPink,
module => FireBrick,
beginend => FireBrick,
meta => black,
versionnote => black
}
\setcnltx
{
name = easybook,
color-scheme = blue,
title = EASYBOOK使用手册,
version = v2025q,
date = 2025/02/16,
authors = 瞿毅,
info = 简便地排版中文学位论文或书籍,
email = [email protected],
url = https://gitee.com/texno3/easybook,
abstract =
{
\easybook{} 是基于 \cls*{ctexbook} 书籍文档类创建的纯净学术模板,同时兼具 \cls*{book} 与 \cls*{article} 文档类的功能。结合中国许多高校学位论文的通用框架设计,提供多个命令和接口可以使用户简便地定制论文模板。它的基础宏包 \pkg*{easybase} 还可以搭配 \CTeX 和标准文档类使用。
},
arg-format = \normalfont\small\kaishu\xeCJKVerbAddon,
abstract-format = \small,
module-sep = \,$\Rightarrow$\,,
title-format = \huge\sffamily
}
\KOMAoptions{numbers = noenddot}
\setfootnoterule[0.5pt]{0.4\columnwidth}
\addtokomafont{headsepline}{\color{DarkBlue}}
\addtokomafont{footnoterule}{\color{DarkBlue}}
\addtokomafont{section}{\normalfont\sffamily}
\addtokomafont{subsection}{\normalfont\sffamily}
\addtokomafont{subsubsection}{\normalfont\sffamily}
\setkomafont{pagehead}{\normalfont\kaishu}
\DeclareTOCStyleEntry[entryformat = \sffamily]{default}{section}
\DeclareFieldFormat[book]{title}{\textsf{#1}}
\geometry{margin = 1in,marginparwidth = 0.6in,footskip = 0.5in}
\renewlist{cnltxlist}{description}{2}
\SetEnumitemValue{label}{textbullet}{\color{DarkBlue}\textbullet}
\setlist{nosep,topsep = \smallskipamount,labelsep = 0.5em}
\setlist[1]{labelindent = \parindent,leftmargin = *}
\setlist[itemize,1]{label = textbullet}
\setlist[cnltxlist]
{
leftmargin = 0pt,
itemindent = -1em,
listparindent = \parindent,
topsep = \smallskipamount,
itemsep = \smallskipamount,
partopsep = 0ex,
parsep = 0ex
}
\setcounter{tocdepth}{2}
\SetTblrInner[longtblr]{columns = c,hline{1,Z} = {1pt,DarkBlue}}
\SetTblrOuter[longtblr]{presep = \bigskipamount,postsep = \bigskipamount}
\DefTblrTemplate{caption-tag}{default}{表\thetable}
\DefTblrTemplate{caption-sep}{default}{\quad}
\DefTblrTemplate{remark-sep}{default}{\space}
\SetTblrStyle{caption-tag}{font = \bfseries}
\SetTblrStyle{remark}{font = \small\normalfont}
\ExplSyntaxOn\makeatletter
% * Do not add entries to the index
% + Canceling the \item command in the list environment
% - Leave the option value blank
\NewDocumentCommand{\kvsplit}{st+t-mm}
{
\IfBooleanF{#2}{\item}
\code
{
\IfBooleanTF{#1}{\option*{#4}}{\option{#4}}
\cnltx@isvalue
\IfBooleanTF{#3}{#5}{\splitmarg{#5}}
}
\cnltx@checkdefault{\hfill\newline}
}
% Traversal output parameters
\newcommand{\splitmeta}[2][\code{,}]
{
\clist_clear:N \l_tmpa_clist
\clist_map_inline:nn {#2} { \clist_put_right:Nn \l_tmpa_clist { \meta{##1} } }
\clist_use:Nn \l_tmpa_clist {#1}
}
% Add delimiters to parameters
\newcommand{\newsplitarg}[4][\code{,}]
{
\newcommand{#2}[1]
{\code{\textcolor{argument}{#3\textnormal{\splitmeta[#1]{##1}}#4}}}
}
\newsplitarg{\splitoarg}{[}{]}
\newsplitarg{\splitdarg}{(}{)}
\newsplitarg{\splitmarg}{\{}{\}}
\newsplitarg[\code{|}]{\baroarg}{[}{]}
\newcommand{\harg}{\textcolor{argument}{\code{-}}}
\newcommand{\HoLogo@TeXLive}[1]{\hologo{TeX}\HOLOGO@space\HOLOGO@mbox{Live}}
\renewcommand{\cnltxpackagenameformat}[1]{\textcolor{cnltx}{\textsf{#1}}}
% Remove default braces of values
\RenewDocumentCommand{\key}{s}
{
\IfBooleanTF{#1}{\cnltx@key@aux*}{\cnltx@key@aux{}}
\meta
}
\RenewDocumentCommand{\keyis}{s}
{
\IfBooleanTF{#1}{\cnltx@key@aux*}{\cnltx@key@aux{}}
\@firstofone
}
% A tag that distinguishes the options for different paths
\newcommand{\hface}{$\symbol{"263A}$}
\newcommand{\sface}{$\symbol{"263B}$}
\NewDocumentCommand{\dtag}{sO{\hface}}
{
\begingroup
\reversemarginpar
\marginnote{\hfill\llap{#2}}
\endgroup
\IfBooleanF{#1}{\cnltx@checkdefault{\hfill\newline}}
}
\newnote{\newtag}[1][New]{\fbox{#1}}
\newnote{\newtagv}[2][New]{#1\\#2}
\NewDocumentCommand{\optpath}{sm}
{
\IfBooleanF{#1}{\item}
\code{\textcolor{SlateGray}{#2}}
}
% Multi-row values alignment when there are many choices
\newcommand{\leftfillchoice}[2]
{
\hspace*{\widthof{\option*{#1}}+\widthof{\code{\cnltx@isvalue}}-1em}
\code{\choices{#2}}
}
% Use a separate module margin marker to prevent overlap
\newcommand{\smodule}[1]{{\normalsize\cnltx@module@text*{#1}}}
\renewcommand{\cnltx@package@abstract@width}{0.85\linewidth}
\renewcommand{\cnltx@write@lastname}{}
\newcommand{\cstext}[1]{\code{\textcolor{cs}{#1}}}
\newcounter{ctexexam}
\define@key{FV}{labelref}{\def\ctexexamlabelref{\label{#1}}}
\let\ctexexamlabelref\empty
\fvset
{
formatcom = \xeCJKVerbAddon,
baselinestretch = 1.2,
gobble = 2,
fontsize = \small,
rulecolor = \color{DarkBlue},
framerule = 0.5pt,
frame = single,
framesep = 8pt
}
\DefineVerbatimEnvironment{frameverb}{Verbatim}
{
listparameters =
{
\setlength{\topsep}{1.2\bigskipamount}
\appto\FV@EndList{\nointerlineskip}
}
}
\DefineVerbatimEnvironment{ctexexam}{Verbatim}
{
label = \rule{0pt}{12pt}\textnormal{\bfseries 例~\arabic{ctexexam}},
listparameters =
{
\setlength{\topsep}{1.2\bigskipamount}
\appto\FV@EndList{\nointerlineskip}
\refstepcounter{ctexexam}\ctexexamlabelref
}
}
\def\command{\cnltx@command}
\def\environment{\cnltx@environment}
\def\opt{\@cnltx@option@item\option}
\def\keyval{\@cnltx@option@item\key}
\def\keylit{\@cnltx@option@item\keyis}
\def\keychoice{\@cnltx@option@item\choicekey}
\def\keybool{\@cnltx@option@item\boolkey}
\renewenvironment{changelogdescription}
{\begin{description}[leftmargin = \parindent]}
{\end{description}}
\renewenvironment{changelogitemize}
{\begin{itemize}[leftmargin = *]}
{\end{itemize}}
\makeatother\ExplSyntaxOff
\labelformat{section}{节#1}
\labelformat{subsection}{小节#1}
\labelformat{subsubsection}{小节#1}
\labelformat{ctexexam}{例#1}
\labelformat{table}{表#1}
\begin{document}
\section{准备开始}
您在使用 \easybook{} 文档类编写文档前可能需要具备以下的条件:
\begin{itemize}
\item 使用 \hologo{XeLaTeX}(推荐)或 \hologo{LuaLaTeX} 两种编译方式之一。
\item 由于文档类用到了一些 \hologo{LaTeX} 和依赖宏包较新的功能,需要版本至少在\textbf{2021/11/15}以后的 \hologo{LaTeX} 内核支持。建议您安装最新的 \hologo{TeX} 发行版。
\item 虽然手册对基本用法做了介绍,但这并不是入门教程,所涉及到宏包的用法与命令并未进行详细介绍,需要对它们有所了解。您应当具有一定的 \hologo{LaTeX} 使用基础,可以在 \hologo{TeX} 综合网站 \href{https://www.ctan.org/}{CTAN} 查看相关资源。
\end{itemize}
\subsection{前言}
对于排版外文文档已有诸如 \cls*{KOMA-Script} 和 \cls*{memoir} 等应用广泛的文档类,但这些文档类并不是为中文用户设计的,难免有些水土不符,且用户手册繁杂,对于普通用户来说学习成本高,难以快速上手。中文文档的解决方案 \CTeX 宏集解决了中文输出和章节标题格式的设置问题,但在编写文档过程中往往需要更多基本的定制功能,例如目录、图表标题、页眉页脚、脚注和页面边距等,这往往需要额外加载不同功能的宏包。\easybook{} 文档类在 \cls*{ctexbook} 基础上载入了一些使用频率较高且基本稳定的宏包,对它们的功能进行整合并优化联动使用,模块化的改装提供统一的接口兼容 \CTeX 文档类,可以满足学术类文档例如中国学位论文模板的基本需求。\easybook{} 提供了与 \CTeX 相同现代化风格的键值设置,支持不同类型的选项与层次化的选项设置。
\subsection{基本用法}
\label{subsec:basic usage}
以下一份简单的 \TeX 文档演示了 \easybook{} 的最基本用法,在导言区进行宏包载入与文档设置,一些详细的使用样例会不定期上传在 \href{https://www.latexstudio.net/}{\hologo{LaTeX} 工作室} 的网站。或者直接使用 \pkg*{easybase} 宏包,目前适用于 \cls*{ctexbook}、\cls*{ctexrep}、\cls*{ctexart} 以及标准文档类,包含了\ref{sec:interface options} 所示各个模块接口命令的功能。当在\textbf{标准文档类}后载入时还可以使用 \pkg*{ctex} 宏包的选项,将会传递给 \pkg*{ctex} 宏包。文档类和宏包支持的全局选项见\ref{sec:document class options}。
\begin{frameverb}
\documentclass[全局选项]{easybook}
% \documentclass[全局选项]{ctexbook}
% \usepackage[全局选项]{easybase}
\ctexset{键值列表}
\usepackage{宏包列表}
\begin{document}
\chapter{hello :)}
\section{Welcome to easybook}
Hello, \LaTeX
\end{document}
\end{frameverb}
\subsection{编译方式}
假设您的 \TeX 源文件名为 \code{easybook-demo.tex},需要使用参考文献和索引功能,并使用 \hologo{XeLaTeX} 和 \hologo{biber} 引擎编译文档,那么需要在命令行中执行:
\begin{frameverb}
xelatex -shell-escape easybook-demo
biber easybook-demo
makeindex easybook-demo
xelatex -shell-escape easybook-demo
xelatex -shell-escape easybook-demo
\end{frameverb}
当然也可以使用 \code{latexmk} 及一些软件自带的编译工具,这里就不做介绍。 \\
$\blacktriangleright$需要注意正确\textbf{编译索引}要增加 \code{-shell-escape} 命令行选项。
\subsection{依赖宏包}
\ref{table:package list} 为 \pkg*{easybase} 直接调用的关键宏包清单,通常情况下它们是常用且稳定的。\colorbox{PaleTurquoise}{蓝色}背景的宏包表示修改了或依赖它们的内部命令。\colorbox{GreenYellow}{绿色}背景的宏包表示并未调用它们,但做了一些预配置,可在导言区手动载入以实现相关的功能。
\begin{longtblr}
[caption = 依赖的宏包清单,label = table:package list]
{
cells = {cmd = \pkg*},
cell{1}{3,4} = PaleTurquoise,
cell{2}{5} = PaleTurquoise,
cell{4}{5} = PaleTurquoise,
cell{5}{2} = PaleTurquoise,
cell{5}{1} = GreenYellow,
cell{1}{2} = GreenYellow,
cell{3}{1} = GreenYellow,
cell{4}{2} = GreenYellow
}
amsthm & bicaption & ctex & caption & chemformula \\
enumitem & etoolbox & fancyhdr & geometry & hyperref \\
indextools & listings & marginnote & graphicx & multicol \\
pifont & pdfpages & siunitx & spbmark & thmtools \\
tcolorbox & titletoc & tabularray & xcolor
\end{longtblr}
\section{全局选项}
\label{sec:document class options}
全局选项应当在使用 \easybook{} 文档类或 \pkg*{easybase} 宏包(部分支持)时指定,可见\ref{subsec:basic usage} 的例子。选项前带有\hface 符号表示只可用于文档类,否则文档类与宏包都适用。文档类选项除了下面额外增加的以外,还支持标准和 \CTeX 文档类的选项。
\subsection{基本选项}
\begin{cnltxlist}
\opt{draft}
开启草稿模式会加快编译速度,表现有显示页面边框、行溢出的地方显示黑色方块、图片变成占位方框、行间代码隐藏、显示当前日期和关闭超链接渲染。不使用绘图宏包及依赖 \pkg*{tcolorbox} 宏包的盒子环境也会增快编译速度,详情见\ref{subsec:box}。
\opt{newline}\dtag
部分和章标题的样式为另起一行,符合一般英文书籍的习惯。
\keychoice{scheme}{\fbox{chinese},plain}\dtag
文档主题方案选项 \option{scheme} 扩展了 \CTeX 文档类中同名选项原有的作用范围,选项值 \code{plain} 可使各类标题变为英文形式。包括章节标题、图表标题和定理名等。
\opt{enmode}\dtag
同时开启 \option{newline} 和 \keyis{scheme}{plain} 选项以符合英文原生风格。
\keychoice{paper}{\fbox{a4paper},b5paper,c5paper,letterpaper,\optpath*{other paper}}
文档页面尺寸选项将参数交给 \pkg*{geometry} 宏包处理,可使用它支持的所有标准纸张规格。
\keyval{configs}{配置文件列表}\dtag
载入用户配置的文件名列表,文件列表以花括号包裹并以英文逗号分隔。文件名应包含如 \code{tex}、\code{def} 或 \code{cfg} 等扩展名。若配置文件不在当前文件夹则文件名需要包含路径,即 \code{path/file.cfg}。
\keychoice{floatpage}{true,\fbox{false}}
开启这个选项后浮动环境 \env{table} 和 \env{figure} 的比例参数会使用默认值。关闭它则尽可能避免出现浮动页,使图表环境与正文段落更加紧凑,减少多余的空白版面。
\keychoice{theorem}{\fbox{thmtools},keytheorems,false}\newtagv[Changed]{2024ea}%
是否提供定理功能支持,定理模块的介绍可见\ref{subsec:theorem}。选项 \code{thmtools} 会载入 \pkg*{amsthm} 和 \pkg*{thmtools} 宏包,选项 \code{keytheorems} 会载入 \pkg*{keytheorems} 宏包,选项 \code{false} 不载入定理功能宏包。
\keychoice{chem}{\fbox{chemformula},mhchem,false}\newtagv{2024ef}%
是否提供化学式功能支持。选项 \code{chemformula} 会载入 \pkg*{chemformula} 宏包,选项 \code{mhchem} 会载入 \pkg*{mhchem} 宏包,选项 \code{false} 不载入化学式功能宏包。\pkg*{chemformula} 的工作原理与 \pkg*{mhchem} 非常相似,但对化合物、化学计量数和箭头的输入方式控制更为严格。
\command{ch}[\oarg{键值列表}\marg{化学式}]
\pkg*{chemformula} 的无机化学式书写命令。化合物表达式中的原子数不需要加下标符号,化学计量数与表达式间隔一个空格。
\begin{ctexexam}
\ch{[Cu(NH3)4]^2+}
\ch{Cu2S + 2 O2 - 2 e^- == 2 Cu^2+ + SO4^2-}
\end{ctexexam}
\end{cnltxlist}
\subsection{配置字体}
\begin{cnltxlist}
\keychoice{cjkfont}{adobe,fandol,founder,mac,macnew,macold,ubuntu,windows,none}\dtag
中文字体采用 \CTeX 宏集包含的字库并与其一致,具体配置方案可以查看 \CTeX 使用手册。它与 \option*{fontset} 选项是等效的,如果没有指定 \option{cjkfont} 的值,将会自动检测操作系统并选择相应的字体。
如果需要使用其它中文字体,可以在启用选项 \keyis{cjkfont}{none} 后,再使用 \pkg*{xeCJK} 宏包的相关命令设置字体以及声明字体族:
\begin{ctexexam}
\setCJKmainfont{SimSun}[BoldFont = SimHei,ItalicFont = KaiTi]
\setCJKsansfont{SimHei}
\setCJKmonofont{FangSong}
\newCJKfontfamily[song]\songti{SimSun}
\end{ctexexam}
如果用 \textsf{Overleaf} 或 \textsf{TeXPage} 等在线平台编译文档,则只有 \code{fandol} 字体可用。使用其它字体可将字体文件上传至项目文件夹,例如上传至 \code{font} 文件夹设置正文和无衬线字体:
\begin{ctexexam}
\setCJKmainfont{simsun.ttc}[Path = ./font/]
\setCJKsansfont{simhei.ttf}[Path = ./font/]
\end{ctexexam}
\keychoice{font}{noto,times,times*,ebgaramond,libertine,palatino,\fbox{auto}}\dtag
预置的英文字体相关配置方案如\ref{table:english font} 所示。这些字体已经包含在了 \hologo{TeXLive} 发行版中,所以通常不需要再专门安装。如果您想使用默认的Latin Modern或其它英文字体,可以使用 \code{auto} 选项配合 \pkg*{fontspec} 宏包的相关命令进行设置。
\begin{longtblr}
[
caption = 英文字体预设方案,
label = table:english font,
remark{$\blacktriangleright$} = \code{times*} 方案为 \textsf{windows} 系统的预置字体。,
postsep = \bigskipamount-\itemsep
]{
hline{2} = {0.5pt,DarkBlue},
row{1} = {font = \sffamily},
column{1} = {cmd = \code}
}
& 正文字体 & 无衬线字体 & 等宽字体 \\
noto & Noto Serif & Noto Sans & Noto Sans Mono \\
times & XITS & TG Heros & TG Cursor \\
times* & Times New Roman & Arial & Courier New \\
ebgaramond & EB Garamond & Libertinus Sans & LM Mono \\
palatino & TG Pagella & Libertinus Sans & LM Mono \\
libertine & Libertinus Serif & Libertinus Sans & LM Mono
\end{longtblr}
\keychoice{mathfont}{\fbox{times},noto,notosans,nc,ncf,stix2,charter,ebgaramond,libertine}\dtag
\leftfillchoice{mathfont}{minion,garamondx,baskervaldx,baskerville,none} \\
选择合适的数学字体,将会加载 \pkg*{newtxmath} 和 \pkg*{bm} 宏包。使用选项 \code{none} 时可以使用 \pkg*{unicode-math} 等其它数学字体宏包定义字体。
\end{cnltxlist}
\subsection{\textsf{article} 模式}
\begin{cnltxlist}
\keychoice{class}{\fbox{book},article}
使用 \easybook{} 文档类可以有两种模式,默认为 \cls*{book} 模式。选用 \code{article} 可用于短篇幅的文章,文档会变为 \option{oneside} 单面排版,同时标题编号和封面等与标准 \cls*{article} 文档类相似,若使用 \cs{chapter} 命令会报错。如果使用 \cls*{ctexart} 配合 \pkg*{easybase} 宏包,则选项值 \code{book} 会失效。
\opt{book}
开启 \cls*{book} 书籍模式,与 \keyis*{class}{book} 等效。
\opt{article}
开启 \cls*{article} 文章模式,与 \keyis*{class}{article} 等效。
\end{cnltxlist}
\section{模块选项}
\label{sec:interface options}
\begin{cnltxlist}
\command{ctexset}[\oarg{模块名}\marg{键值列表}]
\easybook{} 扩展了 \CTeX 宏集 \hologo{LaTeX3} 风格键值的通用控制命令 \cs{ctexset},模块选项同样可用它设置,原有的 \meta{键值列表} 仍然可用。本文档类目前有10个模块用于实现常规的排版功能,如\ref{table:module List} 所示。
\begin{longtblr}
[caption = 模块功能和名称清单,label = table:module List]
{
hline{3} = {0.5pt,DarkBlue},
row{1,3} = {font = \sffamily},
row{2,4} = {cmd = \module*}
}
\hyperref[subsec:tools]{工具} & \hyperref[subsec:font]{部件字体} & \hyperref[subsec:space]{间距} & \hyperref[subsec:hyperlinks]{超链接} & \hyperref[subsec:reference]{参考文献} \\
tools & font & space & ref & bib \\
\hyperref[subsec:theorem]{定理} & \hyperref[subsec:page margins]{页面尺寸} & \hyperref[subsec:header and footer]{页眉页脚} & \hyperref[subsec:contents]{目录} & \hyperref[subsec:caption]{图表题注} \\
thmt & geo & hdr & toc & cap
\end{longtblr}
\ref{exam:kv setting} 使用\ref{subsec:tools} 介绍的工具模块 \module*{tools} 举例三种键值列表设置方式:1. 各 \meta{模块名} 是统一接口 \cs{ctexset} 的键路径。2. 不同模块还具有单独的接口命令 \cs*{eb}\meta{模块名}\cstext{set}。3. \meta{模块名} 也可以使用 \cs{ctexset} 命令的可选参数设置。路径名与所属下级选项之间可以 \code{/} 或 \code{=} 号分开,斜线 \code{/} 后不能有空格或者换行。
\begin{ctexexam}[labelref = exam:kv setting]
\ctexset
{
tools/color = seaside,
tools =
{
fntnumwith = page,
uppercase = first
}
}
\ctexset[tools]{spcmd = \color{red}}
\ebtoolsset{hyphen-figure = {-}}
\end{ctexexam}
\easybook{} 文档类有四种选项:1. 布尔型 \choicekey*{key}{true,false} 选项的值为真 \code{true} 或假 \code{false},如果不指定默认为真。2. 键值型 \key*{key}{value} 需要为选项指定值,后面 \code{=} 号不能省略。3. 键型 \option*{key} 不需要为选项指定值。4. 选择型 \choicekey*{key}{one,\fbox{two},three} 根据提供的可选值进行设定。
\end{cnltxlist}
\subsection[工具]{工具\smodule{tools}}
\label{subsec:tools}
工具模块 \module*{tools} 主要用于综合设置各类杂项的排版元素。
\begin{cnltxlist}
\keychoice{color}{\fbox{none},seaside,energy,cyberpunk}
\easybook{} 预置了四种颜色主题,默认主题 \code{none} 为黑白页面,颜色主题不包括超链接。
\command{DeclareThemeColor}[\marg{风格名称}\splitmarg{颜色1,颜色2,颜色3}]\newtagv[Changed]{2024eu}%
声明新的颜色主题命令。颜色参数的三个部分为 \code{HTML} 颜色代码,构成主题颜色列表,其中 \meta{颜色1} 为标题标签,\meta{颜色2} 为列表编号、定理标签和公式编号括号,\meta{颜色3} 为代码抄录。类似地更改超链接颜色见\ref{subsec:hyperlinks}。
\begin{ctexexam}
\DeclareThemeColor{fancy}{2acb25,60aacc,ebc01c}
\ctexset{tools/color = fancy}
\end{ctexexam}
\keyval{color-every}{HTML颜色代码}
统一设置主题的各部分颜色。参数是6个十六进制数字组成的 \code{HTML} 颜色代码,任意颜色的代码可以在常见的图片处理工具拾色器中查看。
\keyval{multoc}{整数}\Default{2}
设置目录的排版栏数,与\ref{subsec:directory command} 中目录命令的同名选项有相同效果。
\keychoice{withpart}{true,\fbox{false}}
使章标题跟随部分计数器编号,仅在导言区有效。当开启新的部分标题时章编号从1开始。
\keychoice{fntnumwith}{part,\fbox{chapter},page}
设置脚注重置编号的方式,仅在导言区有效。默认跟随章计数器,即开启新的章标题时脚注编号从1开始。选项 \code{page} 代表的是换页而不是页计数器,这是由于在一些排版情况下换页后页计数器仍为上页的值。
\keychoice{uppercase}{\fbox{all},first,none,none*}
使用 \cs{rightmark} 和 \cs{leftmark} 等标题标记命令获取标题内容用于页眉页脚时其中英文的大小写类型。\code{all} 为标题标记中的英文字母全部大写。\code{first} 为标记以英文起始时仅第一个字母大写。\code{none} 不改变标记中英文字母的大小写形式,变体 \code{none*} 则强制标记的字母均为小写形式。
\kvsplit{tagform}{左括号,右括号}\Default{\Marg{(,)}}
设置行间公式标签的括号及格式,以英文逗号分隔,分别代表左右括号。\meta{左括号} 的末尾可以是带有一个参数的命令,用于接受公式编号。将标签括号设置为方括号,并给编号使用无衬线字体:
\begin{ctexexam}
\newcommand{\bracketsf}[1]{[\textsf{#1}}
\ebtoolsset{tagform = {\bracketsf,]}}
\end{ctexexam}
\kvsplit-{figurepath}{\marg{路径名1}\marg{路径名2}$\cdots$\marg{路径名n}}\newtagv[Changed]{2024cd}%
设置插入图片的文件夹路径名。每个路径需包含在花括号内,只有一个路径时括号可以省略。
\begin{ctexexam}
\ctexset{tools/figurepath = path1}
\ctexset{tools/figurepath = {path2}{path3}}
\end{ctexexam}
以下几个选项用于设置题注编号的连字符,\code{chapter} 计数器的值大于0时连字符才有意义。若需更改题注编号的输出格式可在正文中重新定义 \cs*{the}\meta{计数器} 命令。
\keyval{hyphen-figure}{图片连字符}\Default{\Marg{.}}
设置图片题注编号的连字符。
\keyval{hyphen-table}{表格连字符}\Default{\Marg{.}}
设置表格题注编号的连字符。
\keyval{hyphen-lstlisting}{代码连字符}\Default{\Marg{.}}
设置代码题注编号的连字符。\pkg*{listings} 宏包的 \option{numberbychapter} 选项失效。
\keyval{hyphen-equation}{公式连字符}\Default{\Marg{.}}
设置公式题注编号的连字符。
\keyval{hyphen-every}{连字符}\Default{\Marg{.}}
统一设置上述所有编号的连字符。
\end{cnltxlist}
\subsection[超链接]{超链接\smodule{ref}}
\label{subsec:hyperlinks}
模块 \module*{ref} 将超链接选项交给 \pkg*{hyperref} 宏包处理。除了一些超链接颜色的选项失效,其它由宏包全局和接口命令 \cs*{hypersetup} 支持的多数选项可用。
\begin{cnltxlist}
\keychoice{linktype}{\fbox{edge},colors,none}
超链接类型。\code{edge} 使超链接形式为边框,\code{colors} 使超链接字体为彩色,\code{none} 关闭超链接边框与颜色,此时 \option{linkcolor} 选项无效。
\keychoice{linkcolor}{fresh,cutepink,\fbox{navyblue},crimson}
当超链接类型为 \code{colors} 时文本的颜色样式。预置了四种超链接颜色风格,默认为海军蓝 \code{navyblue}。
\command{DeclareLinkColor}[\marg{风格名称}\splitmarg{颜色1,颜色2,颜色3}]\newtagv[Changed]{2024eu}%
声明新的超链接颜色样式命令。颜色参数的三个部分为 \code{HTML} 颜色代码,构成超链接颜色列表,其中 \meta{颜色1} 为普通链接,\meta{颜色2} 为网址,\meta{颜色3} 为参考文献引用。
\keyval{linkcolor-every}{HTML颜色代码}
统一设置超链接的各部分颜色。参数是6个十六进制数字组成的 \code{HTML} 颜色代码,任意颜色的代码可以在常见的图片处理工具拾色器中查看。
\keychoice{linktoc}{none,section,page,\fbox{all}}
将目录中的超链接取消、置于标题上、置于页码上或置于标题和页码上。
\end{cnltxlist}
\subsection[间距]{间距\smodule{space}}
\label{subsec:space}
间距模块 \module*{space} 用于调整段落中的间距。带有 \option*{spread} 的选项可以设置行距倍数,\meta{数值} 是不带有长度单位的浮点数。各类行距既可以在导言区全局设置,也可以在正文中设置对后面生效。
\begin{cnltxlist}
\keyval{linespread}{数值}\Default{1.354}
正文行距因子。中文主题下行距因子初始值为 \code{1.354}(相当于 \textsf{Word} 的1.25倍行距),如果设置了文类或 \pkg*{ctex} 宏包的全局行距选项 \option{linespread} 则初始值设为它的值。
\keyval{capfig-spread}{数值}\Default{1.2}
图片题注的行距因子。
\keyval{captab-spread}{数值}\Default{1.2}
表格题注的行距因子。
\keyval{caplst-spread}{数值}\Default{1.2}
代码题注的行距因子。
\keyval{caption-spread}{数值}\Default{1.2}
同时设置图片、表格和代码题注的行距因子。
\keyval{fntspread}{数值}\Default{1.2}
脚注内容整体的行距因子。可以使用 \module*{hdr} 模块 \option{fnpara-format} 选项的代码单独覆盖每个脚注的行距,从而使脚注间和内容文本自身的行距不同。
\begin{ctexexam}
\ebspaceset{fntspread = 1.3}
\ebhdrset{fnpara-format = \usestretch{1.2}}
\end{ctexexam}
\keyval{everyspread}{数值}
统一设置上述所有的行距因子。
\keyval{abovedisplayskip}{弹性长度}\Default{0.5ex plus .1ex minus .1ex}
行间公式与上面正文间的额外距离。
\keyval{belowdisplayskip}{弹性长度}\Default{0.5ex plus .1ex minus .1ex}
行间公式与下面正文间的额外距离。
\begin{cnltxlist}
\command{usestretch}[\marg{数值}]\newtagv{2024dt}%
设置之后文本的行距。可在任意地方使用,作用范围为局部。
\environment{usespace}[\marg{数值}]\newtagv{2024dt}%
设置环境内文本的行距。可包含行间公式和表格等环境。
\begin{ctexexam}
\begin{usespace}{1.5}\nointerlineskip
\ebspaceset{belowdisplayskip = 6pt}
\begin{align}
\cos 2x &= \cos^2 x - \sin^2 x \\
&= 2\cos^2 x - 1
\end{align}
\end{usespace}
\end{ctexexam}
\end{cnltxlist}
\end{cnltxlist}
\subsection[部件字体]{部件字体\smodule{font}}
\label{subsec:font}
部件字体模块 \module*{font} 用于设置除了正文外其它排版元素的字体。
\begin{cnltxlist}
\keyval{caption-table}{字体命令}\Default{\cs*{sffamily}\cs*{small}}
设置表格题注的字体,包括字体族、字体系列、字体尺寸和字体形状命令。
\keyval{caption-figure}{字体命令}\Default{\cs*{sffamily}\cs*{small}}
设置图片题注的字体,包括字体族、字体系列、字体尺寸和字体形状命令。
\keyval{caption-lstlisting}{字体命令}\Default{\cs*{sffamily}\cs*{small}}
设置代码题注的字体,包括字体族、字体系列、字体尺寸和字体形状命令。
\keyval{caption-every}{字体命令}\Default{\cs*{sffamily}\cs*{small}}
同时设置图片、表格和代码题注的字体命令。
\keyval{footnote}{字体命令}
设置脚注标记与内容的字体,包括字体族、字体系列和字体形状命令。
\keyval{marginpar}{字体命令}\Default{\cs*{footnotesize}}
设置边注的字体,包括字体族、字体系列、字体尺寸和字体形状命令。
\command{ebaddtofont}[\marg{字体类型}\marg{字体命令}]
用于在上述各种字体原有的格式上附加代码。其中 \meta{字体命令} 也可以包括行距命令且相对于 \module*{space} 模块具有优先性,不同题注的 \meta{字体类型} 则为相应选项的后缀名。
\begin{ctexexam}
\ebaddtofont{every}{\usestretch{1.5}}
\ebaddtofont{footnote}{\sffamily}
\end{ctexexam}
\end{cnltxlist}
\subsection[参考文献]{参考文献\smodule{bib}}
\label{subsec:reference}
\begin{cnltxlist}
\keychoice{backend}{bibtex,\fbox{biblatex}}
参考文献处理后端。选择 \code{bibtex} 时使用传统的 \hologo{BibTeX} 引擎处理参考文献,加载 \pkg*{natbib} 宏包。选择 \code{biblatex} 时使用 \hologo{biber} 引擎,加载 \pkg*{biblatex} 宏包。若自动载入参考文献宏包则位于导言区末尾,但在 \pkg*{hyperref} 宏包之前。
\keychoice{bibstyle}{\fbox{numerical},authoryear,\optpath*{other sty}}
参考文献格式使用中国参考文献推荐标准GB/T 7714-2015,对应顺序编码制和著者—出版年制两种风格。若使用其它格式,使用 \hologo{BibTeX} 处理时需确保正确的 \code{bst} 文件,使用 \hologo{biber} 处理可使用 \pkg*{biblatex} 宏包支持的参考文献风格名称。
\keyval{citestyle}{标注风格}
标注参考文献的风格。后端为 \code{bibtex} 时可使用 \option{super}(数字上标标注,默认)或 \option{numbers}(数字标注)等 \pkg*{natbib} 宏包带有的标注风格,后端为 \code{biblatex} 时可使用 \pkg*{biblatex} 宏包支持的标注风格。
\keyval{datafile}{数据库列表}
参考文献数据库的文件名列表,文件列表以花括号包裹并以英文逗号分隔。使用 \hologo{biber} 处理时文件名要带 \code{bib} 扩展名,若参考文献文件不在当前文件夹则文件名需要包含路径,即 \code{path/file.bib}。不设置参考文献数据库名时 \module*{bib} 模块中的选项会失效,即不自动载入 \pkg*{natbib} 或 \pkg*{biblatex} 宏包,此时需要手动载入相关宏包配置参考文献。
\command{printbibliography}[\oarg{键值列表}]
两种方式\textbf{均使用}此命令打印参考文献,不同处理后端此命令的 \meta{键值列表} 不同。使用 \hologo{BibTeX} 处理时选项与\ref{subsec:directory command} 目录命令的选项相同,使用 \hologo{biber} 处理时常用的选项如下:
\keychoice*{heading}{bibliography,subbibliography,\fbox{bibintoc},subbibintoc}
参考文献通常有一个章标题或者节标题,该选项选择由 \cs{defbibheading} 定义的标题名。
\keyval{title}{参考文献标题名}
如果标题定义支持的话,该选项覆盖由 \option*{heading} 选项提供的缺省标题名。
\keyval{prenote}{参考文献前注}
该选项选择由 \cs{defbibnote} 所定义的前注,缺省状态下不打印任何前注。
\keyval{section}{整数}\Default{0}
只打印第 \meta{整数} 文节中引用的条目。该参考文献节从1开始编号,所有在 \env*{refsection} 环境外给出的引用标记为第零节。
\keyval{type}{条目类型}
只打印名为 \meta{条目类型} 的文献条目。
\keyval{filter}{过滤器名}
使用由 \cs{defbibfilter} 定义的 \option*{filter} 来过滤条目。
可能在一些情况下您希望更加灵活地设置参考文献或有更多需求,下面举一个在导言区手动配置 \pkg*{biblatex} 宏包并使一个条目输出双语对照格式文献的例子:
\begin{ctexexam}
\usepackage[style = gb7714-2015]{biblatex}
\addbibresource{reference.bib}
\defbibheading{bibliography}[参考文献] % 定义参考文献标题
{\chapter*{#1}\markboth{#1}{#1}}
\defbibentryset{Zhang2022}{张三2022,ZhangSan2022}
\cite{Zhang2022} % 在正文中引用
\end{ctexexam}
\end{cnltxlist}
\subsection[定理]{定理\smodule{thmt}}
\label{subsec:theorem}
定理模块 \module*{thmt} 根据全局选项 \option{theorem} 的设置可以由 \pkg*{thmtools} 或 \pkg*{keytheorems} 宏包提供支持。\pkg*{keytheorems} 宏包使用 \hologo{LaTeX3} 编写,它的定理功能更完善并且提供了 \pkg*{thmtools} 宏包大部分的功能,但发布日期较新(2024年9月)还未被广泛使用,下面主要介绍传统的 \pkg*{thmtools} 宏包的功能。\pkg*{thmtools} 提供了定理环境和样式声明两个命令,文档类未预声明任何定理环境,如果声明定理环境时不指定样式,则使用默认定理样式 \code{default},可以对它重新定义。
\begin{cnltxlist}
\command{declaretheorem}[\oarg{键值列表1}\marg{环境名列表}\oarg{键值列表2}]
\pkg*{thmtools} 的定理环境声明命令。\pkg*{thmtools} 宏包中此命令实际相当于 \cs{newtheorem},无法强制创建定理环境,这里修复了这个问题。可选参数的 \meta{键值列表1} 与 \meta{键值列表2} 等效,常用的选项如下:
\keyval{name}{定理名}
定理环境的标题名称,默认为英文首字母大写的环境名。
\keychoice{numbered}{no,\fbox{yes},unless unique}
定理可以被编号、不被编号或者只有在文档中多次出现时才被编号。
\keychoice{within}{\fbox{chapter},section,\optpath*{empty},\optpath*{counter}}
定理编号跟随的计数器。当计数器值递增时定理编号会从零开始,通常这是一个章节计数器。
\keyval{numberlike}{计数器}
定理将使用此 \meta{计数器} 进行编号,通常这是另一个定理环境的名称。
\keyval{qed}{证毕符号}
证毕符号。位于定理段落末尾行的版心右边,可以设置成 \cs{qedsymbol} 默认是空心方块。
\keyval{style}{定理样式}\Default{default}
选项的值为使用 \cs{declaretheoremstyle} 命令新定义的定理样式。
使用 \cs{declaretheorem} 命令以\ref{exam:new theorem sty} 中的定理样式 \code{fancy} 新建一个定理环境 \env*{lemma},然后用一个基于 \pkg*{tcolorbox} 宏包的预置彩色盒子 \env{easyboxi} 增加背景:
\begin{ctexexam}[labelref = exam:new theorem env]
\declaretheorem[style = fancy,name = 引理]{lemma}
\addtotcbstyle{tc-easyboxi}{colback = GreenYellow}
\tcolorboxenvironment{lemma}{tc-easyboxi}
\end{ctexexam}
\command{declaretheoremstyle}[\oarg{键值列表1}\marg{定理样式}\oarg{键值列表2}]
\pkg*{thmtools} 的定理样式声明命令,键值列表支持自身以及定理声明命令 \cs{declaretheorem} 的所有选项。为命令增加了可选参数 \meta{键值列表2},与 \meta{键值列表1} 等效,常用的选项如下:
\keyval{headfont}{字体命令}\Default{\cs*{sffamily}}
定理标题部分(包括题注)的字体,包括字体族、字体系列、字体尺寸和字体形状命令。
\keyval{notefont}{字体命令}\Default{\cs*{sffamily}}
定理题注部分的字体,包括字体族、字体系列、字体尺寸和字体形状命令。
\keyval{bodyfont}{字体命令}\Default{\cs*{normalfont}}
定理内容部分的字体,包括字体族、字体系列、字体尺寸和字体形状命令。
\keyval{headpunct}{代码}
紧随定理标题末尾的标记代码,位于定理第一段内容的间距 \option{postheadspace} 之前,可以是字符或插入换行符 \cs*{newline} 等命令。
\keyval{headindent}{刚性长度}\Default{0pt}
定理标题的缩进。默认无缩进,可用 \cs*{parindent} 命令设置为段落缩进。
\keyval{postheadspace}{刚性长度}\Default{1em}
定理标题后与定理第一段内容的间距。
\keyval{spaceabove}{弹性长度}\Default{0ex plus .1ex}
定理环境前的间距,使用 \pkg*{tcolorbox} 的盒子环境包装后被覆盖。
\keyval{spacebelow}{弹性长度}\Default{0ex plus .1ex}
定理环境后的间距,使用 \pkg*{tcolorbox} 的盒子环境包装后被覆盖。
\kvsplit-{notebraces}{\marg{左括号}\marg{右括号}}\Default{\Marg{(}\Marg{)}}
设置定理题注两边的括号,两个必选参数分别代表左括号和右括号。
\keyval{headformat}{标题排列}
定理标题各组成元素的位置排列和格式。定理标题由定理名、编号和题注组成,\meta{标题排列} 中命令 \cs*{NAME}、\cs*{NUMBER} 和 \cs*{NOTE} 分别代表定理名、编号和题注。也可以设置值为 \code{margin} 或 \code{swapnumber},它们的编号均在定理名前方,其中 \code{margin} 的编号在左页边距中。
下面定义一个名为 \code{fancy} 的定理样式用于 \cs{declaretheorem} 的 \option*{style} 选项:
\begin{ctexexam}[labelref = exam:new theorem sty]
\declaretheoremstyle{fancy}[
within = chapter,
spaceabove = 6pt,
spacebelow = 6pt,
headfont = \normalfont\bfseries,
notefont = \sffamily,
notebraces = {[}{]},
bodyfont = \itshape
]
\end{ctexexam}
\begin{cnltxlist}[itemsep = 0ex]
\command{listoftheorems}[\sarg\oarg{键值列表}]\nonl
\keyval{listtheoremname}{定理目录标题名}\nonl
\command{settheoremtocline}[\sarg\marg{环境名列表}\marg{标题定义}]\newtagv{2024bb}%
对 \pkg*{thmtools} 宏包的定理环境目录命令 \cs{listoftheorems} 进行了适配调整\footnote{也对 \pkg*{keytheorems} 宏包作为兼容提供的这个命令进行了适配。},\ref{subsec:directory command} 和\ref{subsec:contents} 中的选项机制均可用,但标题定义选项 \option{tocline} 较为特殊,需用 \cs{settheoremtocline} 命令单独设置。在 \meta{标题定义} 中有三个命令 \cs{thmtname}、\cs{thmtenvname} 和 \cs{thmtnote} 分别代表定理名、定理环境名和题注用于排版目录条目。
\end{cnltxlist}
\optpath{thmt/}\key{loeskip}{弹性长度}\Default{10pt}
定理目录中每章第一个条目上方增加的垂直距离。与 \CTeX 的表格和图片目录中每章间的条目距离选项 \option*{lotskip} 和 \option*{lofskip} 类似,在 \cls*{article} 模式中此选项失效。
\command{thmtifnote}[\marg{存在题注代码}\marg{不存在题注代码}]
如果标题没题注即定理环境不用可选参数,则标题不加入定理目录,这是默认且合理的行为。若需要将无题注的标题加入目录可将 \meta{环境名} 传给目录风格的 \option{show} 选项或使用 \cs*{settheoremtocline}\code{*} 命令。是否存在题注需要在 \meta{标题定义} 中使用 \cs{thmtifnote} 命令判定,从而输出不同的内容。
\command{thmtifname}[\marg{存在编号代码}\marg{不存在编号代码}]
在 \meta{标题定义} 中测试当前定理是否有编号从而输出不同的内容,定理风格选项 \keyis{numbered}{no} 设置当前定理环境没有编号。
\begin{ctexexam}
\contentsuse{lemma}{loe}
\RegisterTocName{lemma}
\setlisttheoremstyle{ignoreall,show = lemma}
\settheoremtocline{lemma}
{
\listnumberline{\thmtenvname}
\thmtname\thmtifnote{[\thmtnote]}{}
}
\end{ctexexam}
如果使用 \pkg*{keytheorems} 宏包创建定理环境,它的目录样式同样可以用 \module*{toc} 模块的命令注册后定制,其中 \option{tocline} 可用目录命令自带的 \option{format-code} 选项设置:
\begin{ctexexam}
\newkeytheorem{corollary}[name = 推论]
\contentsuse{corollary}{thlist}
\RegisterTocName{corollary}
\begin{document}
\keytheoremlistset{format-code = \numberline{#2}#1#3}
\listofkeytheorems % 在正文中输出定理目录
\end{ctexexam}
\end{cnltxlist}
\subsection[页面尺寸]{页面尺寸\smodule{geo}}
\label{subsec:page margins}
页面尺寸模块 \module*{geo} 用于设置纸张大小和各种页面边距,它将选项交给页面尺寸宏包 \pkg*{geometry} 处理,支持通用接口 \cs{geometry} 的键值列表,预置的页面尺寸与 \textsf{Word} 的默认值接近。下面列举几种 \pkg*{geometry} 不同键值输入方式的选项,前面有\hface 符号的选项为额外附加,其它选项可查阅宏包帮助文档。当用此模块设置纸张规格时,会覆盖全局选项 \option{paper} 的设置。模块 \module*{geo} 的通用接口命令只能在导言区中使用。
\begin{cnltxlist}[itemsep = 0ex]
\keyval{headruleskip}{页眉线间距}\dtag\Default*{0pt}
\keyval{footruleskip}{页脚线间距}\dtag\Default*{3.5pt}
\kvsplit{hdivide}{左边距,版心宽度,右边距}\nonl
\kvsplit{hmargin}{左边距,右边距}\nonl
\keyval{textheight}{版心高度}\nonl
\keychoice{nofoot}{true,\fbox{false}}\nonl
\begin{ctexexam}
\ctexset[geo]
{
headruleskip = 3pt,
vscale = 0.9,
hdivide = {2cm,15cm,*},
vcentering
}
\end{ctexexam}
\pkg*{geometry} 宏包支持在文档中部改变页面尺寸,提供了新建和保存页面布局的命令。需要注意的是,\pkg*{fancyhdr} 宏包配置页面标记是以文档开始的页面尺寸为参考,若中途更改页面布局后需用标记偏移命令 \cs{fancyhfoffset} 重置参考的尺寸,以确保标记位置正确。
\begin{cnltxlist}
\command{newgeometry}[\marg{键值列表}]
在正文中更改页面布局,\meta{键值列表} 为 \pkg*{geometry} 宏包通用接口的各种页面尺寸选项。
\command{restoregeometry}
恢复正文开始时的页面布局。
\command{savegeometry}[\marg{布局名}]
保存当前页面布局名为 \meta{布局名}。
\command{loadgeometry}[\marg{布局名}]
载入保存的名为 \meta{布局名} 的页面布局。
\begin{ctexexam}
L1
\newgeometry{left = 3cm,right = 1cm,bottom = 0.1cm}
\savegeometry{L2}
L2 (new, saved)
\restoregeometry
L1 (restored)
\newgeometry{margin = 1cm,includefoot}
L3 (new)
\loadgeometry{L2}
\fancyhfoffset{0pt}
L2 (loaded)
\end{ctexexam}
\end{cnltxlist}
\end{cnltxlist}
\subsection[图表题注]{图表题注\smodule{cap}}
\label{subsec:caption}
模块 \module*{cap} 用于设置图表等浮动体的题注格式。题注主要由三部分组成:标题标签即图表名与题注编号的组合,标题文本本身通常是内容的简短描述,以及将文本与标签分开的题注分隔符。可以在导言区设置整体格式,也可以在正文使用局部更改格式。模块 \module*{cap} 由 \pkg*{caption} 宏包提供支持,接口选项与 \pkg*{caption} 宏包完全一致,但写法为 \meta{条目名}\code{/}\meta{选项}。\pkg*{caption} 宏包提供了多种方法来定制浮动环境(例如 \env{figure} 和 \env{table})中的题注,并可与许多其它宏包配合使用。功能包括旋转题注、侧向题注和连续题注等。下面列举几个题注选项的用法,\ref{exam:caption set} 中两种设置题注的方法是等效的,更多选项和创建方法可查看宏包文档:
\begin{cnltxlist}[itemsep = 0ex]
\keyval{table/labelsep}{标签分隔符}\nonl
\keyval{figure/format}{题注格式}\nonl
\keyval{lstlisting/font}{题注字体}\nonl
\begin{ctexexam}[labelref = exam:caption set]
\ctexset[cap]
{
table/labelsep = space,
figure/format = plain
}
\captionsetup[table]{labelsep = space}
\captionsetup[figure]{format = plain}
\end{ctexexam}
\begin{cnltxlist}
\command{RegisterCapOptions}[\marg{条目名列表}]
给模块 \module*{cap} 注册题注类型为 \meta{条目名} 的 \pkg*{caption} 接口选项。已预注册 \module*{figure}、\module*{table} 和 \module*{lstlisting} 三种类型的题注选项。可以搭配 \pkg*{newfloat} 宏包创建更多类型的浮动环境并设置相应题注。
\end{cnltxlist}
\command{caption}[\sarg\oarg{目录标题}\marg{标题}]\nonl
\command{captionof}[\sarg\marg{条目名}\oarg{目录标题}\marg{标题}]\nonl
\command{bicaption}[\sarg\oarg{目录中文标题}\marg{中文标题}\oarg{目录英文标题}\marg{英文标题}]
题注命令 \cs{caption} 用于在图表上下方插入题注,需要在浮动环境 \env*{figure} 和 \env*{table} 中使用。在浮动环境外可以使用 \cs{captionof} 命令,第一个参数指定条目名。\cs{bicaption} 命令可以实现中英文双语题注,需要在导言区载入 \pkg*{bicaption} 宏包,具体用法见宏包文档。
\end{cnltxlist}
\subsection[页眉页脚]{页眉页脚\smodule{hdr}}
\label{subsec:header and footer}
模块 \module*{hdr} 设置的命令由 \pkg*{fancyhdr} 宏包提供支持。标题标记由标签和标题组成,选项中参数 \code{\#1} 代表当前章、节或小节的标题。在 \cls*{book} 模式时使用标题标记选项 \option{chapter-mark} 和 \option{section-mark},在 \cls*{article} 模式时使用 \option{section-mark} 和 \option{subsection-mark} 选项,这与标准文档类的行为一致。重新设置标题标记选项时标记大小写选项 \option{uppercase} 会失效。
\begin{cnltxlist}
\keyval{chapter-mark}{标题标记}
\code{chapter} 级别标题标记的内容,包含了标签选项 \option{chapter-label} 和章标题 \code{\#1}。
\keyval{section-mark}{标题标记}
\code{section} 级别标题标记的内容,包含了标签选项 \option{section-label} 和节标题 \code{\#1}。
\keyval{subsection-mark}{标题标记}
\code{subsection} 级别标题标记的内容,包含了标签选项 \option{subsection-label} 和小节标题 \code{\#1}。
\kvsplit-{chapter-label}{\oarg{编号输出命令}\marg{距离命令}}\Default{\cs*{hspace}\Marg{1em}}
\code{chapter} 级别标题标记的标签(标题有编号时)。比标题标记选项更常用,可选参数是对应章编号计数器值的输出命令,必选参数是标题标签与内容之间的距离命令:
\begin{ctexexam}
\ebhdrset
{
chapter-label = [\thechapter]{\hspace{1em}},
section-mark = \CTEXifname{\CTEXthesection——}{}#1
}
\end{ctexexam}
\kvsplit-{section-label}{\oarg{编号输出命令}\marg{距离命令}}\Default{\cs*{hspace}\Marg{0.5em}}
\code{section} 级别标题标记的标签,用法与 \option{chapter-label} 类似。
\kvsplit-{subsection-label}{\oarg{编号输出命令}\marg{距离命令}}\Default{\cs*{hspace}\Marg{0.5em}}
\code{subsection} 级别标题标记的标签,用法与 \option{chapter-label} 类似。
\keyval{headrule}{横线命令}
绘制页眉横线的选项,可以使用 \cs*{hrule} 或\ref{exam:markrule} 所述 \cs{markrule} 等画线命令来绘制横线。
\keyval{footrule}{横线命令}
绘制页脚横线的选项,可以使用 \cs*{hrule} 或\ref{exam:markrule} 所述 \cs{markrule} 等画线命令来绘制横线。
\keyval{footnoterule}{横线命令}
绘制脚注横线的选项,可以使用 \cs*{hrule} 或\ref{exam:markrule} 所述 \cs{markrule} 等画线命令来绘制横线。
\keyval{headrulewd}{刚性长度}\Default{0.5pt}
页眉横线默认的粗细,使用 \option{headrule} 选项绘制横线后失效。
\keyval{footnoterulewd}{刚性长度}\Default{0.5pt}
脚注横线默认的粗细,使用 \option{footnoterule} 选项绘制横线后失效。
\command{fancypagestyle}[\marg{风格名}\oarg{基础风格}\marg{风格定义}]
定义名为 \meta{风格名} 的页面风格。\meta{风格定义} 中可包含设置页眉页脚不同位置格式的命令,如果为空则等于 \code{fancy} 风格。如果存在 \meta{基础风格},则在它的基础上进行定义。
\begin{ctexexam}
\fancypagestyle{plain}
{
\fancyhf{}
\fancyfoot[C]{\textbf{--~\thepage~--}}
\ebhdrset{headrule = {}}
}
\end{ctexexam}
\command{pagestyle}[\marg{风格名}]\Default{fancy}
设置 \meta{风格名} 为当前及之后页的页面风格。
\begin{cnltxlist}[itemsep = 0ex]
\command{fancyhead}[\oarg{位置}\marg{内容}]\nonl
\command{fancyfoot}[\oarg{位置}\marg{内容}]
为了确保页面显示正确,使用 \cs{fancyhead} 和 \cs{fancyfoot} 等命令设置页眉页脚时需要在页边距的命令之后。默认设置的是一个名为 \code{fancy} 的页面风格。\pkg*{fancyhdr} 将页眉页脚分成了左中右和奇数页(odd)、偶数页(even)共12个部分,可选参数中 \code{E} 和 \code{O} 代表偶数和奇数,\code{L}、\code{C} 和 \code{R} 代表左、中和右部分。单面排版时,可选参数含有偶数位置的命令无效。
\end{cnltxlist}
\begin{cnltxlist}[itemsep = 0ex]
\command{markboth}[\marg{左页标题标记}\marg{右页标题标记}]\nonl
\command{markright}[\marg{右页标题标记}]\nonl
\command{markdouble}[\marg{双页标题标记}]
这三个命令用于手动设置当前页标题标记,特殊情况下可以使用它们定义与标题不同的页眉页脚标记。其中 \cs{markdouble} 根据是否是双面排版设置相应标记,如果是单面排版,则 \meta{右页标题标记} 为空。标题标记选项 \meta{级别}\option*{-mark} 定义的是它们的参数,左右页标记规则已经进行了优化调整,若需更改可以重定义 \code{\textbackslash}\meta{级别}\cstext{mark} 命令。
\begin{ctexexam}
\makeatletter
\renewcommand{\sectionmark}[1]{\markright{\eb@mark@section@whole{#1}}}
\makeatother
\end{ctexexam}
\end{cnltxlist}
\command{markrule}[\oarg{长度}\darg{颜色名}\marg{高度}\oarg{深度}]
实线命令 \cs{markrule} 既可在 \meta{横线命令} 中用于绘制页眉页脚横线,也可以在正文中使用。实线的 \meta{长度} 默认为版心的宽度,\meta{高度} 为线向上的粗细需要指定,\meta{深度} 为线向下的粗细默认为 \code{0pt}。它们均为刚性长度且可以为负值,支持数学表达式,通过控制 \meta{高度} 和 \meta{深度} 的正负值可以决定实线上下偏移量。下面举一个设置页眉内容的例子:
\begin{ctexexam}[labelref = exam:markrule]
\ebhdrset{headrule = \markrule(DarkOrchid){2pt + 1pt}[-2pt]}
\fancyhead[ER]{\FirstMark{2e-left}} % 来自ltmarks的标记机制
\fancyhead[OL]{\rightmark}
\fancyhead[EL,OR]{\textbf{\thepage}}
\end{ctexexam}
\end{cnltxlist}
\subsection[脚注]{脚注\smodule{hdr}}
模块 \module*{hdr} 还可以灵活调整脚注编号和内容的格式。格式主要包括脚注标记的编号类型、字体、附加符号和对齐方式等,以及脚注内容的首行缩进、行距和字体等。基本思想是提供常规(\code{fnnormal})和自定义(\code{fncustom})两种脚注标记,常规脚注标记又分为正文(\code{fnmark})和内容(\code{fntext})标记,默认情况下正文和内容标记编号类型分离但格式一致,自定义标记与常规标记格式分离。目前脚注模块基本兼容 \pkg*{footmisc} 宏包。
\begin{cnltxlist}
\keychoice{footnotetype}{plain,\fbox{hang},flush,bottom}
脚注的类型。悬挂缩进 \code{hang} 是默认值,\code{plain} 是原始的类型,\code{flush} 使脚注内容标记位于脚注首行边缘外侧并右对齐。当存在浮动环境排版时,脚注可能位于页面中间,\code{bottom} 使脚注始终位于页面底端。其中 \code{bottom} 是复合选项,可以与前三种类型重复或复合使用:
\begin{ctexexam}
\ebhdrset{footnotetype = plain,footnotetype = bottom}
\ebhdrset{footnotetype = {hang,bottom}}
\end{ctexexam}
\command{PushFntBottom}\newtagv{2024cx}%
默认情况下当具有 \code{b} 参数的底部浮动体与脚注同时存在时,脚注将位于浮动体上部。此命令可使脚注始终位于页面底部,与 \keyis{footnotetype}{bottom} 作用相同,只能在导言区全局使用。
\keyval{fnfirstindent}{刚性长度}\Default{1em}
每个脚注首段的首行缩进(悬挂缩进 \code{hang} 为整段缩进),等于长度 \cs{fnfirstindent} 的值。
\keyval{fnafterindent}{刚性长度}\Default{2em}
每个脚注第二段及之后段落的首行缩进,等于长度 \cs{fnafterindent} 的值。
\keyval{fnparskip}{弹性长度}\Default{0ex plus .1ex}
不同脚注自身的段落间距,脚注内容文本分段时生效,等于长度 \cs{fnparskip} 的值。
\keyval{footnotesep}{刚性长度}
不同脚注之间的距离,默认情况下它自适应 \module*{space} 模块脚注行距选项 \option{fntspread} 的值。
\keychoice{fntext-pos}{normal,\fbox{super}}
设置脚注内容标记的位置,正常文本或是上标形式。
\keychoice{fnmark-num}{\fbox{plain},pifont,pifont*,pisans,pisans*,\optpath*{short num}}
脚注正文标记编号的类型。默认为原生样式 \code{plain},还可以改为 \code{pifont} 的各个版本,从左往右依次为普通版、阴文衬线版、阳文无衬线版和阴文无衬线版,缺点是它们的编号仅包括1-10。
短编号的参数与列表环境类似,有 \code{1}、\code{A}、\code{a}、\code{I} 和 \code{i},除此之外还增加了中文数字 \code{c} 和符号 \code{s} 格式。原生样式 \code{plain} 等同于单独使用数字 \code{1} 参数。这个选项可以用在正文中改变其后脚注编号类型。
\command{footref}[\marg{脚注标签名}]
在当前位置对自动编号的脚注进行引用,与被引用的正文标记共享一个编号与格式。
\begin{ctexexam}
\ebhdrset{fnmark-num = 1} % 等于编号类型plain
\ebhdrset{fnmark-num = (a)}
\end{ctexexam}
\begin{cnltxlist}[itemsep = 0ex]
\command{SetFntSymbsList}[\marg{符号表名}\marg{符号数量}\marg{符号列表}]\nonl
\command{UseFntSymbsList}[\marg{符号表名}]
这两个命令用于设置自定义符号型脚注短编号 \code{s} 的符号列表。\cs{SetFntSymbsList} 命令用于定义名为 \meta{符号表名} 的符号列表,\cs{UseFntSymbsList} 命令用于启用已定义的符号列表。预置了一个脚注符号列表 \code{fnsymbol},与 \hologo{LaTeX} 的数字转换命令 \cs{fnsymbol} 一致,只支持9个编号。注意使用符号型标记的脚注时计数器 \code{footnote} 的值仍然递增,以及定义新列表时 \meta{符号列表} 的写法和命令顺序:
\begin{ctexexam}
\SetFntSymbsList{fancy}{2}{{1}{*}{2}{\P}}
\UseFntSymbsList{fancy}
\ebhdrset{fnnormal-num = s}
\end{ctexexam}
\end{cnltxlist}
\keychoice{fntext-num}{\fbox{plain},pifont,pifont*,pisans,pisans*,\optpath*{short num}}
脚注内容标记编号的类型。用法与 \option{fnmark-num} 一样,所以脚注内容与正文标记编号类型\textbf{可以不同}。
\keychoice{fnnormal-num}{\fbox{plain},pifont,pifont*,pisans,pisans*,\optpath*{short num}}
同时设定脚注正文标记编号 \option{fnmark-num} 与脚注内容标记编号 \option{fntext-num} 的类型。目前脚注编号类型选项对于迷你页环境 \env*{minipage} 无效,其中的脚注保持默认英文字母的编号类型。
\keychoice{fnmark-vmove}{\optpath*{fixed length},match}\Default{0pt}
脚注正文标记的垂直偏移。可以设为刚性长度,或用 \code{match} 匹配 \option{spvmove} 全局的值。
\keychoice{fnmark-hmove}{\optpath*{fixed length},match}\Default{0pt}
脚注正文标记的水平偏移。可以设为刚性长度,或用 \code{match} 匹配 \option{sphmove} 全局的值。
\keychoice{fntext-vmove}{\optpath*{fixed length},match}\Default{0pt}
脚注内容标记的垂直偏移。可以设为刚性长度,或用 \code{match} 匹配 \option{spvmove} 全局的值。
\keychoice{fnnormal-format}{\optpath*{format code},match}
常规脚注标记的格式,选项 \code{match} 可以匹配 \option{spcmd} 全局的值。一般配合 \keyis{fnnormal-num}{plain} 原生编号形式使用,例如用 \pkg*{circledtext} 宏包的带圈字符命令 \cs{circledtext} 给脚注标记添加圆圈:
\begin{ctexexam}
\usepackage{circledtext}
\circledtextset{resize = real,width = 0.5em}
\ebhdrset
{
fntext-pos = normal,
fnnormal-format = \circledtext
}
\end{ctexexam}
\command{defupfntmark}[\marg{正文标记格式}]
定义脚注正文标记的格式,与正文标记编号命令 \cs{theupfootnote} 配合使用。
\command{defdownfntmark}[\marg{内容标记格式}]
定义脚注内容标记的格式,与内容标记编号命令 \cs{thedownfootnote} 配合使用。
\command{deffntpara}[\marg{段落文本格式}]
定义脚注段落文本的格式的命令。脚注段落文本由脚注内容标记和文本两部分组成,段落格式定义中参数 \code{\#1} 代表内容文本。
\command{notminipage}[\marg{普通页内容}\marg{迷你页内容}]
用于在定义脚注标记的命令中判断当前脚注是否处于迷你页而输出不同的内容。
\command{ifnormalfnt}[\marg{常规标记内容}\marg{自定义标记内容}]\newtagv{2024eo}%
用于在定义脚注标记的命令中判断当前是否为常规标记而输出不同的内容。
\command{theupfootnote}
保存正文标记编号类型选项 \option{fnmark-num} 指定的正文标记。
\command{thedownfootnote}
保存内容标记编号类型选项 \option{fntext-num} 指定的内容标记。
\begin{ctexexam}
\defupfntmark{\super[vmove = 2pt]{\theupfootnote}}
\defdownfntmark{\notminipage{\textcolor{blue}{\thedownfootnote}}{}}
\deffntpara{\makebox[2em][r]{\thefootnote}#1}
\end{ctexexam}
\keychoice{fncustom-format}{\optpath*{format code},match}
单独设定自定义脚注标记的格式,选项 \code{match} 可以匹配 \option{spcmd} 全局的值。自定义脚注内容和正文标记的命令与用法可以见下方和\ref{exam:custom footnote markers} 的介绍。
\begin{cnltxlist}[itemsep = 0ex]
\command{Footnote}[\oarg{内容标记}\marg{正文标记}\marg{脚注文本}]\nonl
\command{Footnotetext}[\marg{内容标记}\marg{脚注文本}]\nonl
\command{Footnotemark}[\marg{正文标记}]
这些是自定义标记且不影响正常编号的脚注命令,用法与它们对应首字母小写的命令类似。\meta{内容标记} 默认与 \meta{正文标记} 一致,这也是最常见的情况,也可以定义为不同符号或格式。如果当前标记为空,那么将会使用上一个脚注标记。
\begin{ctexexam}[labelref = exam:custom footnote markers]
\Footnote{*}{这是可以自定义标记的脚注。}
\end{ctexexam}
\end{cnltxlist}
\keychoice{fnboth-format}{\optpath*{format code},match}
同时设定常规脚注标记 \option{fnnormal-format} 和自定义脚注标记 \option{fncustom-format} 的格式。两种脚注标记匹配上标格式 \option{spcmd} 的值是独立的,使用 \code{match} 则可以同时匹配。会覆盖 \module*{font} 模块脚注字体选项 \option{footnote} 相同类型的命令,最后一个格式命令可以带有一个参数接受脚注标记。
\keyval{fnpara-format}{格式代码}
脚注内容文本的格式。会覆盖 \module*{font} 模块脚注字体选项 \option{footnote} 相同类型的命令,最后一个格式命令可以带有一个参数接受脚注内容文本。
\kvsplit{fntext-code}{前代码,后代码}
可以用 \meta{前代码} 与 \meta{后代码} 额外增加脚注内容标记前后的代码。也可以只有前部分,\meta{前代码} 中最后一个格式命令可以带有一个参数接受脚注内容标记。由于脚注标记处于水平模式,可以配合盒子命令设置脚注内容标记的对齐方式,或在标记与脚注首行间插入一点距离。
\begin{ctexexam}
\ebhdrset
{
footnotetype = hang,
fntext-code = {\hspace{1em}\llap,\enskip}
}
\end{ctexexam}
\end{cnltxlist}
\subsection[目录]{目录\smodule{toc}}
\label{subsec:contents}
模块 \module*{toc} 将使用 \pkg*{titletoc} 宏包处理目录样式。默认包括 \module*{part}$\longrightarrow$\module*{subparagraph}、\module*{figure}、\module*{table} 和 \module*{lstlisting} 条目名的键路径。选项前带有\hface 符号表示支持所有相应\textbf{条目名}的路径,其它选项则处于 \module*{toc} 键路径下。目录选项均支持标题编号判定命令 \cs{CTEXifname}\footnote{此功能需要\textbf{2023/06/01}以后的 \hologo{LaTeX} 内核支持。}。目前支持多数学术论文目录样式,更复杂的样式可以查看 \pkg*{titletoc} 的相关用法。
\begin{cnltxlist}
\keyval{tocformat}{条目格式}\dtag
目录中各类型条目的格式。可以设置条目字体和加入垂直间距等,垂直间距最好使用防止垂直间距重合的 \cs*{addvspace} 命令。如果是段落型目录,格式代码仅在段落中当前级别条目前执行一次。也可以用 \cs{CTEXifname} 命令或 \option{tocformat*} 选项给有无编号的标题分别设置格式。
\keyval{tocformat+}{条目格式}\dtag
与选项 \option{tocformat} 用法一样,只是在已有的格式命令后附加代码。
\keyval{tocformat*}{条目格式}\dtag
没有编号/名字标题的附加格式代码。目录中判断标题是否有编号/名字的依据为:如果在 \option{tocline} 选项中使用了 \cs{numberline} 命令输出标签,则判定为有编号/名字。格式最后的命令可带有一个参数,用于接受标题内容。
\keyval{tocindent}{刚性长度}\dtag
目录条目左边的缩进距离,通常标题级别越低缩进越大。如果是段落型目录,仅在当前条目级别为段落中最高时有效。
\keyval{tocrule}{引导线定义}\dtag\newtagv[Changed]{2024et}%
目录条目引导线和页码的定义。其中引导线可以使用基于 \cs*{xleaders} 命令的 \cs{tocrule} 绘制(同时输出页码),参数 \code{\#1} 代表页码 \cs{thecontentspage}。如果是一般不需要引导线的段落型目录,则可以使用参数 \code{\#1} 输出页码。
\command{tocrule}[\sarg\harg\oarg{引导点间距}\darg{放大因子}\marg{引导点}\oarg{页码格式}]
生成目录引导线的命令,需要在 \option{tocrule} 选项中使用。带有星号的命令与 \keyis{dotalign}{false} 效果相同。命令带 \harg{} 号参数不输出目录页码,此时无格式的页码被保存在 \option{tocrule} 选项的参数 \code{\#1} 中,可以配合盒子命令设置不同的页码左右间距和对齐方式。\meta{放大因子} 为 \meta{引导点} 的放大倍数。\meta{页码格式} 中最后一个命令可以带有一个参数用于接受页码。
\keyval{toclabel}{标题标签定义}\dtag\newtagv{2024as}%
目录中各类型标题条目标签的定义,可与 \option{tocline} 选项联用设置标题。其中参数 \code{\#1} 代表标签的编号 \cs{thecontentslabel},参数 \code{\#2} 代表 \meta{条目名}。定义最后的命令可带有一个参数,用于接受标题内容,一些特殊情况例如需要将标题内容放在标签前,可以通过定义命令实现:
\begin{ctexexam}
\newcommand{\seqentry}[2]{#2-#1} % #2为标题内容
\ctexset{chapter/toclabel = \seqentry{#1}}
\end{ctexexam}
\command{hytoclink}[\marg{目录条目元素}]\newtagv{2024eb}%
给目录条目元素增加超链接,主要用于 \option{toclabel} 选项中的标签。使用 \pkg*{titletoc} 宏包时标题条目的标签超链接会缺失,这个命令可修复此问题。
\keyval{tocafter}{距离命令}\dtag\Default{\cs*{hspace}\Marg{1em}}
目录条目标签与标题间的代码,默认为插入 \code{1em} 横向距离。
\keyval{tocbelow}{距离命令}\dtag
在目录条目下方执行的代码,可以插入垂直距离等命令。
\keyval{tocline}{标题定义}\dtag[\sface]
这个选项在章节标题基础上扩展了浮动环境的题注标题在目录文件中的定义。章节和题注标题选项中参数 \code{\#1} 代表标题编号 \cs*{the}\meta{计数器} 对应的计数器名称,参数 \code{\#2} 则代表相应标题内容。
\begin{ctexexam}
\ctexset
{
chapter =
{
tocformat = \CTEXifname{\addvspace{8pt}\large}{},
tocindent = \CTEXifname{2em}{1.5em},
tocrule = \tocrule[0.6pc](1.1){.}[\zihao{5}],
tocline = \CTEXnumberline{#1}#2
},
section/toclabel = \contentspush{\hytoclink{#1}\hspace{0.5em}},
section/tocrule = \tocrule-{}\makebox[1cm]{\rlap{#1}},
toc/pagenumwd = 0pt
}
\end{ctexexam}
\command{RegisterTocName}[\sarg\marg{条目名列表}]\newtagv[Changed]{2024bo}%
给 \meta{条目名列表} 中的每个 \meta{条目名} 标题注册用于设置目录样式的选项,即选项前有符号\hface 表示需要注册后使用。前面提到的条目类型均已注册,新类型的条目注册后默认格式与图表条目相同。这个命令可以重复使用,会重置目录条目为默认格式。带有星号参数的命令使注册目录的条目形成一个段落,此时多出下面三个选项可用:
\keyval{tocbegin}{开始代码}\dtag\newtagv{2024as}%
当前级别目录条目第一个标题前的代码,仅在存在更高级别的条目时有效。
\keyval{tocsep}{中间代码}\dtag\Default{\Marg{.—}}\newtagv{2024as}%
当前级别目录条目每个标题之间的代码。
\keyval{tocend}{结束代码}\dtag\Default{\Marg{.}}\newtagv{2024as}%
当前级别目录条目最后一个标题后的代码。
\command{contentsuse}[\oarg{目录层次}\marg{条目名列表}\marg{扩展名}]\newtagv[Changed]{2024et}%
激活条目类型为 \meta{条目名} 的目录定制功能,目录文件后缀为 \meta{扩展名},若 \meta{扩展名} 为 \code{toc} 则条目会自动激活。可选参数 \meta{目录层次} 为条目在目录中的层次深度,默认值为 \code{-1000},当它大于目录深度计数器 \code{tocdepth} 时不显示。图表等标题的目录条目无深度因此为默认值,章节标题 \module*{part}$\longrightarrow$\module*{subparagraph} 的深度则从 \code{-1} 到 \code{5} 依次递增。需要在激活条目后再使用命令 \cs{RegisterTocName} 注册选项。
\command{DeclareFloatList}[\marg{条目名}\marg{扩展名}]
声明一种条目类型的目录命令 \cs*{listof}\meta{条目名}\cstext{s},并且支持\ref{subsec:directory command} 中图表目录命令的机制。使用这个命令要确保将条目加入目录的机制已经存在,例如搭配 \pkg*{newfloat} 宏包创建新的浮动环境。选项前有实心符号\sface(仍包含空心符号\hface 选项的性质)表示在声明后可用。下面举一个声明算法环境和对应题注目录的例子:
\begin{ctexexam}
\usepackage{newfloat}
\DeclareFloatingEnvironment[
fileext = loa,
listname = 算法清单,
name = 算法
]{algorithm}
\DeclareFloatList{algorithm}{loa}
\begin{document}
\listofalgorithms[multoc] % 在正文中输出双栏算法目录
\end{ctexexam}
\command{AssignCaptionExt}[\marg{条目名列表}\marg{扩展名}]
给条目类型名称为 \meta{条目名} 的标题分配目录文件 \meta{扩展名},注意 \meta{扩展名} 需要被定义在 \cs*{ext@}\meta{条目名} 命令中才有效(\pkg*{caption} 宏包的默认定义形式)。可以使不同的 \meta{条目名} 共享一个目录:
\begin{ctexexam}
\AssignCaptionExt{table}{lof}
\newcommand{\listoffiguretables}{\listoffigures} % 同时输出图表目录的命令
\end{ctexexam}
\command{AssignPartialExt}[\marg{扩展名1}\marg{扩展名2}]\newtagv{2024bk}
给目录文件扩展名为 \meta{扩展名1} 的目录分配扩展名为 \meta{扩展名2} 的局部目录\footnote{此功能需要\textbf{2023/06/01}以后的 \hologo{LaTeX} 内核支持。},预注册的条目均无需再分配。用于搭配题注标题 \cs{caption} 命令和 \pkg*{titletoc} 宏包的局部题注目录命令。
\begin{ctexexam}
\AssignPartialExt{loa}{pla}
\startlist[fancy]{loa}
\captionof{algorithm}{算法标题}
\stoplist[fancy]{loa}
\printlist[fancy]{loa}{}{}
\end{ctexexam}
\command{SetTocStyle}[\marg{条目名列表}\marg{风格名}\marg{键值列表}]
定义条目类型名称为 \meta{风格名} 的目录风格。使用 \cs{ctexset} 命令设置目录样式时,除了标题条目定义选项 \option{tocline},其它选项只有在目录输出命令前设置才有效,定义完目录风格后用 \cs{UseTocStyle} 命令可以在正文中任意位置生效。如果是没有\hface 符号的选项,\meta{条目名} 设置为 \module*{toc}。
\command{UseTocStyle}[\marg{条目名列表}\marg{风格名}\marg{扩展名}]
使用对应条目类型名称为 \meta{风格名} 的目录风格,随后标题在目录中的格式会改变。本命令导言区和正文区均可使用,第三个必选参数还需要指定标题条目加入目录文件的 \meta{扩展名}。此命令仅对涉及目录条目排版格式的选项有效。
\begin{ctexexam}
\SetTocStyle{chapter}{fancy}{tocformat = \color{red}\zihao{3}}
\UseTocStyle{chapter}{fancy}{toc}
\end{ctexexam}
\command{listnumberline}[\marg{计数器名}]
在图表等浮动环境的题注目录中插入条目标签,默认标签的名字可以由格式命令 \cs{labelformat} 设置。其中 \meta{计数器名} 一般与 \meta{条目名} 相同,可以用参数 \code{\#1} 指定或用对应计数器名称显式指定。
\begin{ctexexam}
\ctexset
{
lstlisting/tocline = \listnumberline{#1}#2,
figure/tocline = \protect\numberline{图\thefigure\hspace{1em}}#2
}
\end{ctexexam}