summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/xpinyin
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-07-23 21:58:16 +0000
committerKarl Berry <karl@freefriends.org>2012-07-23 21:58:16 +0000
commit4a4697b0ffba8bffa9c86b07e6a6f6ce3067a489 (patch)
treecbc18919276b756c94eee6cf3480f6d402884bf6 /Master/texmf-dist/source/latex/xpinyin
parentca063a3b051262e45eab720a035a2e4fb4268204 (diff)
xpinyin (23jul12)
git-svn-id: svn://tug.org/texlive/trunk@27121 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/xpinyin')
-rw-r--r--Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx907
-rw-r--r--Master/texmf-dist/source/latex/xpinyin/xpinyin.ins61
2 files changed, 968 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx b/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx
new file mode 100644
index 00000000000..d7e93d53579
--- /dev/null
+++ b/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx
@@ -0,0 +1,907 @@
+% \iffalse meta-comment
+% !TEX program = XeLaTeX
+%<*internal>
+\iffalse
+%</internal>
+%<*readme>
+Introduction
+------------
+xpinyin is a LaTeX package written to simplify the input of Hanyu Pinyin.
+The package provides macros to automatically add pinyin to Chinese characters.
+It can only be used in conjunction with xeCJK or CJKutf8 package.
+
+Given that the implementation of pinyin package of CJK bundle is not very
+well, it seems that xpinyin is a good replacement of it.
+
+You can read the package manual (in Chinese) for more detailed explanations.
+
+It may be distributed and/or modified under the conditions of the
+LaTeX Project Public License (LPPL), either version 1.3c 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.
+
+This work has the LPPL maintenance status "maintained".
+The Current Maintainer of this work is Qing Lee.
+
+This package consists of the file xpinyin.dtx,
+ xpinyin-map.cfg,
+ and the derived files xpinyin.sty,
+ xpinyin.pdf,
+ xpinyin.ins and
+ README (this file).
+
+Author
+------
+Qing Lee
+Email: sobenlee@gmail.com
+
+If you are interested in the process of development you may observe
+
+ http://code.google.com/p/ctex-kit/
+
+Installation
+------------
+The package is supplied in dtx format and as a pre-extracted zip file,
+xpinyin.tds.zip. The later is most convenient for most users: simply
+unzip this in your local texmf directory and run texhash to update the
+database of file locations. If you want to unpack the dtx yourself,
+running "xetex xpinyin.dtx" will extract the package whereas
+"xelatex xpinyin.dtx" will extract it and also typeset the documentation.
+
+The package requires LaTeX3 support as provided in the l3kernel and l3packages
+bundles. Both of these are available on CTAN as ready-to-install zip files.
+Suitable versions are available in the latest version of MiKTeX and TeX Live
+(updating the relevant packages online may be necessary).
+
+To compile the documentation without error, you will need the xeCJK package
+and some specific Chinese Simplified fonts (TrueType or OpenType).
+%</readme>
+%<*internal>
+\fi
+\ifnum\strcmp{\fmtname}{plain}=0 \else
+ \expandafter\begingroup
+\fi
+%</internal>
+%<*install>
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+\preamble
+
+ Copyright (C) 2012 by Qing Lee <sobenlee@gmail.com>
+--------------------------------------------------------------------------
+ This work 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.
+
+ This work has the LPPL maintenance status "maintained".
+ The Current Maintainer of this work is Qing Lee.
+
+\endpreamble
+\postamble
+
+ This package consists of the file xpinyin.dtx,
+ xpinyin-map.cfg,
+ and the derived files xpinyin.sty,
+ xpinyin.pdf,
+ xpinyin.ins and
+ README.
+\endpostamble
+\usedir{tex/latex/xpinyin}
+\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
+%</install>
+%<install>\endbatchfile
+%<*internal>
+\usedir{source/latex/xpinyin}
+\generate{\file{\jobname.ins}{\from{\jobname.dtx}{install}}}
+\nopreamble\nopostamble
+\usedir{doc/latex/zhnumber}
+\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}}
+\ifnum\strcmp{\fmtname}{plain}=0
+ \expandafter\endbatchfile
+\else
+ \expandafter\endgroup
+\fi
+%</internal>
+%
+%<*driver|package>
+\NeedsTeXFormat{LaTeX2e}
+%<*driver>
+\ProvidesFile{xpinyin.dtx}
+%</driver>
+\RequirePackage{expl3}
+\GetIdInfo$Id: xpinyin.dtx 351 2012-07-20 05:30:58Z sobenlee $
+ {package for automatically add pinyin to Chinese characters}
+%</driver|package>
+%
+%<*driver>
+\documentclass{l3doc}
+\usepackage{xeCJK}
+\usepackage{xpinyin}
+\usepackage{fvrb-ex}
+\usepackage{metalogo}
+\hypersetup{pdfstartview=FitH}
+\fvset{formatcom=\CJKfixedspacing}
+\linespread{1.1}
+\addtolength{\voffset}{-5\baselineskip}
+\addtolength\textheight{8\baselineskip}
+\setmainfont{TeX Gyre Pagella}
+\setmonofont{Inconsolata}
+\setCJKmainfont[BoldFont=Adobe Heiti Std,ItalicFont=Adobe Kaiti Std]{Adobe Song Std}
+\setCJKmonofont{Adobe Kaiti Std}
+\xeCJKsetup{PunctStyle=kaiming}
+\newfontfamily\PinYinFont{TeX Gyre Adventor}
+\xpinyinsetup{font=\PinYinFont,multiple=\color{red}}
+\def\MacroFont{\small\normalfont\ttfamily}
+\makeatletter
+\let\orig@meta\meta
+\def\meta#1{\orig@meta{\normalfont\itshape#1}}
+\def\TF{true\orvar{}false}
+\def\TTF{\defaultvar{true}\orvar{}false}
+\def\TFF{true\orvar\defaultvar{false}}
+\def\orvar{\char`\|}
+\let\defaultvar\textbf
+\def\argbrace#1{\char`\{#1\char`\}}
+\makeatother
+\def\indexname{代码索引}
+\IndexPrologue{%
+ \section*{\indexname}
+ \markboth{\indexname}{\indexname}
+ 斜体的数字表示对应项说明所在的页码,下划线的数字表示定义所在的代码行号,而直立体的
+ 数字表示对应项使用时所在的行号。}
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \GetFileInfo{\jobname.sty}
+%
+% \title{\bfseries\pkg{xpinyin} 宏包}
+% \author{李清\\ \path{sobenlee@gmail.com}}
+% \date{\filedate\qquad\fileversion}
+% \maketitle
+%
+% \begin{documentation}
+%
+% \section{简介}
+%
+% \pkg{xpinyin} 是一个 \LaTeX 宏包,提供了为汉字自动注音的功能。
+%
+% \section{基本用法}
+%
+% \pkg{xpinyin} 只支持采用 |UTF-8| 编码的 \TeX 源文件。如果使用 \LaTeX 或 pdf\LaTeX 的
+% 编译方式,则 \pkg{xpinyin} 依赖 \pkg{CJKutf8} 宏包^^A
+% \footnote{\url{http://mirrors.ctan.org/language/chinese/CJK/}};
+% 如果使用 \XeLaTeX{},则依赖 \pkg{xeCJK} 宏包^^A
+% \footnote{\url{http://mirrors.ctan.org/macros/xetex/latex/xecjk/}}。
+% \pkg{xpinyin} 不会自动载入 \pkg{CJKutf8} 或 \pkg{xeCJK} 宏包,应该在它之前或之后
+% 自行载入。
+%
+% 需要注意的是,\pkg{xpinyin} 缺省将拼音的字体设置为与文档的主字体(\cs{normalfont})相同,
+% 所以为了保证声调字母的正确输出,应该选用合适的西文主字体。也可以通过将在下一节介绍的
+% \meta{font} 选项来单独设置拼音的字体。
+%
+% \begin{minipage}[t]{\dimexpr(\linewidth-\parindent-2em)/2\relax}
+% \XeLaTeX 下的简单示例:
+% \begin{verbatim}[frame=single,gobble=3]
+% \documentclass{article}
+% \usepackage{xeCJK}
+% \usepackage{xpinyin}
+% \setmainfont{CMU Serif}
+% \setCJKmainfont{SimSun}
+%
+% \begin{document}
+% \xpinyin*{汉语拼音示例}
+% \end{document}
+% \end{verbatim}
+% \end{minipage}\qquad
+% \begin{minipage}[t]{\dimexpr(\linewidth-\parindent-2em)/2\relax}
+% (pdf)\LaTeX 下的简单示例:
+% \begin{verbatim}[frame=single,gobble=3]
+% \documentclass{article}
+% \usepackage{CJKutf8}
+% \usepackage{xpinyin}
+% \usepackage[T1]{fontenc}
+% \usepackage{lmodern}
+%
+% \begin{document}
+% \begin{CJK}{UTF8}{gbsn}
+% \xpinyin*{汉语拼音示例}
+% \end{CJK}
+% \end{document}
+% \end{verbatim}
+% \hrule height \dp\strutbox width 0pt \relax
+% \end{minipage}
+%
+% 运行上述示例要求系统安装了设置的字体,源文件用 |UTF-8| 编码保存,使用相应的编译方式。
+%
+% \pkg{xpinyin} 可以与 \pkg{ctex} 宏包或文档类^^A
+% \footnote{\url{http://mirrors.ctan.org/language/chinese/ctex/}} 共同使用,使用
+% 方式与上面类似。
+%
+% \section{用户手册}
+%
+% \begin{function}{pinyinscope}
+% \begin{syntax}
+% \cs{begin}\argbrace{pinyinscope}\oarg{options}
+% .....
+% \cs{end}\argbrace{pinyinscope}
+% \end{syntax}
+% 为 \env{pinyinscope} 环境中的汉字自动注音。例如
+% \begin{Example}[frame=single,numbers=left,gobble=5]
+% \begin{pinyinscope}
+% 列位看官:你道此书从何而来?说起根由,虽近荒唐,细按则深有趣味。
+% 待在下将此来历注明,方使阅者\xpinyin{了}{liao3}然不惑。
+% \end{pinyinscope}
+% \end{Example}
+% 可选项 \meta{options} 用于局部设置拼音的格式,将在下面说明。
+% \end{function}
+%
+% \begin{function}{\xpinyin}
+% \begin{syntax}
+% \cs{xpinyin} \oarg{options} \Arg{单个汉字} \Arg{拼音}
+% \cs{xpinyin*} \oarg{options} \Arg{文字}
+% \end{syntax}
+% 对于多音字,可以使用 \cs{xpinyin} 为其设置拼音;而 \cs{xpinyin*} 相当于
+% \env{pinyinscope} 环境的命令形式。\cs{xpinyin} 可以在 \env{pinyinscope} 环境和
+% \cs{xpinyin*} 中使用。例如,\\[1ex]
+% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.5\linewidth,gobble=5]
+% \xpinyin{长}{chang2}\\
+% \xpinyin*{甄士隐梦幻识通灵}\\
+% \xpinyin*{\xpinyin{重}{zhong4}要}
+% \end{SideBySideExample}
+% \end{function}
+%
+% \begin{function}{\pinyin}
+% \begin{syntax}
+% \cs{pinyin} \oarg{options} \Arg{拼音}
+% \end{syntax}
+% 用于输出拼音,为了输入的方便 \texttt{\"u} 可以用 |v| 代替。例如,\\[1ex]
+% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.5\linewidth,gobble=5]
+% \pinyin{lv2zi}\\
+% \pinyin{nv3hai2zi}
+% \end{SideBySideExample}
+% \end{function}
+%
+% \begin{function}{\setpinyin}
+% \begin{syntax}
+% \cs{setpinyin} \Arg{汉字} \Arg{拼音}
+% \end{syntax}
+% \pkg{xpinyin} 宏包的拼音数据(\file{xpinyin-map.cfg})来源于 \texttt{Unicode 6.1.0}
+% 的 \texttt{Unihan} 数据库\footnotemark 中的 \file{Unihan_Readings.txt} 文件。对于多
+% 音字,一般来说这个文件选用的是常用读音。可以使用 \cs{setpinyin} 来设置多音字的首选读音。
+% \end{function}
+%
+% \footnotetext{\url{http://www.unicode.org/Public/UNIDATA/Unihan.zip}}
+%
+% \begin{function}{\xpinyinsetup}
+% \begin{syntax}
+% \cs{xpinyinsetup} \argbrace{\meta{key1}=\meta{var1}, \meta{key2}=\meta{var2}, ...}
+% \end{syntax}
+% 用于在导言区或文档中,设置拼音的格式。目前可以设置的 \meta{key} 如下介绍。
+% \end{function}
+%
+% \begin{function}{ratio}
+% \begin{syntax}
+% ratio = \marg{number}
+% \end{syntax}
+% 设置拼音字体大小与当前正文字体大小的比例,缺省值是 |0.4|。
+% \end{function}
+%
+% \begin{function}{vsep}
+% \begin{syntax}
+% vsep = \marg{dimen}
+% \end{syntax}
+% 设置拼音的基线与汉字基线的间距,缺省值是 |1 em|。
+% \end{function}
+%
+% \begin{function}{hsep}
+% \begin{syntax}
+% hsep = \marg{skip}
+% \end{syntax}
+% 设置注音汉字之间的间距,缺省值与 \cs{CJKglue} 的值相同。为了断行时行末的对齐,设置
+% 的 \meta{skip} 最后有一定的弹性。例如
+% \begin{Example}[frame=single,numbers=left,gobble=5]
+% \xpinyin*[ratio={.7},hsep={.5em plus .1em},vsep={1.1em}]{贾雨村风尘怀闺秀}
+% \end{Example}
+% \end{function}
+%
+% \begin{function}{pysep}
+% \begin{syntax}
+% pysep = \marg{glue}
+% \end{syntax}
+% 设置 \cs{pinyin} 输出的相邻两个汉语拼音的空白,缺省值是一个空格。
+% \end{function}
+%
+% \begin{function}{font}
+% \begin{syntax}
+% font = \marg{font}
+% \end{syntax}
+% 设置拼音的字体,缺省值是 \cs{normalfont},即以正文西文字体相同。为了保证拼音能正确
+% 输出,最好选用收字量较大的西文字体。
+% \end{function}
+%
+% \begin{function}{format}
+% \begin{syntax}
+% format = \marg{format}
+% \end{syntax}
+% 设置拼音的其它格式,例如颜色等,缺省值为空。
+% \end{function}
+%
+% \begin{function}{multiple}
+% \begin{syntax}
+% multiple = \marg{format}
+% \end{syntax}
+% 设置多音字拼音的其它格式,缺省值为空。可以通过这个选项来提醒校正多音字的拼音。例如
+% 本文档设置多音字拼音的颜色是红色:
+% \begin{verbatim}[frame=single,gobble=5]
+% \xpinyinsetup{multiple={\color{red}}}
+% \end{verbatim}
+% \end{function}
+%
+% \end{documentation}
+%
+%
+% \begin{implementation}
+%
+% \section{代码实现}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+% \begin{macrocode}
+\ProvidesExplPackage{\ExplFileName}{\ExplFileDate}{1.1}{\ExplFileDescription}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\msg_new:nnn { xpinyin } { no-LuaTeX }
+ {
+ The~xpinyin~package~is~not~supported~in~LuaTeX.\\\\
+ You~must~change~your~typesetting~engine~to\\
+ "xelatex"~or~"pdflatex"~or~"latex"~instead~of~"lualatex".
+ }
+\luatex_if_engine:T { \msg_critical:nn { xpinyin } { no-LuaTeX } }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{xparse}
+\RequirePackage{l3keys2e}
+% \end{macrocode}
+%
+% \begin{macro}[internal,var]{\l_xpinyin_tmpa_box,\l_xpinyin_tmpb_box}
+% \begin{macrocode}
+\box_new:N \l_xpinyin_tmpa_box
+\box_new:N \l_xpinyin_tmpb_box
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_make_box:nn}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_make_box:nn
+ { \xpinyin_save_CJKsymbol:n {#1} \xpinyin_make_pinyin_box:nn {#1} {#2} }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_make_pinyin_box:nn}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_make_pinyin_box:nn
+ {
+ \hbox_overlap_left:n
+ {
+ \hbox_set:Nn \l_xpinyin_tmpa_box
+ { \xpinyin_CJKsymbol_hook: \xpinyin_save_CJKsymbol:n {#1} }
+ \hbox_set:Nn \l_xpinyin_tmpb_box
+ {
+ \color_group_begin: \color_ensure_current:
+ \xpinyin_select_font:
+ \l_xpinyin_format_tl
+ \clist_if_exist:cT
+ { c_xpinyin_multiple_ \xpinyin_CJKsymbol_to_unicode:n {#1} _clist }
+ { \l_xpinyin_multiple_tl }
+ {#2}
+ \color_group_end:
+ }
+ \dim_compare:nNnT
+ { \box_wd:N \l_xpinyin_tmpb_box } >
+ { \box_wd:N \l_xpinyin_tmpa_box + \l_xpinyin_CJKglue_dim }
+ {
+ \box_resize:Nnn \l_xpinyin_tmpb_box
+ { \dim_eval:n { \box_wd:N \l_xpinyin_tmpa_box + \l_xpinyin_CJKglue_dim } }
+ { \dim_eval:n { \box_ht:N \l_xpinyin_tmpb_box + \box_dp:N \l_xpinyin_tmpb_box } }
+ }
+ \box_move_up:nn { \l_xpinyin_vsep_tl }
+ {
+ \hbox_to_wd:nn { \box_wd:N \l_xpinyin_tmpa_box }
+ { \tex_hss:D \box_use_clear:N \l_xpinyin_tmpb_box \tex_hss:D }
+ }
+ }
+ { \xpinyin_CJK_node: }
+ \xpinyin_CJK_ignorespaces:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_CJKsymbol:n}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_CJKsymbol:n
+ { \xpinyin_make_box:nn {#1} { \xpinyin_to_pinyin:n {#1} } }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_to_pinyin:n}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_to_pinyin:n
+ { \use:c { c_xpinyin_ \xpinyin_CJKsymbol_to_unicode:n {#1} _tl } }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{pinyinscope}
+% \begin{macrocode}
+\NewDocumentEnvironment { pinyinscope } { O{} }
+ {
+ \keys_set:nn { xpinyin } {#1}
+ \tl_if_empty:NF \l_xpinyin_hsep_tl
+ { \cs_set_nopar:Npn \CJKglue { \skip_horizontal:n { \l_xpinyin_hsep_tl } } }
+ \settowidth \l_xpinyin_CJKglue_dim { \CJKglue }
+ \xpinyin_replace_CJKsymbol:
+ }
+ { \cs_gset_eq:NN \CJKsymbol \xpinyin_save_CJKsymbol:n }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\xpinyin}
+% \begin{macrocode}
+\NewDocumentCommand \xpinyin { s O{} m }
+ {
+ \IfBooleanTF {#1}
+ {
+ \group_begin:
+ \keys_set:nn { xpinyin } {#2}
+ \tl_if_empty:NF \l_xpinyin_hsep_tl
+ { \cs_set_nopar:Npn \CJKglue { \skip_horizontal:n { \l_xpinyin_hsep_tl } } }
+ \settowidth \l_xpinyin_CJKglue_dim { \CJKglue }
+ \xpinyin_replace_CJKsymbol:
+ #3
+ \group_end:
+ }
+ {
+ \group_begin:
+ \keys_set:nn { xpinyin } {#2}
+ \settowidth \l_xpinyin_CJKglue_dim { \CJKglue }
+ \xpinyin_xpinyin_single_aux:nn {#3}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal,var]{\l_xpinyin_CJKglue_dim}
+% \begin{macrocode}
+\dim_new:N \l_xpinyin_CJKglue_dim
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_xpinyin_single_aux:nn}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_xpinyin_single_aux:nn
+ {
+ \xpinyin_xpinyin_single_hook:n
+ { \cs_set_eq:NN \xpinyin_save_CJKsymbol:n \use:n }
+ \cs_set_eq:NN \xpinyin_CJKsymbol_to_unicode:n \xpinyin_CJKchar_to_unicode:n
+ \xpinyin_make_box:nn {#1} { \xpinyin_pinyin:n {#2} }
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_replace_CJKsymbol_aux:}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_replace_CJKsymbol_aux:
+ {
+ \cs_if_eq:NNF \CJKsymbol \xpinyin_CJKsymbol:n
+ {
+ \cs_set_eq:NN \xpinyin_save_CJKsymbol:n \CJKsymbol
+ \cs_set_eq:NN \CJKsymbol \xpinyin_CJKsymbol:n
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_xpinyin_single_hook_aux:n}
+% \begin{macrocode}
+\cs_new_nopar:Npn \xpinyin_xpinyin_single_hook_aux:n
+ {
+ \cs_if_eq:NNTF \CJKsymbol \xpinyin_CJKsymbol:n
+ {
+ \cs_set_eq:NN \CJKsymbol \xpinyin_save_CJKsymbol:n
+ \cs_set_eq:NN \xpinyin_save_CJKsymbol:n \use:n
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_select_font_xetex:}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_select_font_xetex:
+ {
+ \cs_if_exist_use:cF { \l_xpinyin_coor_tl }
+ {
+ \tl_set:Nx \l_xpinyin_current_coor_tl { \l_xpinyin_coor_tl }
+ \xpinyin_select_font_aux:
+ \int_compare:nNnT { \XeTeXfonttype \tex_font:D } > \c_zero
+ {
+ \exp_last_unbraced:NNV
+ \cs_gset_eq:cN \l_xpinyin_current_coor_tl \tex_font:D
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_select_font_aux:}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_select_font_aux:
+ {
+ \dim_set:Nn \l_tmpa_dim { \f@size \p@ }
+ \fontsize { \l_xpinyin_ratio_tl \l_tmpa_dim } \c_zero_dim
+ \l_xpinyin_font_tl
+ \selectfont
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_CJKsymbol_to_unicode_xetex:n}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_CJKsymbol_to_unicode_xetex:n { \int_to_hexadecimal:n {`#1} }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]
+% {\xpinyin_CJKsymbol_to_unicode_pdftex:n,\xpinyin_CJKchar_to_unicode_pdftex:n}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_CJKsymbol_to_unicode_pdftex:n
+ { \int_to_hexadecimal:n { \int_from_hexadecimal:V \CJK@plane * "100 + #1 } }
+\cs_new_nopar:Nn \xpinyin_CJKchar_to_unicode_pdftex:n
+ { \int_to_hexadecimal:n { \xpinyin_UTF_viii_to_unicode:NNNw #1 \q_stop } }
+\cs_new_nopar:Npn \xpinyin_UTF_viii_to_unicode:NNNw #1#2#3#4 \q_stop
+ {
+ \tl_if_empty:nTF {#4}
+ { ( `#1 - "E0 ) * "1000 + ( `#2 - "80 ) * "40 + ( `#3 - "80 ) }
+ { ( `#1 - "F0 ) * "4000 + ( `#2 - "80 ) * "1000 + ( `#3 - "80 ) * "40 + ( `#4 - "80 ) }
+ }
+\cs_generate_variant:Nn \int_from_hexadecimal:n { V }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_adjust_xeCJK_hook:}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_adjust_xeCJK_hook:
+ {
+ \cs_new_eq:NN \xpinyin_select_font: \xpinyin_select_font_xetex:
+ \cs_new_eq:NN \xpinyin_CJKsymbol_to_unicode:n \xpinyin_CJKsymbol_to_unicode_xetex:n
+ \cs_new_eq:NN \xpinyin_CJKchar_to_unicode:n \xpinyin_CJKsymbol_to_unicode:n
+ \cs_new_eq:NN \xpinyin_replace_CJKsymbol: \xpinyin_replace_CJKsymbol_aux:
+ \cs_new_eq:NN \xpinyin_CJK_node: \xeCJK_CJK_kern:
+ \cs_new_eq:NN \xpinyin_CJK_ignorespaces: \xeCJK_ignorespaces:
+ \cs_if_exist:NF \xpinyin_CJK_node:
+ { \cs_new_nopar:Npn \xpinyin_CJK_node: { \xeCJK_make_node:n { CJK } } }
+ \tl_gset:Nn \l_xpinyin_coor_tl
+ { (\cs_meaning:N \l_xpinyin_font_tl)/\l_xeCJK_font_coor_tl/\l_xpinyin_ratio_tl }
+ \cs_new_nopar:Nn \xpinyin_CJKsymbol_hook: { \makexeCJKinactive \xeCJK_select_font: }
+ \cs_new_nopar:Npn \xpinyin_xpinyin_single_hook:n
+ { \cs_if_eq:NNTF \CJKsymbol \xpinyin_CJKsymbol:n { \cs_set_eq:NN \CJKsymbol \use:n } }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_adjust_CJK_hook:}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_adjust_CJK_hook:
+ {
+ \cs_new_eq:NN \xpinyin_select_font: \xpinyin_select_font_aux:
+ \cs_new_eq:NN \xpinyin_CJKsymbol_to_unicode:n \xpinyin_CJKsymbol_to_unicode_pdftex:n
+ \cs_new_eq:NN \xpinyin_CJKchar_to_unicode:n \xpinyin_CJKchar_to_unicode_pdftex:n
+ \cs_new_eq:NN \xpinyin_CJKsymbol_hook: \prg_do_nothing:
+ \cs_new_eq:NN \xpinyin_CJK_node: \CJK@CJK
+ \cs_new_eq:NN \xpinyin_CJK_ignorespaces: \prg_do_nothing:
+ \@ifpackageloaded { CJKpunct }
+ { \xpinyin_adjust_CJKpunct_hook: }
+ {
+ \cs_new_eq:NN \xpinyin_replace_CJKsymbol: \xpinyin_replace_CJKsymbol_aux:
+ \cs_new_eq:NN \xpinyin_xpinyin_single_hook:n \xpinyin_xpinyin_single_hook_aux:n
+ }
+ \prop_map_function:NN \g_xpinyin_tone_prop \DeclareUnicodeCharacter
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_adjust_CJKpunct_hook:}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_adjust_CJKpunct_hook:
+ {
+ \cs_new_nopar:Nn \xpinyin_replace_CJKsymbol:
+ {
+ \int_compare:nNnTF { \CJKpunct@punctstyle } = { \CJKpunct@ps@plain }
+ { \xpinyin_replace_CJKsymbol_aux: }
+ {
+ \cs_if_eq:NNF \CJKosymbol \xpinyin_CJKsymbol:n
+ {
+ \cs_set_eq:NN \xpinyin_save_CJKsymbol:n \CJKosymbol
+ \cs_set_eq:NN \CJKosymbol \xpinyin_CJKsymbol:n
+ }
+ }
+ }
+ \cs_new_nopar:Npn \xpinyin_xpinyin_single_hook:n
+ {
+ \int_compare:nNnTF { \CJKpunct@punctstyle } = { \CJKpunct@ps@plain }
+ { \xpinyin_xpinyin_single_hook_aux:n }
+ {
+ \cs_if_eq:NNTF \CJKosymbol \xpinyin_CJKsymbol:n
+ {
+ \cs_set_eq:NN \CJKosymbol \xpinyin_save_CJKsymbol:n
+ \cs_set_eq:NN \xpinyin_save_CJKsymbol:n \use:n
+ }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\AtBeginDocument
+ {
+ \@ifpackageloaded { xeCJK }
+ { \xpinyin_adjust_xeCJK_hook: }
+ {
+ \@ifpackageloaded { CJKutf8 }
+ { \xpinyin_adjust_CJK_hook: }
+ { \msg_warning:nn { xpinyin } { invalid } }
+ }
+ }
+\msg_new:nnn { xpinyin } { invalid }
+ {
+ If~you~want~to~use~xpinyin~in~the~right~way,~you\\
+ should~load~the~\xetex_if_engine:TF { xeCJK } { CJKutf8 }~
+ package~in~the~preamble.\\
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\pinyin}
+% \begin{macrocode}
+\NewDocumentCommand \pinyin { O{} m }
+ {
+ \group_begin:
+ \keys_set:nn { xpinyin } {#1}
+ \l_xpinyin_font_tl
+ \l_xpinyin_format_tl
+ \selectfont
+ \xpinyin_pinyin:n {#2}
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_pinyin:n}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_pinyin:n
+ {
+ \xpinyin_xpinyin_init:
+ \bool_set_true:N \l_xpinyin_first_bool
+ \tl_set:Nn \l_xpinyin_save_tl {#1}
+ \xpinyin_xpinyin_aux:N #1 \q_recursion_tail \q_recursion_stop
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_xpinyin_aux:N}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_xpinyin_aux:N
+ {
+ \quark_if_recursion_tail_stop_do:Nn #1
+ {
+ \bool_if:NTF \l_xpinyin_first_bool { \l_xpinyin_save_tl }
+ { \tl_if_empty:NF \l_tmpc_tl { \l_xpinyin_pysep_tl \l_tmpc_tl } }
+ }
+ \xpinyin_if_number:NTF {#1}
+ {
+ \bool_if:NTF \l_xpinyin_first_bool
+ { \bool_set_false:N \l_xpinyin_first_bool }
+ { \l_xpinyin_pysep_tl }
+ \l_tmpa_tl
+ \xpinyin_tone:Vn \l_xpinyin_tone_tl {#1}
+ \l_tmpb_tl
+ \xpinyin_xpinyin_init:
+ }
+ {
+ \int_compare:nNnTF
+ { 0 \use:c { c_xpinyin_ \tl_to_str:V \l_xpinyin_tone_tl _tl } } >
+ { 0 \use:c { c_xpinyin_ \tl_to_str:n {#1} _tl } }
+ { \tl_put_right:Nn \l_tmpb_tl {#1} }
+ {
+ \tl_set:Nn \l_xpinyin_tone_tl {#1}
+ \tl_set_eq:NN \l_tmpa_tl \l_tmpc_tl
+ \tl_clear:N \l_tmpb_tl
+ }
+ \tl_put_right:Nx \l_tmpc_tl { \xpinyin_replace_v:N {#1} }
+ }
+ \xpinyin_xpinyin_aux:N
+ }
+\cs_generate_variant:Nn \tl_to_str:n { V }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_tone:Nn}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_tone:Nn
+ { \use:c { xpinyin_num_to_tone_ #1 :Nn } {#1} {#2} }
+\cs_generate_variant:Nn \xpinyin_tone:Nn { V }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_replace_v:N}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_replace_v:N
+ {
+ \str_if_eq:nnTF {#1} { v }
+ {
+ \bool_if:nTF
+ { \str_if_eq_p:Vn \l_tmpc_tl { l } || \str_if_eq_p:Vn \l_tmpc_tl { n } }
+ { \exp_not:n { ü} } { u }
+ }
+ { \exp_not:n {#1} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_xpinyin_init:}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_xpinyin_init:
+ {
+ \tl_clear:N \l_tmpa_tl \tl_clear:N \l_tmpb_tl
+ \tl_clear:N \l_tmpc_tl \tl_clear:N \l_xpinyin_tone_tl
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal,pTF]{\xpinyin_if_number:N}
+% \begin{macrocode}
+\prg_new_conditional:Nnn \xpinyin_if_number:N { p , T , F , TF }
+ {
+ \if_int_compare:w \c_one < 1 #1 \exp_stop_f:
+ \prg_return_true: \else: \prg_return_false: \fi:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal,var]{\l_xpinyin_first_bool}
+% \begin{macrocode}
+\bool_new:N \l_xpinyin_first_bool
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal,var]
+% {\c_xpinyin_a_tl,\c_xpinyin_o_tl,\c_xpinyin_e_tl,\c_xpinyin_i_tl,
+% \c_xpinyin_u_tl,\c_xpinyin_v_tl}
+% \begin{macrocode}
+\tl_const:Nn \c_xpinyin_a_tl { 3 }
+\tl_const:Nn \c_xpinyin_o_tl { 2 }
+\tl_const:Nn \c_xpinyin_e_tl { 2 }
+\tl_const:Nn \c_xpinyin_i_tl { 1 }
+\tl_const:Nn \c_xpinyin_u_tl { 1 }
+\tl_const:Nn \c_xpinyin_v_tl { 1 }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\xpinyin_num_to_tone:Nn}
+% \begin{macrocode}
+\cs_new_nopar:Nn \xpinyin_num_to_tone:Nn
+ {
+ \if_case:w \int_eval:n { #2 - \c_one } \exp_stop_f:
+ \= {#1} \or: \'{#1} \or: \v {#1} \or: \` {#1} \else: #1 \fi:
+ }
+\tl_map_inline:nn { a o e u }
+ { \cs_new_eq:cN { xpinyin_num_to_tone_ #1 :Nn } \xpinyin_num_to_tone:Nn }
+\cs_new_nopar:Nn \xpinyin_num_to_tone_i:Nn
+ {
+ \if_case:w \int_eval:n { #2 - \c_one } \exp_stop_f:
+ ī \or: í \or: ǐ \or: ì \else: i \fi:
+ }
+\cs_new_nopar:Nn \xpinyin_num_to_tone_v:Nn
+ {
+ \bool_if:nTF
+ { \str_if_eq_p:Vn \l_tmpa_tl { l } || \str_if_eq_p:Vn \l_tmpa_tl { n } }
+ {
+ \if_case:w \int_eval:n { #2 - \c_one } \exp_stop_f:
+ ǖ \or: ǘ \or: ǚ \or: ǜ \else: ü \fi:
+ }
+ { \xpinyin_num_to_tone:Nn u {#2} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\g_xpinyin_tone_prop,\xpinyin_prop_put_aux:n}
+% \begin{macrocode}
+\prop_new:N \g_xpinyin_tone_prop
+\cs_new_nopar:Nn \xpinyin_prop_put_aux:n { \prop_gput:Nnn \g_xpinyin_tone_prop #1 }
+\clist_map_function:nN
+ {
+ {0101}{\=a} , {00E1}{\'a} , {01CE}{\v{a}} , {00E0}{\`a} ,
+ {014D}{\=o} , {00F3}{\'o} , {01D2}{\v{o}} , {00F2}{\`o} ,
+ {0113}{\=e} , {00E9}{\'e} , {011B}{\v{e}} , {00E8}{\`e} ,
+ {012B}{\={\i}} , {00ED}{\'{\i}} , {01D0}{\v{\i}} , {00EC}{\`{\i}} ,
+ {016B}{\=u} , {00FA}{\'u} , {01D4}{\v{u}} , {00F9}{\`u} ,
+ {00FC}{\"u} ,
+ {01D6}{\={\"u}} , {01D8}{\'{\"u}} , {01DA}{\v{\"u}} , {01DC}{\`{\"u}}
+ }
+ \xpinyin_prop_put_aux:n
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\xpinyinsetup}
+% \begin{macrocode}
+\NewDocumentCommand \xpinyinsetup { m } { \keys_set:nn { xpinyin } {#1} }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{ratio,vsep,hsep,pysep,font,format,multiple}
+% \begin{macrocode}
+\clist_map_inline:nn
+ { ratio , vsep , hsep , pysep , font , format , multiple }
+ { \keys_define:nn { xpinyin } { #1 .tl_set:c = { l_xpinyin_ #1 _tl } } }
+\keys_set:nn { xpinyin }
+ {
+ ratio = .4 ,
+ vsep = 1 em ,
+ pysep = \c_space_tl ,
+ font = \normalfont ,
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{xpinyin-map.cfg}
+% \begin{macrocode}
+\group_begin:
+\char_set_catcode_active:N \U
+\char_set_catcode_active:N \V
+\cs_set_nopar:Npn U+ #1 ~ #2 ~ { \tl_gset:cn { c_xpinyin_ #1 _tl } {#2} }
+\cs_set_nopar:Npn V+ #1 ~ #2 ~ { \clist_gset:cn { c_xpinyin_multiple_ #1 _clist } {#2} }
+\char_set_catcode_space:N \
+\file_input:n {xpinyin-map.cfg}
+\group_end:
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setpinyin}
+% \begin{macrocode}
+\NewDocumentCommand \setpinyin { m m }
+ {
+ \tl_set:cn
+ { c_xpinyin_ \xpinyin_CJKchar_to_unicode:n {#1} _tl }
+ { \xpinyin_pinyin:n {#2} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\ProcessKeysOptions { xpinyin }
+% \end{macrocode}
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \end{implementation}
+%
+% \PrintIndex
+% \Finale
+%
+\endinput
diff --git a/Master/texmf-dist/source/latex/xpinyin/xpinyin.ins b/Master/texmf-dist/source/latex/xpinyin/xpinyin.ins
new file mode 100644
index 00000000000..d9c59d952df
--- /dev/null
+++ b/Master/texmf-dist/source/latex/xpinyin/xpinyin.ins
@@ -0,0 +1,61 @@
+%%
+%% This is file `xpinyin.ins',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% xpinyin.dtx (with options: `install')
+%%
+%% Copyright (C) 2012 by Qing Lee <sobenlee@gmail.com>
+%% --------------------------------------------------------------------------
+%% This work 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.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%% The Current Maintainer of this work is Qing Lee.
+%%
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+\preamble
+
+ Copyright (C) 2012 by Qing Lee <sobenlee@gmail.com>
+--------------------------------------------------------------------------
+ This work 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.
+
+ This work has the LPPL maintenance status "maintained".
+ The Current Maintainer of this work is Qing Lee.
+
+\endpreamble
+\postamble
+
+ This package consists of the file xpinyin.dtx,
+ xpinyin-map.cfg,
+ and the derived files xpinyin.sty,
+ xpinyin.pdf,
+ xpinyin.ins and
+ README.
+\endpostamble
+\usedir{tex/latex/xpinyin}
+\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
+\endbatchfile
+%%
+%% This package consists of the file xpinyin.dtx,
+%% xpinyin-map.cfg,
+%% and the derived files xpinyin.sty,
+%% xpinyin.pdf,
+%% xpinyin.ins and
+%% README.
+%%
+%% End of file `xpinyin.ins'.