blob: 3229c41c82dfc8a8ed3d7cdf22039e687ded2736 (
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
|
% ctex-common.def: common definitions for all ctex packages/classes
% vim:ft=tex
\@ifclassloaded{article}{\def\CTEX@cls@article{}}{}
\@ifclassloaded{report}{\def\CTEX@cls@report{}}{}
\@ifclassloaded{book}{\def\CTEX@cls@book{}}{}
% Load some extra packages
\RequirePackage{ifpdf}
\RequirePackage{ifxetex}
\ifxetex
\CTEX@GBKfalse % XeTeX always uses UTF-8 as default encoding
\fi
\RequirePackage{keyval}[1999/03/16]
\ifCTEX@indent
\RequirePackage{indentfirst}
\fi
\RequirePackage{fix-cm}
\ifCTEX@fancyhdr
\RequirePackage{fancyhdr}
\fi
% Useful definitions
\DeclareRobustCommand\CTeX{C\kern-.05em\TeX{}}
\newcommand*\CTEX@key{\define@key{CTEX}}
\newcommand*\CTEXoptions[1][]{\setkeys{CTEX}{#1}}
\newcommand*\CTEX@subkey[1]{\define@key{CTEX#1}}
\newcommand*\CTEXsetup[2][]{\setkeys{CTEX#2}{#1}}
\def\ifCTEX@cls#1{%
\expandafter\ifx\csname CTEX@cls@#1\endcsname\relax
\expandafter\@secondoftwo
\else
\expandafter\@firstoftwo
\fi}
\def\CTEX@replacecommand#1#2#3{%
\expandafter\expandafter\expandafter\let\expandafter
\csname #1#3\expandafter\endcsname
\csname #2#3\endcsname
\expandafter\expandafter\expandafter\def\expandafter
\csname #2#3\expandafter\endcsname
{\csname #1#3\endcsname}}
% Set our hooks
\let\CTEX@begindocumenthook\@empty
\let\CTEX@enddocumenthook\@empty
\let\CTEX@save@begindocumenthook\@begindocumenthook
\let\CTEX@save@enddocumenthook\@enddocumenthook
\def\@begindocumenthook{\CTEX@save@begindocumenthook\CTEX@begindocumenthook}
\def\@enddocumenthook{\CTEX@enddocumenthook\CTEX@save@enddocumenthook}
\def\AtBeginDocument{\g@addto@macro\CTEX@save@begindocumenthook}
\def\AtEndDocument{\g@addto@macro\CTEX@save@enddocumenthook}
\def\CTEX@AtBeginDocument{\g@addto@macro\CTEX@begindocumenthook}
\def\CTEX@AtEndDocument{\g@addto@macro\CTEX@enddocumenthook}
% Select engine: xetex has the highest priority, if not,
% then try cct, otherwise we use traditional cjk.
\ifxetex
\input{ctex-xecjk-engine.def}
\else
\ifCTEX@cct
\input{ctex-cct-engine.def}
\else
\input{ctex-cjk-engine.def}
\fi
\fi
\AtEndOfPackage{%
\makeatletter
\ifCTEX@GBK
\input{ctex-gbk.def}
\else
\input{ctex-utf8.def}
\fi\makeatother}
\newcommand*\CTEXindent{\CTEXsetfont\parindent2\ccwd}
\newcommand*\CTEXnoindent{\parindent\z@}
\ifCTEX@indent
\CTEX@AtBeginDocument{\CTEXindent}
\fi
\def\CTEX@spaceChar{\hskip \f@size \p@}
\def\baselinestretch{1.3}
% About font sizing
\def\CTEX@fs@eight{5.02} \def\CTEX@fs@eightskip{6.02} %八号字 5bp
\def\CTEX@fs@seven{5.52} \def\CTEX@fs@sevenskip{6.62} %七号字 5.5bp
\def\CTEX@fs@ssix{6.52} \def\CTEX@fs@ssixskip{7.83} %小六号 6.5bp
\def\CTEX@fs@six{7.53} \def\CTEX@fs@sixskip{9.03} %六号字 7.5bp
\def\CTEX@fs@sfive{9.03} \def\CTEX@fs@sfiveskip{10.84} %小五号 9bp
\def\CTEX@fs@five{10.54} \def\CTEX@fs@fiveskip{12.65} %五号字 10.5bp
\def\CTEX@fs@sfour{12.05} \def\CTEX@fs@sfourskip{14.45} %小四号 12bp
\def\CTEX@fs@four{14.05} \def\CTEX@fs@fourskip{16.86} %四号字 14bp
\def\CTEX@fs@sthree{15.06} \def\CTEX@fs@sthreeskip{18.07} %小三号 15bp
\def\CTEX@fs@three{16.06} \def\CTEX@fs@threeskip{19.27} %三号字 16bp
\def\CTEX@fs@stwo{18.07} \def\CTEX@fs@stwoskip{21.68} %小二号 18bp
\def\CTEX@fs@two{22.08} \def\CTEX@fs@twoskip{26.50} %二号字 22bp
\def\CTEX@fs@sone{24.09} \def\CTEX@fs@soneskip{28.91} %小一号 24bp
\def\CTEX@fs@one{26.10} \def\CTEX@fs@oneskip{31.32} %一号字 26bp
\def\CTEX@fs@szero{36.14} \def\CTEX@fs@szeroskip{43.36} %小初号 36bp
\def\CTEX@fs@zero{42.16} \def\CTEX@fs@zeroskip{50.59} %初号字 42bp
\DeclareMathSizes{\CTEX@fs@eight}{\CTEX@fs@eight}{5}{5}
\DeclareMathSizes{\CTEX@fs@seven}{\CTEX@fs@seven}{5}{5}
\DeclareMathSizes{\CTEX@fs@ssix}{\CTEX@fs@ssix}{5}{5}
\DeclareMathSizes{\CTEX@fs@six}{\CTEX@fs@six}{5}{5}
\DeclareMathSizes{\CTEX@fs@sfive}{\CTEX@fs@sfive}{6}{5}
\DeclareMathSizes{\CTEX@fs@five}{\CTEX@fs@five}{7}{5}
\DeclareMathSizes{\CTEX@fs@sfour}{\CTEX@fs@sfour}{8}{6}
\DeclareMathSizes{\CTEX@fs@four}
{\CTEX@fs@four}{\CTEX@fs@five}{\CTEX@fs@six}
\DeclareMathSizes{\CTEX@fs@sthree}
{\CTEX@fs@sthree}{\CTEX@fs@sfour}{\CTEX@fs@sfive}
\DeclareMathSizes{\CTEX@fs@three}
{\CTEX@fs@three}{\CTEX@fs@four}{\CTEX@fs@five}
\DeclareMathSizes{\CTEX@fs@stwo}
{\CTEX@fs@stwo}{\CTEX@fs@sthree}{\CTEX@fs@sfour}
\DeclareMathSizes{\CTEX@fs@two}
{\CTEX@fs@two}{\CTEX@fs@three}{\CTEX@fs@four}
\DeclareMathSizes{\CTEX@fs@sone}
{\CTEX@fs@sone}{\CTEX@fs@stwo}{\CTEX@fs@sthree}
\DeclareMathSizes{\CTEX@fs@one}
{\CTEX@fs@one}{\CTEX@fs@two}{\CTEX@fs@three}
\DeclareMathSizes{\CTEX@fs@szero}
{\CTEX@fs@szero}{\CTEX@fs@sone}{\CTEX@fs@stwo}
\DeclareMathSizes{\CTEX@fs@zero}
{\CTEX@fs@zero}{\CTEX@fs@one}{\CTEX@fs@two}
\def\CTEX@zihao{}
\DeclareRobustCommand*\zihao[1]{\def\CTEX@zihao{#1}%
\ifnum #11<0%
\@tempcnta=-#1
\ifcase\@tempcnta%
\fontsize\CTEX@fs@szero\CTEX@fs@szeroskip%
\or \fontsize\CTEX@fs@sone\CTEX@fs@soneskip%
\or \fontsize\CTEX@fs@stwo\CTEX@fs@stwoskip%
\or \fontsize\CTEX@fs@sthree\CTEX@fs@sthreeskip%
\or \fontsize\CTEX@fs@sfour\CTEX@fs@sfourskip%
\or \fontsize\CTEX@fs@sfive\CTEX@fs@sfiveskip%
\or \fontsize\CTEX@fs@ssix\CTEX@fs@ssixskip%
\else \PackageError{ctex}{%
Undefined Chinese font size in command \protect\zihao}{%
The old font size is used if you continue.}%
\fi%
\else%
\@tempcnta=#1
\ifcase\@tempcnta%
\fontsize\CTEX@fs@zero\CTEX@fs@zeroskip%
\or \fontsize\CTEX@fs@one\CTEX@fs@oneskip%
\or \fontsize\CTEX@fs@two\CTEX@fs@twoskip%
\or \fontsize\CTEX@fs@three\CTEX@fs@threeskip%
\or \fontsize\CTEX@fs@four\CTEX@fs@fourskip%
\or \fontsize\CTEX@fs@five\CTEX@fs@fiveskip%
\or \fontsize\CTEX@fs@six\CTEX@fs@sixskip%
\or \fontsize\CTEX@fs@seven\CTEX@fs@sevenskip%
\or \fontsize\CTEX@fs@eight\CTEX@fs@eightskip%
\else \PackageError{ctex}{%
Undefined Chinese font size in command \protect\zihao}{%
The old font size is used if you continue.}%
\fi%
\fi%
\selectfont\ignorespaces}
% About numbers
\newif\ifCTEX@zero@
\newif\ifCTEX@previous@
\newif\ifCTEX@null@
\newcount\CTEX@q
\newcount\CTEX@r
\def\CTEX@appendstring#1#2{%
\expandafter\def\expandafter#1\expandafter{#1#2}}
\def\CTEX@appendnumber#1#2{%
\ifcase #2\relax
\ifCTEX@null@
\CTEX@appendstring{#1}{\CTEX@null}%
\else
\CTEX@appendstring{#1}{\CTEX@zero}%
\fi
\or \CTEX@appendstring{#1}{\CTEX@one}%
\or \CTEX@appendstring{#1}{\CTEX@two}%
\or \CTEX@appendstring{#1}{\CTEX@three}%
\or \CTEX@appendstring{#1}{\CTEX@four}%
\or \CTEX@appendstring{#1}{\CTEX@five}%
\or \CTEX@appendstring{#1}{\CTEX@six}%
\or \CTEX@appendstring{#1}{\CTEX@seven}%
\or \CTEX@appendstring{#1}{\CTEX@eight}%
\or \CTEX@appendstring{#1}{\CTEX@nine}%
\fi}
\def\CTEX@splitnumber#1{%
\CTEX@q #1\relax
\CTEX@r #1\relax
\divide\CTEX@q \@M
\begingroup
\multiply\CTEX@q \@M
\advance\CTEX@r -\CTEX@q
\ifnum\CTEX@r = \z@
\xdef\CTEX@low{}%
\else
\xdef\CTEX@low{\number\CTEX@r}%
\fi
\endgroup
\ifnum\CTEX@q > \z@
\CTEX@r \CTEX@q
\divide\CTEX@q \@M
\begingroup
\multiply\CTEX@q \@M
\advance\CTEX@r -\CTEX@q
\ifnum\CTEX@r = \z@
\xdef\CTEX@high{}%
\else
\xdef\CTEX@high{\number\CTEX@r}%
\fi
\endgroup
\ifnum\CTEX@q > \z@
\xdef\CTEX@yi{\number\CTEX@q}%
\else
\xdef\CTEX@yi{}%
\fi
\else
\xdef\CTEX@high{}%
\xdef\CTEX@yi{}%
\fi
}
\def\CTEX@processnumber#1#2{%
\CTEX@zero@false
\CTEX@q #2\relax
\CTEX@r #2\relax
\divide\CTEX@q \@m
\ifnum\CTEX@q = \z@
\ifCTEX@previous@
\CTEX@zero@true
\fi
\else
\ifCTEX@zero@
\CTEX@appendstring{#1}{\CTEX@zero}%
\fi
\CTEX@appendnumber{#1}{\CTEX@q}%
\CTEX@appendstring{#1}{\CTEX@thousand}%
\CTEX@previous@true
\CTEX@zero@false
\fi
\multiply\CTEX@q \@m
\advance\CTEX@r -\CTEX@q
\CTEX@q \CTEX@r
\divide\CTEX@q 100\relax
\ifnum\CTEX@q = \z@
\ifCTEX@previous@
\CTEX@zero@true
\fi
\else
\ifCTEX@zero@
\CTEX@appendstring{#1}{\CTEX@zero}%
\fi
\CTEX@appendnumber{#1}{\CTEX@q}%
\CTEX@appendstring{#1}{\CTEX@hundred}%
\CTEX@previous@true
\CTEX@zero@false
\fi
\multiply\CTEX@q 100
\advance\CTEX@r -\CTEX@q
\CTEX@q \CTEX@r
\divide \CTEX@q 10\relax
\ifnum\CTEX@q = \z@
\ifCTEX@previous@
\CTEX@zero@true
\fi
\else
\ifCTEX@zero@
\CTEX@appendstring{#1}{\CTEX@zero}%
\fi
\ifnum\CTEX@q = \@ne
\ifCTEX@previous@
\CTEX@appendstring{#1}{\CTEX@one}%
\fi
\else
\CTEX@appendnumber{#1}{\CTEX@q}%
\fi
\CTEX@appendstring{#1}{\CTEX@ten}%
\CTEX@previous@true
\CTEX@zero@false
\fi
\multiply\CTEX@q 10
\advance\CTEX@r -\CTEX@q
\ifnum\CTEX@r = \z@
\else
\ifCTEX@zero@
\CTEX@appendstring{#1}{\CTEX@zero}%
\fi
\CTEX@appendnumber{#1}{\CTEX@r}%
\CTEX@previous@true
\fi}
\DeclareRobustCommand\CTEXnumber[2]{%
\def#1{}%
\CTEX@null@false
\CTEX@q #2\relax
\ifnum\CTEX@q < \z@
\multiply\CTEX@q \m@ne
\CTEX@appendstring{#1}{\CTEX@minus}%
\fi
\CTEX@previous@false
\CTEX@zero@false
\ifnum\CTEX@q = \z@
\CTEX@appendstring{#1}{\CTEX@zero}%
\else
\CTEX@splitnumber{\CTEX@q}%
\ifx\CTEX@yi \@empty
\else
\CTEX@processnumber{#1}{\CTEX@yi}%
\CTEX@appendstring{#1}{\CTEX@hundredmillion}%
\fi
\ifx\CTEX@high \@empty
\else
\CTEX@processnumber{#1}{\CTEX@high}%
\CTEX@appendstring{#1}{\CTEX@tenthousand}%
\fi
\ifx\CTEX@low \@empty
\else
\ifx\CTEX@yi \@empty
\else
\ifx\CTEX@high \@empty
\CTEX@appendstring{#1}{\CTEX@zero}% this catches 100002345
\fi
\fi
\CTEX@processnumber{#1}{\CTEX@low}%
\fi
\fi}
\def\CTEX@getdigit#1#2\@nil{%
\edef\CTEX@tempa{#1}%
\edef\CTEX@tempb{#2}}
\DeclareRobustCommand\CTEXdigits[2]{%
\def#1{}%
\CTEX@null@true
\edef\CTEX@tempa{}%
\edef\CTEX@tempb{#2}%
\ifx\CTEX@tempb \@empty
\else
\loop
\expandafter\CTEX@getdigit\CTEX@tempb\@nil
\CTEX@appendnumber{#1}{\CTEX@tempa}%
\ifx\CTEX@tempb \@empty
\else
\repeat
\fi}
\DeclareRobustCommand\CTEXcounter[1]{%
\@ifundefined{c@#1}{}{%
\CTEXnumber{\reserved@a}{\@arabic\csname c@#1\endcsname}%
\expandafter\expandafter\expandafter\def%
\expandafter\expandafter\csname cc@#1\endcsname%
\expandafter{\reserved@a}}}
\CTEX@AtBeginDocument{%
\makeatletter%
\@ifundefined{CTEX@save@setcounter}{%
\let\CTEX@save@setcounter\setcounter%
\def\setcounter#1#2{%
\CTEX@save@setcounter{#1}{#2}%
\CTEXcounter{#1}}}{}
\@ifundefined{CTEX@save@addtocounter}{%
\let\CTEX@save@addtocounter\addtocounter%
\def\addtocounter#1#2{%
\CTEX@save@addtocounter{#1}{#2}%
\CTEXcounter{#1}}}{}
\@ifundefined{CTEX@save@stepcounter}{%
\let\CTEX@save@stepcounter\stepcounter%
\def\stepcounter#1{%
\CTEX@save@stepcounter{#1}%
\CTEXcounter{#1}}}{}
\makeatother}
\def\chinese#1{%
\@ifundefined{cc@#1}{\CTEX@null}{\csname cc@#1\endcsname}}
\def\Chinese#1{\CTEXcounter{#1}\chinese{#1}}
% About caption
\ifCTEX@caption
\let\CTEX@save@refstepcounter\refstepcounter
\def\refstepcounter#1{\CTEX@save@refstepcounter{#1}%
\protected@edef\@currentlabel
{\csname p@#1\endcsname%
\@ifundefined{CTEX@the#1}%
{\csname the#1\endcsname}%
{\csname CTEX@the#1\endcsname}%
}}%
\fi
% `today' definitions
\let\CTEX@todayold\today
\ifCTEX@caption
\renewcommand*\today{\CTEX@todaysmall}
\fi
\CTEX@key{today}{\CTEX@settoday{#1}}
\newcommand*\CTEX@settoday[1]{%
\@ifundefined{CTEX@today#1}
{\PackageError{ctex}{%
unknown today format}{%
Available today format are "old", "small", and "big".}}
{\renewcommand*\today{\csname CTEX@today#1\endcsname}}}
% Put hyperref as bottom as possible, otherwise there may be page
% count issues
\AtEndOfPackage{%
\ifCTEX@hyperref
\ifxetex
\RequirePackage{hyperref}
\else
\ifpdf % pdftex
\RequirePackage[pdftex]{hyperref}
\else % dvipdfmx
\ifCTEX@GBK
\AtBeginDvi{\special{pdf:tounicode GBK-EUC-UCS2}}
\fi
\RequirePackage[dvipdfmx]{hyperref}
\fi
\ifCTEX@GBK
\hypersetup{CJKbookmarks=true}
\else
\hypersetup{unicode=true}
\fi
\fi
\hypersetup{colorlinks=true}
\fi}
\endinput
|