% \iffalse %<*internal> \iffalse % %<*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. % %<*internal> \fi % % %<*internal> \begingroup % %<*batchfile> \input docstrip.tex \keepsilent \preamble Version 2.3.10 (30-Sept-2009) Copyright (C) Wenchang Sun 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}}} % %\endbatchfile %<*internal> \generate{\file{xeCJK.ins}{\from{xeCJK.dtx}{batchfile}}} \nopreamble\nopostamble \generate{\file{README.txt}{\from{\jobname.dtx}{readme}}} \endgroup % % %<*driver> \documentclass[12pt]{ltxdoc} \usepackage{xcolor} \usepackage[bookmarks=true,bookmarksopen=true,dvipdfm,pdfstartview=FitH]{hyperref} \usepackage[BoldFont,SlantFont,CJKnumber]{xeCJK} \textheight 210mm \textwidth 150mm \oddsidemargin 0pt \evensidemargin 0pt \defaultfontfeatures{Mapping=tex-text} \ifcsname CJKmainfont\endcsname \else \def\CJKmainfont{AR PL SungtiL GB} \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} % % %<*xeCJK> \def\fileversion{2.3.10} \def\filedate{2009/09/30} \ProvidesPackage{xeCJK}[\filedate\space\fileversion] % % % \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:& 启用 \textsl{斜体字slshape}\\ % CJKnumber: & 调用CJKnumb宏包\\ % CJKchecksingle: &避免单个汉字单独占一行。 % \end{tabular} % % % \begin{decl} % \defmacro{\setCJKmainfont} [\textcolor{optioncolor}{}]\arg{font name}\\ % \defmacro{\setCJKsansfont} [\textcolor{optioncolor}{}]\arg{font name}\\ % \defmacro{\setCJKmonofont} [\textcolor{optioncolor}{}]\arg{font name}\\ % \defmacro{\setCJKfamilyfont} \arg{family name}[\textcolor{optioncolor} % {}]\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, 缺省中文字体为 AR PL SungtiL GB (文鼎 PL简报宋), % 最后一个命令设置 CJKfamily “song”。 % \begin{verbatim} % \setmainfont{TeX Gyre Termes} % \setCJKmainfont{AR PL SungtiL GB} % \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} & 全角式:所有标点占一个汉字宽度,相邻两个标点占1.5汉字宽度。\\ % \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{\CJKsetecglue} % \end{decl} % % % % \defmacro{\CJKsetecglue}: 设置中英文间距. 缺省值为\defmacro{\CJKsetecglue\{ \}}. % 注意: 这个宏命令仅仅影响自动添加的空格. 源文件中直接输入的中英文之间的空格不受影响(直接输出). % \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 % 排版效果: % % 这是 English 中文 \textit{Chinese} 中文 \LaTeX\ % 中文\textbf{字体} a {\bfseries 数学} $c$ $d$-th\par % 这是English中文\textit{Chinese}中文\LaTeX\ % 中文\textbf{字体}a{\bfseries 数学}$c$ $d$-th\par % % 说明: % \begin{enumerate} % % \item 中英文之间的空格会保留(不能调整), % 但若没有空格,则会根据需要添加(见上面的例子)。 % % 有时可能无效, % 解决方案是手动加空格。 %\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}{}]\arg{caption} % \end{decl} % % 与 \verb+\CJKcaption+ 类似,可选参数用以选择编码, 缺省为 UTF-8。 % % \begin{decl} % \defmacro{\xeCJKsetkern}\arg{标点1}\arg{标点2}\arg{kern} % \end{decl} % % 如果对缺省配置不满意,可以使用此命令设置两个标点之间的距离。例如, % % \verb+\xeCJKsetkern{:}{“}{0.3em}+ % % \begin{decl} % \defmacro{\normalspacedchars}\arg{char list} % \end{decl} % 在中出现的字符两端不自动添加空格. % % % \begin{decl} % \defmacro{\makexeCJKactive}\\ % \defmacro{\makexeCJKinactive} % \end{decl} % 打开/关闭对中文的特殊处理. % % \section{兼容性} % % \subsection{CJKfntef} % 可以在 \xeCJK\ 包之后调入 CJKfntef 宏包, 以实现汉字加点等。 % % \subsection{CJKnumber} % % \verb+\CJKnumber{12345}+: \CJKnumber{12345} % % \subsection{CJK} % 为了与 CJKnumb 和 CJKulem 包兼容,\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. % \\ % \end{tabular} % % % % \begin{decl} % \defmacro{\setCJKmainfont} [\textcolor{optioncolor}{}]\arg{font name}\\ % \defmacro{\setCJKsansfont} [\textcolor{optioncolor}{}]\arg{font name}\\ % \defmacro{\setCJKmonofont} [\textcolor{optioncolor}{}]\arg{font name}\\ % \defmacro{\setCJKfamilyfont} \arg{family name}[\textcolor{optioncolor} % {}]\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}{} % 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. % % % % % % \section{Compatibility} % % \subsection{CJK} % To be compatible with some CJK-related packages \texttt{CJKnumb} % 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} \newif\ifxeCJK@SlantFont@ \xeCJK@SlantFont@false \newif\ifxeCJK@BoldFont@ \xeCJK@BoldFont@false \newif\ifxeCJK@num \xeCJK@numfalse \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}{} \DeclareOption{CJKaddspaces}{} \DeclareOption{CJKtextspaces}{} \DeclareOption{CJKmathspaces}{} \DeclareOption{CJKsetspaces}{} \DeclareOption{CJKnospaces}{} \DeclareOption{CJKchecksingle}{\AtEndOfPackage{\let\xeCJK@i@i\xeCJK@checksingle}} \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{fontspec}} \ProcessOptions\relax \RequirePackage{fontspec} \relax % \end{macrocode} % 抑制换行符产生的空格 % \begin{macrocode} \endlinechar \m@ne % \end{macrocode} % 设置CJK字符类。 % \begin{macrocode} \def\makexeCJKactive{ \XeTeXinterchartokenstate=1\relax} \def\makexeCJKinactive{ \XeTeXinterchartokenstate=0\relax} \makexeCJKactive \def\xeCJKsetcharclass#1#2#3{ \@tempcnta=#1 \loop \XeTeXcharclass \@tempcnta #3\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} \def\CJK@stop{\CJK@stop} \def\normalspacedchars#1{ \xeCJK@setnormalspacedchar#1\CJK@stop} \def\xeCJK@setnormalspacedchar#1{ \ifx#1\CJK@stop \else \XeTeXcharclass`#1=6 \expandafter\xeCJK@setnormalspacedchar \fi} \normalspacedchars{/} % \end{macrocode} % % \section{字符输出规则} % \begin{macrocode} \XeTeXinterchartoks 1 0{\egroup\CJKecglue} \XeTeXinterchartoks 1 1{\xeCJK@i@i} \XeTeXinterchartoks 1 2{\xeCJK@i@ii} \XeTeXinterchartoks 1 3{\xeCJK@i@iii} \XeTeXinterchartoks 1 4{\egroup\CJKecglue} \XeTeXinterchartoks 1 5{\egroup} \XeTeXinterchartoks 1 255{\xeCJK@i@cclv} \XeTeXinterchartoks 2 0{\xeCJK@ii@} \XeTeXinterchartoks 2 1{\xeCJK@ii@i} \XeTeXinterchartoks 2 2{\xeCJK@ii@ii} \XeTeXinterchartoks 2 3{\xeCJK@ii@iii} \XeTeXinterchartoks 2 4{\xeCJK@ii@iv} \XeTeXinterchartoks 2 5{\xeCJK@ii@v} \XeTeXinterchartoks 2 255{\xeCJK@ii@cclv} \XeTeXinterchartoks 3 0{\xeCJK@iii@} \XeTeXinterchartoks 3 1{\xeCJK@iii@i} \XeTeXinterchartoks 3 2{\xeCJK@iii@ii} \XeTeXinterchartoks 3 3{\xeCJK@iii@iii} \XeTeXinterchartoks 3 4{\xeCJK@iii@iv} \XeTeXinterchartoks 3 5{\xeCJK@iii@v} \XeTeXinterchartoks 3 255{\xeCJK@iii@cclv} \XeTeXinterchartoks 0 1{\xeCJK@@i} \XeTeXinterchartoks 0 2{\xeCJK@@ii} \XeTeXinterchartoks 0 3{\xeCJK@@iii} \XeTeXinterchartoks 0 255{\xeCJK@@cclv} \XeTeXinterchartoks 4 1{\xeCJK@iv@i} \XeTeXinterchartoks 4 2{\xeCJK@iv@ii} \XeTeXinterchartoks 4 3{\xeCJK@iv@iii} \XeTeXinterchartoks 5 1{\xeCJK@v@i} \XeTeXinterchartoks 5 2{\xeCJK@v@ii} \XeTeXinterchartoks 5 3{\xeCJK@v@iii} \XeTeXinterchartoks 5 255{\xeCJK@v@cclv} \XeTeXinterchartoks 255 0{\xeCJK@cclv@} \XeTeXinterchartoks 255 1{\xeCJK@cclv@i} \XeTeXinterchartoks 255 2{\xeCJK@cclv@ii} \XeTeXinterchartoks 255 3{\xeCJK@cclv@iii} \XeTeXinterchartoks 255 4{\xeCJK@cclv@iv} \XeTeXinterchartoks 1 6{\xeCJK@i@vi} \XeTeXinterchartoks 6 1{\xeCJK@vi@i} \def\xeCJK@vi@i{ \bgroup \xeCJK@emptyCJKtoks \xeCJK@setfont \CJKsymbol} \def\xeCJK@i@vi{ \egroup} \def\xeCJK@i@i{ \CJKglue \CJKsymbol} \def\xeCJK@i@ii#1{ \xeCJK@punctrule{#1}{l} \hskip \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @lglue@#1\endcsname plus 0.1em minus 0.1 em \xeCJK@setprepunct{#1}} \def\xeCJK@i@iii#1{ \xeCJK@punctrule{#1}{r} \ifcsname xeCJK@specialpunct#1\endcsname \CJKglue % breakable \else \nobreak \fi \global\edef\xeCJK@lastpunct{#1} \CJKpunctsymbol{#1}} \def\xeCJK@setprepunct#1{ \edef\xeCJK@lastpunct{#1} \vrule width \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @lrule@#1\endcsname depth \z@ height \z@ \CJKpunctsymbol{#1}} \def\xeCJK@i@cclv{ \egroup {\xeCJK@CJKkern} \xeCJK@ignorespaces} \def\xeCJK@ii@i{ \nobreak \CJKsymbol} \def\xeCJK@ii@ii#1{ \nobreak \xeCJK@punctrule{#1}{l} \xeCJK@setkern{\xeCJK@lastpunct}{#1} \kern \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern\xeCJK@lastpunct#1\endcsname \xeCJK@setprepunct{#1}} \def\xeCJK@ii@iii#1{ \nobreak \xeCJK@punctrule{#1}{r} \xeCJK@setkern{\xeCJK@lastpunct}{#1} \kern \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern\xeCJK@lastpunct#1\endcsname \nobreak \edef\xeCJK@lastpunct{#1} \CJKpunctsymbol{#1}} \def\xeCJK@ii@{ \nobreak \egroup} \let\xeCJK@ii@iv\xeCJK@ii@ \let\xeCJK@ii@v\xeCJK@ii@ \def\xeCJK@ii@cclv{ \nobreak \egroup \ignorespaces} \def\xeCJK@iii@{ \xeCJK@afterpostpunct \egroup} \def\xeCJK@iii@i{ \xeCJK@afterpostpunct \CJKsymbol} \def\xeCJK@iii@ii#1{ \vrule width \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @rrule@\xeCJK@lastpunct\endcsname depth \z@ height \z@ \xeCJK@punctrule{#1}{l} \xeCJK@setkern{\xeCJK@lastpunct}{#1} \kern \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern\xeCJK@lastpunct#1\endcsname \xeCJKpunctnobreak \xeCJK@setprepunct{#1}} \def\xeCJK@iii@iii#1{ \vrule width \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @rrule@\xeCJK@lastpunct\endcsname depth \z@ height \z@ \xeCJK@punctrule{#1}{r} \xeCJK@setkern{\xeCJK@lastpunct}{#1} \kern \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @kern\xeCJK@lastpunct#1\endcsname \nobreak \edef\xeCJK@lastpunct{#1} \CJKpunctsymbol{#1}} \def\xeCJK@iii@iv{ \xeCJK@afterpostpunct \egroup} \def\xeCJK@afterpostpunct{ \vrule width \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @rrule@\xeCJK@lastpunct\endcsname depth \z@ height \z@ \hskip \csname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @rglue@\xeCJK@lastpunct\endcsname plus 0.1em minus 0.1 em} \let\xeCJK@iii@v\xeCJK@iii@iv \def\xeCJK@iii@cclv{ \xeCJK@afterpostpunct \egroup \expandafter\xeCJK@ignorespaces} \def\xeCJK@@i{ \CJKecglue \bgroup \xeCJK@setfont \xeCJK@emptyCJKtoks \CJKsymbol} \def\xeCJK@@ii{ \bgroup \xeCJK@setfont \XeTeXinterchartoks 0 2{\relax} \xeCJK@emptyCJKtoks \xeCJK@i@ii} \def\xeCJK@@iii{ \bgroup \xeCJK@setfont \XeTeXinterchartoks 0 3{\relax} \xeCJK@emptyCJKtoks \xeCJK@i@iii} \def\xeCJK@iv@i{ \bgroup \xeCJK@setfont \XeTeXinterchartoks 4 1{\relax} \xeCJK@emptyCJKtoks \CJKsymbol} \def\xeCJK@iv@ii{ \bgroup \xeCJK@setfont \XeTeXinterchartoks 4 2{\relax} \xeCJK@emptyCJKtoks \xeCJK@i@ii} \def\xeCJK@iv@iii{ \bgroup \xeCJK@setfont \XeTeXinterchartoks 4 3{\relax} \xeCJK@emptyCJKtoks \xeCJK@i@iii} \def\xeCJK@v@i{ \CJKecglue \bgroup \xeCJK@setfont \xeCJK@emptyCJKtoks \CJKsymbol} \def\xeCJK@v@ii{ \bgroup \xeCJK@setfont \XeTeXinterchartoks 5 2{\relax} \xeCJK@emptyCJKtoks \xeCJK@i@ii} \def\xeCJK@v@iii{ \bgroup \xeCJK@setfont \XeTeXinterchartoks 5 3{\relax} \xeCJK@emptyCJKtoks \xeCJK@i@iii} \def\xeCJK@emptyCJKtoks{ \XeTeXinterchartoks 255 1{\relax} \XeTeXinterchartoks 255 2{\relax} \XeTeXinterchartoks 255 3{\relax}} \def\xeCJK@@cclv{ \futurelet\xeCJK@nexttoken\xeCJK@zz@cclv} \def\xeCJK@zz@cclv{ \ifx\xeCJK@nexttoken\@sptoken \else {\xeCJK@zerokern} \fi} \let\xeCJK@v@cclv\xeCJK@@cclv \def\xeCJK@cclv@{ \ifnum\lastkern=\@ne \@sptoken%\CJKecglue \fi} \let\xeCJK@cclv@iv\xeCJK@cclv@ \def\xeCJK@cclv@i{{ \ifnum\lastkern=\@ne \CJKglue \else \ifnum\lastkern=\xeCJK@four \@sptoken%\CJKecglue \else \ifnum\lastnodetype=\xeCJK@ten \CJKecglue \fi \fi \fi} \bgroup \xeCJK@emptyCJKtoks \xeCJK@setfont \CJKsymbol} \def\xeCJK@cclv@ii{ \bgroup \xeCJK@emptyCJKtoks \xeCJK@setfont \xeCJK@i@ii} \def\xeCJK@cclv@iii{ \bgroup \xeCJK@emptyCJKtoks \xeCJK@setfont \xeCJK@i@iii} \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@zerokern{\kern -4sp\kern 4sp} \chardef\xeCJK@four=4 \chardef\xeCJK@ten=10 \def\xeCJK@ignorespaces{ \futurelet\xeCJK@nexttoken\xeCJK@checknext} \def\xeCJK@checknext{ \ifx\xeCJK@nexttoken\@sptoken \expandafter\xeCJK@@checknext \else \ifx $\xeCJK@nexttoken \CJKecglue \fi \fi} { \def\:{\xeCJK@@checknext} \global\expandafter\def\: {\futurelet\@let@token\xeCJK@@@checknext} } \def\xeCJK@@@checknext{ \ifx $\@let@token \@sptoken%\CJKecglue \else \if\relax\noexpand\@let@token \ifx\@let@token\xeCJK@par \else \@sptoken \fi \fi \fi \let\xeCJK@nexttoken\relax} \long\def\xeCJK@gobble#1\CJK@stop{} % \end{macrocode} % % 避免单个汉字占一行。 % \begin{macrocode} \def\xeCJK@checksingle#1{ \def\xeCJK@setcurrentchar@i{ \CJKglue \CJKsymbol{#1}} \def\xeCJK@setcurrentnobreakchar@i{ \CJKsymbol{#1}} \futurelet\@let@token\xeCJK@@checksingle} \def\xeCJK@@checksingle{ \ifcat 。\noexpand\@let@token \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} \let\xeCJK@par\par \def\xeCJK@checkpar{ \@ifnextchar\xeCJK@par{\xeCJK@setcurrentnobreakchar@ii}{\xeCJK@setcurrentchar@ii}} % \end{macrocode} % % 设置中英文间距。 % \begin{macrocode} \def\xeCJKsetecglue#1{ \def\CJK@ecglue{#1} \let\CJKecglue\CJK@ecglue} \let\CJKsetecglue\xeCJKsetecglue \CJKsetecglue{ } % \end{macrocode} % % 缺省状态下,不允许在相邻标点中间换行。 % \begin{macrocode} \def\xeCJKallowbreakbetweenpuncts{ \def\xeCJKpunctnobreak{ \hskip 0pt}} \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{ \xdef\xeCJK@bboxname{\xeCJK@family/\f@series/\f@shape} % \end{macrocode} % % 如果 punctstyle$=$plain 不作特殊处理 % % \begin{macrocode} \ifcsname xeCJK\xeCJK@punctstyle\xeCJK@bboxname @#2rule@#1\endcsname \else \ifcsname xeCJK@\xeCJK@bboxname @lspace@#1\endcsname \else {\xeCJK@setfont \xeCJK@setpunctbounds{#1}} \fi \xeCJK@dokerningtrue \ifnum\xeCJK@punctstyle=\xeCJK@ps@plain\relax \xeCJK@dokerningfalse \else \ifcsname xeCJK@specialpunct#1\endcsname \xeCJK@dokerningfalse \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} \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{ \xdef\xeCJK@bboxname{\xeCJK@family/\f@series/\f@shape} \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 \xeCJK@dima 1em\relax \xeCJK@cntb=\number\xeCJK@dima \multiply\xeCJK@cnta 100\relax \divide\xeCJK@cnta\xeCJK@cntb \advance\xeCJK@cnta 1\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} \ifcsname XeTeXglyphbounds\endcsname \else \PackageError{xeCJK}{\string\XeTeXglyphbounds \space not defined.^^J You have to update XeTeX to the version 0.9995.0 or later} \relax \fi % \end{macrocode} % \section{字体设置} % \begin{macrocode} \def\CJKsymbol#1{#1} \def\CJKpunctsymbol#1{#1} \DeclareRobustCommand{\xeCJK@ULprepunctchar}[1]{ {\XeTeXinterchartokenstate=0 \CJKpunctsymbol{#1} \nobreak} \ignorespaces} \DeclareRobustCommand{\xeCJK@ULpostpunctchar}[1]{ {\XeTeXinterchartokenstate=0 \CJKpunctsymbol{#1}} \xeCJK@ignorespaces} \def\xeCJK@ULroutines{ \XeTeXinterchartoks 0 1 {\CJKecglue\CJKsymbol} \XeTeXinterchartoks 4 1 {\CJKsymbol} \XeTeXinterchartoks 5 1 {\CJKecglue\CJKsymbol} \XeTeXinterchartoks 255 1 {\xeCJK@cclv@i} \XeTeXinterchartoks 0 2 {\xeCJK@ULprepunctchar} \XeTeXinterchartoks 4 2 {\xeCJK@ULprepunctchar} \XeTeXinterchartoks 5 2 {\xeCJK@ULprepunctchar} \XeTeXinterchartoks 255 2 {\xeCJK@ULprepunctchar} \XeTeXinterchartoks 0 3 {\xeCJK@ULpostpunctchar} \XeTeXinterchartoks 4 3 {\xeCJK@ULpostpunctchar} \XeTeXinterchartoks 5 3 {\xeCJK@ULpostpunctchar} \XeTeXinterchartoks 255 3 {\xeCJK@ULpostpunctchar}} \AtBeginDocument{ \ifcsname UL@hook\endcsname \addto@hook\UL@hook{ \def\CJKsymbol#1{{\xeCJK@setfont #1}\kern -1sp\kern 1sp\xeCJK@ignorespaces} \def\CJKpunctsymbol#1{{\xeCJK@setfont #1}} \xeCJK@ULroutines} \fi \ifcsname ver@CJKfntef.sty\endcsname \def\XeTeX@CJKfntef@hook{ \xeCJK@setfont \XeTeXinterchartokenstate=0} \fi} \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}} % \end{macrocode} % Redefine \string\rmfamily, \string\sffamily and \string\ttfamily to set CJKfamily % \begin{macrocode} \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} % \end{macrocode} % \string\xeCJK@newfontfamily is similar to \string\newfontfamily % but introduce fake slant/bold fonts for CJK characters. % \begin{macrocode} \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 \edef\xeCJK@Features{} \ifxeCJK@BoldFont@ \ifx\xeCJK@BoldFont\@empty \edef\xeCJK@Features{BoldFont={#3}, BoldFeatures={RawFeature={embolden=\xeCJK@emboldenfactor}}} \fi \fi \ifxeCJK@SlantFont@ \ifx\xeCJK@ItalicFont\@empty \ifx\xeCJK@Features\@empty \edef\xeCJK@Features{ItalicFont={#3}, ItalicFeatures={RawFeature={slant=\xeCJK@slantfactor}}} \else \edef\xeCJK@Features{\xeCJK@Features,ItalicFont={#3}, ItalicFeatures={RawFeature={slant=\xeCJK@slantfactor}}} \fi \fi \ifx\xeCJK@BoldItalicFont\@empty \ifx\xeCJK@BoldFont\@empty \edef\xeCJK@Features{\xeCJK@Features,BoldItalicFont={#3}, BoldItalicFeatures={RawFeature={embolden=\xeCJK@emboldenfactor,slant=\xeCJK@slantfactor}}} \else \edef\xeCJK@Features{\xeCJK@Features,BoldItalicFont={\xeCJK@BoldFont}, BoldItalicFeatures={RawFeature={slant=\xeCJK@slantfactor}}} \fi \fi \fi \edef\xeCJK@temp{#2} \ifx\xeCJK@temp\@empty \else \ifx\xeCJK@Features\@empty \edef\xeCJK@Features{#2} \else \edef\xeCJK@Features{\xeCJK@Features,#2} \fi \fi \edef\@tempa{\noexpand\zf@fontspec{\xeCJK@Features}{#3}} \@tempa \edef\@tempa{ \noexpand\DeclareRobustCommand\expandafter\noexpand\csname xeCJK@font@#1\endcsname {\noexpand\fontfamily{\zf@family}\noexpand\selectfont}} \@tempa \expandafter\edef\csname xeCJK@nsff#1\endcsname{\zf@family}} \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} \define@key[zf]{preparse}{ItalicFeatures}{ \edef\zf@it@feat{,#1} \edef\zf@family@long{\zf@family@long itfeat:#1}} % \end{macrocode} % Redefine \string\zf@fontspec to set slant shape. % \begin{macrocode} \renewcommand*\zf@fontspec[2]{% \begingroup \zf@init \edef\zf@fontname{#2}% \let\zf@family@long\zf@fontname \setkeys*[zf]{prepreparse}{#1}% \let\zf@up\zf@fontname \edef\@tempa{\noexpand\setkeys*[zf]{preparse}{\XKV@rm}}\@tempa \let\zf@fontname\zf@up \let\zf@font@feat\XKV@rm \font\zf@basefont="\zf@font@wrap\zf@fontname\zf@suffix" at \f@size pt \unless\ifzf@icu \zf@set@font@type \fi \ifx\zf@suffix\@empty \ifzf@atsui \def\zf@suffix{/AAT}% \else \ifzf@icu \def\zf@suffix{/ICU}% \fi \fi \font\zf@basefont="\zf@font@wrap\zf@fontname\zf@suffix" at \f@size pt \fi \zf@firsttimetrue \zf@get@feature@requests{\zf@font@feat}% \zf@firsttimefalse \unless\ifcsname zf@UID@\zf@family@long\endcsname \edef\@tempa{#2}% \ifcsname c@zf@famc@\@tempa\endcsname \expandafter\stepcounter\else \expandafter\newcounter\fi {zf@famc@\@tempa}% \gdef@cx{zf@UID@\zf@family@long}{% \expandafter\expandafter\expandafter \zap@space\expandafter\@tempa\space\@empty (\expandafter\the\csname c@zf@famc@\@tempa\endcsname)}% \fi \xdef\zf@family{\@nameuse{zf@UID@\zf@family@long}}% \unless\ifcsname zf@family@fontname\zf@family\endcsname \zf@PackageInfo{Defining font family for '#2' with options [\zf@default@options #1]}% \gdef@cx{zf@family@fontname\zf@family}{\zf@fontname}% \gdef@cx{zf@family@options\zf@family}{\zf@default@options #1}% \gdef@cx{zf@family@fontdef\zf@family} {\zf@fontname\zf@suffix:\zf@pre@ff\zf@ff}% \DeclareFontFamily{\zf@enc}{\zf@family}{}% \zf@make@font@shapes{\zf@fontname} {\mddefault}{\updefault}{\zf@font@feat\zf@up@feat}% \unless\ifzf@nobf \ifx\zf@bf\@empty \zf@make@font@shapes[\zf@fontname]{/B} {\bfdefault}{\updefault}{\zf@font@feat\zf@bf@feat}% \else \zf@make@font@shapes{\zf@bf} {\bfdefault}{\updefault}{\zf@font@feat\zf@bf@feat}% \fi \fi \unless\ifzf@noit \ifx\zf@it\@empty \zf@make@font@shapes[\zf@fontname]{/I} {\mddefault}{\itdefault}{\zf@font@feat\zf@it@feat}% \else \zf@make@font@shapes{\zf@it} {\mddefault}{\itdefault}{\zf@font@feat\zf@it@feat}% \fi \fi \@tempswatrue \ifzf@nobf\@tempswafalse\fi \ifzf@noit\@tempswafalse\fi \if@tempswa \ifx\zf@bfit\@empty \ifx\zf@bf\@empty \ifx\zf@it\@empty \zf@make@font@shapes[\zf@fontname]{/BI} {\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% \else \zf@make@font@shapes[\zf@it]{/B} {\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% \fi \else \zf@make@font@shapes[\zf@bf]{/I} {\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% \fi \else \zf@make@font@shapes{\zf@bfit} {\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% \fi \fi \ifxeCJK@SlantFont@ \zf@make@font@shapes{\zf@fontname}{\mddefault}{\sldefault} {\zf@font@feat,RawFeature={slant=0.167}} \ifx\zf@bf\@empty \ifzf@nobf \zf@make@font@shapes{\zf@fontname}{\bfdefault}{\sldefault} {\zf@font@feat,RawFeature={embolden=4,slant=0.167}} \else \zf@make@font@shapes[\zf@fontname]{/B} {\bfdefault}{\sldefault}{\zf@font@feat\zf@bf@feat,RawFeature={slant=0.167}} \fi \else \ifx\zf@fontname\zf@bf \zf@make@font@shapes{\zf@fontname}{\bfdefault}{\sldefault} {\zf@font@feat,RawFeature={embolden=4,slant=0.167}} \else \zf@make@font@shapes{\zf@bf}{\bfdefault}{\sldefault} {\zf@font@feat\zf@bf@feat,RawFeature={slant=0.167}} \fi \fi \fi \fi \endgroup} \newcount\xeCJK@featureadded \xeCJK@featureadded=0 \let\xeCJK@addfontfeatures\addfontfeatures \def\addCJKfontfeatures#1{ \global\advance\xeCJK@featureadded\@ne \ifcsname xeCJK@family\endcsname \edef\xeCJK@temp{\csname xeCJK@nsff\xeCJK@family\endcsname} \edef\xeCJK@Features{[\csname zf@family@options\xeCJK@temp\endcsname,#1]} \expandafter \newfontfamily@i\csname xeCJK@font@\xeCJK@family @\the\xeCJK@featureadded\expandafter\endcsname \xeCJK@Features {\csname zf@family@fontname\xeCJK@temp\endcsname} \expandafter\edef\csname xeCJK@nsff\xeCJK@family @\the\xeCJK@featureadded\endcsname{\zf@family} \CJKfamily{\xeCJK@family @\the\xeCJK@featureadded} \fi} \def\addfontfeatures#1{ \xeCJK@addfontfeatures{#1} \addCJKfontfeatures{#1}} % redefine \CJKfamily. \def\xeCJK@font@rm{} \DeclareRobustCommand\CJKfamily[1]{ \ifcsname xeCJK@font@#1\endcsname \edef\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{使用CJKnumb宏包} % \begin{macrocode} % \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"} \endlinechar `\^^M \catcode "FEFF=9\relax % \end{macrocode} % % % % \iffalse % % % %<*example-addspaces> % \fi % % \clearpage % \part{example-addspaces.tex} % \begin{macrocode} \documentclass{article} \usepackage[boldfont,slantfont]{xeCJK} \usepackage{xcolor} \setCJKmainfont{AR PL SungtiL GB} \textwidth 190mm \oddsidemargin 0pt \begin{document} \baselineskip 18pt \parskip 10pt \parindent 0em {\slshape 斜体 Slanted \bfseries 斜体 Slanted} \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} \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} \CJKsetecglue{ } \verb+\CJKsetecglue{ }+ \sometexts \end{document} % \end{macrocode} % \iffalse % %<*example-CJKchecksingle> % \fi % % \clearpage % \part{example-CJKchecksingle.tex} % \begin{macrocode} \documentclass{article} \usepackage[boldfont,slantfont,CJKaddspaces,CJKchecksingle]{xeCJK} \setCJKmainfont{AR PL SungtiL GB} \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 \def\xeCJK@i@i{\CJKglue\CJKsymbol} \sometexts \end{document} % \end{macrocode} % \iffalse % %<*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{AR PL SungtiL GB}% 设置缺省中文字体 \setCJKmonofont{AR PL SungtiL GB}% 设置缺省中文字体 \baselineskip 16pt \parindent 2em \section{举例} \begin{verbatim} 标点。 \end{verbatim} \CJKunderline{汉字}\CJKunderline{加下划线加下划线加下划线加下划线% 加下划线加下划线加下划线加下划线加下划线加下划线加下划线} \CJKunderwave{波浪线} \ifcsname CJKunderanyline\endcsname \CJKunderanyline{0.5em}{\sixly \kern-.021em\char58 \kern-.021em}{自定义下划线} \CJKunderanyline{0.2em}{\kern-.03em\vtop{\kern.2ex\hrule width.2em\kern 0.11em \hrule height .1em}\kern-.03em}{自定义下划线} \CJKunderanysymbol{0.2em}{$\cdot$}{汉字加点} \fi \end{document} % \end{macrocode} % \iffalse % % \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