summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/xpinyin
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-11-23 22:45:59 +0000
committerKarl Berry <karl@freefriends.org>2012-11-23 22:45:59 +0000
commita75a0391a6a6873345d5d864a61031eb4dd09780 (patch)
tree5c97d052ef94bdedc08b6b39f9ea7010af4956d3 /Master/texmf-dist/source/latex/xpinyin
parent18197c1aaecb34702640c078c7a0d59c3ed40acc (diff)
xpinyin (23nov12)
git-svn-id: svn://tug.org/texlive/trunk@28346 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/xpinyin')
-rw-r--r--Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx103
1 files changed, 57 insertions, 46 deletions
diff --git a/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx b/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx
index d7e93d53579..ab69c0efe3c 100644
--- a/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx
+++ b/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx
@@ -118,21 +118,22 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\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}
+\GetIdInfo$Id: xpinyin.dtx 367 2012-11-23 04:45:50Z sobenlee $
+ {Automatically add pinyin to Chinese characters}
%</driver|package>
%
%<*driver>
-\documentclass{l3doc}
+\documentclass[full,a4paper]{l3doc}
\usepackage{xeCJK}
\usepackage{xpinyin}
\usepackage{fvrb-ex}
\usepackage{metalogo}
+\usepackage{geometry}
\hypersetup{pdfstartview=FitH}
-\fvset{formatcom=\CJKfixedspacing}
+\geometry{includemp,hmargin={0mm,15mm},vmargin=15mm,footskip=7mm}
+\BeforeBeginEnvironment{SideBySideExample}{\vskip1ex\relax}
+\fvset{formatcom=\xeCJKVerbAddon}
\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}
@@ -140,7 +141,17 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\xeCJKsetup{PunctStyle=kaiming}
\newfontfamily\PinYinFont{TeX Gyre Adventor}
\xpinyinsetup{font=\PinYinFont,multiple=\color{red}}
-\def\MacroFont{\small\normalfont\ttfamily}
+\def\MacroFont{\small\normalfont\ttfamily}\ExplSyntaxOn
+\DeclareDocumentCommand \package { o m }
+ {
+ \href
+ {
+ http://mirrors.ctan.org/help/Catalogue/entries/
+ \IfNoValueTF {#1} { \tl_expandable_lowercase:n {#2} } {#1} .html
+ }
+ { \pkg {#2} }
+ }
+\ExplSyntaxOff
\makeatletter
\let\orig@meta\meta
\def\meta#1{\orig@meta{\normalfont\itshape#1}}
@@ -149,7 +160,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\def\TFF{true\orvar\defaultvar{false}}
\def\orvar{\char`\|}
\let\defaultvar\textbf
-\def\argbrace#1{\char`\{#1\char`\}}
+\def\argbrace#1{\{#1\}}
\makeatother
\def\indexname{代码索引}
\IndexPrologue{%
@@ -159,10 +170,13 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
数字表示对应项使用时所在的行号。}
\begin{document}
\DocInput{\jobname.dtx}
+ \newgeometry{margin=15mm,footskip=7mm}
+ \PrintIndex
\end{document}
%</driver>
% \fi
%
+% \CheckSum{528}
% \GetFileInfo{\jobname.sty}
%
% \title{\bfseries\pkg{xpinyin} 宏包}
@@ -179,12 +193,9 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \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} 依赖 \package[cjk]{CJKutf8} 宏包;如果使用 \XeLaTeX,
+% 则依赖 \package{xeCJK} 宏包。\pkg{xpinyin} 不会自动载入 \pkg{CJKutf8} 或 \pkg{xeCJK}
+% 宏包,应该在它之前或之后自行载入。
%
% 需要注意的是,\pkg{xpinyin} 缺省将拼音的字体设置为与文档的主字体(\cs{normalfont})相同,
% 所以为了保证声调字母的正确输出,应该选用合适的西文主字体。也可以通过将在下一节介绍的
@@ -224,9 +235,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%
% 运行上述示例要求系统安装了设置的字体,源文件用 |UTF-8| 编码保存,使用相应的编译方式。
%
-% \pkg{xpinyin} 可以与 \pkg{ctex} 宏包或文档类^^A
-% \footnote{\url{http://mirrors.ctan.org/language/chinese/ctex/}} 共同使用,使用
-% 方式与上面类似。
+% \pkg{xpinyin} 可以与 \package{ctex} 宏包或文档类共同使用,使用方式与上面类似。
%
% \section{用户手册}
%
@@ -253,7 +262,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{syntax}
% 对于多音字,可以使用 \cs{xpinyin} 为其设置拼音;而 \cs{xpinyin*} 相当于
% \env{pinyinscope} 环境的命令形式。\cs{xpinyin} 可以在 \env{pinyinscope} 环境和
-% \cs{xpinyin*} 中使用。例如,\\[1ex]
+% \cs{xpinyin*} 中使用。例如,
% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.5\linewidth,gobble=5]
% \xpinyin{长}{chang2}\\
% \xpinyin*{甄士隐梦幻识通灵}\\
@@ -265,7 +274,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{syntax}
% \cs{pinyin} \oarg{options} \Arg{拼音}
% \end{syntax}
-% 用于输出拼音,为了输入的方便 \texttt{\"u} 可以用 |v| 代替。例如,\\[1ex]
+% 用于输出拼音,为了输入的方便 \texttt{\"u} 可以用 |v| 代替。例如,
% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.5\linewidth,gobble=5]
% \pinyin{lv2zi}\\
% \pinyin{nv3hai2zi}
@@ -285,7 +294,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%
% \begin{function}{\xpinyinsetup}
% \begin{syntax}
-% \cs{xpinyinsetup} \argbrace{\meta{key1}=\meta{var1}, \meta{key2}=\meta{var2}, ...}
+% \cs{xpinyinsetup} \argbrace{\meta{key_1}=\meta{var_1}, \meta{key_2}=\meta{var_2}, ...}
% \end{syntax}
% 用于在导言区或文档中,设置拼音的格式。目前可以设置的 \meta{key} 如下介绍。
% \end{function}
@@ -342,7 +351,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% multiple = \marg{format}
% \end{syntax}
% 设置多音字拼音的其它格式,缺省值为空。可以通过这个选项来提醒校正多音字的拼音。例如
-% 本文档设置多音字拼音的颜色是红色:
+% 本文档设置多音字拼音的颜色是红色(需要载入 \pkg{color} 宏包):
% \begin{verbatim}[frame=single,gobble=5]
% \xpinyinsetup{multiple={\color{red}}}
% \end{verbatim}
@@ -350,6 +359,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%
% \end{documentation}
%
+% \StopEventually{}
%
% \begin{implementation}
%
@@ -360,7 +370,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \fi
%
% \begin{macrocode}
-\ProvidesExplPackage{\ExplFileName}{\ExplFileDate}{1.1}{\ExplFileDescription}
+\ProvidesExplPackage{\ExplFileName}{\ExplFileDate}{1.2}{\ExplFileDescription}
% \end{macrocode}
%
% \begin{macrocode}
@@ -416,8 +426,8 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{ \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_wd:N \l_xpinyin_tmpa_box + \l_xpinyin_CJKglue_dim }
+ { \box_ht:N \l_xpinyin_tmpb_box + \box_dp:N \l_xpinyin_tmpb_box }
}
\box_move_up:nn { \l_xpinyin_vsep_tl }
{
@@ -551,8 +561,9 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \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
+ \fontsize
+ { \l_xpinyin_ratio_tl \etex_dimexpr:D \f@size pt \scan_stop: }
+ { \c_zero_skip }
\l_xpinyin_font_tl
\selectfont
}
@@ -591,11 +602,10 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\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 } } }
+ \cs_new_eq:NN \xpinyin_CJK_ignorespaces: \xeCJK_ignore_spaces:w
+ \cs_new_protected_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_meaning:N \l_xpinyin_font_tl)/\l_xeCJK_current_font_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 } }
@@ -709,29 +719,29 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\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 } }
+ { \tl_if_empty:NF \l_xpinyin_item_tl { \l_xpinyin_pysep_tl \l_xpinyin_item_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
+ \l_xpinyin_pre_tl
\xpinyin_tone:Vn \l_xpinyin_tone_tl {#1}
- \l_tmpb_tl
+ \l_xpinyin_post_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} }
+ { 0 \cs_if_exist_use:c { c_xpinyin_ \tl_to_str:V \l_xpinyin_tone_tl _tl } } >
+ { 0 \cs_if_exist_use:c { c_xpinyin_ \tl_to_str:n {#1} _tl } }
+ { \tl_put_right:Nn \l_xpinyin_post_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_set_eq:NN \l_xpinyin_pre_tl \l_xpinyin_item_tl
+ \tl_clear:N \l_xpinyin_post_tl
}
- \tl_put_right:Nx \l_tmpc_tl { \xpinyin_replace_v:N {#1} }
+ \tl_put_right:Nx \l_xpinyin_item_tl { \xpinyin_replace_v:N {#1} }
}
\xpinyin_xpinyin_aux:N
}
@@ -754,7 +764,10 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\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 } }
+ {
+ \str_if_eq_p:Vn \l_xpinyin_item_tl { l } ||
+ \str_if_eq_p:Vn \l_xpinyin_item_tl { n }
+ }
{ \exp_not:n { ü} } { u }
}
{ \exp_not:n {#1} }
@@ -766,8 +779,8 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \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
+ \tl_clear:N \l_xpinyin_pre_tl \tl_clear:N \l_xpinyin_post_tl
+ \tl_clear:N \l_xpinyin_item_tl \tl_clear:N \l_xpinyin_tone_tl
}
% \end{macrocode}
% \end{macro}
@@ -831,8 +844,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \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
+\clist_map_inline:nn
{
{0101}{\=a} , {00E1}{\'a} , {01CE}{\v{a}} , {00E0}{\`a} ,
{014D}{\=o} , {00F3}{\'o} , {01D2}{\v{o}} , {00F2}{\`o} ,
@@ -842,7 +854,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{00FC}{\"u} ,
{01D6}{\={\"u}} , {01D8}{\'{\"u}} , {01DA}{\v{\"u}} , {01DC}{\`{\"u}}
}
- \xpinyin_prop_put_aux:n
+ { \prop_gput:Nnn \g_xpinyin_tone_prop #1 }
% \end{macrocode}
% \end{macro}
%
@@ -901,7 +913,6 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%
% \end{implementation}
%
-% \PrintIndex
% \Finale
%
\endinput