summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/xelatex/xecjk/tex/xeCJK-manual.tex
blob: cecc61f71c8ab5618c6d6741d8fb2a566e89f6c1 (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
% -*- coding: utf-8 -*-
\documentclass[11pt,a4paper]{article}
\textwidth 150mm
\textheight 220mm
\oddsidemargin 0pt
\def\xeCJK{xeCJK}
\usepackage{color}
\usepackage{xeCJK}
\setCJKmainfont{Bitstream CyberCJK}
\setmainfont{TeX Gyre Termes}% 设置缺省英文字体
\begin{document}
\title{The \xeCJK\ Package }
\author{Wenchang Sun (xecjk@yahoo.cn)}
\date{\today}
\maketitle
\parskip 5pt
\parindent 2em

\section{Main features}
With \xeCJK, one can
\begin{enumerate}
\item specify different default fonts for CJK and other characters, respectively.
\item set bold and/or slant fonts for CJK characters easily.
\item automatically ignore spaces between CJK characters.
\item get better output for full-width CJK punctuation.
\item adjust spaces between CJK and other characters automatically.
\end{enumerate}


\section{Usage}

To use \xeCJK, one need some version of XeTeX after [2008/03/07].

\begin{verbatim}
   \usepackage[options]{xeCJK}
\end{verbatim}

\noindent
Options:

\def\arraystretch{1.5}
\begin{tabular}{lp{100mm}}
   [BoldFont]:  &  Create "synthetic bold" fonts for CJK characters.
                  Will be overridden by specifying {BoldFont}
                  in the definition of a CJK family.
\\
  {}[ItalicFont]: & Create slanted fonts for CJK characters.
                  Will be overridden by specifying {ItalicFont}
                  in the definition of a CJK family.
\\
 {}[CJKnumber]:  & Load the CJKnumb package.
\\
 {}[CJKaddspaces]:&Add spaces between CJK and other characters.
\\
  {}[CJKnorspaces]:&Ignore only spaces between CJK characters while leave spaces
                  between CJK and other characters as they are.
\end{tabular}

\section{Font selection}
\xeCJK\ provides the following macros for font selection:
\begin{verbatim}
  \setCJKmainfont[<font features>]{<font name>}
  \setCJKsansfont[<font features>]{<font name>}
  \setCJKmonofont[<font features>]{<font name>}
  \setCJKfamilyfont{<family name>}[<font features>]{<font name>}
\end{verbatim}

The first three macros are analogs of

\verb+    \setmainfont+, \verb+\setsansfont+, and \verb+\setmonofont+,

\noindent
respectively.
The only different is that they effect only CJK characters.

The last macro sets a font for a CJK family which will be  called by

\verb+    \CJKfamily{<family name>}+.

With these macros, one can set different default fonts for CJK and other characters,
respectively.

For a full description on the parameters \verb+<font features>+ and \verb+<font name>+,
we refer to the package \verb+fontspec+.

\section{Advanced settings}

\subsection{Set the slant and embolden factors}

One can use the following macros
\begin{verbatim}
  \xeCJKsetslantfactor{<slant factor>}
  \xeCJKsetemboldenfactor{<embolden factor>}
\end{verbatim}
to set the slant and embolden factors, respectively. The default settings are
\begin{verbatim}
  \xeCJKsetslantfactor{0.17}
  \xeCJKsetemboldenfactor{4}
\end{verbatim}

Note that both macros effect only CJK families defined after them.




\subsection{Language selection}

Use \verb+\CJKlanguage{<language spec>}+ to load language-dependent settings.
This feature is intended to add glue around punctuation for better typesetting.
Currently, only the followings are valid:
\begin{verbatim}
  \CJKlanguage{Chinese-Simp} % Simplified Chinese (default)
  \CJKlanguage{Chinese-Trad} % Traditional Chinese
  \CJKlanguage{Japanese}     % Japanese
  \CJKlanguage{Korean}       % Korean
\end{verbatim}


Use \verb+\punctstyle{<style>}+ to select punctuation style.
\xeCJK\ predefines 4 style for typesetting full-width punctuation.


\begin{tabular}{lp{100mm}}
style& \\
quanjiao& typeset all punctuation in full-width,
            for two adjoint punctuation, the first is typeset
            in half-width.
\\
banjiao & typeset all punctuation in half-width.
\\
kaiming & typeset all punctuation in half-width except
            the period, question, and exclamation marks.
\\
CCT     & a style used in CCT.
\end{tabular}

\noindent Examples:
\long\def\sometexts{计算机(computer / calculation machine)是总称,一般在学术性或正式场合使用。
在通常用语中,计算机一般指电子计算机中用的个人电脑。
计算机是一种能够按照指令对各种数据和信息进行自动加工和处理的电子设备。
它由多个零配件组成,如中央处理器、主板、内存、电源、显卡等。接收、
处理和提供数据的一种装置,通常由输入输出设备、存储器、运算和逻辑
部件以及控制器组成;有模拟式、数字式及混合式三种类型。}

{\color{blue}
\verb+\punctstyle{quanjiao}+

\punctstyle{quanjiao}\sometexts}

\verb+\punctstyle{banjiao}+

\punctstyle{banjiao}\sometexts

{\color{blue}
\verb+\punctstyle{kaiming}+

\punctstyle{kaiming}\sometexts}

To get better performance on the typeset of full-width punctuation, one need to build
font-dependent tbl files. We provide some scripts to do this.
See utils/xeCJK/make-tbl-file/readme.txt for details.


\subsection{Spaces between CJK and other characters}

By default, \xeCJK\ leaves spaces between CJK and other characters
as they are while it ignores spaces between CJK characters.
One can use \verb+\CJKaddspaces+ to add a space between CJK and
 other characters if a blank space is not present.
And use \verb+\CJKnormalspaces+ to change to the default.

An example for \verb+\CJKaddspaces+

\CJKaddspaces
The input
\begin{verbatim}
  这是 English 中文 $x=y$ 数学 \textit{Chinese} {\bfseries 中文} \LaTeX\
  间隔 {\itshape Italic} 字体\par
  这是English中文$x=y$数学\textit{Chinese}{\bfseries 中文}\LaTeX\
  间隔{\itshape Italic}字体\par
\end{verbatim}

The output

这是 English 中文 $x=y$ 数学 \textit{Chinese} {\bfseries 中文} \LaTeX\
间隔 {\itshape Italic} 字体\par
这是English中文$x=y$数学\textit{Chinese}{\bfseries 中文}\LaTeX\
间隔{\itshape Italic}字体\par


\section{Compatibility}

\subsection{CJKfntef}

Load \verb+CJKfntef+ after \verb+xeCJK+ to get various effects on CJK characters.

\CJKnormalspaces
Load \verb+CJKfntef+ after \verb+xeCJK+ to get various effects on CJK characters.


\subsection{CJKnumber}

To use the package \verb+CJKnumb+, one can specify the option [CJKnumber] while loading \xeCJK.


\subsection{CJK}
To be compatible with some CJK-related packages, e.g., \texttt{CJKnumb},
\texttt{CJKfntef}, \texttt{CJKulem}, \xeCJK\ re-defines some macros in the package \texttt{CJK}
and it is not compatible with the later.
In fact, \xeCJK\ prevents automatically from loading \texttt{CJK} after \xeCJK.






\end{document}