summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/xelatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-07-20 00:40:16 +0000
committerKarl Berry <karl@freefriends.org>2009-07-20 00:40:16 +0000
commit05ce59d3f94be6128b7840f17ce476c614356551 (patch)
tree4be64fa7c50a698a552dbbd826cc488e729c0e51 /Master/texmf-dist/source/xelatex
parentbefa55daf259a7f10fdcfe9bc77813d9d0c46abe (diff)
new xelatex package xecjk (5jul09)
git-svn-id: svn://tug.org/texlive/trunk@14329 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/xelatex')
-rw-r--r--Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx1764
1 files changed, 1764 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
new file mode 100644
index 00000000000..a71a45a66a8
--- /dev/null
+++ b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
@@ -0,0 +1,1764 @@
+% \iffalse
+%<*internal>
+\iffalse
+%</internal>
+%<*readme>
+
+xeCJK is a package written for XeLaTeX which allows users to typeset
+CJK scripts easily.
+
+
+ - different default fonts for CJK and other characters;
+ - spaces automatically ignored between CJK characters;
+ - special effects on full-width CJK punctuation; and
+ - automatic adjustment of the space between CJK and other characters.
+
+%</readme>
+%<*internal>
+\fi
+%</internal>
+%
+%<*internal>
+\begingroup
+%</internal>
+%<*batchfile>
+\input docstrip.tex
+\keepsilent
+\preamble
+
+ Version 2.3.0 (30-June-2009)
+
+ Copyright (C) Wenchang Sun <sunwch@hotmail.com>
+
+ This file may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either version 1.3
+ of this license or (at your option) any later version.
+ The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+ and version 1.3 or later is part of all distributions of LaTeX
+ version 2005/12/01 or later.
+
+\endpreamble
+\askforoverwritefalse
+\generate{\file{xeCJK.sty}{\from{xeCJK.dtx}{xeCJK}}}
+\generate{\file{example-addspaces.tex}{\from{xeCJK.dtx}{example-addspaces}}}
+\generate{\file{example-CJKchecksingle.tex}{\from{xeCJK.dtx}{example-CJKchecksingle}}}
+\generate{\file{example-CJKfntef.tex}{\from{xeCJK.dtx}{example-CJKfntef}}}
+%</batchfile>
+%<batchfile>\endbatchfile
+%<*internal>
+\generate{\file{xeCJK.ins}{\from{xeCJK.dtx}{batchfile}}}
+\nopreamble\nopostamble
+\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}}
+\endgroup
+%</internal>
+%
+%<*driver>
+\documentclass[12pt]{ltxdoc}
+\usepackage{xcolor}
+\usepackage[bookmarks=true,bookmarksopen=true,dvipdfm,pdfstartview=FitH]{hyperref}
+\usepackage[BoldFont,SlantFont,CJKnumber,CJKaddspaces,CJKchecksingle]{xeCJK}
+\textheight 210mm
+\textwidth 150mm
+\oddsidemargin 0pt
+\evensidemargin 0pt
+\defaultfontfeatures{Mapping=tex-text}
+\ifcsname CJKmainfont\endcsname
+\else
+ \def\CJKmainfont{Bitstream CyberCJK}
+\fi
+\setCJKmainfont{\CJKmainfont}% 设置缺省中文字体
+\setCJKmonofont[Scale=1.1]{\CJKmainfont}% 设置 中文字体
+\setCJKfamilyfont{song}{\CJKmainfont}% 设置 中文字体
+\def\xeCJK{{\textcolor{blue}{\texttt{xeCJK}}}}
+% macros
+{\catcode`\|=0 \catcode`\\=12
+ |gdef|bslash{\}}
+
+\newcommand{\defmacro}[1]{% % Define a macro.
+ \textcolor{macrocolor}{\string#1}\index{\string\verb+\string#1+}%
+}
+
+\newcommand{\usemacro}[1]{% % Define a macro.
+ \textcolor{macrocolor}{\string#1}%
+ #1\index{\string\verb+\string#1+}%
+}
+
+\definecolor{parametercolor}{rgb}{1,0,1}
+\definecolor{optioncolor}{rgb}{0,0,1}
+\definecolor{macrocolor}{rgb}{0,0,0.63}
+
+\newcommand{\usepmacro}[3][]{%
+ \edef\tempa{#1}%
+ \textcolor{macrocolor}{\string#2}%
+ \string{\textcolor{parametercolor}{#3}\string}%
+ \ifx\tempa\@empty\else (#1)\fi%
+ #2{#3}\index{\string\verb+\string#2+}%
+}
+
+\newenvironment{decl}[1][]%
+ {\par\small\addvspace{4.5ex plus 1ex}%
+ \vskip -\parskip
+ \ifx\relax#1\relax
+ \def\@decl@date{}%
+ \else
+ \def\@decl@date{\NEWfeature{#1}}%
+ \fi
+ \noindent\hspace{-\leftmargini}%
+ \begin{tabular}{|l|}\hline\ignorespaces}%
+ {\\\hline\end{tabular}\nobreak\@decl@date\par\nobreak
+ \vspace{2.3ex}\vskip -\parskip}
+
+\renewcommand{\arg}[1]{{\tt\string{}\m{#1}{\tt\string}}}
+\newcommand{\m}[1]{\mbox{\color{parametercolor}$\langle$\it #1\/$\rangle$}}
+
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+\ifxetex
+ \DocInput{xeCJK.dtx}
+ \makeatletter
+ \c@IndexColumns = 2
+ \PrintIndex
+\else
+ \makeatletter
+ \@latex@error{Use XeLaTeX to compile this file.}
+\fi
+\end{document}
+%</driver>
+%
+%<*xeCJK>
+\def\fileversion{2.3.0}
+\def\filedate{2009/06/30}
+\ProvidesPackage{xeCJK}[\filedate\space\fileversion]
+%</xeCJK>
+%
+% \fi
+%
+% \makeatletter ^^A% To document @-cmds
+% \errorcontextlines=999 ^^A% Show up all my mistakes
+%
+% \GetFileInfo{xeCJK.sty}
+%
+% \title{\hypertarget{Chinese}{xeCJK 宏包}
+% \hbox to 0pt{\hskip 40mm\hyperlink{English}{\normalsize\texttt{English Version}}}}
+% \author{孙文昌}
+% \date{}
+% \maketitle
+%
+% \newpage
+%
+% \section{简介}
+% \parindent 2em
+% \parskip 5pt
+%
+% \xeCJK\ 是一个 XeLaTeX 宏包,用于排版 CJK 文字,包括字体选择、标点控制等。主要特点:
+% \begin{enumerate}
+% \item 分别设置CJK和英文字体;
+% \item 自动忽略CJK文字间的空格而保留其它空格,允许在非标点汉字和英文字母 (a-z, A-Z) 间断行;
+% \item 提供多种标点处理方式: 全角式、半角式、开明式、行末半角式;
+% \item 自动调整中英文间空白。
+% \end{enumerate}
+%
+% \long\def\sometextsa{\xeCJK\ 是在CCT和CJK包基础上发展起来的,
+% 支持多种标点格式。例如,“标点挤压”。\xeCJK\ 是在CCT和CJK包基础上
+% 发展起来的,支持多种标点格式。例如,“标点挤压”。}
+%
+%
+% \usepmacro[全角式]{\punctstyle}{quanjiao}
+%
+% \sometextsa
+%
+% \usepmacro[半角式]{\punctstyle}{banjiao}
+%
+% \sometextsa
+%
+%
+% \usepmacro[开明式]{\punctstyle}{kaiming}
+%
+% \sometextsa
+%
+% \usepmacro[行末半角式]{\punctstyle}{hangmobanjiao}
+%
+% \sometextsa
+%
+% {\usepmacro[plain]{\punctstyle}{plain}
+%
+% \sometextsa}
+%
+% \punctstyle{kaiming}
+%
+% \section{使用方法}
+%
+% \xeCJK\ 使用了 XeTeX 的一些最新特性, 需要 XeTeX 0.9995.0 [2009/06/29] 以后的版本。
+%
+%
+%
+% \begin{decl}
+% \defmacro{\usepackage}[\textcolor{optioncolor}{Options}]
+% \{\textcolor{parametercolor}{xeCJK}\}
+% \end{decl}
+%
+% \begin{tabular}{ll}
+% Options & \\
+% BoldFont:& 启用CJK\textbf{粗体字}\\
+% SlantFont:& 启用CJK\textit{斜体字}\\
+% CJKnumber: & 调用CJKnumb宏包\\
+% CJKaddspaces:& 在中英文之间以及 \\
+% & 中文和行内数学表达式之间根据需要插入空格\\
+% & 并允许设置中英文之间的距离\\
+% CJKnormalspaces: & 忽略中文之间的空格但保留其它空格\\
+% CJKchecksingle: &避免单个汉字单独占一行。
+% \end{tabular}
+%
+%
+% \begin{decl}
+% \defmacro{\setCJKmainfont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\
+% \defmacro{\setCJKsansfont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\
+% \defmacro{\setCJKmonofont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\
+% \defmacro{\setCJKfamilyfont} \arg{family name}[\textcolor{optioncolor}
+% {<font features>}]\arg{font name}
+% \end{decl}
+% 分别设置缺省CJK字体、CJK sffamily、CJK ttfamily 和某个 CJKfamily 所对应中文字体,
+% 其中最后两个参数的意义请参考 \verb+\fontspec.+
+%
+% 如果在定义CJK字体时 指定了\texttt{ItalicFont=\{...\}},
+% 则宏包的\texttt{SlantFont}选项对该字体不起作用。
+% 类似地,可以指定\texttt{BoldFont=\{font name\}}以抑制
+% \texttt{BoldFont}选项。
+%
+%
+%
+%
+%
+% 与 CJK 包类似, 使用命令 \defmacro{\CJKfamily}\arg{family name} 改变当前中文字体。
+%
+%
+% \subsection*{例子}
+%
+% 以下命令设置缺省英文字体为 TeX Gyre Termes, 缺省中文字体为 Bitstream CyberCJK (宋体),
+% 最后一个命令设置 CJKfamily “song” 为 “AR PL SungtiL GB”
+% ({\CJKfamily{song}文鼎 PL简报宋})。
+% \begin{verbatim}
+% \setmainfont{TeX Gyre Termes}
+% \setCJKmainfont{Bitstream CyberCJK}
+% \setCJKfamilyfont{song}{AR PL SungtiL GB}
+% \end{verbatim}
+%
+% \noindent
+% 下表中, 左边为输入, 右边为排版效果:
+%
+% \begin{tabular}{ll}
+% \verb+这是缺省字体 abCD+ &这是缺省字体 abCD\\
+% \verb+\bfseries 这是缺省字体 abCD+ &{\bfseries 这是缺省字体 abCD}\\
+% \verb+\itshape 这是缺省字体 abCD+ &{\itshape 这是缺省字体 abCD}\\
+% \verb+\bfseries\itshape 这是缺省字体 abCD+ &\bfseries\itshape 这是缺省字体 abCD\\
+% \\
+% \verb+\CJKfamily{song}这是宋体+ &{\CJKfamily{song}这是宋体}\\
+% \end{tabular}
+%
+%
+%
+%
+%
+% \section{高级设置}
+%
+% \begin{decl}
+% \defmacro{\punctstyle}\arg{punct style}
+% \end{decl}
+%
+% 设置标点格式,有效值分别为
+%
+% \begin{tabular}{ll}
+% punct style & \\
+% \textcolor{parametercolor}{banjiao} & 半角式 \\
+% \textcolor{parametercolor}{quanjiao} & 全角式\\
+% \textcolor{parametercolor}{kaiming} & 开明式\\
+% \textcolor{parametercolor}{hangmobanjiao}& 行末半角式\\
+% \textcolor{parametercolor}{CCT} & CCT格式\\
+% \textcolor{parametercolor}{plain} & 原样(不调整标点间距)
+% \end{tabular}
+%
+%
+%
+% \begin{decl}
+% \defmacro{\xeCJKallowbreakbetweenpuncts} \\
+% \defmacro{\xeCJKnobreakbetweenpuncts}
+% \end{decl}
+%
+% 缺省状态下,\xeCJK\ 禁止在相邻的标点间换行。 使用
+%
+% \defmacro{\xeCJKallowbreakbetweenpuncts}\newline
+% 改变这一设置。
+%
+% \begin{decl}
+% \defmacro{\xeCJKsetslantfactor}\arg{slant factor}\\
+% \defmacro{\xeCJKsetemboldenfactor}\arg{embolden factor}
+% \end{decl}
+% 分别设置斜体和粗体的倾斜和粗细程度。
+% 其中 slant factor 的范围为 -0.999 $\sim$ 0.999. 缺省设置为
+%
+% \begin{verbatim}
+% \xeCJKsetslantfactor{0.17}
+% \xeCJKsetemboldenfactor{4}
+% \end{verbatim}
+%
+% 注意,这两个宏命令仅对随后定义的 CJK 字体有效。
+%
+%
+%
+% \begin{decl}
+% \defmacro{\CJKnormalspaces}\\
+% \defmacro{\CJKaddspaces}\\
+% \defmacro{\CJKsetecglue}
+% \end{decl}
+%
+%
+% \defmacro{\CJKnormalspaces}: 仅忽略CJK
+% 文字之间的空白,但保留中文与英文之间的空白。
+%
+%
+% \defmacro{\CJKaddspaces}(缺省值): 忽略CJK文字之间的空白,
+% 并且自动在中文与英文之间以及中文和行内数学表达式之间插入空白。
+% 允许调整中英文之间的距离。
+%
+% \defmacro{\CJKsetecglue}: 设置中英文间距. 缺省值为\defmacro{\CJKsetecglue\{ \}}。
+%
+%
+%
+% 可以在调用宏包时指定 \textcolor{optioncolor}{\ttfamily CJKaddspaces}
+% 选项以自动自动在中英文转换时插入空白。
+% 试比较:
+% \CJKnormalspaces
+% \begin{verbatim}
+% 这是 English 中文 \textit{Chinese} 中文 \LaTeX\
+% 中文\textbf{字体} a {\bfseries 数学} $c$ $d$-th\par
+% 这是English中文\textit{Chinese}中文\LaTeX\
+% 中文\textbf{字体}a{\bfseries 数学}$c$ $d$-th\par
+% \end{verbatim}
+%
+% \noindent
+% 使用 \usemacro{\CJKnormalspaces} 排版的效果:
+%
+% 这是 English 中文 \textit{Chinese} 中文 \LaTeX\
+% 中文\textbf{字体} a {\bfseries 数学} $c$ $d$-th\par
+% 这是English中文\textit{Chinese}中文\LaTeX\
+% 中文\textbf{字体}a{\bfseries 数学}$c$ $d$-th\par
+%
+% \noindent
+% 使用 \usemacro{\CJKaddspaces} 排版的效果:
+%
+% 这是 English 中文 \textit{Chinese} 中文 \LaTeX\
+% 中文\textbf{字体} a {\bfseries 数学} $c$ $d$-th\par
+% 这是English中文\textit{Chinese}中文\LaTeX\
+% 中文\textbf{字体}a{\bfseries 数学}$c$ $d$-th\par
+%
+% \noindent
+% 使用 \usemacro{\CJKaddspaces}\verb+\CJKsetecglue{\hskip 0.15em plus 0.05em minus 0.05em}+
+% \CJKsetecglue{\hskip 0.15em plus 0.05em minus 0.05em}
+% 排版的效果:
+%
+%
+% 这是 English 中文 \textit{Chinese} 中文 \LaTeX\
+% 中文\textbf{字体} a {\bfseries 数学} $c$ $d$-th\par
+% 这是English中文\textit{Chinese}中文\LaTeX\
+% 中文\textbf{字体}a{\bfseries 数学}$c$ $d$-th\par
+%
+% \noindent
+% 说明:
+% \begin{enumerate}
+%
+% \item \verb+{<texts>} {<texts>}+ 以及\verb+English {<texts>}+中间的空格会保留(不能调整),
+% 但若没有空格,则会根据需要添加(见上面的例子)。
+%
+% \item 中文与行内数学表达式的间隔控制是通过定义\string\everymath 和\string\everydisplay
+% 实现的,有时可能无效,
+% 解决方案是手动加空格。
+%\end{enumerate}
+%
+%
+%
+%
+%
+% \begin{decl}
+% \defmacro{\xeCJKsetcharclass}\arg{first}\arg{last}\arg{class}
+% \end{decl}
+%
+%
+% 缺省状态下,\xeCJK\ 把 0x2000 --- 0xFFFF 之间的字符看成 CJK 文字,即 CJK
+% 相关的字体设置(仅)对
+% 在此范围内的字符有效。
+% 可以使用上述宏命令
+% 改变字符类别。
+% 例如,以下命令设置 0x0080 --- 0x2FFF 之间的字符为非 CJK 文字,而 0x20000
+% --- 0x30000 之间的为 CJK 文字:
+% \begin{verbatim}
+% \xeCJKsetcharclass{"80}{"2FFF}{0}
+% \xeCJKsetcharclass{"20000}{"30000}{1}
+% \end{verbatim}
+% 注意:最后一个参数只能为 0 或 1。不要轻易改变字符类别。
+%
+%
+% \begin{decl}
+% \defmacro{\xeCJKcaption}[\textcolor{optioncolor}{<encoding>}]\arg{caption}
+% \end{decl}
+%
+% 与 \verb+\CJKcaption+ 类似,可选参数用以选择编码, 缺省为 UTF-8。
+%
+% \begin{decl}
+% \defmacro{\xeCJKsetkern}\arg{标点1}\arg{标点2}\arg{kern}
+% \end{decl}
+%
+% 如果对缺省配置不满意,可以使用此命令设置两个标点之间的距离。例如,
+%
+% \verb+\xeCJKsetkern{:}{“}{0.3em}+
+%
+%
+%
+% \section{兼容性}
+%
+% \subsection{CJKfntef}
+% 可以在 \xeCJK\ 包之后调入 CJKfntef 宏包, 以实现对汉字加点、下划线等。
+%
+% \subsection{CJKnumber}
+%
+% \verb+\CJKnumber{12345}+: \CJKnumber{12345}
+%
+% \subsection{CJK}
+% 为了与 CJKnumb, CJKulem 和 CJKfntef 包兼容,\xeCJK\ 重新定义了 CJK 包的部分宏命令,如
+% \verb+\CJKfamily+, \verb+\CJKsymbol+, \verb+\CJKpunctsymbol+ 等。
+%
+% 需要指出,\xeCJK\ 包不需要 CJK 包的支持,并且 \xeCJK\ 包自动禁止载入 CJK 包。
+%
+%
+% \title{ \hypertarget{English}{The xeCJK Package}
+% \hbox to 0pt{\hskip 40mm\hyperlink{Chinese}{\normalsize 中文版}} }
+% \author{Wenchang Sun}
+% \date{\today}
+% \maketitle
+%
+% \newpage
+%
+% \section{Main features}
+% The package \xeCJK\ allows XeLaTeX users to typeset CJK scripts easily.
+%
+%
+% \begin{enumerate}
+% \item different default fonts for CJK and other characters;
+% \item spaces automatically ignored between CJK characters;
+% \item special effects on full-width CJK punctuation; and
+% \item automatic adjustment of the space between CJK and other characters.
+% \end{enumerate}
+%
+% \section{Usage}
+%
+% To use \xeCJK, one need some version of XeTeX after [2008/03/07].
+%
+% \begin{decl}
+% \defmacro{usepackage}[\textcolor{optioncolor}{Options}]
+% \{\textcolor{parametercolor}{xeCJK}\}
+% \end{decl}
+%
+% \def\arraystretch{1.5}
+% \begin{tabular}{lp{90mm}}
+% Options & \\
+% BoldFont: & Create "synthetic bold" fonts for CJK characters.
+% Will be overridden by specifying {BoldFont}
+% in the definition of a CJK family.
+% \\
+% SlantFont: & 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 if there is not any.
+% \\
+% CJKnormalspaces: &Ignore only spaces between CJK characters while leave spaces
+% between CJK and other characters as they are.
+% \end{tabular}
+%
+%
+%
+% \begin{decl}
+% \defmacro{setCJKmainfont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\
+% \defmacro{setCJKsansfont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\
+% \defmacro{setCJKmonofont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\
+% \defmacro{setCJKfamilyfont} \arg{family name}[\textcolor{optioncolor}
+% {<font features>}]\arg{font name}
+% \end{decl}
+%
+% The first three macros are analogs of
+%
+% \defmacro{setmainfont}, \defmacro{setsansfont}, and \defmacro{setmonofont},
+%
+% \noindent respectively.
+% The only difference is that they effect only CJK characters.
+%
+% The last macro sets a font for a CJK family which will be called by
+%
+% \defmacro{CJKfamily}\arg{family name}.
+%
+% With these macros, one can set different default fonts for CJK and other characters,
+% respectively.
+%
+% For a full description on the parameters \textcolor{optioncolor}{<font features>}
+% and \arg{font name},
+% we refer to the package \verb+fontspec+.
+%
+%
+%
+% \section{Advanced settings}
+%
+%
+%
+% \begin{decl}
+% \defmacro{punctstyle}\arg{punct style}
+% \end{decl}
+%
+% Set the CJK punctuation style. \xeCJK\ predefines several styles for typesetting full-width punctuation.
+%
+%
+% \begin{tabular}{lp{60mm}}
+% style& \\
+% \textcolor{parametercolor}{quanjiao} or \textcolor{parametercolor}{fullwidth}& typeset all punctuation in full-width,
+% for two adjoint punctuation, the first is typeset
+% in half-width.
+% \\
+% \textcolor{parametercolor}{banjiao} or \textcolor{parametercolor}{halfwidth}& typeset all punctuation in half-width.
+% \\
+% \textcolor{parametercolor}{kaiming} or \textcolor{parametercolor}{mixedwidth}& typeset all punctuation in half-width except
+% the period, question, and exclamation marks.\\
+% \textcolor{parametercolor}{hangmobanjiao} or \textcolor{parametercolor}{marginkerning} & typeset punctuation at the end of lines in half-width.
+% \end{tabular}
+%
+%
+%
+%
+%
+% \begin{decl}
+% \defmacro{xeCJKallowbreakbetweenpuncts} \\
+% \defmacro{xeCJKnobreakbetweenpuncts}
+% \end{decl}
+%
+% By default, \xeCJK\ prohibits line breaks between punctuation. Use
+%
+% \defmacro{xeCJKallowbreakbetweenpuncts}\newline
+% to make it breakable.
+%
+%
+% \begin{decl}
+% \defmacro{xeCJKsetslantfactor}\arg{slant factor}\\
+% \defmacro{xeCJKsetemboldenfactor}\arg{embolden factor}
+% \end{decl}
+% Set 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.
+%
+%
+%
+%
+% \begin{decl}
+% \defmacro{CJKnormalspaces}\\
+% \defmacro{CJKaddspaces}\\
+% \end{decl}
+%
+%
+%
+%
+% By default, \xeCJK\ leaves spaces between CJK and other characters
+% as they are while it ignores spaces between CJK characters.
+% One can use \defmacro{CJKaddspaces} to add a space between CJK and
+% other characters if a blank space is not present.
+% And use \defmacro{CJKnormalspaces} to change to the default.
+%
+% An example for
+% \usemacro{\CJKaddspaces} \CJKsetecglue{ }
+%
+% The input
+% \begin{verbatim}
+% 这是 English 中文 \textit{Chinese} 中文 \LaTeX\
+% 中文\textbf{字体} a {\bfseries 数学} $c$ $d$-th\par
+% 这是English中文\textit{Chinese}中文\LaTeX\
+% 中文\textbf{字体}a{\bfseries 数学}$c$ $d$-th\par
+% \end{verbatim}
+%
+% The output
+%
+% {
+% \color{blue}
+% 这是 English 中文 \textit{Chinese} 中文 \LaTeX\
+% 中文\textbf{字体} a {\bfseries 数学} $c$ $d$-th\par
+% 这是English中文\textit{Chinese}中文\LaTeX\
+% 中文\textbf{字体}a{\bfseries 数学}$c$ $d$-th\par
+% }
+%
+% \section{Compatibility}
+%
+% \subsection{CJKfntef}
+%
+% 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 \texttt{CJKnumb},
+% \texttt{CJKfntef} and \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.
+% \StopEventually{}
+%
+% \clearpage
+% \part{xeCJK.sty}
+% \section{xeCJK.sty 源文件}
+%
+% \iffalse
+%<*xeCJK>
+% \fi
+% \fontsize{10pt}{10pt}\selectfont
+% \xeCJK\ 只能在XeLaTeX中使用
+% \begin{macrocode}
+\RequirePackage{ifxetex}
+\RequireXeTeX
+% \end{macrocode}
+% 禁止在\xeCJK\ 之后调入CJK包。
+% \begin{macrocode}
+\expandafter\def\csname ver@CJK.sty\endcsname{2020/01/01}
+\RequirePackage{fontspec}
+
+\newif\ifxeCJK@SlantFont@
+\xeCJK@SlantFont@false
+
+\newif\ifxeCJK@BoldFont@
+\xeCJK@BoldFont@false
+
+\newif\ifxeCJK@num
+\xeCJK@numfalse
+
+\newif\ifxeCJK@indisplay
+\xeCJK@indisplayfalse
+
+\newif\ifxeCJK@addspaces
+\xeCJK@addspacesfalse
+
+\newif\ifxeCJK@checksingle
+\xeCJK@checksinglefalse
+
+\DeclareOption{boldfont}{\xeCJK@BoldFont@true}
+\DeclareOption{BoldFont}{\ExecuteOptions{boldfont}}
+\DeclareOption{slantfont}{\xeCJK@SlantFont@true}
+\DeclareOption{SlantFont}{\ExecuteOptions{slantfont}}
+\DeclareOption{CJKnumber}{\xeCJK@numtrue}
+\DeclareOption{CJKnormalspaces}{\xeCJK@addspacesfalse}
+\DeclareOption{CJKaddspaces}{\xeCJK@addspacestrue}
+\DeclareOption{CJKtextspaces}{}
+\DeclareOption{CJKmathspaces}{}
+\DeclareOption{CJKsetspaces}{}
+\DeclareOption{CJKnospaces}{}
+\DeclareOption{CJKchecksingle}{\xeCJK@checksingletrue}
+\ExecuteOptions{CJKaddspaces}\relax
+\ProcessOptions\relax
+% \end{macrocode}
+% 抑制换行符产生的空格
+% \begin{macrocode}
+\endlinechar \m@ne
+% \end{macrocode}
+% 设置CJK字符类。
+% \begin{macrocode}
+\XeTeXinterchartokenstate=1\relax
+
+\def\xeCJKsetcharclass#1#2#3{
+ \@tempcnta=#1
+ \loop
+ \XeTeXcharclass \@tempcnta #3\relax
+ \catcode\@tempcnta=11\relax
+ \advance\@tempcnta 1\relax
+ \ifnum\the\@tempcnta<#2 \repeat
+ \xeCJK@setpunctcharclass}
+
+\def\xeCJK@prePunct#1#2{\xeCJK@setPunct{2}{#1}{#2}}
+\def\xeCJK@postPunct#1#2{\xeCJK@setPunct{3}{#1}{#2}}
+
+\def\xeCJK@setPunct#1#2#3{
+ \def\xeCJK@class{#1}
+ \@tempcnta "#2\relax
+ \multiply\@tempcnta 256\relax
+ \xeCJK@setPunct@#3,,}
+
+\def\xeCJK@setPunct@#1,{
+ \edef\xeCJK@temp{#1}%
+ \ifx\xeCJK@temp\@empty
+ \else
+ \@tempcntb "#1\relax
+ \advance\@tempcntb\@tempcnta\relax
+ \XeTeXcharclass \@tempcntb=\xeCJK@class\relax
+ \def\xeCJK@temp{\xeCJK@setPunct@}
+ \fi
+ \xeCJK@temp}
+
+\def\xeCJK@setpunctcharclass{
+ \xeCJK@prePunct{20}{18,1C}
+ \xeCJK@postPunct{20}{19,1D,14,26}
+ \xeCJK@postPunct{25}{00}
+ \xeCJK@prePunct{30}{08,0A,0C,0E,10,12,14,16,18,1A,1D,1F,36}
+
+ \xeCJK@postPunct{30}{01,02,05,06,09,0B,0D,0F,11,15,17,19,1B,1E,
+ 41,43,45,47,49,63,83,85,87,8E,
+ 9B,9C,9D,9E,A1,A3,A5,A7,A9,C3,E3,E5,E7,EE,F5,F6,FB,FC,FD,FE}
+ \xeCJK@prePunct {FE}{59,5B,5D,5F,60,69,6B}
+ \xeCJK@postPunct{FE}{50,51,52,54,55,56,57,5A,5C,5E,6A}
+ \xeCJK@prePunct {FF}{03,04,08,20,3B,5B,E0,E1,E5,E6}
+ \xeCJK@postPunct{FF}{01,05,09,0C,0E,1A,1B,1F,3D,5D,
+ 61,63,64,65,67,68,69,6A,6B,6C,6D,6E,6F,70,9E,9F}
+
+ \xeCJK@setPunct{4}{0}{28,2D,5B,60,7B}
+ \xeCJK@setPunct{5}{0}{21,22,25,27,29,2C,2E,3A,3B,3F,5D,7D}}
+
+\xeCJKsetcharclass{"2000}{"FFFF}{1}
+
+\XeTeXinterchartoks 0 255 {\xeCJK@@cclv}
+\XeTeXinterchartoks 0 1 {\xeCJK@@i\xeCJK@char}
+\XeTeXinterchartoks 4 1 {\xeCJK@char}
+\XeTeXinterchartoks 5 1 {\xeCJK@v@i\xeCJK@char}
+\XeTeXinterchartoks 255 1 {\xeCJK@checksingle}
+
+\XeTeXinterchartoks 0 2 {\xeCJK@prepunctchar}
+\XeTeXinterchartoks 4 2 {\xeCJK@prepunctchar}
+\XeTeXinterchartoks 5 2 {\xeCJK@prepunctchar}
+\XeTeXinterchartoks 255 2 {\xeCJK@prepunctchar}
+
+\XeTeXinterchartoks 0 3 {\xeCJK@postpunctchar}
+\XeTeXinterchartoks 4 3 {\xeCJK@postpunctchar}
+\XeTeXinterchartoks 5 3 {\xeCJK@postpunctchar}
+\XeTeXinterchartoks 255 3 {\xeCJK@postpunctchar}
+
+\XeTeXinterchartoks 255 0 {\xeCJK@cclv@}
+\XeTeXinterchartoks 255 4 {\xeCJK@cclv@iv}
+
+\def\CJKglue{\hskip \z@ \@plus .08\baselineskip}
+\def\CJK@nobreakglue{\nobreak\CJKglue\nobreak}
+
+\edef\xeCJK@CJKkern{\kern -1sp\kern 1sp}
+\edef\xeCJK@prepunctkern{\kern -2sp\kern 2sp}
+\edef\xeCJK@postpunctkern{\kern -3sp\kern 3sp}
+\edef\xeCJK@zerokern{\kern -4sp\kern 4sp}
+
+\newif\if@xeCJK@inmath
+\@xeCJK@inmathfalse
+
+\newif\if@xeCJK
+% \end{macrocode}
+% \section{调整中英文间隔}
+% \verb+\CJKaddspaces+ 和 \verb+\CJKnormalspaces+ 公用宏命令
+% \begin{macrocode}
+\def\xeCJK@ignorespaces{
+ \futurelet\xeCJK@nexttoken\xeCJK@checknext}
+
+\def\xeCJK@n@checknext{
+ \ifx\xeCJK@nexttoken\@sptoken
+ \expandafter\xeCJK@@checknext
+ \fi}
+
+{
+ \def\:{\xeCJK@@checknext}
+ \global\expandafter\def\: {\futurelet\@let@token\xeCJK@@@checknext}
+}
+
+\def\CJK@stop{\CJK@stop}
+
+\def\xeCJK@@@checknext{
+ \ifcat L\noexpand\@let@token
+ \else
+ \let\xeCJK@nexttoken\relax
+ \CJKecglue
+ \fi}
+
+\long\def\xeCJK@gobble#1\CJK@stop{}
+
+% \end{macrocode}
+%
+% 避免单个汉字占一行。
+% \begin{macrocode}
+
+\def\xeCJK@notchecksingle{
+ \xeCJK@cclv@i
+ \xeCJK@char}
+
+\def\xeCJK@z@checksingle#1{
+ \def\xeCJK@setcurrentchar@i{
+ \xeCJK@cclv@i
+ \xeCJK@char{#1}}
+ \def\xeCJK@setcurrentnobreakchar@i{
+ \xeCJK@char{#1}}
+ \futurelet\@let@token\xeCJK@@checksingle}
+
+\def\xeCJK@@checksingle{
+ \expandafter\futurelet
+ \expandafter\xeCJK@tempb
+ \expandafter\xeCJK@gobble\meaning\@let@token\CJK@stop
+ \if t\xeCJK@tempb
+ \expandafter\xeCJK@@@checksingle
+ \else
+ \expandafter\xeCJK@setcurrentchar@i
+ \fi}
+
+\def\xeCJK@@@checksingle#1{
+ \def\xeCJK@setcurrentchar@ii{
+ \xeCJK@setcurrentchar@i #1}
+ \def\xeCJK@setcurrentnobreakchar@ii{
+ \xeCJK@setcurrentnobreakchar@i #1}
+ \futurelet\@let@token\xeCJK@@@@checksingle}
+
+\def\xeCJK@@@@checksingle{
+ \ifx\@let@token\@sptoken
+ \expandafter\xeCJK@checkpar
+ \else
+ \expandafter\xeCJK@setcurrentchar@ii
+ \fi}
+
+\def\xeCJK@checkpar{
+ \@ifnextchar\par{\xeCJK@setcurrentnobreakchar@ii}{\xeCJK@setcurrentchar@ii}}
+% \end{macrocode}
+%
+% 在中英文转换时插入空格,并调整中英文间距。
+% \begin{macrocode}
+
+\def\xeCJK@doaftermath{
+ \futurelet\xeCJK@nexttoken\xeCJK@aftermath}
+
+\def\xeCJK@z@cclv{\futurelet\xeCJK@nexttoken\xeCJK@zz@cclv}
+
+\def\xeCJK@zz@cclv{
+ \ifx\xeCJK@nexttoken\@sptoken
+ \expandafter\xeCJK@zzz@cclv
+ \else
+ {\xeCJK@zerokern}
+ \fi}
+
+{
+ \def\:{\xeCJK@zzz@cclv}
+ \global\expandafter\def\: {\futurelet\@let@token\xeCJK@zzzz@cclv}
+}
+
+\def\xeCJK@zzzz@cclv{
+ \ifcat L\noexpand\@let@token
+ \expandafter\xeCJK@zzzzz@cclv
+ \else
+ \xeCJK@space
+ \fi}
+
+\def\xeCJK@zzzzz@cclv#1{
+ \ifnum`#1>"FF\relax
+ \CJKecglue
+ \else
+ \xeCJK@space
+ \fi
+ #1}
+
+\def\xeCJK@space{ }
+
+\def\xeCJK@z@checknext{
+ \ifx\xeCJK@nexttoken\@sptoken
+ \expandafter\xeCJK@@checknext
+ \else
+ \ifx $\xeCJK@nexttoken
+ \CJKecglue
+ \fi
+ \fi}
+
+\def\CJKaddspaces{
+ \let\xeCJK@@cclv\xeCJK@z@cclv
+ \let\CJKecglue\CJK@ecglue
+ \let\xeCJK@@i\CJKecglue
+ \let\xeCJK@v@i\CJKecglue
+
+ \def\xeCJK@cclv@{
+ \ifnum\lastkern=1\relax
+ \CJKecglue
+ \fi}
+ \let\xeCJK@cclv@iv\xeCJK@cclv@
+
+ \def\xeCJK@cclv@i{{
+ \ifcase\lastkern
+ \hskip 0pt
+ \or %1
+ \CJKglue
+ \or %2
+ \xeCJK@ULspecials
+ \or %3
+ \xeCJK@ULspecials
+ \or %4
+ \CJKecglue
+ \fi}}
+
+ \everymath{\ifxeCJK@indisplay\else\aftergroup\xeCJK@doaftermath\fi}
+ \everydisplay{\xeCJK@indisplaytrue}
+ \let\xeCJK@checknext\xeCJK@z@checknext
+ \let\xeCJK@aftermath\xeCJK@zz@cclv}
+
+% \end{macrocode}
+% \subsection{CJKnormalspaces}
+% 保留中英文之间的空格但不增加额外的空格
+% \begin{macrocode}
+\def\CJKnormalspaces{
+ \let\xeCJK@@cclv\relax
+ \let\xeCJK@@i\relax
+ \let\xeCJK@v@i\relax
+ \let\xeCJK@checknext\xeCJK@n@checknext
+ \def\CJKecglue{ }
+
+ \def\xeCJK@cclv@{
+ \ifodd\lastkern
+ \xeCJK@@glue
+ \fi}
+ \let\xeCJK@cclv@iv\xeCJK@cclv@
+
+ \def\xeCJK@cclv@i{{
+ \ifcase\lastkern
+ \hskip 0pt
+ \or %1
+ \CJKglue
+ \or %2
+ \xeCJK@ULspecials
+ \or %3
+ \xeCJK@ULspecials
+ \fi}}
+
+ \def\xeCJK@@glue{
+ \ifx\xeCJK@nexttoken\@sptoken
+ { }
+ \fi
+ \let\xeCJK@nexttoken\relax}
+ \everymath{}
+ \everydisplay{}}
+% \end{macrocode}
+% \subsection{初始化}
+% \begin{macrocode}
+
+\def\xeCJK@setspacemode{
+ \ifxeCJK@addspaces
+ \CJKaddspaces
+ \else
+ \CJKnormalspaces
+ \fi
+ \ifxeCJK@checksingle
+ \let\xeCJK@checksingle\xeCJK@z@checksingle
+ \else
+ \let\xeCJK@checksingle\xeCJK@notchecksingle
+ \fi}
+
+\def\CJK@ecglue{ }
+
+\def\xeCJKsetecglue#1{
+ \ifxeCJK@addspaces
+ \def\CJK@ecglue{#1}
+ \let\CJKecglue\CJK@ecglue
+ \let\xeCJK@@i\CJKecglue
+ \let\xeCJK@v@i\CJKecglue
+ \fi}
+\let\CJKsetecglue\xeCJKsetecglue
+\CJKaddspaces
+
+\AtBeginDocument{
+ \xeCJK@setspacemode
+ \ifcsname UL@hook\endcsname
+ \addto@hook\UL@hook{
+ \let\xeCJK@unskip\xeCJK@UL@unskip
+ \let\xeCJK@ULspecials\xeCJK@UL@punctgroup}
+ \fi}
+% \end{macrocode}
+%
+% \section{字符输出命令}
+% 普通字符
+% \begin{macrocode}
+\DeclareRobustCommand{\xeCJK@char}[1]{
+ {\XeTeXinterchartokenstate=0
+ \CJKsymbol{#1}
+ \xeCJK@CJKkern}
+ \xeCJK@ignorespaces}
+% \end{macrocode}
+%
+% 左标点如‘“「『〔([{〈《〖【
+% \begin{macrocode}
+\DeclareRobustCommand{\xeCJK@prepunctchar}[1]{
+ {\xeCJK@punctrule{#1}{l}
+ \@xeCJKfalse
+ \ifnum\lastkern>1\relax
+ \ifnum\lastkern<4\relax
+ \unkern
+ \unkern
+ \ifnum\xeCJK@punctstyle>0\relax
+ \@xeCJKtrue
+ \fi
+ \fi
+ \fi
+ \if@xeCJK
+ \xeCJK@unskip
+ \xeCJK@setkern{\@xeCJK@lastpunct}{#1}
+ \kern \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern\@xeCJK@lastpunct#1\endcsname
+ \xeCJKpunctnobreak
+ \else
+ \xeCJK@ULspecials
+ \hskip \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @lglue@#1\endcsname
+ plus 0.1em minus 0.1 em
+ \fi
+
+ \global\edef\@xeCJK@lastpunct{#1}
+ \vrule width \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
+ @lrule@#1\endcsname depth \z@ height \z@
+
+ \XeTeXinterchartokenstate=0
+ \CJKpunctsymbol{#1}
+
+ \nobreak
+ \gdef\xeCJK@lastcharclass{2}
+ \xeCJK@prepunctkern}
+ \ignorespaces}
+% \end{macrocode}
+%
+% 右标点如 ─—…、。,.:;!?%〕)]}〉》〗】’”」』
+% \begin{macrocode}
+\DeclareRobustCommand{\xeCJK@postpunctchar}[1]{
+ {\xeCJK@punctrule{#1}{r}
+ \@xeCJKfalse
+ \ifnum\lastkern>1\relax
+ \ifnum\lastkern<4\relax
+ \unkern
+ \unkern
+ \@xeCJKtrue
+ \fi
+ \fi
+ \if@xeCJK
+ \xeCJK@unskip
+ \xeCJK@setkern{\@xeCJK@lastpunct}{#1}
+ \kern \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
+ @kern\@xeCJK@lastpunct#1\endcsname
+ \nobreak
+ \else
+ \xeCJK@ULspecials
+ \ifcsname xeCJK@specialpunct#1\endcsname
+ \CJKglue % breakable
+ \else
+ \nobreak
+ \fi
+ \fi
+ \global\edef\@xeCJK@lastpunct{#1}
+
+ \XeTeXinterchartokenstate=0
+ \CJKpunctsymbol{#1}
+
+ \vrule width \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
+ @rrule@#1\endcsname depth \z@ height \z@
+
+ \hskip \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @rglue@#1\endcsname
+ plus 0.1em minus 0.1 em
+
+ \gdef\xeCJK@lastcharclass{3}
+ \xeCJK@postpunctkern}
+ \xeCJK@ignorespaces}
+
+\let\xeCJK@unskip\unskip
+\def\xeCJK@UL@unskip{
+ \ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @rglue@\@xeCJK@lastpunct\endcsname
+ \hskip -\csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
+ @rglue@\@xeCJK@lastpunct\endcsname\relax
+ \fi}
+% \end{macrocode}
+%
+% 缺省状态下,不允许在相邻标点中间换行。
+% \begin{macrocode}
+\def\xeCJKallowbreakbetweenpuncts{
+ \def\xeCJKpunctnobreak{
+ \ifnum\xeCJK@lastcharclass=3
+ \hskip 0pt
+ \fi}}
+
+\def\xeCJKnobreakbetweenpuncts{
+ \let\xeCJKpunctnobreak\nobreak}
+\xeCJKnobreakbetweenpuncts
+% \end{macrocode}
+% \section{标点挤压规则}
+% \begin{macrocode}
+\newcount\xeCJK@cnta
+\newcount\xeCJK@cntb
+\newcount\xeCJK@cntc
+\newcount\xeCJK@cntd
+\newcount\xeCJK@cnte
+\newdimen\xeCJK@dima
+\newif\ifxeCJK@dokerning
+
+\def\xeCJK@punctrule#1#2{
+ \ifcsname xeCJK@bbox\xeCJK@family/\f@series/\f@shape\endcsname
+ \global\edef\xeCJK@bboxname{
+ \csname xeCJK@bbox\xeCJK@family/\f@series/\f@shape\endcsname}
+ \else
+ \xeCJK@getbboxname
+ \global\expandafter\edef\csname
+ xeCJK@bbox\xeCJK@family/\f@series/\f@shape\endcsname{\xeCJK@bboxname}
+ \fi
+ \ifcsname xeCJK@\xeCJK@bboxname @lspace@#1\endcsname
+ \else
+ {\xeCJK@setfont
+ \xeCJK@setpunctbounds{#1}}
+ \fi
+% \end{macrocode}
+%
+% 如果 punctstyle$=$plain, 或者标点符号的两侧空白大小没有定义时,不作特殊处理
+%
+% \begin{macrocode}
+ \ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2rule@#1\endcsname
+ \else
+ \xeCJK@dokerningtrue
+ \ifnum\xeCJK@punctstyle=\xeCJK@ps@plain\relax
+ \xeCJK@dokerningfalse
+ \else
+ \ifcsname xeCJK@specialpunct#1\endcsname
+ \xeCJK@dokerningfalse
+ \else
+ \ifcsname xeCJK@\xeCJK@bboxname @#2space@#1\endcsname
+ \else
+ \typeout{....Something is wrong with ...xeCJK@\xeCJK@bboxname @#2space@.....}
+ \xeCJK@dokerningfalse
+ \fi
+ \fi
+ \fi
+ \ifxeCJK@dokerning
+ \xeCJK@cnta=\csname xeCJK@\xeCJK@bboxname @#2space@#1\endcsname\relax
+ \xeCJK@cntc=\xeCJK@cnta
+ \ifcase\xeCJK@punctstyle
+ % hangmobanjiao
+ \or % quanjiao
+ \or % banjiao
+ \advance\xeCJK@cntc -50\relax
+ \or % kaiming
+ \ifcsname xeCJK@kaiming#1\endcsname
+ \else
+ \advance\xeCJK@cntc -50\relax
+ \fi
+ \or %CCT
+ \advance\xeCJK@cntc -20\relax
+ \fi
+ \xeCJK@cntd=\xeCJK@cntc
+ \ifnum\xeCJK@cntc<0\relax
+ \xeCJK@cntc=0\relax
+ \fi
+ \else
+ \xeCJK@cnta=0\relax
+ \xeCJK@cntc=0\relax
+ \xeCJK@cntd=0\relax
+ \fi
+ \xeCJK@numtodim{\xeCJK@cnta}
+ \global\expandafter\edef\csname
+ xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2rule@#1\endcsname{
+ -\xeCJK@temp em}
+ \xeCJK@numtodim{\xeCJK@cntc}
+ \global\expandafter\edef\csname
+ xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2glue@#1\endcsname{
+ \xeCJK@temp em}
+ \global\expandafter\edef\csname
+ xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2oglue@#1\endcsname{
+ \the\xeCJK@cntd}
+ \fi}
+
+\def\xeCJK@numtodim#1{
+ \xeCJK@cnte=#1\relax
+ \ifnum\the\xeCJK@cnte<100\relax
+ \def\xeCJK@temp{0}
+ \else
+ \advance\xeCJK@cnte -100\relax
+ \def\xeCJK@temp{1}
+ \fi
+ \ifnum\the\xeCJK@cnte<10
+ \edef\xeCJK@temp{\xeCJK@temp.0\the\xeCJK@cnte}
+ \else
+ \edef\xeCJK@temp{\xeCJK@temp.\the\xeCJK@cnte}
+ \fi}
+
+\def\xeCJK@getbboxname{
+ {\csname xeCJK@font@\xeCJK@family\endcsname
+ \get@external@font
+ \global\let\xeCJK@tempx\external@font}
+ \expandafter\xeCJK@@getbboxname\xeCJK@tempx\relax
+ \global\expandafter\edef\csname
+ xeCJK@bbox\xeCJK@family/\f@series/\f@shape\endcsname{\xeCJK@bboxname}}
+
+\def\xeCJK@@getbboxname"#1/#2"#3\relax{
+ \edef\xeCJK@temp{\zap@space #1 \@empty}
+ \edef\xeCJK@temp{\lowercase{\gdef\noexpand\xeCJK@bboxname{\xeCJK@temp}}}
+ \xeCJK@temp}
+
+\expandafter\def\csname xeCJK@kaiming。\endcsname{}
+\expandafter\def\csname xeCJK@kaiming?\endcsname{}
+\expandafter\def\csname xeCJK@kaiming!\endcsname{}
+\expandafter\def\csname xeCJK@specialpunct—\endcsname{}% U+2014
+\expandafter\def\csname xeCJK@specialpunct─\endcsname{}% U+2500
+\expandafter\def\csname xeCJK@specialpunct…\endcsname{}
+\def\xeCJK@setkern#1#2{
+ \ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern#1#2\endcsname
+ \else
+ \xeCJK@cnta=0\relax
+ \ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @roglue@#1\endcsname
+ \advance\xeCJK@cnta\csname
+ xeCJK\xeCJK@punctstyle\xeCJK@bboxname @roglue@#1\endcsname
+ \fi
+ \ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @loglue@#2\endcsname
+ \advance\xeCJK@cnta\csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname
+ @loglue@#2\endcsname
+ \fi
+ \relax
+ \ifcase\xeCJK@punctstyle
+ % hangmobanjiao
+ \or % quanjiao
+ \advance\xeCJK@cnta -50\relax
+ \or % banjiao
+ \or % kaiming
+ \ifcsname xeCJK@kaiming#1\endcsname
+ \ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @roglue@#2\endcsname
+ \advance\xeCJK@cnta -50\relax
+ \fi
+ \fi
+ \fi
+ \ifnum\xeCJK@cnta<0\relax
+ \xeCJK@cnta=0\relax
+ \fi
+ \xeCJK@numtodim{\xeCJK@cnta}
+ \global\expandafter\edef\csname
+ xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern#1#2\endcsname{
+ \xeCJK@temp em}
+ \fi}
+
+% \end{macrocode}
+% 用户命令:设置两个标点之间的间距
+% \begin{macrocode}
+\def\xeCJKsetkern#1#2#3{
+ \xeCJK@getbboxname
+ \global\expandafter\edef\csname
+ xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern#1#2\endcsname{#3}}
+
+\def\punctstyle#1{
+ \ifcsname xeCJK@ps@#1\endcsname
+ \edef\xeCJK@punctstyle{\csname xeCJK@ps@#1\endcsname}
+ \ifnum\xeCJK@punctstyle=\xeCJK@ps@plain\relax
+ \xeCJKallowbreakbetweenpuncts
+ \fi
+ \else
+ \typeout{Warning: Punctstyle #1\space is not defined.}
+ \fi}
+
+\def\xeCJK@ps@hangmobanjiao{0}
+\def\xeCJK@ps@marginkerning{0}
+\def\xeCJK@ps@quanjiao{1}
+\def\xeCJK@ps@fullwidth{1}
+\def\xeCJK@ps@banjiao{2}
+\def\xeCJK@ps@halfwidth{2}
+\def\xeCJK@ps@kaiming{3}
+\def\xeCJK@ps@mixedwidth{3}
+\def\xeCJK@ps@CCT{4}
+\def\xeCJK@ps@plain{5}
+\punctstyle{quanjiao}
+
+\let\@afterindentfalse\relax
+
+\def\xeCJKplainchr{\punctstyle{plain}}
+
+\def\xeCJK@sidespace{10}
+
+\def\xeCJK@getglyphbounds#1{
+ \xeCJK@cnta=\number\XeTeXglyphbounds #1 \xeCJK@gid
+ \xeCJK@dima 1em\relax
+ \xeCJK@cntb=\number\xeCJK@dima
+ \multiply\xeCJK@cnta 100\relax
+ \divide\xeCJK@cnta\xeCJK@cntb
+ \advance\xeCJK@cnta -15\relax
+ \edef\xeCJK@temp{\the\xeCJK@cnta}
+ \ifnum\xeCJK@temp<0\relax
+ \def\xeCJK@temp{0}
+ \fi}
+
+
+\def\xeCJK@setpunctbounds#1{
+ \edef\xeCJK@gid{\the\XeTeXcharglyph`#1}
+ \xeCJK@getglyphbounds{1}
+ \expandafter\xdef\csname xeCJK@\xeCJK@bboxname @lspace@#1\endcsname{
+ \xeCJK@temp}
+ \xeCJK@getglyphbounds{3}
+ \expandafter\xdef\csname xeCJK@\xeCJK@bboxname @rspace@#1\endcsname{
+ \xeCJK@temp}
+ \ifcsname xeCJK@specialpunct#1\endcsname
+ \ifx#1…
+ \else
+ \xeCJK@cnta=\number\XeTeXglyphbounds 1 \xeCJK@gid
+ \advance\xeCJK@cnta\number\XeTeXglyphbounds 3 \xeCJK@gid
+ \advance\xeCJK@cnta 1000\relax
+ \divide\xeCJK@cnta 6554\relax
+ \ifnum\xeCJK@cnta>9
+ \edef\xeCJK@temp{-0.\the\xeCJK@cnta em}
+ \else
+ \ifnum\xeCJK@cnta>1
+ \edef\xeCJK@temp{-0.0\the\xeCJK@cnta em}
+ \else
+ \edef\xeCJK@temp{-0.01 em}
+ \fi
+ \fi
+ \xeCJK@cnta=0
+ \loop
+ \global\expandafter\edef\csname xeCJK\the\xeCJK@cnta\xeCJK@bboxname
+ @kern#1#1\endcsname{\xeCJK@temp}
+ \advance \xeCJK@cnta 1\relax
+ \ifnum\xeCJK@cnta<6\repeat
+ \fi
+ \fi}
+
+% \end{macrocode}
+% \section{字体设置}
+% \begin{macrocode}
+\def\CJKsymbol#1{{\xeCJK@setfont #1}}
+\def\CJKpunctsymbol#1{{\xeCJK@setfont #1}}
+\def\xeCJK@setfont{
+ \ifcsname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname
+ \csname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname
+ \else
+ \csname xeCJK@font@\xeCJK@family\endcsname
+ \get@external@font
+ \expandafter\global\expandafter\font
+ \csname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname=\external@font
+ \fi}
+
+\def\setCJKmainfont{
+ \xeCJK@newfontfamily{rm}}
+
+\let\setCJKromanfont\setCJKmainfont
+
+\def\setCJKsansfont{
+ \xeCJK@newfontfamily{sf}}
+
+\def\setCJKmonofont{
+ \xeCJK@newfontfamily{tt}}
+
+\def\setCJKfamilyfont#1{
+ \xeCJK@newfontfamily{#1}}
+
+%
+% Redefine \rmfamily, \sffamily and \ttfamily to set CJKfamily
+\DeclareRobustCommand\rmfamily
+ {\not@math@alphabet\rmfamily\mathrm
+ \fontfamily\rmdefault\CJKfamily{rm}\selectfont}
+
+\DeclareRobustCommand\sffamily
+ {\not@math@alphabet\sffamily\mathsf
+ \fontfamily\sfdefault\CJKfamily{sf}\selectfont}
+
+\DeclareRobustCommand\ttfamily
+ {\not@math@alphabet\ttfamily\mathtt
+ \fontfamily\ttdefault\CJKfamily{tt}\selectfont}
+
+% \xeCJK@newfontfamily is similar to \newfontfamily
+% but introduce fake slant/bold fonts for CJK characters.
+\newcommand*\xeCJK@newfontfamily[1]{
+ \@ifnextchar[
+ {\xeCJK@newfontfamily@{#1}}
+ {\xeCJK@newfontfamily@{#1}[]}}
+
+\def\xeCJK@newfontfamily@#1[#2]#3{
+ %
+ % Get user defined options
+ \def\xeCJK@temp{#2}
+ \expandafter
+ \xeCJK@getBoldFont\xeCJK@temp BoldFont={}{}\relax
+ \expandafter
+ \xeCJK@getBoldItalicFont\xeCJK@temp BoldItalicFont={}{}\relax
+ \expandafter
+ \xeCJK@getItalicFont\xeCJK@temp ItalicFont={}{}\relax
+
+ \expandafter
+ \xeCJK@getBoldItalicFeatures\xeCJK@temp BoldItalicFeatures={}{}\relax
+ \expandafter
+ \xeCJK@getBoldFeatures\xeCJK@temp BoldFeatures={}{}\relax
+ \expandafter
+ \xeCJK@getItalicFeatures\xeCJK@temp ItalicFeatures={}{}\relax
+
+ \expandafter
+ \xeCJK@getRawFeature\xeCJK@BoldFeatures RawFeature={}{}\relax
+ \edef\xeCJK@Bold@RawFeature{\xeCJK@tempRawFeature}
+
+ \expandafter
+ \xeCJK@getRawFeature\xeCJK@BoldItalicFeatures RawFeature={}{}\relax
+ \edef\xeCJK@BoldItalic@RawFeature{\xeCJK@tempRawFeature}
+
+ \expandafter
+ \xeCJK@getRawFeature\xeCJK@ItalicFeatures RawFeature={}{}\relax
+ \edef\xeCJK@Italic@RawFeature{\xeCJK@tempRawFeature}
+
+ \edef\xeCJK@Features{}
+
+ \ifxeCJK@BoldFont@
+ \ifx\xeCJK@BoldFont\@empty
+
+ \ifx\xeCJK@Bold@RawFeature\@empty
+ \def\xeCJK@Bold@RawFeature{
+ embolden=\xeCJK@emboldenfactor}
+ \else
+ \edef\xeCJK@Bold@RawFeature{
+ embolden=\xeCJK@emboldenfactor,
+ \xeCJK@Bold@RawFeature}
+ \fi
+
+ \ifx\xeCJK@BoldFeatures\@empty
+ \edef\xeCJK@Features{
+ BoldFeatures={
+ RawFeature={\xeCJK@Bold@RawFeature}}}
+ \else
+ \edef\xeCJK@Features{
+ BoldFeatures={
+ \xeCJK@BoldFeatures,
+ RawFeature={\xeCJK@Bold@RawFeature}}}
+ \fi
+
+ \ifx\xeCJK@BoldItalic@RawFeature\@empty
+ \def\xeCJK@BoldItalic@RawFeature{
+ embolden=\xeCJK@emboldenfactor}
+ \else
+ \edef\xeCJK@BoldItalic@RawFeature{
+ embolden=\xeCJK@emboldenfactor,
+ \xeCJK@BoldItalic@RawFeature}
+ \fi
+ \fi
+ \fi
+
+ \ifxeCJK@SlantFont@
+ \ifx\xeCJK@ItalicFont\@empty
+
+ \ifx\xeCJK@Italic@RawFeature\@empty
+ \edef\xeCJK@Italic@RawFeature{
+ slant=\xeCJK@slantfactor}
+ \else
+ \edef\xeCJK@Italic@RawFeature{
+ slant=\xeCJK@slantfactor,
+ \xeCJK@Italic@RawFeature}
+ \fi
+
+ \ifx\xeCJK@ItalicFeatures\@empty
+ \edef\xeCJK@ItalicFeatures{
+ RawFeature={\xeCJK@Italic@RawFeature}}
+ \else
+ \edef\xeCJK@ItalicFeatures{
+ \xeCJK@ItalicFeatures,
+ RawFeature={\xeCJK@Italic@RawFeature}}
+ \fi
+
+ \ifx\xeCJK@BoldItalic@RawFeature\@empty
+ \edef\xeCJK@BoldItalic@RawFeature{
+ slant=\xeCJK@slantfactor}
+ \else
+ \edef\xeCJK@BoldItalic@RawFeature{
+ slant=\xeCJK@slantfactor,
+ \xeCJK@BoldItalic@RawFeature}
+ \fi
+
+ \ifx\xeCJK@BoldItalicFeatures\@empty
+ \edef\xeCJK@BoldItalicFeatures{
+ RawFeature={\xeCJK@BoldItalic@RawFeature}}
+ \else
+ \edef\xeCJK@BoldItalicFeatures{
+ \xeCJK@BoldItalicFeatures,
+ RawFeature={\xeCJK@BoldItalic@RawFeature}}
+ \fi
+
+ \ifx\xeCJK@Features\@empty
+ \edef\xeCJK@Features{
+ ItalicFeatures={\xeCJK@ItalicFeatures},
+ BoldItalicFeatures={\xeCJK@BoldItalicFeatures}}
+ \else
+ \edef\xeCJK@Features{
+ \xeCJK@Features,
+ ItalicFeatures={\xeCJK@ItalicFeatures},
+ BoldItalicFeatures={\xeCJK@BoldItalicFeatures}}
+ \fi
+ \fi
+ \fi
+
+ \edef\xeCJK@temp{#2}
+ \ifx\xeCJK@temp\@empty
+ \else
+ \edef\xeCJK@temp{,#2}
+ \fi
+
+ \ifx\xeCJK@Features\@empty
+ \else
+ \edef\xeCJK@Features{,\xeCJK@Features}
+ \fi
+
+ \edef\xeCJK@Features{
+ [BoldFont={#3},
+ ItalicFont={#3},
+ BoldItalicFont={#3}% The first three parameters can be overridden by
+ % user defined parameters in #2
+ \xeCJK@temp\xeCJK@Features]}
+
+ \expandafter
+ \newfontfamily@i\csname xeCJK@font@#1\expandafter\endcsname
+ \xeCJK@Features
+ {#3}}
+
+\def\xeCJK@setmacro@getkey#1{
+ \expandafter\def\csname xeCJK@get#1\endcsname ##1#1=##2##3\relax{
+ \expandafter\edef\csname xeCJK@#1\endcsname{##2}
+ \edef\xeCJK@temp{##1##3}}}
+
+\xeCJK@setmacro@getkey{BoldFont}
+\xeCJK@setmacro@getkey{ItalicFont}
+\xeCJK@setmacro@getkey{BoldItalicFont}
+\xeCJK@setmacro@getkey{ItalicFeatures}
+\xeCJK@setmacro@getkey{BoldFeatures}
+\xeCJK@setmacro@getkey{BoldItalicFeatures}
+
+\def\xeCJK@getRawFeature#1RawFeature=#2#3\relax{
+ \edef\xeCJK@tempRawFeature{#2}}
+
+\define@key[zf]{preparse}{ItalicFeatures}{
+ \edef\zf@it@feat{,#1}
+ \edef\zf@family@long{\zf@family@long itfeat:#1}}
+
+% redefine \CJKfamily.
+
+\def\xeCJK@font@rm{}
+
+\DeclareRobustCommand\CJKfamily[1]{
+ \ifcsname xeCJK@font@#1\endcsname
+ \def\xeCJK@family{#1}
+ \else
+ \ifcsname xeCJK@#1@warned\endcsname
+ \else
+ \PackageWarning{xeCJK}{
+ Unknown CJK family `#1' is ignored.^^J
+ Use \string\setCJKfamilyfont \space to define a CJK family.}
+ \expandafter\gdef\csname xeCJK@#1@warned\endcsname{}
+ \fi
+ \fi}
+\CJKfamily{rm}
+
+\def\xeCJKsetslantfactor#1{\edef\xeCJK@slantfactor{#1}}
+\def\xeCJKsetemboldenfactor#1{\edef\xeCJK@emboldenfactor{#1}}
+
+\xeCJKsetslantfactor{0.17}
+\xeCJKsetemboldenfactor{4}
+% \end{macrocode}
+% \section{使用CJKfntef和CJKnumb宏包}
+% \begin{macrocode}
+%
+\@ifundefined{UL@hskip}{\let\UL@hskip\relax}{}
+
+\let\xeCJK@ULspecials\relax
+
+\def\xeCJK@UL@punctgroup{
+ \ifx\hskip\UL@hskip
+ \egroup
+ \UL@stop
+ \UL@start
+ \bgroup
+ \fi}
+
+
+\ifxeCJK@num
+ \edef\CJK@UnicodeEnc{UTF8}
+ \def\CJKaddEncHook#1#2{\expandafter\def\csname xeCJK@enc@#1\endcsname{#2}}
+ \def\Unicode#1#2{\@tempcnta #1\relax
+ \multiply\@tempcnta 256\relax
+ \advance\@tempcnta #2\relax
+ \char\@tempcnta}
+ \RequirePackage{CJKnumb}
+ \csname xeCJK@enc@UTF8\endcsname
+ \def\CJK@tenthousand{万}
+\fi
+% \end{macrocode}
+% 可以使用CJK包中的cpx或cp文件。
+% \begin{macrocode}
+
+\def\CJK@ifundefined#1{
+ \ifx #1\@undefined
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
+
+\newcommand{\xeCJKcaption}[2][]{
+ \edef\xeCJK@temp{#1}
+ \ifx\xeCJK@temp\@empty
+ \else
+ \XeTeXdefaultencoding "#1"
+ \fi
+ \makeatletter
+ \input{#2.cpx}
+ \makeatother
+ \XeTeXdefaultencoding "UTF-8"}
+% \end{macrocode}
+% 不再使用的旧版本命令
+% \begin{macrocode}
+
+\def\CJKlanguage#1{}
+\endlinechar `\^^M
+\catcode "FEFF=9\relax
+% \end{macrocode}
+%
+%
+%
+% \iffalse
+%</xeCJK>
+%
+%<*example-addspaces>
+% \fi
+%
+% \clearpage
+% \part{example-addspaces.tex}
+% \begin{macrocode}
+\documentclass{article}
+\usepackage[boldfont,slantfont,CJKaddspaces]{xeCJK}
+\usepackage{xcolor}
+\setCJKmainfont{Bitstream CyberCJK}
+\textwidth 190mm
+\oddsidemargin 0pt
+\def\usemacro#1{\csname#1\endcsname $\backslash$#1}
+\begin{document}
+\baselineskip 18pt
+\parskip 10pt
+\parindent 0em
+
+\long\def\sometexts{\par{\color{\colora}
+ 这是 English 中文 {\itshape Chinese} 中文 \LaTeX\
+ 间隔 \textit{Italic} 中文\textbf{字体} a 数学 $b$ $c$ $d$
+\\
+ 这是English中文{\itshape Chinese}中文\LaTeX\
+ 间隔\textit{Italic}中文\textbf{字体}a数学$b$ $c$ $d$\\
+This is an example. 这是一个例子
+}}
+
+\def\colora{blue}
+\usemacro{CJKaddspaces}
+\CJKsetecglue{\hskip 0.15em plus 0.05em minus 0.05em}
+\verb+\CJKsetecglue{\hskip 0.15em plus 0.05em minus 0.05em}+
+\sometexts
+
+\def\colora{red}
+\usemacro{CJKaddspaces}
+\CJKsetecglue{ }
+\verb+\CJKsetecglue{ }+
+\sometexts
+
+\def\colora{blue!50!red}
+\usemacro{CJKnormalspaces}
+\sometexts
+
+
+\end{document}
+
+% \end{macrocode}
+% \iffalse
+%</example-addspaces>
+%<*example-CJKchecksingle>
+% \fi
+%
+% \clearpage
+% \part{example-CJKchecksingle.tex}
+% \begin{macrocode}
+\documentclass{article}
+\usepackage[boldfont,slantfont,CJKaddspaces,CJKchecksingle]{xeCJK}
+\setCJKmainfont{Bitstream CyberCJK}
+\textwidth 120mm
+\oddsidemargin 0pt
+\def\usemacro#1{\csname#1\endcsname $\backslash$#1}
+\begin{document}
+\baselineskip 18pt
+\parskip 10pt
+\parindent 0em
+
+\long\def\sometexts{xeCJK 改进了中英文间距的处理,并可以避免单个汉字独占一段的最后一行。
+
+xeCJK 改进了中英文间距的处理,并且可以避免单个汉字独占一段的最后一行。
+
+xeCJK 改进了中英文间距的处理, 并且还可以避免单个汉字独占一段的最后一行.
+
+}
+
+\sometexts
+\vskip 20mm
+
+不用CJKchecksingle的效果:
+
+\makeatletter
+\let\xeCJK@checksingle\xeCJK@notchecksingle
+\sometexts
+\end{document}
+
+% \end{macrocode}
+% \iffalse
+%</example-CJKchecksingle>
+%<*example-CJKfntef>
+% \fi
+%
+% \clearpage
+% \part{example-CJKfntef.tex}
+% \begin{macrocode}
+
+\documentclass[11pt]{article}
+\textheight 220mm
+\textwidth 150mm
+\oddsidemargin 0pt
+\evensidemargin 0pt
+\usepackage[slantfont,boldfont]{xeCJK}
+\usepackage{xcolor}
+\usepackage{CJKfntef}
+
+\begin{document}
+\setCJKmainfont{Bitstream CyberCJK}% 设置缺省中文字体
+\setCJKmonofont{Bitstream CyberCJK}% 设置缺省中文字体
+
+\baselineskip 16pt
+\parindent 2em
+
+ \section{举例}
+\begin{verbatim}
+标点。
+\end{verbatim}
+
+
+汉字Chinese数学$x=y$空格
+
+汉字 Chinese 数学 $x=y$ 空格
+
+\CJKunderline{汉字Chinese数学$x=y$加下划线,可以\CJKunderdot{同时加点}。}
+
+\CJKunderline{汉字 Chinese 数学 $x=y$ 加下划线,可以\CJKunderdot{同时加点}。}
+
+\CJKunderline*{汉字加下划线,可以\CJKunderdot{同时加点}。}
+
+
+\CJKunderdot{汉字加点,可以\CJKunderline{同时加下划线}。}
+
+
+\end{document}
+% \end{macrocode}
+% \iffalse
+%</example-CJKfntef>
+% \fi
+%
+% \Finale
+%
+% \typeout{*************************************************************}
+% \typeout{*}
+% \typeout{* To finish the installation you have to move the following}
+% \typeout{* files into a directory searched by XeTeX:}
+% \typeout{*}
+% \typeout{* \space\space\space xeCJK.sty}
+% \typeout{*}
+% \typeout{*************************************************************}
+% \Finale
+\endinput