summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/ctex/ctex.tex
blob: 1e1343d366997745e1347ff22e0b2db25ebff8a0 (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
%# -*- coding: utf-8 -*-
% ctex.tex: manual of ctex package

\documentclass{ltxdoc}
\usepackage[fntef,hyperref,adobefonts]{ctexcap}
\usepackage{texnames}
 \topmargin 0.5 true cm
 \oddsidemargin 1 true cm
 \evensidemargin 1 true cm
 \textheight 21 true cm
 \textwidth 14 true cm

\MakeShortVerb{\|}
\setcounter{StandardModuleDepth}{1}

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

\newcommand{\ctex}{\texttt{ctex}}
\newcommand{\ctexorg}{\texttt{ctex.org}}

\newcommand{\ctexdefault}{\emph{这个是 \ctex{} 宏包的缺省模式。}}

\setlength{\parskip}{0.75ex plus .2ex minus .5ex}
\renewcommand{\baselinestretch}{1.2}

\makeatletter
\def\parg#1{\mbox{$\langle${\it #1\/}$\rangle$}}
\def\@smarg#1{{\tt\string{}\parg{#1}{\tt\string}}}
\def\@marg#1{{\tt\string{}{\rm #1}{\tt\string}}}
\def\marg{\@ifstar\@smarg\@marg}
\def\@soarg#1{{\tt[}\parg{#1}{\tt]}}
\def\@oarg#1{{\tt[}{\rm #1}{\tt]}}
\def\oarg{\@ifstar\@soarg\@oarg}
\makeatother

\begin{document}

\title{\bf \ctex{} 宏包说明}
\author{\it \ctexorg\thanks{\url{http://www.ctex.org}}}
\date{\small 版本号:v0.94 \hskip 2\ccwd 修改日期:2009/09/13}
\maketitle


\begin{abstract}
\ctex{} 宏包提供了一个统一的中文 \LaTeX{} 文档框架,底层支持 CCT、CJK 和
 xeCJK 三种中文 \LaTeX{} 系统。\ctex{} 宏包提供了编写中文 \LaTeX{} 文档
常用的一些宏定义和命令。

\ctex{} 宏包需要 CCT 系统或者 CJK 宏包或者 xeCJK 宏包的支持。主要文件包括
 \texttt{ctexart.cls}、\texttt{ctexrep.cls}、\texttt{ctexbook.cls} 和
 \texttt{ctex.sty}、\texttt{ctexcap.sty}。

\ctex{} 宏包由 \ctexorg{} 制作并负责维护。
\end{abstract}

\tableofcontents

\section{简介}

这个宏包的部分原始代码来自于由王磊编写 \texttt{cjkbook.cls} 文档类,
还有一小部分原始代码来自于吴凌云编写的 \texttt{GB.cap} 文件。
原来的这些工作都是零零碎碎编写的,没有认真、系统的设计,
也没有用户文档,非常不利于维护和改进。2003 年,吴凌云用 \texttt{doc} 
和 \texttt{docstrip} 工具重新编写了整个文档,并增加了许多新的功能。
2007 年,oseen 和王越在 \ctex{} 宏包基础上增加了对 UTF-8 编码的支持,
开发出了 \texttt{ctexutf8} 宏包。
2009 年 5 月,我们在 Google Code 建立了 ctex-kit 项目\footnote{\url{http://code.google.com/p/ctex-kit/}},
对 \ctex{} 宏包及相关宏包和脚本进行了整合,并加入了对 Xe\TeX{} 的支持。
该项目由 \ctexorg{} 社区的开发者共同维护,新版本号为 v0.9。
在开发新版本时,考虑到合作开发和调试的方便,
我们不再使用 \texttt{doc} 和 \texttt{docstrip} 工具,改为直接编写宏包文件。

最初 Knuth 设计开发 \TeX{} 的时候没有考虑到支持多国语言,
特别是多字节的中日韩语言。这使得 \TeX{} 以至后来的
\LaTeX{} 对中文的支持一直不是很好。即使在 CJK 解决了中文字符
处理的问题以后,中文用户使用 \LaTeX{} 仍然要面对许多困难。
最常见的就是中文化的标题。由于中文习惯和西方语言的不同,
使得很难直接使用原有的标题结构来表示中文标题。因此需要对
标准 \LaTeX{} 宏包做较大的修改。此外,还有诸如中文字号的对应
关系等等。\ctex{} 宏包正是尝试着解决这些问题。中间很多地方
用到了在 \ctexorg{} 论坛上的讨论结果,在此对参与讨论的
朋友们表示感谢。

\ctex{} 宏包由五个主要文件构成:\texttt{ctexart.cls}、\texttt{ctexrep.cls}、\texttt{ctexbook.cls}
和 \texttt{ctex.sty}、\texttt{ctexcap.sty}。\texttt{ctex.sty} 主要是提供整合的中文环境,可以配合大多数文档类使用。而
\texttt{ctexcap.sty} 则是在 \texttt{ctex.sty} 的基础上对 \LaTeX{} 的三个标准文档类的格式进行修改以符合中文习惯,该宏包只能配合这三个
标准文档类使用。\texttt{ctexart.cls}、\texttt{ctexrep.cls}、\texttt{ctexbook.cls}
则是 \texttt{ctex.sty}、\texttt{ctexcap.sty} 分别和三个标准文档类
结合产生的新文档类,除了包含 \texttt{ctex.sty}、\texttt{ctexcap.sty}
的所有功能,还加入了一些修改文档类缺省设置的内容(如使用五号字体为缺
省字体)。

\vskip 10pt
\emph{这份说明文档可以通过用 Xe\LaTeX{} 编译 \texttt{ctex.tex} 文件来得到。
编译说明文档需要先安装 \ctex{} 宏包。}


\section{使用帮助}

\ctex{} 宏包的使用十分简单。如果是使用 \ctex{} 的文档类,只需用
\texttt{ctexart}、\texttt{ctexrep} 或者 \texttt{ctexbook} 替换原来的
文档类就可以了。你也可以继续使用原来的文档类,而用 \texttt{ctex.sty} 或者
\texttt{ctexcap.sty} 宏包来配合使用,两者的效果是一样的
(除了不能修改一些文档设置如缺省字体大小)。

\subsection{使用 CJK 或 xeCJK}

这是 \ctex{} 宏包的缺省设置。\ctex{} 宏包会自动根据使用的 \TeX{} 引擎
调用 CJK 或者 xeCJK 宏包,你无需再自己调用。

此外,\ctex{} 宏包会在 |\begin{document}| 和 |\end{document}|
之间自动加入一个 CJK 环境,你无需再添加 CJK 环境。CJK 宏包的命令都可以
在 |\begin{document}| 和 |\end{document}| 之间正常使用。

例子1:使用文档类宏包
\begin{verbatim}
\documentclass{ctexart}
\begin{document}
中文宏包测试
\end{document}
\end{verbatim}

例子2:使用普通宏包
\begin{verbatim}
\documentclass{article}
\usepackage{ctex}
\begin{document}
中文宏包测试
\end{document}
\end{verbatim}

\subsection{使用 CCT}

注:CCT 方式\emph{不再建议}使用。

\ctex{} 宏包也可以配合新版的 CCT 使用,只需在使用 \ctex{} 宏包时加上 CCT 选项即可。
缺省 CCT 会使用 CJK 字库,因为这种字库方式比传统 CCT 字库更方便,兼容性也更好。
如果要使用传统 CCT 字库,则还要加上 CCTfont 选项。

例子3:使用 CJK 方式字库
\begin{verbatim}
\documentclass[CCT]{ctexart}
\begin{document}
中文宏包测试
\end{document}
\end{verbatim}

例子2:使用 CCT 方式字库
\begin{verbatim}
\documentclass[CCT,CCTfont]{ctexart}
\begin{document}
中文宏包测试
\end{document}
\end{verbatim}


\subsection{选项}

宏包的选项用于改变一些缺省风格的设置。缺省的设置已经针对中文
的习惯进行了尽量的修改,所以一般用户无需使用这些选项。
如果你觉得某些设置不合适,可以向作者反映。我们会考虑在后面的
版本中予以改进。我们也欢迎关于增加或者删减选项的建议。

\emph{除了 \ref{class-opts} 和 \ref{caption-opts} 的选项,
其余的选项都可以在所有文档类宏包和普通宏包上使用。}

\subsubsection{只能用于文档类的选项} \label{class-opts}

下面的选项可能会是最经常使用的。但是它们只能用于文档类
(\texttt{ctexart}、 \texttt{ctexrep} 和 \texttt{ctexbook})。
\begin{description}
\item[cs4size] 使用小四字号为缺省字体大小。
\item[c5size] 使用五号字为缺省字体大小。\ctexdefault
\end{description}

\subsubsection{只能用于文档类和 \texttt{ctexcap.sty} 的选项} \label{caption-opts}

下面这些则只可以在文档类宏包和 \texttt{ctexcap.sty} 上使用。
\begin{description}
\item[sub3section] 将 |\paragraph| 命令产生的标题改为 section 类格式。
此时 |\subparagraph| 命令产生的标题会具有原来 |\paragraph| 的格式。

\item[sub4section] 将 |\paragraph| 和 |\subparagraph| 命令产生的标题
都改为 section 类格式。
\end{description}

\subsubsection{中文编码选项}

下面的选项用于选择 ctex 宏包的内部编码。

\begin{description}
\item[GBK] 使用 GBK 编码。\ctexdefault

\item[UTF8] 使用 UTF-8 编码。
\end{description}

\emph{注意使用 Xe\TeX{} 引擎的情况下总是内部使用 UTF-8 编码,所以不必使用
这个选项,但这并不妨碍编写 GBK 编码的文档。}

\subsubsection{中文字库选项} \label{fontset}

下面的选项用于选择可用的中文字库。设置这些选项是考虑到不同的操作系统平台
提供的中文字库是不同的。不同的 \TeX{} 发行版可以根据目标操作系统平台和
提供的中文字库在 \texttt{ctexfonts.cfg} 文件中修改这些选项之一为缺省设置。
\begin{description}
\item[nofonts] 没有中文字库,此时没有中文字体命令可用。

\item[cjkfonts] 在 CJK 模式(即不使用 Xe\TeX{} 时)使用 CJKfonts 中的两套
文鼎字库:宋体和楷体。在 xeCJK 模式(即使用 Xe\TeX{} 时),该选项将使用
 adobefonts 选项的设置。

\item[winfonts] 使用 Windows 的字体设置,默认为六种中易字体:宋体、仿宋、黑体、
楷体、隶书、幼圆。该选项的结果将和老版本 \ctex{} 宏包完全一致。

\item[adobefonts] 在 xeCJK 模式中使用 Adobe 的四套字体:宋体、仿宋、黑体、楷体。
在 CJK 模式(即不使用 Xe\TeX{} 时)下,该选项将使用 winfonts 选项的设置。
\end{description}

\subsubsection{CCT 引擎选项}

下面的选项用于选择底层的中文系统。缺省情况下,宏包会根据编译方式自动选择 CJK 
或者 xeCJK 引擎。
\begin{description}
\item[CCT] 使用 CCT 代替 CJK 做为底层的中文支持系统。

\item[CCTfont] 使用传统的 CCT 字库方式,该选项会自动激活 CCT 选项。
\end{description}

\subsubsection{排版风格选项}

\begin{description}
\item[cap] 使用中文的标题样式,缺省格式由 \texttt{ctexcap.cfg} 配置文件
内的定义给出。对于 \texttt{ctex.sty},该选项只影响交叉引用中的数字和日期格式。
\ctexdefault

\item[nocap] 保留使用英文的标题样式。

\item[punct] 对中文标点的位置(宽度)进行调整。\ctexdefault

\item[nopunct] 不对中文标点的位置进行调整(每个标点占有相同的宽度)。

\item[space] 使用 CJK 的保留空格模式,保留中文字符间的空格(类似英文的
习惯)。你需要自己处理中文字符间的空格以及换行产生的空格(在行尾加上
 \% 符号可以避免),否则排版结果可能不符合中文习惯。这种模式可以通过
 |\CTEXnospace| 转换到 nospace 模式。

\item[nospace] 使用 CJK 的忽略空格模式,也就是 CJK* 环境的模式。
 CJK 会自动忽略中文字符间的空格,比较符合中文习惯。在这种模式下,
可以使用 \textasciitilde 来分隔中英文字符,产生的间距稍小于普通空格,
排版效果比较美观。这种模式可以通过 |\CTEXspace| 命令转换到 space 模式。
\ctexdefault

\item[indent] 使用中文的段首缩进模式,即缩进两个汉字宽度,同时每个段落
都缩进。\ctexdefault

\item[noindent] 使用原来的段首缩进模式,章节标题后的第一段不缩进。
\end{description}

\subsubsection{宏包兼容选项}

\begin{description}
\item[fancyhdr] 保持和 \texttt{fancyhdr} 宏包的兼容性。该选项将使得
 \texttt{fancyhdr} 宏包被自动调用。

\item[hyperref] 自动判断调用 \texttt{fancyhdr} 宏包的正确参数以避免产生乱码。
该选项将使得 \texttt{hyperref} 宏包被自动调用。

\item[fntef] 为 \texttt{CJKfntef} 宏包和 \texttt{CCTfntef} 宏包提供统一接口。
该选项将使得 \texttt{CJKfntef} 宏包或者 \texttt{CCTfntef} 宏包被自动调用。
\end{description}

\subsubsection{缺省选项}

总结一下:\ctex{} 宏包的缺省选项是 GBK nospace cap punct indent,\ctex{} 文档类
的缺省选项是 GBK nospace cap punct indent c5size。


\subsection{基本命令}

\ctex{} 宏包给用户提供一个通用的文档框架,使得用户可以自由地在不同的
底层中文系统间切换。为此,我们为 CJK 定制了一些模拟 CCT 的命令,
也对部分 CCT 命令进行了修改,使得两者保持一致。
此外,我们还定义了用于设置文档参数的高级设置命令。

\subsubsection{字体设置}

中文字体很多,但是常用的就那么几个。我们为 CJK 常用的六种中文
字体定义了简单易用的命令。它们是:

\DescribeMacro{\songti}
宋体: |\songti|, CJK 等价命令 |\CJKfamily{song}|

\DescribeMacro{\heiti}
黑体: |\heiti|, CJK 等价命令 |\CJKfamily{hei}|

\DescribeMacro{\fangsong}
仿宋: |\fangsong|, CJK 等价命令 |\CJKfamily{fs}|

\DescribeMacro{\kaishu}
楷书: |\kaishu|, CJK 等价命令 |\CJKfamily{kai}|

\DescribeMacro{\lishu}
隶书: |\lishu|, CJK 等价命令 |\CJKfamily{li}|

\DescribeMacro{\youyuan}
幼圆: |\youyuan|, CJK 等价命令 |\CJKfamily{you}|

\vskip 10pt
{\kaishu \TeX{} 系统中必须已经定义好这六种中文字体,并且使用和 \CTeX{} 套装中
一致的字体名称。(参见上面 CJK 等价命令的参数)

可用的字体命令还取决于使用的中文字库选项,参见 \ref{fontset} 一节的介绍。

上面的字体命令和 CCT 中的一致,但传统的 CCT 字库中没有隶书和
仿宋两种字体,需要用户自行安装定义。如果使用 CCT 时选择 CJK 字库方式,
则可以使用这两种中文字体。}

\subsubsection{字号、字距、字宽和缩进}

\DescribeMacro{\zihao}
中文字号的设置命令是 |\zihao|\marg*{字号},例如 |\zihao{3}|。
可以使用的参数有 16 个,小号字体在前面加负号表示,从大到小依次为
\begin{center}
\begin{tabular}{cccccccc}
\hline
初号 & 小初 & 一号 & 小一 & 二号 & 小二 & 三号 & 小三 \\
0 & -0 & 1 & -1 & 2 & -2 & 3 & -3 \\
\hline
四号 & 小四 & 五号 & 小五 & 六号 & 小六 & 七号 & 八号 \\
4 & -4 & 5 & -5 & 6 & -6 & 7 & 8 \\
\hline
\end{tabular}
\end{center}
\noindent 英文字体大小会始终保持和中文字体一致。

\DescribeMacro{\ziju}
汉字字距的调整使用命令 |\ziju|\marg*{字宽的倍数}。参数可以是任意的数字,
例如 |\ziju{5}| 设置汉字字距为当前汉字字宽的 5 倍, |\ziju{0.5}| 设置汉字
字距为当前汉字字宽的一半。这里的汉字字宽指的是实际汉字的宽度,
不包含当前字距。该命令不影响英文字距。

\DescribeMacro{\ccwd}
当前汉字的字宽保存在宏 |\ccwd| 中。字宽是相邻两个汉字中心的距离,
也就是说字距会被计算在内。

\DescribeMacro{\CTEXindent}
正常的缩进两个汉字字宽的距离,同时在汉字大小和字距改变的
情况都可以自动修改缩进距离。

\DescribeMacro{\CTEXnoindent}
取消缩进。

\DescribeMacro{\CTEXsetfont}
|\CTEXsetfont| 命令用于更新当前的中文字体信息,包括当前字距和缩进
距离。一般来说,用户无需使用这个命令。


\subsubsection{中文数字转换}

\DescribeMacro{\CTEXnumber}
使用 CJK 提供的 |\CJKnumber| 命令可以将阿拉伯数字转换为中文数字。
由于 \LaTeX{} 臭名昭著的脆弱命令的原因,当 |\CJKnumber| 被用在
章节标题等地方的时候,要么出现错误无法使用,要么无法达到预期目的,
例如在产生 PDF 书签的时候。于是我们定义了一个 |\CTEXnumber| 命令,
可以将产生的中文数字保存下来。该命令的格式为
\begin{quote}
|\CTEXnumber|\marg*{result}\marg*{number}
\end{quote}
其中 \parg{result} 必须是一个 \TeX{} 宏的名字,不需要预先定义。
例如
\begin{quote}
|\CTEXnumber{\test}{100002005}|
\end{quote}
则 |\test| 中的内容就是“一亿零二千零五”(不包括引号)。

\DescribeMacro{\CTEXdigits}
|\CTEXdigits| 命令和 |\CTEXnumber| 命令类似,用于代替 CJK 提供的
 |\CJKdigits| 命令。它和 |\CTEXnumber| 命令的不同之处在于转换后
结果是中文数字串,而不是按照中文习惯的数字。该命令的格式为
\begin{quote}
|\CTEXdigits|\marg*{result}\marg*{number}
\end{quote}
其中 \parg{result} 必须是一个 \TeX{} 宏的名字,不需要预先定义。
例如
\begin{quote}
|\CTEXnumber{\test}{100002005}|
\end{quote}
\CTEXdigits{\test}{100002005}
则 |\test| 中的内容就是“\test{}”(不包括引号)。

\DescribeMacro{\chinese}
对于经常需要转换的计数器,我们特别定义了一个 |\chinese| 命令。
该命令可以象罗马数字转换命令 |\roman|、 |\Roman| 一样使用。
具体格式是
\begin{quote}
|\chinese|\marg*{counter}
\end{quote}
其中 \parg{counter} 是一个 \LaTeX{} 计数器(counter),即由
 |\newcounter| 命令产生的,例如 |section|, |figure| 等。


\subsection{高级设置}

\DescribeMacro{\CTEXoptions}
\ctex{} 宏包中一般的设置通过 |\CTEXoptions| 命令完成。
这个命令的基本格式是
\begin{quote}
|\CTEXoptions|\oarg{\parg{key1}={\parg{val1}},
                  \parg{key2}={\parg{val2}}, ...}
\end{quote}
其中 \parg{key1}, \parg{key2} 是设置选项,
 \parg{val1}, \parg{val2} 则是对应选项的设置内容。
多个选项可以在一个语句中完成设置。

\DescribeMacro{\CTEXsetup}
部分设置如章节标题则通过 |\CTEXsetup| 命令完成。这个命令比
 |\CTEXoptions| 多一个参数,用于指定设置对象。
基本格式是
\begin{quote}
|\CTEXsetup|\oarg{\parg{key1}={\parg{val1}},
                  \parg{key2}={\parg{val2}}, ...}\marg*{type}
\end{quote}
其中 \parg{type} 是设置的对象类型,如 |part|, |chapter|, |section|,
|subsection|, |subsubsection|, |paragraph|, |subparagraph| 等。
 \parg{key1}, \parg{key2} 是设置选项,如 |name|, |number|, |format|,
|nameformat|, |numberformat|, |aftername|, |titleformat| 等。
 \parg{val1}, \parg{val2} 则是对应选项的设置内容。
同一个目标类型的多个选项可以在一个语句中完成设置。

{\kaishu 
在 v0.7 版本之前,如果以上命令的参数中包含中文字符,则命令必须放在
|\begin{document}| 之后才能正常工作。从 v0.7 版本开始支持在导言区使用中文。
}

\subsubsection{章节标题设置}

普通章节标题的格式全部通过 |\CTEXsetup| 命令完成。
章节类型在 |\CTEXsetup| 命令的第二个参数中指定。

{\kaishu 在 v0.7 版本之前,如果使用了宏包选项 cap (缺省情况即是如此),则所有
对章节标题的修改必须在 |\begin{document}| 以后进行。原因是
缺省的中文标题设置文件 \texttt{ctexcap.cfg} 文件是在
 |\begin{document}| 之后才会自动装入,因而之前的修改都
会被覆盖而无效。这一限制对后面的附录标题以及其他标题设置
一样有效。从 v0.7 版本开始,\texttt{ctexcap.cfg} 文件
在宏包文件结束时就已经被装入,因此可以在导言区使用设置命令。}

\begin{description}

\item[name=\{\parg{prename},\parg{postname}\}]
该选项用于设置章节的名字,包括章节编号前后的词语,两个之间用逗号分开。
例如
\begin{quote}
|\CTEXsetup[name={第,节}]{section}|
\end{quote}
会使得 section 的标题使用形如“第1节”的名字。注意{\bf 不要}使用中文
的逗号。

该选项的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part & \{第,部分\} & \{Part\cs{space},\} \\
chapter & \{第,章\} & \{Chapter\cs{space},\} \\
section & 同右 & \{,\} \\
subsection & 同右 & \{,\} \\
subsubsection & 同右 & \{,\} \\
paragraph & 同右 & \{,\} \\
subparagraph & 同右 & \{,\} \\
\hline\hline
\end{tabular}
\end{center}

\item[number=\{\parg{number}\}]
该选项用于设置章节编号的数字样式。例如
\begin{quote}
|\CTEXsetup[number={\roman{section}}]{section}|
\end{quote}
会使得 section 的标题使用小写罗马数字作为编号。常用的数字样式命令有
\begin{description}
\item \cs{chinese}\marg*{counter}: 一, 二, 三, ...
\item \cs{arabic}\marg*{counter}: 1, 2, 3, ...
\item \cs{roman}\marg*{counter}: i, ii, iii, ...
\item \cs{Roman}\marg*{counter}: I, II, III, ...
\item \cs{alph}\marg*{counter}: a, b, c, ...
\item \cs{Alph}\marg*{counter}: A, B, C, ...
\end{description}

该选项的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part & \{\cs{chinese}\marg{part}\} & \{\cs{Roman}\marg{part}\} \\
chapter & \{\cs{chinese}\marg{chapter}\} & \{\cs{arabic}\marg{chapter}\} \\
section & 同右 & \{\cs{thesection}\} \\
subsection & 同右 & \{\cs{thesubsection}\} \\
subsubsection & 同右 & \{\cs{thesubsubsection}\} \\
paragraph & 同右 & \{\cs{theparagraph}\} \\
subparagraph & 同右 & \{\cs{thesubparagraph}\} \\
\hline\hline
\end{tabular}
\end{center}

\item[format=\{\parg{format}\}]
用于控制章节标题的全局格式,作用域为章节名字和随后的标题内容。
常用于控制章节标题的对齐方式。

该选项的缺省设置是
\begin{center} \small
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part (article) & \{\cs{centering}\} & \{\cs{raggedright}\} \\
part & \{\cs{centering}\} & \{\cs{centering}\} \\
chapter & \{\cs{centering}\} & \{\cs{raggedright}\} \\
section & \{\cs{Large}\cs{bfseries}\cs{centering}\} & \{\cs{Large}\cs{bfseries}\} \\
subsection & \{\cs{large}\cs{bfseries}\cs{centering}\} & \{\cs{large}\cs{bfseries}\} \\
subsubsection & \{\cs{normalsize}\cs{bfseries}\cs{centering}\} & \{\cs{normalsize}\cs{bfseries}\} \\
paragraph & \{\cs{normalsize}\cs{bfseries}\cs{centering}\} & \{\cs{normalsize}\cs{bfseries}\} \\
subparagraph & \{\cs{normalsize}\cs{bfseries}\cs{centering}\} & \{\cs{normalsize}\cs{bfseries}\} \\
\hline\hline
\end{tabular}
\end{center}

\item[nameformat=\{\parg{nameformat}\}]
用于控制章节名字的格式,作用域为章节名字,包括编号。

该选项的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part (article) & 同右 & \{\cs{Large}\cs{bfseries}\} \\
part & 同右 & \{\cs{huge}\cs{bfseries}\} \\
chapter & 同右 & \{\cs{huge}\cs{bfseries}\} \\
section & 同右 & \{\} \\
subsection & 同右 & \{\} \\
subsubsection & 同右 & \{\} \\
paragraph & 同右 & \{\} \\
subparagraph & 同右 & \{\} \\
\hline\hline
\end{tabular}
\end{center}

\item[numberformat=\{\parg{numberformat}\}]
用于控制章节编号的格式。一般为空,当你需要编号的格式和前后的章节名字
不一样时使用。

\item[aftername=\{\parg{aftername}\}]
用于控制章节标题中章节名字和随后的标题内容之间的格式变换。
常用于控制标题内容是否另起一行。

该选项的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part (article) & \{\cs{quad}\} & \{\cs{par}\cs{nobreak}\} \\
part & 同右 & \{\cs{par}\cs{vskip} 20pt\} \\
chapter & \{\cs{quad}\} & \{\cs{par}\cs{vskip} 20pt\} \\
section & 同右 & \{\} \\
subsection & 同右 & \{\} \\
subsubsection & 同右 & \{\} \\
paragraph & 同右 & \{\} \\
subparagraph & 同右 & \{\} \\
\hline\hline
\end{tabular}
\end{center}

\item[titleformat=\{\parg{titleformat}\}]
用于控制标题内容的格式,作用域为章节标题内容。

该选项的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part (article) & \{\cs{Large}\cs{bfseries}\} & \{\cs{huge}\cs{bfseries}\} \\
part & \{\cs{huge}\cs{bfseries}\} & \{\cs{Huge}\cs{bfseries}\} \\
chapter & \{\cs{huge}\cs{bfseries}\} & \{\cs{Huge}\cs{bfseries}\} \\
section & 同右 & \{\} \\
subsection & 同右 & \{\} \\
subsubsection & 同右 & \{\} \\
paragraph & 同右 & \{\} \\
subparagraph & 同右 & \{\} \\
\hline\hline
\end{tabular}
\end{center}

\item[beforeskip=\{\parg{beforeskip}\}]
用于控制章节标题前的空距。

该选项的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part (article) & 同右 & \{4ex\} \\
part & 无效 & 无效 \\
chapter & 同右 & \{50pt\} \\
section & 同右 & \{-3.5ex plus -1ex minus -.2ex\} \\
subsection & 同右 & \{-3.25ex plus -1ex minus -.2ex\} \\
subsubsection & 同右 & \{-3.25ex plus -1ex minus -.2ex\} \\
paragraph & 同右 & \{3.25ex plus 1ex minus .2ex\} \\
subparagraph & 同右 & \{3.25ex plus 1ex minus .2ex\} \\
\hline\hline
\end{tabular}
\end{center}

在 section 及以下的标题中,使用负的距离表示标题后的段落不缩进
(如标准的英文 LaTeX 文档),否则缩进。标题上方真正的空距是该参数的绝对值。

\item[afterskip=\{\parg{afterskip}\}]
用于控制章节标题后的空距。

该选项的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part (article) & 同右 & \{3ex\} \\
part & 无效 & 无效 \\
chapter & 同右 & \{40pt\} \\
section & 同右 & \{2.3ex plus .2ex\} \\
subsection & 同右 & \{1.5ex plus .2ex\} \\
subsubsection & 同右 & \{1.5ex plus .2ex\} \\
paragraph & 同右 & \{-1em\} \\
subparagraph & 同右 & \{-1em\} \\
\hline\hline
\end{tabular}
\end{center}

在 section 及以下的标题中,正的距离表示向下留出的空距(如标准的 section 标题),
使用负的距离则表示向右留出的空距的负值(如标准的 paragraph 标题)。

\item[indent=\{\parg{indent}\}]
用于控制章节标题本身的缩进。

该选项的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
part (article) & 同右 & \{0pt\} \\
part & 无效 & 无效 \\
chapter & 同右 & \{0pt\} \\
section & 同右 & \{0pt\} \\
subsection & 同右 & \{0pt\} \\
subsubsection & 同右 & \{0pt\} \\
paragraph & 同右 & \{0pt\} \\
subparagraph & 同右 & \{\cs{parindent}\} \\
\hline\hline
\end{tabular}
\end{center}

\end{description}


\subsubsection{部分修改标题格式}

如果只想修改标题格式中的某些参数而不是完全重新设置,可以使用带 + 号的
设置选项。例如
\begin{quote}
|\CTEXsetup[format+={\zihao{1}}]{section}|
\end{quote}
则 section 的标题使用一号字体,而其他格式设置保持不变。

标题格式相关的选项都支持这一功能,包括 |format|, |nameformat|, |numberformat|,
|aftername| 和 |titleformat|,而且对所有文档类型都有效。

\subsubsection{附录标题设置}

附录(appendix)的标题也使用 |\CTEXsetup| 命令进行设置,
第二个参数设为 |appendix|。但是只能使用 |name| 和 |number| 
两个设置选项。在使用了 |\appendix| 命令之后,附录
的名字和编号会被自动使用。{\bf 附录的名字和前面的章节不同,
它只有一个部分,放在编号之前。}在 article 类文档中,
附录是用 section 实现的,而在 report 和 book 类文档中附录
使用的是 chapter 的设置。因此在设置附录的编号的时候要注意
使用正确的计数器。如果你要设置其他格式的附录标题,
可以根据使用的文档类直接用 section 或者 chapter 的设置命令来控制,
但是要记住把设置命令放在 |\appendix| (如果有的话)的后面,
否则会被 |\appendix| 命令的设置覆盖。

附录的缺省设置是
\begin{center}
\begin{tabular}{lll}
\hline\hline
   & 使用宏包选项 cap  & 使用宏包选项 nocap  \\
\hline
name (article) & 同右 & \{\} \\
name & \{附录\textasciitilde\} & \{Appendix\cs{space}\} \\
number (article) & 同右 & \{\cs{Alph}\marg{section}\} \\
number & 同右 & \{\cs{Alph}\marg{chapter}\} \\
\hline\hline
\end{tabular}
\end{center}


\subsubsection{其他标题设置}

除章节标题外其他标题的设置通过 |\CTEXoptions| 设置。包括

\begin{description}
\item[contentsname] 目录名
\item[listfigurename] 表格目录
\item[listtablename] 插图目录
\item[figurename] 图
\item[tablename] 表
\item[abstractname] 摘要
\item[indexname] 索引
\item[bibname] 参考文献
\end{description}

例如
\begin{quote}
|\CTEXoptions[indexname={总索引}]|
\end{quote}
把索引的名字改为“总索引”。


\subsubsection{其他设置}

\paragraph{设置 \cs{today} 的日期格式}
使用 |\CTEXoptions| 可以设置 |\today| 命令产生的日期格式。
支持的格式包括

\begin{enumerate}

\item 阿拉伯数字加中文年月日
\begin{quote}
|\CTEXoptions[today=small]|
\end{quote}
\CTEXoptions[today=small]
|\today| 生成的日期例子为“\today{}”。

\item 中文数字加中文年月日
\begin{quote}
|\CTEXoptions[today=big]|
\end{quote}
\CTEXoptions[today=big]
|\today| 生成的日期例子为“\today{}”。

\item \LaTeX{} 标准格式
\begin{quote}
|\CTEXoptions[today=old]|
\end{quote}
\CTEXoptions[today=old]
|\today| 生成的日期例子为“\today{}”。

\end{enumerate}


\paragraph{设置图表标题的分隔符}
使用 |\CTEXoptions| 可以设置 |\caption| 命令产生的图表标题的分隔符。
这个分隔符缺省是使用冒号 : 。可以通过命令
\begin{quote}
|\CTEXoptions[captiondelimiter={|\parg{string}|}]|
\end{quote}
设置为任意的单个字符或者字符串 \parg{string}。


\subsection{配置文件}

主要的配置文件有:
\begin{itemize}
\item \texttt{ctexopts.cfg}
\item \texttt{ctexcap.cfg}, \texttt{ctexcap-gbk.cfg}, \texttt{ctexcap-utf8.cfg}
\item \texttt{ctex.cfg}
\end{itemize}

\texttt{ctexopts.cfg} 用于设置缺省选项。例如可以根据系统中的可用中文字库,
设置 \ref{fontset} 一节中的几个选项之一为缺省选项。
该文件会在处理宏包选项之前装入。

\texttt{ctexcap.cfg} 是缺省中文标题格式的定义,当你使用 \texttt{cap} 
选项时就会使用这里的定义。你可以把它改为你经常使用的格式,这样就不用
每次都在正文中修改了。 \texttt{ctexcap.cfg} 中的设置都可以通过宏包提供
的设置命令在正文中进行修改。与中文编码有关的定义分别在
 \texttt{ctexcap-gbk.cfg} 和 \texttt{ctexcap-utf8.cfg} 文件中。

最后,宏包还将读入 \texttt{ctex.cfg} 文件,该文件中的设置将覆盖其他配置
文件中的设置。用户可以在该文件中加入自己的定义。

在修改这些配置文件的时候,你可以修改系统目录中的文件,也可以拷贝一份放到
当前目录下,然后修改。TeX 会优先使用当前目录下的同名文件。这样你可以针对
不同的应用设置不同的缺省配置文件。


\section{版本更新}

\begin{description}

\item[v0.94 2009/09/13]
改进 hyperref 选项的支持

\item[v0.93 2009/07/10]
加入选项 hyperref 以支持自动用合适的参数调用 hyperref 宏包

\item[v0.92 2009/06/25]
Add backward compatibility to old ctexutf8 packages

\item[v0.91 2009/05/23]
调整宏包结构,增加对各种系统中文字库的支持选项: cjkfonts, winfonts,
adobefonts

\item[v0.9 2009/05/05]
整合 ctexutf8 宏包,增加对 UTF-8 编码的支持;
开始支持 Xe\TeX{} 中文系统(使用 xeCJK 宏包)

\item[v0.8a 2007/05/06]
增加 bold 字体的定义

\item[v0.8 2006/06/09]
将 ctex.sty 文件分割为 ctex.sty 和 ctexcap.sty,
后者只支持标准文档类增加对 |\stepcounter| 的重定义,以和 calc 宏包兼容

\item[v0.7f 2006/04/12]
采用修改 |\AtBeginDocument| 和 |\AtEndDocument| 命令的方式
来设置 CJK 环境,以减少宏包冲突

\item[v0.7e 2006/03/22]
改用 |\DeclareRobustCommand| 定义 |\CTEXnumber| 和 |\CTEXcounter|;
除去 |\CTEXdigits| 和 |\CTEX@getdigit| 命令带来的多余空格

\item[v0.7d 2005/12/28]
在 fntef 类宏包后使用 |\normalem| 恢复 |\em| 宏的缺省定义

\item[v0.7c 2005/12/20]
增加对 |\if@mainmatter| 的判断,以兼容 amsbook 宏包

\item[v0.7b 2005/12/09]
调整宏包导入位置,解决 fntef 类宏包早于相应中文宏包导入的问题

\item[v0.7a 2005/11/28]
将 ctex.cfg 文件的读取时间前移,使得导言中的设置命令优先

\item[v0.7 2005/11/25]
支持在导言区中使用中文和章节标题设置命令(感谢 tercelxy 的建议);
增加 CJKfntef 宏包和 CCTfntef 宏包的统一接口(感谢 chenyu\_21cn 的建议)

\item[v0.6b 2005/11/07]
将节以下编号和标题之间的空距定义转移到相应的 aftername 变量中

\item[v0.6a 2005/09/30]
增加对 |\CCT@set@fontsize| 的判断

\item[v0.6 2005/09/24]
针对 cct 0.6180 的修改,
|\set@fontsize|: cct 从 0.6180 开始将宏 |\oset@fontsize| 改为 |\CCT@set@fontsize|

\item[v0.5c 2004/09/29]
避免重复执行设置 CJK 环境结束语句

\item[v0.5b 2004/09/29]
改变设置 CJK 环境结束语句的 |\AtEndDocument| 执行的位置,以减少宏包冲突

\item[v0.5a 2004/09/06]
修改图表标题分隔符设置中的错误

\item[v0.5 2004/08/23]
General: Move Chinese definitions from ctex.cfg to ctex.def

\item[v0.4d 2004/08/14]
|\ps@fancy|: 增加对 mainmatter 的判断;
|\refstepcounter|: 修改 |\ref| 命令,不再包含除编号外的内容

\item[v0.4c 2004/07/26]
增加判断以避免嵌套定义 |\setcounter| 和 |\addtocounter|

\item[v0.4b 2004/07/13]
|\baselinestretch|: 把 |\baselinestretch| 从 1.2 改为 1.3

\item[v0.4a 2004/05/15]
|\CTEXdigits|: 增加 |\CTEXdigits| 命令;
|\ziju|: 修改 CCT 的字距命令使得缩进保持一致

\item[v0.4 2004/05/13]
General: 如果指定了标准的 \LaTeX{} 字体大小,则不使用中文字号;
中文字号定义改为直接使用 pt 为单位;
|\zihao|: 删除 |\CTEX@fontsize| 命令,改为直接使用 |\fontsize| 命令

\item[v0.3b 2004/05/11]
General: 增加 fancyhdr 选项

\item[v0.3a 2004/04/30]
General: 修改命令 |\CCTpuncttrue| 的拼写错误

\item[v0.3 2004/04/24]
General: 对页眉设置进行微调;
对中文标题的章节编号格式进行调整,去掉 |\S|;
修改为使用 |\chinese| 命令以避免产生错误;
修正 sub3section 和 sub4section 选项无效的问题;
增加对图表标题分隔符的设置;
|\ps@fancy|: 解决与 fancyhdr 的冲突

\item[v0.2d 2004/04/23]
General: Change option c5size to base on 10pt basic class;
补上字号定义中行间距参数中缺少的 |\CTEX@bp|;
修改缺省的字号大小

\item[v0.2c 2004/02/13]
General: Add CJKpunct as standard configuration;
|\ifCTEX@punct|: 增加判断是否调整中文标点宽度的选项

\item[v0.2b 2004/02/13]
General: 修改缺省的行距;
修改缺省的字号大小

\item[v0.2a 2004/02/11]
|\baselinestretch|: 增加对行距的设置;
|\CTEX@spaceChar|: 加快处理速度,改善和 CJKpunct 的兼容性

\item[v0.2 2004/01/16]
General: Add support for CCT;
增加部分修改标题格式设置的选项;
增加修改标题前后空距设置的选项;
|\CTEXsetfont|: |\CTEXfontinfo| 命令改为 |\CTEXsetfont|;
|\ziju|: 参数的单位由绝对距离改为相对于当前汉字大小的倍数

\item[v0.1f 2003/12/24]
|\refname|: 修正 article 类中参考文献标题没有使用中文的问题

\item[v0.1e 2003/11/05]
|\refstepcounter|: 修正 |\ref| 命令后多出空格的问题

\item[v0.1d 2003/09/27]
|\addtocounter|: 将对 |\setcounter| 和 |\addtocounter| 的修改放到导言的最后以和其他宏包兼容

\item[v0.1c 2003/08/19]
General: 去掉生成的 .out 文件里章的标题前的多余空格

\item[v0.1b 2003/08/17]
|\zihao|: 删除多余的 |\newcount| 命令

\item[v0.1a 2003/08/15]
General: 修正 ctex.sty 中无法使用 sub3section 和 sub4section 选项的问题

\item[v0.1 2003/08/15]
General: First beta release

\item[v0.0 2003/04/26] General: Initial version

\end{description}


\section{开发人员}

\begin{itemize}

\item 吴凌云 (\email{aloft@ctex.org})
\item 江疆 (\email{gzjjgod@gmail.com})
\item 王越 (\email{yuleopen@gmail.com})
\item 刘海洋 (\email{LeoLiu.PKU@gmail.com})
\item LiYanrui.m2 (LiYanrui)
\item 陈之初 (Neals)

\end{itemize}

\end{document}