texlive[60661] Master/texmf-dist: hanzibox (30sep21)

commits+karl at tug.org commits+karl at tug.org
Thu Sep 30 22:13:28 CEST 2021


Revision: 60661
          http://tug.org/svn/texlive?view=revision&revision=60661
Author:   karl
Date:     2021-09-30 22:13:28 +0200 (Thu, 30 Sep 2021)
Log Message:
-----------
hanzibox (30sep21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/xelatex/hanzibox/README.md
    trunk/Master/texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf
    trunk/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx
    trunk/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty

Modified: trunk/Master/texmf-dist/doc/xelatex/hanzibox/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/xelatex/hanzibox/README.md	2021-09-30 20:13:14 UTC (rev 60660)
+++ trunk/Master/texmf-dist/doc/xelatex/hanzibox/README.md	2021-09-30 20:13:28 UTC (rev 60661)
@@ -1,5 +1,5 @@
 hanzibox
-LaTeX3-based Chinese Character package, v2.0.0
+LaTeX3-based Chinese Character package
 =======
 
 `hanzibox` is a LaTeX package developed in LaTeX3, which provides `\hanzibox` and `\hanzidialog` macros. These two macros are used for typesetting Chinese character with or without a background grid such as a cross grid or star grid for Chinese character writting learning.
@@ -6,15 +6,15 @@
 
 And you can display the Hanyu Pinyin above the Chinese character and the translation below them as needed.
 
-The `\hanzibox` macro can automatically invoke the `\xpinyin*` command of the `xpinyin` package to achieve Hanyu Pinyin according to the Chinese characters.  And the `\hanzibox` command provides an asterisk version of `\hanzibox*`, whose function is achieved by automatically invoking the `xpinyin` package's `\pinyin` macro to achieve this. The `\hanzidialog` macro is implemented by manually inserting the `\pinyin` macro of the `xpinyin` package in it's pinyin option.
+The `\hanzibox` macro can automatically invoke the `\xpinyin*` macro of the `xpinyin` package to get Hanyu Pinyin according to the Chinese characters.  And the `\hanzibox` macro provides an asterisk version of `\hanzibox*`, whose function is achieved by automatically invoking the `xpinyin` package's `\pinyin` macro to get Hanyu Pinyin. The `\hanzidialog` macro is implemented by manually inserting the `\pinyin` macro of the `xpinyin` package in it's pinyin option.
 
 `hanzibox` is a utility for learning to write and pronounce Chinese characters, and can be used for Chinese character learning plans, presentations, exercise booklets and other documentation work.
 
 The development of this package was inspired by [Jan Vorisek's hanzibox package](https://github.com/janvorisek/chinese-latex-utilities).
 
-However, the new package redesigned the `\hanzibox` and `\hanzidialog` macros and the background grid is redesigned with the `l3draw` package with reference to [zitie package](https://www.ctan.org/pkg/zitie).  Also, the new macro package provides more options and arguments in order to get better typesetting results.
+However, the new package redesigned the `\hanzibox` and `\hanzidialog` macros and the background grid is redesigned with the `l3draw` package by reference to [zitie package](https://www.ctan.org/pkg/zitie).  Also, the new package provides more options and arguments in order to get better results.
 
-Due to the limitations of the `xpinyin` package, the `hanzibox.sty` package currently only supports the XeTeX engine and only supports UTF-8 encoded LaTeX source files.
+The `hanzibox.sty` package currently only supports the XeTeX engine and only supports UTF-8 encoded LaTeX source files.
 
 You can read the manual (in Chinese) for more details and examples.
 
@@ -22,19 +22,19 @@
 ------------
 
 1. Gitee repository: [hanzibox-l3](https://gitee.com/nwafu_nan/hanzibox-l3)
-2. Issues and pull requests are welcome. [issue](https://gitee.com/nwafu_nan/hanzibox-l3/issues) or [pull request](https://gitee.com/nwafu_nan/hanzibox- l3/pulls).
+2. Issues and pull requests are welcome. [issue](https://gitee.com/nwafu_nan/hanzibox-l3/issues) or [pull request](https://gitee.com/nwafu_nan/hanzibox-l3/pulls).
 
 hanzibox
-基于LaTeX3的汉字练习宏包, v2.0.0
+基于LaTeX3的汉字练习宏包
 =======
 
-`hanzibox`是一个用LaTeX3开发的LaTeX宏包,它提供了`\hanzibox`和`\hanzidialog` 两个命令。这两个命令用于排版汉字学习中带有或不带田字格、米字格等背景格子的汉字,并可以根据需要在汉字正上方显示拼音,在正下方显示译文。其中,`\hanzibox`命令能够根据汉字自动调用`xpinyin`宏包的`\xpinyin*`命令实现汉字注音。并且`\hanzibox`命令提供了`\hanzibox*`星号版本,其注音功能是通过自动调用`xpinyin`宏包的`\pinyin`命令实现的。`\hanzidialog`命令的注音功能通过在拼音选项中手动插入`xpinyin`宏包的`\pinyin`命令实现。
+`hanzibox`是一个用LaTeX3开发的LaTeX宏包,它提供了`\hanzibox`和`\hanzidialog` 两个命令。这两个命令分别用于排版汉字学习中带有或不带田字格、米字格等背景格子的汉字,并可以根据需要在汉字正上方显示拼音,在正下方显示译文。其中,`\hanzibox`命令能够根据汉字自动调用`xpinyin`宏包的`\xpinyin*`命令实现汉字注音。并且`\hanzibox`命令提供了`\hanzibox*`星号版本,其注音功能是通过自动调用`xpinyin`宏包的`\pinyin`命令实现的。`\hanzidialog`命令的注音功能是通过在拼音选项中手动插入`xpinyin`宏包`\pinyin`命令实现的。
 
 `hanzibox` 是一个用于学习汉字书写与发音的工具,可以用于汉字学习教案、演示文稿、习题册等文档工作。
 
-开发该宏的灵感来自于[Jan Vorisek的hanzibox宏包](https://github.com/janvorisek/chinese-latex-utilities)。但该宏包对`\hanzibox`和`\hanzidialog`命令进行了重新设计,并参考[zitie字贴宏包](https://www.ctan.org/pkg/zitie)重新用`l3draw`宏包设计了背景格子。同时,新的宏包也提供了更多命令选项和参数,以期更好地控制排版结果。
+该宏包的开发灵感源自[Jan Vorisek的hanzibox宏包](https://github.com/janvorisek/chinese-latex-utilities)。但对`\hanzibox`和`\hanzidialog`命令重新进行了设计,并参考[zitie字贴宏包](https://www.ctan.org/pkg/zitie)重新用`l3draw`宏包设计了背景格子。同时,新的宏包也提供了更多命令选项和参数,以期更好地控制排版结果。
 
-受`xpinyin`基础宏包所限,目前`hanzibox.sty`宏包仅支持XeTeX编译引擎,并且只支持UTF-8编码的LaTeX源文件。
+目前,`hanzibox.sty`宏包仅支持XeTeX编译引擎,并且只支持UTF-8编码的LaTeX源文件。
 
 可以通过阅读宏包手册(中文)以也解该宏包更多的使用细节和使用样例。
 

Modified: trunk/Master/texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx
===================================================================
--- trunk/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx	2021-09-30 20:13:14 UTC (rev 60660)
+++ trunk/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx	2021-09-30 20:13:28 UTC (rev 60661)
@@ -5,7 +5,7 @@
 %</internal>
 %<*readme>
 hanzibox
-LaTeX3-based Chinese Character package, v2.0.0
+LaTeX3-based Chinese Character package
 =======
 
 `hanzibox` is a LaTeX package developed in LaTeX3, which provides `\hanzibox` and `\hanzidialog` macros. These two macros are used for typesetting Chinese character with or without a background grid such as a cross grid or star grid for Chinese character writting learning.
@@ -12,15 +12,15 @@
 
 And you can display the Hanyu Pinyin above the Chinese character and the translation below them as needed.
 
-The `\hanzibox` macro can automatically invoke the `\xpinyin*` command of the `xpinyin` package to achieve Hanyu Pinyin according to the Chinese characters.  And the `\hanzibox` command provides an asterisk version of `\hanzibox*`, whose function is achieved by automatically invoking the `xpinyin` package's `\pinyin` macro to achieve this. The `\hanzidialog` macro is implemented by manually inserting the `\pinyin` macro of the `xpinyin` package in it's pinyin option.
+The `\hanzibox` macro can automatically invoke the `\xpinyin*` macro of the `xpinyin` package to get Hanyu Pinyin according to the Chinese characters.  And the `\hanzibox` macro provides an asterisk version of `\hanzibox*`, whose function is achieved by automatically invoking the `xpinyin` package's `\pinyin` macro to get Hanyu Pinyin. The `\hanzidialog` macro is implemented by manually inserting the `\pinyin` macro of the `xpinyin` package in it's pinyin option.
 
 `hanzibox` is a utility for learning to write and pronounce Chinese characters, and can be used for Chinese character learning plans, presentations, exercise booklets and other documentation work.
 
 The development of this package was inspired by [Jan Vorisek's hanzibox package](https://github.com/janvorisek/chinese-latex-utilities).
 
-However, the new package redesigned the `\hanzibox` and `\hanzidialog` macros and the background grid is redesigned with the `l3draw` package with reference to [zitie package](https://www.ctan.org/pkg/zitie).  Also, the new macro package provides more options and arguments in order to get better typesetting results.
+However, the new package redesigned the `\hanzibox` and `\hanzidialog` macros and the background grid is redesigned with the `l3draw` package by reference to [zitie package](https://www.ctan.org/pkg/zitie).  Also, the new package provides more options and arguments in order to get better results.
 
-Due to the limitations of the `xpinyin` package, the `hanzibox.sty` package currently only supports the XeTeX engine and only supports UTF-8 encoded LaTeX source files.
+The `hanzibox.sty` package currently only supports the XeTeX engine and only supports UTF-8 encoded LaTeX source files.
 
 You can read the manual (in Chinese) for more details and examples.
 
@@ -28,19 +28,19 @@
 ------------
 
 1. Gitee repository: [hanzibox-l3](https://gitee.com/nwafu_nan/hanzibox-l3)
-2. Issues and pull requests are welcome. [issue](https://gitee.com/nwafu_nan/hanzibox-l3/issues) or [pull request](https://gitee.com/nwafu_nan/hanzibox- l3/pulls).
+2. Issues and pull requests are welcome. [issue](https://gitee.com/nwafu_nan/hanzibox-l3/issues) or [pull request](https://gitee.com/nwafu_nan/hanzibox-l3/pulls).
 
 hanzibox
-基于LaTeX3的汉字练习宏包, v2.0.0
+基于LaTeX3的汉字练习宏包
 =======
 
-`hanzibox`是一个用LaTeX3开发的LaTeX宏包,它提供了`\hanzibox`和`\hanzidialog` 两个命令。这两个命令用于排版汉字学习中带有或不带田字格、米字格等背景格子的汉字,并可以根据需要在汉字正上方显示拼音,在正下方显示译文。其中,`\hanzibox`命令能够根据汉字自动调用`xpinyin`宏包的`\xpinyin*`命令实现汉字注音。并且`\hanzibox`命令提供了`\hanzibox*`星号版本,其注音功能是通过自动调用`xpinyin`宏包的`\pinyin`命令实现的。`\hanzidialog`命令的注音功能通过在拼音选项中手动插入`xpinyin`宏包的`\pinyin`命令实现。
+`hanzibox`是一个用LaTeX3开发的LaTeX宏包,它提供了`\hanzibox`和`\hanzidialog` 两个命令。这两个命令分别用于排版汉字学习中带有或不带田字格、米字格等背景格子的汉字,并可以根据需要在汉字正上方显示拼音,在正下方显示译文。其中,`\hanzibox`命令能够根据汉字自动调用`xpinyin`宏包的`\xpinyin*`命令实现汉字注音。并且`\hanzibox`命令提供了`\hanzibox*`星号版本,其注音功能是通过自动调用`xpinyin`宏包的`\pinyin`命令实现的。`\hanzidialog`命令的注音功能是通过在拼音选项中手动插入`xpinyin`宏包`\pinyin`命令实现的。
 
 `hanzibox` 是一个用于学习汉字书写与发音的工具,可以用于汉字学习教案、演示文稿、习题册等文档工作。
 
-开发该宏的灵感来自于[Jan Vorisek的hanzibox宏包](https://github.com/janvorisek/chinese-latex-utilities)。但该宏包对`\hanzibox`和`\hanzidialog`命令进行了重新设计,并参考[zitie字贴宏包](https://www.ctan.org/pkg/zitie)重新用`l3draw`宏包设计了背景格子。同时,新的宏包也提供了更多命令选项和参数,以期更好地控制排版结果。
+该宏包的开发灵感源自[Jan Vorisek的hanzibox宏包](https://github.com/janvorisek/chinese-latex-utilities)。但对`\hanzibox`和`\hanzidialog`命令重新进行了设计,并参考[zitie字贴宏包](https://www.ctan.org/pkg/zitie)重新用`l3draw`宏包设计了背景格子。同时,新的宏包也提供了更多命令选项和参数,以期更好地控制排版结果。
 
-受`xpinyin`基础宏包所限,目前`hanzibox.sty`宏包仅支持XeTeX编译引擎,并且只支持UTF-8编码的LaTeX源文件。
+目前,`hanzibox.sty`宏包仅支持XeTeX编译引擎,并且只支持UTF-8编码的LaTeX源文件。
 
 可以通过阅读宏包手册(中文)以也解该宏包更多的使用细节和使用样例。
 
@@ -153,7 +153,7 @@
 %</internal>
 %<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01]
 %<package>\RequirePackage{expl3}
-%<+package>\GetIdInfo$Id: hanzibox.dtx 2.0.0 2021-09-28 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
+%<+package>\GetIdInfo$Id: hanzibox.dtx 2.1.0 2021-09-30 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
 %<package>  {Boxed Chinese characters with Pinyin above and translation below.}
 %<package>\ProvidesExplPackage{\ExplFileName}
 %<package>  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -186,7 +186,7 @@
 % \changes{v2.0.0}{2021/09/25}{基于l3draw重新设计}
 % \changes{v2.0.0}{2021/09/28}{重新编写README.md内容}
 %
-% \CheckSum{829}
+% \CheckSum{1043}
 % \GetFileId{hanzibox.sty}
 %
 % \CharacterTable
@@ -220,9 +220,9 @@
 % \pkg{hanzibox} 是一个用\LaTeX3开发的 \LaTeX 宏包,它提供了\tn{hanzibox}和\tn{hanzidialog}
 % 两个命令。这两个命令用于输出汉字学习中带有或不带田字格、米字格等背景格子的汉字,
 % 并可以根据需要在汉字正上方显示拼音,在正下方显示译文。
-% 其中,\tn{hanzibox}命令能够根据汉字自动调用\pkg{xpinyin}宏包的\tn{xpinyin*}命令实现汉字注音。
-% 同时,\tn{hanzibox}命令还提供了\tn{hanzibox*}星号版本,其注音功能是通过自动调用\pkg{xpinyin}宏包
-% 的\tn{pinyin}命令实现的。\tn{hanzidialog}命令的注音功能则是通过在其拼音选项中手动插入
+% 其中,\tn{hanzibox}命令能够根据汉字利用\pkg{xpinyin}宏包实现汉字注音。
+% 同时,\tn{hanzibox}命令还提供了\tn{hanzibox*}星号版本,以实现手动注音功能。
+% \tn{hanzidialog}命令的注音功能则是通过在其拼音选项中手动插入
 % \pkg{xpinyin}宏包的\tn{pinyin}命令实现。
 %
 % \end{abstract}
@@ -230,7 +230,8 @@
 % \section{简要说明}
 %
 % \pkg{hanzibox} 是一个用于输出汉字学习中的田字格、米字格等背景,并在汉字正上方显示拼音,
-% 在正下方显示译文。当然,也可以根据需要隐藏拼音、汉字或译文。
+% 在正下方显示译文。当然,也可以根据需要隐藏拼音、汉字或译文,还可以选择性地隐藏拼音中的
+% 声母、韵母或音调,从而有效实现汉字学习中的素材准备。
 %
 % 使用\pkg{hanzibox}宏包的\LaTeX 源文件需采用 \texttt{UTF-8}编码,并且需使用\XeLaTeX 进行编译。
 %
@@ -238,7 +239,7 @@
 %
 % \section{用户接口}
 %
-% \begin{function}[added=2021-09-18,updated=2021-09-28]{\hanzibox,\hanzibox*}
+% \begin{function}[added=2021-09-18,updated=2021-09-30]{\hanzibox,\hanzibox*}
 %   \begin{syntax}
 %     \tn{hanzibox}  \oarg{外观选项} \Arg{汉字} \oarg{拼音选项} \oarg{译文选项}
 %     \tn{hanzibox*} \oarg{外观选项} \Arg{汉字} \oarg{拼音选项} \oarg{译文选项}
@@ -245,18 +246,19 @@
 %   \end{syntax}
 %   排版汉字,并根据选项内容在顶部排版拼音,在底部排版译文。\\
 %   其中,\Arg{汉字}可以留空,\oarg{外观选项}用于设置盒子外观;
-%   \tn{hanzibox}命令中的\oarg{拼音选项}无效,可以省略,也可以留空;\\
+%   \tn{hanzibox}命令中的\oarg{拼音选项}无效,可以省略,也可以留空;
 %   \oarg{译文选项}可以是任意文本,需要注意的是,当需要\oarg{译文选项}时,
 %   \oarg{拼音选项}可以留空,但不能省略。
 %   注音由\pkg{xpinyin}宏包自动根据汉字获得,此时,可能会存在多音字等问题,
-%   其调整详情请参阅其\pkg{xpinyin}宏包说明。
+%   其调整详情请参阅\pkg{xpinyin}宏包说明。星号命令\tn{hanzibox*}用于手动排版拼音。
 %
-%   排版样式可能通过\tn{hanziboxset}命令或\tn{hanzidialog}\oarg{外观选项}的key-value进行设置。
-%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.43\linewidth,gobble=5]
+%   排版样式可通过\tn{hanziboxset}命令或\tn{hanzibox}\oarg{外观选项}的key-value进行设置。
+%
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.40\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{fillcolor=yellow!30, charcolor=red,
-%                  framecolor=red}
+%       xscale=1.5,yscale=1.5,resize=real,framecolor=red}
 %     \hanzibox[frametype=none]{我}
-%     \hanzibox[frametype=none]{我}[][me]
 %     \hanzibox[frametype=口  ]{我}[][吾]
 %     \hanzibox[frametype=十  ]{我}[wo3][俺]
 %     \hanzibox[frametype=×   ]{我}[wo2][爷]
@@ -264,8 +266,8 @@
 %     \hanzibox[frametype=米  ]{我}[ni3][奴]
 %     \hanzibox[frametype=咪  ]{我}[ta1][山人]
 %   \end{SideBySideExample}
-%   星号命令\tn{hanzibox*}用于手动排版拼音。\\
-%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.43\linewidth,gobble=5]
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.40\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{xscale=1.5,yscale=1.5,resize=real}
 %     \hanzibox*[frametype=none]{我}[wo3][me]
 %     \hanzibox*[frametype=口  ]{我}[wo3][吾]
@@ -288,7 +290,8 @@
 %   如果是汉语拼音则需要手动使用\pkg{xpinyin}宏包的\tn{pinyin}命令,
 %   排版样式可能通过\tn{hanziboxset}命令或\tn{hanzidialog}\oarg{外观选项}的key-value进行设置。
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.25\linewidth,gobble=5]
-%     \hanzidialog{王老师}[teacher wang][Wang \pinyin{lao3shi1}]
+%     \centering
+%     \hanzidialog{王老师}[Wang \pinyin{lao3shi1}][teacher wang]
 %
 %     \hanzidialog[frametype=田]{王老师}[Wang \pinyin{lao3shi1}]
 %                 [王先生]
@@ -303,11 +306,10 @@
 %   \begin{syntax}
 %     \tn{hanziboxset} \marg{键值列表}
 %   \end{syntax}
-%
 %   \tn{hanziboxset} 的参数是一组由(英文)逗号隔开的选项列表,
 %   列表中的选项通常是 \kvopt{\meta{key}}{\meta{value}} 形式。
 %   部分选项的\meta{value} 可以省略。对于同一项,后续设置会覆盖以前的设置。
-%   在下文的说明中,将用\textbf{粗体}表示默认值。
+%   在下文的说明中,多数选项都设有默认值。
 %
 %   \tn{hanziboxset} 采用 \LaTeX3 风格的键值设置,支持不同类型以及多种
 %   层次的选项设定。键值列表中,“|=|”左右的空格不影响设置;但需注意,
@@ -319,25 +321,25 @@
 % \section{选项说明}
 %
 %   本宏包提供了一系列选项,以实现汉字盒子外观样式设置。
-%   载入\pkg{hanzibox}宏包后,以下选项均可通过统一的\tn{hanziboxset}命令进行设置。
-%   同时,这些选项也可以通过\tn{hanzibox}命令的外观选项进行设置。
+%   载入\pkg{hanzibox}宏包后,以下选项均可通过统一命令\tn{hanziboxset}进行设置。
+%   同时,这些选项也可以通过\tn{hanzibox}或\tn{hanzidialog}命令的\oarg{外观选项}进行设置。
 %
 % \begin{function}[added=2021-09-24,updated=2021-09-24]{basechar,zihao}
 %   \begin{syntax}
 %     basechar = \meta{CJK char} \init{好}
-%     zihao = \meta{字号} \init{4}
+%     zihao    = \meta{字号}     \init{4}
 %   \end{syntax}
 %   \opt{basechar} 设置基字符,用于计算缩放比例,
 %   基字符不同时,即使给定相同的缩放比例,其实际缩放比例也可能不同。
 % 
-%   \opt{zihao} 设置计算缩放比例时的字号大小。
+%   \opt{zihao} 设置计算缩放比例时字号大小。
 % \end{function}
 %
 % \begin{function}[added=2021-09-27,updated=2021-09-28]{pinyinf,charf,tranf}
 %   \begin{syntax}
-%     pinyinf = \meta{格式命令} \init{\normalsize}
-%     charf = \meta{格式命令}   \init{\tiny}
-%     tranf = \meta{格式命令}   \init{\tiny}
+%     pinyinf = \meta{格式命令}   \init{\normalsize}
+%     charf   = \meta{格式命令}   \init{\tiny}
+%     tranf   = \meta{格式命令}   \init{\tiny}
 %   \end{syntax}
 %   分别用于设置拼音、汉字、译文的排版格式。
 % \end{function}
@@ -348,10 +350,11 @@
 %    resize    = <none|real|base> \init{none}
 %  \end{syntax}
 %  \opt{frametype} 设置汉字盒子样式。可用值的效果与选项值文字形状类似:\verb|口|--仅方框,
-%  \verb|十|--仅中间的横线和竖线,\verb|田|--常见的田字格,\verb|米|--十字格再加上斜的两条线,
+%  \verb|十|--仅中间的横线和竖线,\verb|田|--常见的田字格,\verb|米|--十字格再加上斜的两条对角线,
 %  \verb|咪|--常见的米字格。
 %
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.50\linewidth,gobble=5]
+%     \centering
 %     \hanzibox[frametype=none]{无}
 %     \hanzibox[frametype=口  ]{口}
 %     \hanzibox[frametype=十  ]{十}
@@ -365,6 +368,7 @@
 %
 %  以下为宽度设置为 1cm 时的缩放情况。
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.45\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{width=1cm,frametype=咪,
 %                  framecolor=black}
 %     \hanzibox[resize=none  ]{无}
@@ -386,7 +390,7 @@
 %   设置缩放比例和盒子宽高。
 %
 %   宽高具有更高的优先级,即若比例和宽高都设置了,则使用宽高来计算。
-%   宽高为二者都为0cm视为未设置,二者有一大于0cm,视为设置了宽高。
+%   宽高都为0cm视为未设置,二者有一大于0cm,视为设置了宽高。
 %
 %   此处的宽高和最终的宽高可能略有差异,最终的宽高保存在
 %   \tn{hanziboxwidth} 和 \tn{hanziboxheight} dim寄存器中。
@@ -406,7 +410,8 @@
 %   \end{syntax}
 %   设置边框线宽、线型、转角样式。
 %
-%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.30\linewidth,gobble=5]
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.28\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{width=1.0cm,resize=real,framecolor=red}
 %     \hanzibox[linewidth=1pt,frametype=口]{好}
 %     \hanzibox[dashpattern={1.5mm,1mm,2mm,1.5mm},frametype=田]{好}
@@ -433,10 +438,11 @@
 %     fillcolor   = \meta{color expr}
 %     fillcolor*  = \meta{model(s)} \meta{value(s)}
 %   \end{syntax}
-%   命名的颜色仅支持 \LaTeX3 定义的 black, white, red, green, blue, cyan, magenta 和 yellow。
+%   分别设置格子线条、字符和填充颜色。
+%   颜色名称仅支持 \LaTeX3 定义的 black, white, red, green, blue, cyan, magenta 和 yellow。
 %   颜色模型和表达式也应使用 \LaTeX3 支持的模型和表达式,详见 \pkg{interface3.pdf} 文档。
 %
-%   若要去掉 \opt{fillcolor},应将其设置为空,即 \verb|fillcolor={}|,而不是将其设置为白色。
+%   若要去掉 \opt{fillcolor},应将其置为空(\verb|fillcolor={}|),而不是将其设置为white(白色)。
 % \end{function}
 %
 % \begin{function}[added=2021-09-24,updated=2021-09-24]{initial,vowel,tone}
@@ -448,6 +454,7 @@
 %   分别用于设置是否输出拼音的声母、韵母和声调,默认值为\textbf{true}。
 %   该选项仅对\tn{hanzibox}命令有效。
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.33\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{frametype=咪,framecolor=red,
 %                  fillcolor=yellow!40,resize=real}
 %     \hanzibox{明月几时有}[]
@@ -462,6 +469,7 @@
 %       [][How long will the full moon appear?]
 %   \end{SideBySideExample}
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.28\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{frametype=咪,framecolor=red,fillcolor=yellow!40,
 %                  charf=\Huge,resize=real}
 %     \hanzibox*[initial=false]{我}[wo3][吾]
@@ -482,10 +490,10 @@
 %     \centering
 %     \hanziboxset{frametype=咪,framecolor=red,charf=\large,
 %                  fillcolor=yellow!40}
+%     \hanzibox[pinyin=false]{明月几时有}[]
+%       [How long will the full moon appear?]\\[0.5ex]
 %     \hanzibox[hanzi=false]{明月几时有}[]
 %       [How long will the full moon appear?]\\[0.5ex]
-%     \hanzibox[pinyin=false]{明月几时有}[]
-%       [How long will the full moon appear?]\\[0.5ex]
 %     \hanzibox[tran=false]{明月几时有}[]
 %       [How long will the full moon appear?]\\[0.5ex]
 %   \end{SideBySideExample}
@@ -500,6 +508,7 @@
 % \subsection{拼一拼---写一写练习}
 %
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.45\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{frametype=田,framecolor=blue}
 %     \hanzibox{门}\hanzibox[hanzi=false]{口}\hfill
 %     \hanzibox{生}\hanzibox[hanzi=false]{日}\hfill
@@ -510,6 +519,7 @@
 % \subsection{标注声母练习}
 %
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{frametype=咪,framecolor=red,charcolor=red,
 %                  charf=\Huge,pinyinf=\small,initial=false}
 %     \hanzibox{门口}\hfill
@@ -521,6 +531,7 @@
 % \subsection{标注韵母练习}
 %
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{frametype=咪,framecolor=red,charcolor=red,
 %                  charf=\Huge,pinyinf=\small,vowel=false}
 %     \hanzibox{门口}\hfill
@@ -532,6 +543,7 @@
 % \subsection{标注声调练习}
 %
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \centering
 %     \hanziboxset{frametype=咪,framecolor=red,charcolor=red,
 %                  charf=\Huge,pinyinf=\small,tone=false}
 %     \hanzibox{门口}\hfill
@@ -542,8 +554,8 @@
 %
 % \subsection{随机生成生词练习}
 %
-% 假设提前准备了生词表的\verb!\clist_set:Nn \l__words_clist!,则可以使用
-% \LaTeX3的随机处理随机生成生词练习题(每次编译可以成不同的结果)。
+% 假设提前准备了生词表\verb!\clist_set:Nn \l__words_clist!,则可以使用
+% \LaTeX3的随机函数随机生成生词练习题(每次编译可以得到不同的结果)。
 %
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.30\linewidth,gobble=5]
 %     \ExplSyntaxOn
@@ -569,9 +581,9 @@
 %
 % \subsection{随机生成拼音练习}
 %
-% 假设提前准备了生词表的声母和韵母表,则可以使用
-% \LaTeX3的随机处理随机生成拼音练习题(每次编译可以成不同的结果)。
-% 此时,可能生成的拼音不正确,可让学生填写“无”。
+% 假设提前准备了声母和韵母表,则可以使用
+% \LaTeX3的随机函数随机生成拼音练习题(每次编译可以得到不同的结果)。
+% 此时,若生成的拼音不正确,可让学生填写“无”。
 %
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.25\linewidth,gobble=5]
 %     \ExplSyntaxOn
@@ -608,8 +620,14 @@
 %     \ExplSyntaxOff
 %   \end{SideBySideExample}
 %
-% \subsection{生成格式纸}
+% \subsection{生成汉字书写练习格子纸}
 %
+% 可以通过将\tn{hanzibox}命令的\Arg{汉字}参数留空,
+% 或将\tn{hanzibox}、\tn{hanzibox*}命令的\verb!hanzi!选项置为
+% \verb!false!(\verb!hanzi=false!),从而生成空白背景格子,
+% 再根据需要通过循环的方式生成指定行数和列数的
+% 汉字书写练习用格子纸。
+%
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.50\linewidth,gobble=5]
 %     \hanziboxset{frametype=咪,framecolor=red,
 %        charcolor=red,charf=\huge}
@@ -627,8 +645,29 @@
 %     \ExplSyntaxOff
 %   \end{SideBySideExample}
 %
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.50\linewidth,gobble=5]
+%     \hanziboxset{frametype=咪,framecolor=red,
+%        charcolor=red,charf=\huge,hanzi=false}
+%     \centering
+%     \ExplSyntaxOn
+%     \int_step_inline:nn {8}
+%       {
+%         \int_step_inline:nn {6}
+%           {
+%             \hanzibox*{国}
+%             \hspace*{-0.4pt}
+%           }
+%         \par\nointerlineskip\vspace*{-6.0pt}
+%      }
+%     \ExplSyntaxOff
+%   \end{SideBySideExample}
+%
 % \subsection{生成诗词注音}
 %
+% 可以通过自动注音生成带有注音的诗词排版,
+% 但当有多音字时,需要使用\pkg{xpinyin}宏包的\tn{setpinyin}命令
+% 为多音字设置正确的读音。
+%
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.50\linewidth,gobble=5]
 %     \setpinyin{长}{chang2}
 %     \setpinyin{尽}{jin4}
@@ -642,6 +681,22 @@
 %     \hanzibox{唯见长江天际流}
 %   \end{SideBySideExample}
 %
+% \subsection{诗词手动注音}
+%
+% 也可以使用\tn{hanzibox*}命令实现诗词手动注音,
+% 此时,可以通过留空拼音或文字构成注音或根据拼音写汉字练习。
+% 但需要注意,目前只能在一行文本的尾部实现留空练习。
+%
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.33\linewidth,gobble=5]
+%     \hanziboxset{frametype=咪,framecolor=red,charf=\Large,
+%       charcolor=green!40!black,}
+%     \centering
+%     \hanzibox*{故人西辞黄鹤楼}[gu4ren2xi1ci2huang2he2lou2]
+%     \hanzibox*{烟花三月下扬州}[yan1hua1san1yue4]
+%     \hanzibox*{孤帆远影      }[gu1fan1yuan3ying3bi4kong1jin4]
+%     \hanzibox*{唯见长江天际流}[wei2jian4]
+%   \end{SideBySideExample}
+%
 % \end{documentation}
 %
 % \StopEventually{}
@@ -651,7 +706,7 @@
 % \section{代码实现}
 %
 % 本宏包使用 \LaTeX3 语法编写,依赖 \pkg{expl3} 环境,
-% 并需调用 \pkg{l3packages} 中的\pkg{l3draw}等相关宏包。
+% 并需调用 \pkg{l3packages}、\pkg{l3draw}、\pkg{xpinyin}等相关宏包。
 %
 % 按照 \LaTeX3 语法,代码中的空格、换行、回车与制表符会完全被忽略,
 % 而下划线“|_|”和冒号“|:|”则可作为一般字母使用。
@@ -728,7 +783,7 @@
 %
 % \changes{v1.1.0}{2021/09/22}{为用户命令添加组限制}
 % \changes{v2.0.0}{2021/09/26}{调整星号命令为手动拼音注音}
-% 汉字背景盒子改为l3draw实现,
+% 背景盒子由l3draw实现,
 % 其设计思路和部分源码来自\LaTeX 字帖宏包(\url{https://www.ctan.org/pkg/zitie})。
 %
 % \begin{macro}{\hanzibox}
@@ -740,7 +795,7 @@
       {
         \bool_set_false:N \l_@@_autopinyin_bool
       }{
-        \bool_set_true:N \l_@@_autopinyin_bool
+        \bool_set_true:N  \l_@@_autopinyin_bool
       }
       \group_begin:
         \@@_handle:nnnn { #2 } { #3 } { #4 } { #5 }
@@ -768,9 +823,10 @@
 %
 % \changes{v1.1.0}{2021/09/21}{添加缩放比例,前景/背景色,隐藏控制变量。}
 % \changes{v2.0.0}{2021/09/24}{根据l3draw的需要重新设计各个变量。}
+% \changes{v2.1.0}{2021/09/30}{添加记录拼音返回结果的clist变量。}
 %
 % \begin{variable}{\l_@@_autopinyin_bool,
-%   \l_@@_withinitials_bool,
+%   \l_@@_withinitial_bool,
 %   \l_@@_withvowel_bool,
 %   \l_@@_withtone_bool,
 %   \l_@@_withpinyin_bool,
@@ -792,12 +848,8 @@
 %   \l_@@_tmpb_coffin,
 %   \hanziboxwidth,
 %   \hanziboxheight,
-%   \hanziboxboxwd,
-%   \hanziboxboxht,
-%   \hanziboxboxdp,
-%   \hanziboxxscaleratio,
-%   \hanziboxyscaleratio,
 %   \l_@@_pinyin_tl,
+%   \l_@@_tone_pinyin_clist,
 %   \l_@@_character_tl,
 %   \l_@@_translation_tl,
 %   \l_@@_pinyin_format_tl,
@@ -815,7 +867,7 @@
 %
 %    \begin{macrocode}
 \bool_new:N   \l_@@_autopinyin_bool
-\bool_new:N   \l_@@_withinitials_bool
+\bool_new:N   \l_@@_withinitial_bool
 \bool_new:N   \l_@@_withvowel_bool
 \bool_new:N   \l_@@_withtone_bool
 \bool_new:N   \l_@@_withpinyin_bool
@@ -834,6 +886,8 @@
 \dim_new:N    \l_@@_box_height_dim
 \dim_new:N    \l_@@_linewidth_dim
 
+\clist_new:N  \l_@@_tone_pinyin_clist
+
 \coffin_new:N \l_@@_str_box_coffin
 \coffin_new:N \l_@@_box_coffin
 \coffin_new:N \l_@@_pinyin_box_coffin
@@ -843,11 +897,6 @@
 
 \dim_new:N    \hanziboxwidth
 \dim_new:N    \hanziboxheight
-\dim_new:N    \hanziboxboxwd
-\dim_new:N    \hanziboxboxht
-\dim_new:N    \hanziboxboxdp
-\tl_new:N     \hanziboxxscaleratio
-\tl_new:N     \hanziboxyscaleratio
 
 \tl_new:N     \l_@@_pinyin_tl
 \tl_new:N     \l_@@_character_tl
@@ -911,7 +960,7 @@
 % \changes{v2.0.0}{2021/09/28}{添加根据基字符格式计算外观盒子尺寸的函数}
 %
 % \begin{macro}{\@@_calc_frame_size:}
-% 计算外框长度(正方形,由基字符按charf选项设定的格式盒子确定)
+% 计算外框长度(正方形,由基字符按charf选项设定的格式构造的盒子确定)
 %    \begin{macrocode}
 \cs_new:Npn \@@_calc_frame_size:
   {
@@ -1308,8 +1357,7 @@
 % resize 设置缩放方式,其取值可以是:
 % none,不使用缩放
 % real,使用字符实际宽高缩放,
-% base,使用 basechar 设置的字符的宽高缩放,
-% square,使得字符的宽高相等再进行缩放。
+% base,使用 basechar 设置的字符的宽高缩放。
 %    \begin{macrocode}
     resize    .code:n = { \exp_args:NNx \clist_if_in:NnTF \g_@@_resize_method_clist {#1}
                             { \tl_set:Nx \l_@@_resize_method_tl {#1} }
@@ -1444,7 +1492,7 @@
 % \begin{macro}{initial}
 % 是否输出声母,默认为true。
 %    \begin{macrocode}
-    initial .bool_set:N = \l_@@_withinitials_bool,
+    initial .bool_set:N = \l_@@_withinitial_bool,
     initial .default:n = true,
     initial .initial:n = true,
 
@@ -1600,8 +1648,255 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \changes{v2.0.1}{2021/09/28}{分离多字、单字、0个字的盒子构造代码}
+% \changes{v2.1.0}{2021/09/30}{更新拼音获取方式,以处理\tn{setuppinyin}的结果}
+%
+% \begin{macro}{\@@_multi_str_coffin_construct:}
+% 构造多汉字带拼音字符串盒子。
+%    \begin{macrocode}
+\cs_new:Npn \@@_multi_str_coffin_construct:
+  {
+    \bool_if:NTF \l_@@_autopinyin_bool
+      {
+        \hcoffin_set:Nn \l_@@_str_box_coffin
+          {
+            \tl_map_inline:Nn \l_@@_character_tl
+              {
+                \hcoffin_set:Nn \l_tmpa_coffin
+                  {
+                    \@@_single_handle:N ##1
+                  }
+
+                \bool_if:NT \l_@@_withpinyin_bool
+                  {
+                    \@@_get_hanzi_pinyin:n { ##1 }
+                    \@@_single_pinyin:V \l_@@_hanzi_pinyin_tl
+
+                    \coffin_join:NnnNnnnn \l_tmpa_coffin
+                      { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                  }
+                \coffin_typeset:Nnnnn \l_tmpa_coffin
+                  { l } { b } { 0pt } { 0pt }
+                \allowbreak
+              }
+          }
+      }
+      {
+        \@@_get_tone_pinyin:V \l_@@_pinyin_tl
+        \clist_clear:N \l_@@_tone_pinyin_clist
+        \clist_set:NV \l_@@_tone_pinyin_clist \l_@@_tone_pinyin_tl
+        \int_set:Nn \l_tmpa_int {\clist_count:N \l_@@_tone_pinyin_clist}
+        \hcoffin_set:Nn \l_@@_str_box_coffin
+          {
+            \int_compare:nNnTF { \l_@@_character_int } = { \l_tmpa_int }
+              {
+                \tl_map_inline:Nn \l_@@_character_tl
+                  {
+                    \hcoffin_set:Nn \l_tmpa_coffin
+                      {
+                        \@@_single_handle:N ##1
+                      }
+
+                    \bool_if:NT \l_@@_withpinyin_bool
+                      {
+                        \clist_pop:NN \l_@@_tone_pinyin_clist \l_tmpb_tl
+                        \@@_single_pinyin:V \l_tmpb_tl
+
+                        \coffin_join:NnnNnnnn \l_tmpa_coffin
+                          { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                      }
+                    \coffin_typeset:Nnnnn \l_tmpa_coffin
+                      { l } { b } { 0pt } { 0pt }
+                    \allowbreak
+                  }
+              }
+              {
+                \int_compare:nNnTF { \l_@@_character_int } > { \l_tmpa_int }
+                  {
+                    \int_step_inline:nn { \l_tmpa_int }
+                      {
+                        \hcoffin_set:Nn \l_tmpa_coffin
+                          {
+                            \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l_@@_character_tl { ##1 }}
+                            \@@_single_handle:N \l_tmpa_tl
+                          }
+                        \bool_if:NT \l_@@_withpinyin_bool
+                          {
+                            \clist_pop:NN \l_@@_tone_pinyin_clist \l_tmpb_tl
+                            \@@_single_pinyin:V \l_tmpb_tl
+
+                            \coffin_join:NnnNnnnn \l_tmpa_coffin
+                              { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                          }
+                        \coffin_typeset:Nnnnn \l_tmpa_coffin
+                          { l } { b } { 0pt } { 0pt }
+                        \allowbreak
+                      }
+                    \int_step_inline:nnn { \l_tmpa_int + 1 } { \l_@@_character_int }
+                      {
+                        \hcoffin_set:Nn \l_tmpa_coffin
+                          {
+                            \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l_@@_character_tl { ##1 }}
+                            \@@_single_handle:N \l_tmpa_tl
+                          }
+                        \coffin_typeset:Nnnnn \l_tmpa_coffin
+                          { l } { b } { 0pt } { 0pt }
+                        \allowbreak
+                      }
+                  }
+                  {
+                    \int_step_inline:nn { \l_@@_character_int }
+                      {
+                        \hcoffin_set:Nn \l_tmpa_coffin
+                          {
+                            \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l_@@_character_tl { ##1 }}
+                            \@@_single_handle:N \l_tmpa_tl
+                          }
+                        \bool_if:NT \l_@@_withpinyin_bool
+                          {
+                            \clist_pop:NN \l_@@_tone_pinyin_clist \l_tmpb_tl
+                            \@@_single_pinyin:V \l_tmpb_tl
+
+                            \coffin_join:NnnNnnnn \l_tmpa_coffin
+                              { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                          }
+                        \coffin_typeset:Nnnnn \l_tmpa_coffin
+                          { l } { b } { 0pt } { 0pt }
+                        \allowbreak
+                      }
+
+                    \bool_if:NTF \l_@@_withhanzi_bool
+                      {
+                        \bool_set_false:N \l_@@_withhanzi_bool
+                        \int_step_inline:nnn { \l_@@_character_int + 1 } { \l_tmpa_int }
+                          {
+                            \hcoffin_set:Nn \l_tmpa_coffin
+                              {
+                                \@@_single_handle:N \c_@@_basechar_tl
+                              }
+                            \bool_if:NT \l_@@_withpinyin_bool
+                              {
+                                \clist_pop:NN \l_@@_tone_pinyin_clist \l_tmpb_tl
+                                \@@_single_pinyin:V \l_tmpb_tl
+
+                                \coffin_join:NnnNnnnn \l_tmpa_coffin
+                                  { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                              }
+                            \coffin_typeset:Nnnnn \l_tmpa_coffin
+                              { l } { b } { 0pt } { 0pt }
+                            \allowbreak
+                          }
+                        \bool_set_true:N \l_@@_withhanzi_bool
+                      }
+                      {
+                        \int_step_inline:nnn { \l_@@_character_int + 1 } { \l_tmpa_int }
+                          {
+                            \hcoffin_set:Nn \l_tmpa_coffin
+                              {
+                                \@@_single_handle:N \c_@@_basechar_tl
+                              }
+                            \bool_if:NT \l_@@_withpinyin_bool
+                              {
+                                \clist_pop:NN \l_@@_tone_pinyin_clist \l_tmpb_tl
+                                \@@_single_pinyin:V \l_tmpb_tl
+
+                                \coffin_join:NnnNnnnn \l_tmpa_coffin
+                                  { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                              }
+                            \coffin_typeset:Nnnnn \l_tmpa_coffin
+                              { l } { b } { 0pt } { 0pt }
+                            \allowbreak
+                          }
+                      }
+                  }
+              }
+          }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_single_str_coffin_construct:}
+% 构造单个汉字带拼音字符串盒子。
+%    \begin{macrocode}
+\cs_new:Npn \@@_single_str_coffin_construct:
+  {
+    \bool_if:NTF \l_@@_autopinyin_bool
+      {
+        \@@_multi_str_coffin_construct:
+      }
+      {
+        \hcoffin_set:Nn \l_@@_str_box_coffin
+          {
+            \hcoffin_set:Nn \l_tmpa_coffin
+              {
+                \@@_single_handle:N \l_@@_character_tl
+              }
+
+            \bool_if:NT \l_@@_withpinyin_bool
+              {
+                \hcoffin_set:Nn \l_@@_pinyin_box_coffin
+                  {
+                    \color_select:n { hanziboxcharcolor }
+                    \tl_use:N \l_@@_pinyin_format_tl
+                    \@@_get_tone_pinyin:V \l_@@_pinyin_tl
+                    \clist_clear:N \l_@@_tone_pinyin_clist
+                    \clist_set:NV \l_@@_tone_pinyin_clist \l_@@_tone_pinyin_tl
+                    \clist_use:Nn \l_@@_tone_pinyin_clist {}
+                  }
+                \coffin_join:NnnNnnnn \l_tmpa_coffin
+                  { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+              }
+            \coffin_typeset:Nnnnn \l_tmpa_coffin
+              { l } { b } { 0pt } { 0pt }
+            \allowbreak
+          }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_null_str_coffin_construct:}
+% 构造空白汉字(0个汉字)带拼音字符串盒子。
+%    \begin{macrocode}
+\cs_new:Npn \@@_null_str_coffin_construct:
+  {
+    \hcoffin_set:Nn \l_@@_str_box_coffin
+      {
+        \bool_set_false:N \l_@@_withhanzi_bool
+
+        \hcoffin_set:Nn \l_tmpa_coffin
+          {
+            \@@_single_handle:N \c_@@_basechar_tl
+          }
+
+        \bool_if:NT \l_@@_withpinyin_bool
+          {
+            \hcoffin_set:Nn \l_@@_pinyin_box_coffin
+              {
+                \color_select:n { hanziboxcharcolor }
+                \tl_use:N \l_@@_pinyin_format_tl
+                \@@_get_tone_pinyin:V \l_@@_pinyin_tl
+                \clist_clear:N \l_@@_tone_pinyin_clist
+                \clist_set:NV \l_@@_tone_pinyin_clist \l_@@_tone_pinyin_tl
+                \clist_use:Nn \l_@@_tone_pinyin_clist {}
+                % \@@_get_tone_pinyin:V \l_@@_pinyin_tl
+                % \l_@@_tone_pinyin_tl
+              }
+            \coffin_join:NnnNnnnn \l_tmpa_coffin
+              { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+          }
+        \coffin_typeset:Nnnnn \l_tmpa_coffin
+          { l } { b } { 0pt } { 0pt }
+        \allowbreak
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \changes{v2.0.0}{2021/09/28}{将拼音处理调整为在handle函数中直接实现}
-% \changes{v2.0.0}{2021/09/28}{区分了单个汉字和0个汉字的处理}
+% \changes{v2.0.0}{2021/09/28}{区分了单个汉字和空白汉字的处理}
+% \changes{v2.0.1}{2021/09/29}{将汉字盒子处理过程拆解为函数实现}
 %
 % \begin{macro}{\@@_handle:nnnn}
 % 构造汉字盒子入口
@@ -1611,9 +1906,9 @@
     \group_begin:
       \keys_set:nn { hanzibox } { #1 }
 
-      \tl_set:Nx \l_@@_character_tl {#2}
-      \tl_set:Nx \l_@@_pinyin_tl {#3}
-      \tl_set:Nx \l_@@_translation_tl {#4}
+      \tl_gset:Nx \l_@@_character_tl {#2}
+      \tl_gset:Nx \l_@@_pinyin_tl {#3}
+      \tl_gset:Nx \l_@@_translation_tl {#4}
 
       \int_set:Nn \l_@@_character_int
         {
@@ -1628,138 +1923,17 @@
           \tl_count:V \l_@@_pinyin_tl
         }
 
-      \bool_if:NTF \l_@@_autopinyin_bool
+      \int_compare:nNnTF { \l_@@_character_int } > { 1 }
         {
-          \int_compare:nNnTF { \l_@@_character_int } > { 0 }
-            {
-              \hcoffin_set:Nn \l_@@_str_box_coffin
-                {
-                  \tl_map_inline:Nn \l_@@_character_tl
-                    {
-                      \hcoffin_set:Nn \l_tmpa_coffin
-                        {
-                          \@@_single_handle:N ##1
-                        }
-
-                      \bool_if:NT \l_@@_withpinyin_bool
-                        {
-                          \tl_gset_eq:Nc \l_@@_pinyin_tl
-                            {
-                              c__xpinyin_ \int_to_arabic:n { `##1 } _tl
-                            }
-                          \@@_single_pinyin:V \l_@@_pinyin_tl
-
-                          \coffin_join:NnnNnnnn \l_tmpa_coffin
-                            { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
-                        }
-                      \coffin_typeset:Nnnnn \l_tmpa_coffin
-                        { l } { b } { 0pt } { 0pt }
-                      \allowbreak
-                    }
-                }
-            }
-            {
-              \hcoffin_set:Nn \l_@@_str_box_coffin
-                {
-                  \bool_set_false:N \l_@@_withhanzi_bool
-                  \tl_set:Nn \l_@@_character_tl {好}
-
-                  \hcoffin_set:Nn \l_tmpa_coffin
-                    {
-                      \@@_single_handle:N \l_@@_character_tl
-                    }
-
-                  \bool_if:NT \l_@@_withpinyin_bool
-                    {
-                      \hcoffin_set:Nn \l_@@_pinyin_box_coffin
-                        {
-                          \color_select:n { hanziboxcharcolor }
-                          \tl_use:N \l_@@_pinyin_format_tl
-                          \@@_pinyinaux:x {\l@@_pinyin_tl}
-                        }
-                      \coffin_join:NnnNnnnn \l_tmpa_coffin
-                        { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
-                    }
-                  \coffin_typeset:Nnnnn \l_tmpa_coffin
-                    { l } { b } { 0pt } { 0pt }
-                  \allowbreak
-                }
-            }
+          \@@_multi_str_coffin_construct:
         }
         {
-          \int_compare:nNnTF { \l_@@_character_int } > { 1 }
+          \int_compare:nNnTF { \l_@@_character_int } = { 1 }
             {
-              \hcoffin_set:Nn \l_@@_str_box_coffin
-                {
-                  \tl_map_inline:Nn \l_@@_character_tl
-                    {
-                      \@@_single_handle:N ##1 \allowbreak
-                    }
-                }
-              \bool_if:NT \l_@@_withpinyin_bool
-                {
-                  \hcoffin_set:Nn \l_@@_pinyin_box_coffin
-                    {
-                      \color_select:n { hanziboxcharcolor }
-                      \@@_pinyinaux:x {\l_@@_pinyin_tl}
-                    }
-                }
-              \coffin_join:NnnNnnnn \l_@@_str_box_coffin
-                { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 7pt }
+              \@@_single_str_coffin_construct:
             }
             {
-              \int_compare:nNnTF { \l_@@_character_int } = { 1 }
-                {
-                  \hcoffin_set:Nn \l_@@_str_box_coffin
-                    {
-                      \hcoffin_set:Nn \l_tmpa_coffin
-                        {
-                          \@@_single_handle:N \l_@@_character_tl
-                        }
-
-                      \bool_if:NT \l_@@_withpinyin_bool
-                        {
-                          \hcoffin_set:Nn \l_@@_pinyin_box_coffin
-                            {
-                              \color_select:n { hanziboxcharcolor }
-                              \tl_use:N \l_@@_pinyin_format_tl
-                              \@@_pinyinaux:x {\l@@_pinyin_tl}
-                            }
-                          \coffin_join:NnnNnnnn \l_tmpa_coffin
-                            { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
-                        }
-                      \coffin_typeset:Nnnnn \l_tmpa_coffin
-                        { l } { b } { 0pt } { 0pt }
-                      \allowbreak
-                    }
-                }
-                {
-                  \hcoffin_set:Nn \l_@@_str_box_coffin
-                    {
-                      \bool_set_false:N \l_@@_withhanzi_bool
-                      \tl_set:Nn \l_@@_character_tl {好}
-
-                      \hcoffin_set:Nn \l_tmpa_coffin
-                        {
-                          \@@_single_handle:N \l_@@_character_tl
-                        }
-
-                      \bool_if:NT \l_@@_withpinyin_bool
-                        {
-                          \hcoffin_set:Nn \l_@@_pinyin_box_coffin
-                            {
-                              \color_select:n { hanziboxcharcolor }
-                              \tl_use:N \l_@@_pinyin_format_tl
-                              \@@_pinyinaux:x {\l@@_pinyin_tl}
-                            }
-                          \coffin_join:NnnNnnnn \l_tmpa_coffin
-                            { hc } { t } \l_@@_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
-                        }
-                      \coffin_typeset:Nnnnn \l_tmpa_coffin
-                        { l } { b } { 0pt } { 0pt }
-                      \allowbreak
-                    }
-                }
+              \@@_null_str_coffin_construct:
             }
         }
       \bool_if:NT \l_@@_withtran_bool
@@ -1795,7 +1969,7 @@
   {
     \bool_if:NTF \l_@@_withtone_bool
       {
-        \bool_if:nTF { !(\l_@@_withinitials_bool) || !(\l_@@_withvowel_bool) }
+        \bool_if:nTF { !(\l_@@_withinitial_bool) || !(\l_@@_withvowel_bool) }
           {
             \@@_split_pinyin_withtone:n { #1 }
             \hcoffin_set:Nn \l_@@_pinyin_box_coffin
@@ -1803,7 +1977,7 @@
                 \color_select:n { hanziboxcharcolor }
                 \tl_use:N \l_@@_pinyin_format_tl
 
-                \bool_if:NTF \l_@@_withinitials_bool
+                \bool_if:NTF \l_@@_withinitial_bool
                   {
                     \bool_if:NTF \l_@@_withvowel_bool
                     {
@@ -1914,7 +2088,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \changes{v2.0.0}{2021/09/28}{为边框添加偏移,以使汉字尽量居中}
+% \changes{v2.0.0}{2021/09/28}{将汉字盒子与边框按中心对齐,以使汉字居中}
 %
 % \begin{macro}{\@@_single_frame_construct:}
 % 构造单个汉字盒子边框
@@ -1929,11 +2103,11 @@
       \exp_after:wN \draw_path_corner_arc:nn \l_@@_frame_arc_tl
 
       \draw_path_scope_begin:
-        \draw_transform_shift:n { -1.00pt, -1.50pt }
         \@@_frame_type_c:n { \l_@@_frame_type_tl }
           { 0 } { 0 } { \hanziboxwidth } { \hanziboxheight } { 1.0 } { 1.0 }
+        \draw_transform_shift:n {\hanziboxwidth / 2.0, \hanziboxheight / 2.0 }
+        \draw_coffin_use:Nnn \l_@@_box_coffin { hc } { vc }
       \draw_path_scope_end:
-      \draw_coffin_use:Nnn \l_@@_box_coffin { l } { b }
     \draw_end:
   }
 %    \end{macrocode}
@@ -1941,6 +2115,99 @@
 %
 % \subsection{\pkg{xpinyin}宏包拼音后处理函数}
 %
+% \changes{v2.1.0}{2021/09/30}{添加从xpinyin宏包中提取拼音串函数。}
+% 摘录自LaTeX工作室问答:如何得到xpinyin拼音宏包得到的拼音文本?
+% (\url{https://ask.latexstudio.net/ask/question/3768.html})
+%
+% 变量定义
+%    \begin{macrocode}
+\tl_new:N \l_@@_save_tl
+\tl_new:N \l_@@_hanzi_pinyin_tl
+\tl_new:N \l_@@_tone_pinyin_tl
+%    \end{macrocode}
+%
+% 构造声调表
+%    \begin{macrocode}
+\clist_const:Nn \c_@@_tone_a_clist { ā,á,ǎ,à,a }
+\clist_const:Nn \c_@@_tone_o_clist { ō,ó,ǒ,ò,o }
+\clist_const:Nn \c_@@_tone_e_clist { ē,é,ě,è,e }
+\clist_const:Nn \c_@@_tone_u_clist { ū,ú,ǔ,ù,u }
+\clist_const:Nn \c_@@_tone_i_clist { ī,í,ǐ,ì,i }
+\clist_const:Nn \c_@@_tone_v_clist { ǖ,ǘ,ǚ,ǜ,ü }
+%    \end{macrocode}
+%
+% \begin{macro}{\@@_pinyin_aux:n}
+% 拼音生成辅助函数(改自xpinyin宏包的\verb!\__xpinyin_pinyin_aux:n #1!函数)
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_pinyin_aux:n #1
+  {
+    \quark_if_recursion_tail_stop_do:nn {#1}
+      {
+        \bool_if:NT \l__xpinyin_first_bool
+          { \tl_set:NV \l_@@_tone_pinyin_tl \l__xpinyin_item_tl }
+      }
+    \__xpinyin_if_number:nTF {#1}
+      {
+        \bool_if:NT \l__xpinyin_first_bool
+          { \bool_set_false:N \l__xpinyin_first_bool }
+        \tl_put_right:NV \l_@@_tone_pinyin_tl \l__xpinyin_pre_tl
+        \tl_put_right:Nx \l_@@_tone_pinyin_tl
+          { \clist_item:cn { c_@@_tone_ \l__xpinyin_tone_tl _clist } {#1} }
+        \tl_put_right:NV \l_@@_tone_pinyin_tl \l__xpinyin_post_tl
+        \bool_if:NF \l_@@_autopinyin_bool
+          {
+            \tl_put_right:Nn \l_@@_tone_pinyin_tl {,}
+          }
+        \__xpinyin_pinyin_init:
+      }
+      {
+        \int_compare:nNnTF
+          { 0 \cs_if_exist_use:c { c__xpinyin_ \tl_to_str:N \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__xpinyin_pre_tl \l__xpinyin_item_tl
+            \tl_clear:N \l__xpinyin_post_tl
+          }
+        \tl_put_right:Nx \l__xpinyin_item_tl { \__xpinyin_replace_v:n {#1} }
+      }
+    \@@_pinyin_aux:n
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_get_tone_pinyin:n}
+% 根据手动拼音得到拼音
+%    \begin{macrocode}
+\cs_new:Npn \@@_get_tone_pinyin:n #1
+  {
+    \tl_clear:N \l_@@_tone_pinyin_tl
+    \__xpinyin_pinyin_init:
+    \tl_set:Nn \l_@@_save_tl {#1}
+    \bool_set_true:N \l__xpinyin_first_bool
+    \@@_pinyin_aux:n #1 \q_recursion_tail \q_recursion_stop
+  }
+\cs_generate_variant:Nn  \@@_get_tone_pinyin:n { V }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_get_hanzi_pinyin:n}
+% 自动拼音
+%    \begin{macrocode}
+\cs_new:Npn \@@_get_hanzi_pinyin:n #1
+  {
+    \tl_set_eq:Nc \l_tmpa_tl { c__xpinyin_ \__xpinyin_char_to_unicode:n {#1} _tl }
+    \exp_args:No \tl_if_head_eq_meaning:nNTF { \l_tmpa_tl } \__xpinyin_pinyin:n
+      {
+        \exp_args:Nf \@@_get_tone_pinyin:n { \exp_after:wN \use_ii:nn \l_tmpa_tl }
+        \tl_set_eq:NN \l_@@_hanzi_pinyin_tl \l_@@_tone_pinyin_tl
+      }
+      { \tl_set_eq:NN \l_@@_hanzi_pinyin_tl \l_tmpa_tl }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \changes{v2.0.0}{2021/09/24}{添加从xpinyin宏包中提取拼音函数。}
 % 代码摘录自LaTeX工作室:基于xpinyin宏包获取汉字的声母,韵母,声调
 % (\url{https://www.latexstudio.net/index/details/index/mid/1994.html})
@@ -2086,7 +2353,6 @@
           }
       }
   }
-\cs_generate_variant:Nn  \@@_split_pinyin:n { V }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2131,7 +2397,6 @@
           }
       }
   }
-\cs_generate_variant:Nn  \@@_split_pinyin:n { V }
 %    \end{macrocode}
 % \end{macro}
 %

Modified: trunk/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty	2021-09-30 20:13:14 UTC (rev 60660)
+++ trunk/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty	2021-09-30 20:13:28 UTC (rev 60661)
@@ -27,7 +27,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2020/10/01]
 \RequirePackage{expl3}
-\GetIdInfo$Id: hanzibox.dtx 2.0.0 2021-09-28 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
+\GetIdInfo$Id: hanzibox.dtx 2.1.0 2021-09-30 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
   {Boxed Chinese characters with Pinyin above and translation below.}
 \ProvidesExplPackage{\ExplFileName}
   {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -54,7 +54,7 @@
       {
         \bool_set_false:N \l__hanzibox_autopinyin_bool
       }{
-        \bool_set_true:N \l__hanzibox_autopinyin_bool
+        \bool_set_true:N  \l__hanzibox_autopinyin_bool
       }
       \group_begin:
         \__hanzibox_handle:nnnn { #2 } { #3 } { #4 } { #5 }
@@ -70,7 +70,7 @@
   }
 
 \bool_new:N   \l__hanzibox_autopinyin_bool
-\bool_new:N   \l__hanzibox_withinitials_bool
+\bool_new:N   \l__hanzibox_withinitial_bool
 \bool_new:N   \l__hanzibox_withvowel_bool
 \bool_new:N   \l__hanzibox_withtone_bool
 \bool_new:N   \l__hanzibox_withpinyin_bool
@@ -89,6 +89,8 @@
 \dim_new:N    \l__hanzibox_box_height_dim
 \dim_new:N    \l__hanzibox_linewidth_dim
 
+\clist_new:N  \l__hanzibox_tone_pinyin_clist
+
 \coffin_new:N \l__hanzibox_str_box_coffin
 \coffin_new:N \l__hanzibox_box_coffin
 \coffin_new:N \l__hanzibox_pinyin_box_coffin
@@ -98,11 +100,6 @@
 
 \dim_new:N    \hanziboxwidth
 \dim_new:N    \hanziboxheight
-\dim_new:N    \hanziboxboxwd
-\dim_new:N    \hanziboxboxht
-\dim_new:N    \hanziboxboxdp
-\tl_new:N     \hanziboxxscaleratio
-\tl_new:N     \hanziboxyscaleratio
 
 \tl_new:N     \l__hanzibox_pinyin_tl
 \tl_new:N     \l__hanzibox_character_tl
@@ -448,7 +445,7 @@
     autopinyin .default:n = true,
     autopinyin .initial:n = true,
 
-    initial .bool_set:N = \l__hanzibox_withinitials_bool,
+    initial .bool_set:N = \l__hanzibox_withinitial_bool,
     initial .default:n = true,
     initial .initial:n = true,
 
@@ -532,14 +529,239 @@
         { l } { b } { 0pt } { 0pt }
     \group_end:
   }
+\cs_new:Npn \__hanzibox_multi_str_coffin_construct:
+  {
+    \bool_if:NTF \l__hanzibox_autopinyin_bool
+      {
+        \hcoffin_set:Nn \l__hanzibox_str_box_coffin
+          {
+            \tl_map_inline:Nn \l__hanzibox_character_tl
+              {
+                \hcoffin_set:Nn \l_tmpa_coffin
+                  {
+                    \__hanzibox_single_handle:N ##1
+                  }
+
+                \bool_if:NT \l__hanzibox_withpinyin_bool
+                  {
+                    \__hanzibox_get_hanzi_pinyin:n { ##1 }
+                    \__hanzibox_single_pinyin:V \l__hanzibox_hanzi_pinyin_tl
+
+                    \coffin_join:NnnNnnnn \l_tmpa_coffin
+                      { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                  }
+                \coffin_typeset:Nnnnn \l_tmpa_coffin
+                  { l } { b } { 0pt } { 0pt }
+                \allowbreak
+              }
+          }
+      }
+      {
+        \__hanzibox_get_tone_pinyin:V \l__hanzibox_pinyin_tl
+        \clist_clear:N \l__hanzibox_tone_pinyin_clist
+        \clist_set:NV \l__hanzibox_tone_pinyin_clist \l__hanzibox_tone_pinyin_tl
+        \int_set:Nn \l_tmpa_int {\clist_count:N \l__hanzibox_tone_pinyin_clist}
+        \hcoffin_set:Nn \l__hanzibox_str_box_coffin
+          {
+            \int_compare:nNnTF { \l__hanzibox_character_int } = { \l_tmpa_int }
+              {
+                \tl_map_inline:Nn \l__hanzibox_character_tl
+                  {
+                    \hcoffin_set:Nn \l_tmpa_coffin
+                      {
+                        \__hanzibox_single_handle:N ##1
+                      }
+
+                    \bool_if:NT \l__hanzibox_withpinyin_bool
+                      {
+                        \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+                        \__hanzibox_single_pinyin:V \l_tmpb_tl
+
+                        \coffin_join:NnnNnnnn \l_tmpa_coffin
+                          { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                      }
+                    \coffin_typeset:Nnnnn \l_tmpa_coffin
+                      { l } { b } { 0pt } { 0pt }
+                    \allowbreak
+                  }
+              }
+              {
+                \int_compare:nNnTF { \l__hanzibox_character_int } > { \l_tmpa_int }
+                  {
+                    \int_step_inline:nn { \l_tmpa_int }
+                      {
+                        \hcoffin_set:Nn \l_tmpa_coffin
+                          {
+                            \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
+                            \__hanzibox_single_handle:N \l_tmpa_tl
+                          }
+                        \bool_if:NT \l__hanzibox_withpinyin_bool
+                          {
+                            \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+                            \__hanzibox_single_pinyin:V \l_tmpb_tl
+
+                            \coffin_join:NnnNnnnn \l_tmpa_coffin
+                              { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                          }
+                        \coffin_typeset:Nnnnn \l_tmpa_coffin
+                          { l } { b } { 0pt } { 0pt }
+                        \allowbreak
+                      }
+                    \int_step_inline:nnn { \l_tmpa_int + 1 } { \l__hanzibox_character_int }
+                      {
+                        \hcoffin_set:Nn \l_tmpa_coffin
+                          {
+                            \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
+                            \__hanzibox_single_handle:N \l_tmpa_tl
+                          }
+                        \coffin_typeset:Nnnnn \l_tmpa_coffin
+                          { l } { b } { 0pt } { 0pt }
+                        \allowbreak
+                      }
+                  }
+                  {
+                    \int_step_inline:nn { \l__hanzibox_character_int }
+                      {
+                        \hcoffin_set:Nn \l_tmpa_coffin
+                          {
+                            \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
+                            \__hanzibox_single_handle:N \l_tmpa_tl
+                          }
+                        \bool_if:NT \l__hanzibox_withpinyin_bool
+                          {
+                            \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+                            \__hanzibox_single_pinyin:V \l_tmpb_tl
+
+                            \coffin_join:NnnNnnnn \l_tmpa_coffin
+                              { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                          }
+                        \coffin_typeset:Nnnnn \l_tmpa_coffin
+                          { l } { b } { 0pt } { 0pt }
+                        \allowbreak
+                      }
+
+                    \bool_if:NTF \l__hanzibox_withhanzi_bool
+                      {
+                        \bool_set_false:N \l__hanzibox_withhanzi_bool
+                        \int_step_inline:nnn { \l__hanzibox_character_int + 1 } { \l_tmpa_int }
+                          {
+                            \hcoffin_set:Nn \l_tmpa_coffin
+                              {
+                                \__hanzibox_single_handle:N \c__hanzibox_basechar_tl
+                              }
+                            \bool_if:NT \l__hanzibox_withpinyin_bool
+                              {
+                                \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+                                \__hanzibox_single_pinyin:V \l_tmpb_tl
+
+                                \coffin_join:NnnNnnnn \l_tmpa_coffin
+                                  { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                              }
+                            \coffin_typeset:Nnnnn \l_tmpa_coffin
+                              { l } { b } { 0pt } { 0pt }
+                            \allowbreak
+                          }
+                        \bool_set_true:N \l__hanzibox_withhanzi_bool
+                      }
+                      {
+                        \int_step_inline:nnn { \l__hanzibox_character_int + 1 } { \l_tmpa_int }
+                          {
+                            \hcoffin_set:Nn \l_tmpa_coffin
+                              {
+                                \__hanzibox_single_handle:N \c__hanzibox_basechar_tl
+                              }
+                            \bool_if:NT \l__hanzibox_withpinyin_bool
+                              {
+                                \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+                                \__hanzibox_single_pinyin:V \l_tmpb_tl
+
+                                \coffin_join:NnnNnnnn \l_tmpa_coffin
+                                  { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+                              }
+                            \coffin_typeset:Nnnnn \l_tmpa_coffin
+                              { l } { b } { 0pt } { 0pt }
+                            \allowbreak
+                          }
+                      }
+                  }
+              }
+          }
+      }
+  }
+\cs_new:Npn \__hanzibox_single_str_coffin_construct:
+  {
+    \bool_if:NTF \l__hanzibox_autopinyin_bool
+      {
+        \__hanzibox_multi_str_coffin_construct:
+      }
+      {
+        \hcoffin_set:Nn \l__hanzibox_str_box_coffin
+          {
+            \hcoffin_set:Nn \l_tmpa_coffin
+              {
+                \__hanzibox_single_handle:N \l__hanzibox_character_tl
+              }
+
+            \bool_if:NT \l__hanzibox_withpinyin_bool
+              {
+                \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
+                  {
+                    \color_select:n { hanziboxcharcolor }
+                    \tl_use:N \l__hanzibox_pinyin_format_tl
+                    \__hanzibox_get_tone_pinyin:V \l__hanzibox_pinyin_tl
+                    \clist_clear:N \l__hanzibox_tone_pinyin_clist
+                    \clist_set:NV \l__hanzibox_tone_pinyin_clist \l__hanzibox_tone_pinyin_tl
+                    \clist_use:Nn \l__hanzibox_tone_pinyin_clist {}
+                  }
+                \coffin_join:NnnNnnnn \l_tmpa_coffin
+                  { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+              }
+            \coffin_typeset:Nnnnn \l_tmpa_coffin
+              { l } { b } { 0pt } { 0pt }
+            \allowbreak
+          }
+      }
+  }
+\cs_new:Npn \__hanzibox_null_str_coffin_construct:
+  {
+    \hcoffin_set:Nn \l__hanzibox_str_box_coffin
+      {
+        \bool_set_false:N \l__hanzibox_withhanzi_bool
+
+        \hcoffin_set:Nn \l_tmpa_coffin
+          {
+            \__hanzibox_single_handle:N \c__hanzibox_basechar_tl
+          }
+
+        \bool_if:NT \l__hanzibox_withpinyin_bool
+          {
+            \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
+              {
+                \color_select:n { hanziboxcharcolor }
+                \tl_use:N \l__hanzibox_pinyin_format_tl
+                \__hanzibox_get_tone_pinyin:V \l__hanzibox_pinyin_tl
+                \clist_clear:N \l__hanzibox_tone_pinyin_clist
+                \clist_set:NV \l__hanzibox_tone_pinyin_clist \l__hanzibox_tone_pinyin_tl
+                \clist_use:Nn \l__hanzibox_tone_pinyin_clist {}
+                % \__hanzibox_get_tone_pinyin:V \l__hanzibox_pinyin_tl
+                % \l__hanzibox_tone_pinyin_tl
+              }
+            \coffin_join:NnnNnnnn \l_tmpa_coffin
+              { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
+          }
+        \coffin_typeset:Nnnnn \l_tmpa_coffin
+          { l } { b } { 0pt } { 0pt }
+        \allowbreak
+      }
+  }
 \cs_new:Npn \__hanzibox_handle:nnnn #1#2#3#4
   {
     \group_begin:
       \keys_set:nn { hanzibox } { #1 }
 
-      \tl_set:Nx \l__hanzibox_character_tl {#2}
-      \tl_set:Nx \l__hanzibox_pinyin_tl {#3}
-      \tl_set:Nx \l__hanzibox_translation_tl {#4}
+      \tl_gset:Nx \l__hanzibox_character_tl {#2}
+      \tl_gset:Nx \l__hanzibox_pinyin_tl {#3}
+      \tl_gset:Nx \l__hanzibox_translation_tl {#4}
 
       \int_set:Nn \l__hanzibox_character_int
         {
@@ -554,138 +776,17 @@
           \tl_count:V \l__hanzibox_pinyin_tl
         }
 
-      \bool_if:NTF \l__hanzibox_autopinyin_bool
+      \int_compare:nNnTF { \l__hanzibox_character_int } > { 1 }
         {
-          \int_compare:nNnTF { \l__hanzibox_character_int } > { 0 }
-            {
-              \hcoffin_set:Nn \l__hanzibox_str_box_coffin
-                {
-                  \tl_map_inline:Nn \l__hanzibox_character_tl
-                    {
-                      \hcoffin_set:Nn \l_tmpa_coffin
-                        {
-                          \__hanzibox_single_handle:N ##1
-                        }
-
-                      \bool_if:NT \l__hanzibox_withpinyin_bool
-                        {
-                          \tl_gset_eq:Nc \l__hanzibox_pinyin_tl
-                            {
-                              c__xpinyin_ \int_to_arabic:n { `##1 } _tl
-                            }
-                          \__hanzibox_single_pinyin:V \l__hanzibox_pinyin_tl
-
-                          \coffin_join:NnnNnnnn \l_tmpa_coffin
-                            { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
-                        }
-                      \coffin_typeset:Nnnnn \l_tmpa_coffin
-                        { l } { b } { 0pt } { 0pt }
-                      \allowbreak
-                    }
-                }
-            }
-            {
-              \hcoffin_set:Nn \l__hanzibox_str_box_coffin
-                {
-                  \bool_set_false:N \l__hanzibox_withhanzi_bool
-                  \tl_set:Nn \l__hanzibox_character_tl {好}
-
-                  \hcoffin_set:Nn \l_tmpa_coffin
-                    {
-                      \__hanzibox_single_handle:N \l__hanzibox_character_tl
-                    }
-
-                  \bool_if:NT \l__hanzibox_withpinyin_bool
-                    {
-                      \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
-                        {
-                          \color_select:n { hanziboxcharcolor }
-                          \tl_use:N \l__hanzibox_pinyin_format_tl
-                          \__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}
-                        }
-                      \coffin_join:NnnNnnnn \l_tmpa_coffin
-                        { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
-                    }
-                  \coffin_typeset:Nnnnn \l_tmpa_coffin
-                    { l } { b } { 0pt } { 0pt }
-                  \allowbreak
-                }
-            }
+          \__hanzibox_multi_str_coffin_construct:
         }
         {
-          \int_compare:nNnTF { \l__hanzibox_character_int } > { 1 }
+          \int_compare:nNnTF { \l__hanzibox_character_int } = { 1 }
             {
-              \hcoffin_set:Nn \l__hanzibox_str_box_coffin
-                {
-                  \tl_map_inline:Nn \l__hanzibox_character_tl
-                    {
-                      \__hanzibox_single_handle:N ##1 \allowbreak
-                    }
-                }
-              \bool_if:NT \l__hanzibox_withpinyin_bool
-                {
-                  \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
-                    {
-                      \color_select:n { hanziboxcharcolor }
-                      \__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}
-                    }
-                }
-              \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin
-                { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 7pt }
+              \__hanzibox_single_str_coffin_construct:
             }
             {
-              \int_compare:nNnTF { \l__hanzibox_character_int } = { 1 }
-                {
-                  \hcoffin_set:Nn \l__hanzibox_str_box_coffin
-                    {
-                      \hcoffin_set:Nn \l_tmpa_coffin
-                        {
-                          \__hanzibox_single_handle:N \l__hanzibox_character_tl
-                        }
-
-                      \bool_if:NT \l__hanzibox_withpinyin_bool
-                        {
-                          \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
-                            {
-                              \color_select:n { hanziboxcharcolor }
-                              \tl_use:N \l__hanzibox_pinyin_format_tl
-                              \__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}
-                            }
-                          \coffin_join:NnnNnnnn \l_tmpa_coffin
-                            { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
-                        }
-                      \coffin_typeset:Nnnnn \l_tmpa_coffin
-                        { l } { b } { 0pt } { 0pt }
-                      \allowbreak
-                    }
-                }
-                {
-                  \hcoffin_set:Nn \l__hanzibox_str_box_coffin
-                    {
-                      \bool_set_false:N \l__hanzibox_withhanzi_bool
-                      \tl_set:Nn \l__hanzibox_character_tl {好}
-
-                      \hcoffin_set:Nn \l_tmpa_coffin
-                        {
-                          \__hanzibox_single_handle:N \l__hanzibox_character_tl
-                        }
-
-                      \bool_if:NT \l__hanzibox_withpinyin_bool
-                        {
-                          \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
-                            {
-                              \color_select:n { hanziboxcharcolor }
-                              \tl_use:N \l__hanzibox_pinyin_format_tl
-                              \__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}
-                            }
-                          \coffin_join:NnnNnnnn \l_tmpa_coffin
-                            { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
-                        }
-                      \coffin_typeset:Nnnnn \l_tmpa_coffin
-                        { l } { b } { 0pt } { 0pt }
-                      \allowbreak
-                    }
-                }
+              \__hanzibox_null_str_coffin_construct:
             }
         }
       \bool_if:NT \l__hanzibox_withtran_bool
@@ -712,7 +813,7 @@
   {
     \bool_if:NTF \l__hanzibox_withtone_bool
       {
-        \bool_if:nTF { !(\l__hanzibox_withinitials_bool) || !(\l__hanzibox_withvowel_bool) }
+        \bool_if:nTF { !(\l__hanzibox_withinitial_bool) || !(\l__hanzibox_withvowel_bool) }
           {
             \__hanzibox_split_pinyin_withtone:n { #1 }
             \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
@@ -720,7 +821,7 @@
                 \color_select:n { hanziboxcharcolor }
                 \tl_use:N \l__hanzibox_pinyin_format_tl
 
-                \bool_if:NTF \l__hanzibox_withinitials_bool
+                \bool_if:NTF \l__hanzibox_withinitial_bool
                   {
                     \bool_if:NTF \l__hanzibox_withvowel_bool
                     {
@@ -824,13 +925,76 @@
       \exp_after:wN \draw_path_corner_arc:nn \l__hanzibox_frame_arc_tl
 
       \draw_path_scope_begin:
-        \draw_transform_shift:n { -1.00pt, -1.50pt }
         \__hanzibox_frame_type_c:n { \l__hanzibox_frame_type_tl }
           { 0 } { 0 } { \hanziboxwidth } { \hanziboxheight } { 1.0 } { 1.0 }
+        \draw_transform_shift:n {\hanziboxwidth / 2.0, \hanziboxheight / 2.0 }
+        \draw_coffin_use:Nnn \l__hanzibox_box_coffin { hc } { vc }
       \draw_path_scope_end:
-      \draw_coffin_use:Nnn \l__hanzibox_box_coffin { l } { b }
     \draw_end:
   }
+\tl_new:N \l__hanzibox_save_tl
+\tl_new:N \l__hanzibox_hanzi_pinyin_tl
+\tl_new:N \l__hanzibox_tone_pinyin_tl
+\clist_const:Nn \c__hanzibox_tone_a_clist { ā,á,ǎ,à,a }
+\clist_const:Nn \c__hanzibox_tone_o_clist { ō,ó,ǒ,ò,o }
+\clist_const:Nn \c__hanzibox_tone_e_clist { ē,é,ě,è,e }
+\clist_const:Nn \c__hanzibox_tone_u_clist { ū,ú,ǔ,ù,u }
+\clist_const:Nn \c__hanzibox_tone_i_clist { ī,í,ǐ,ì,i }
+\clist_const:Nn \c__hanzibox_tone_v_clist { ǖ,ǘ,ǚ,ǜ,ü }
+\cs_new_protected:Npn \__hanzibox_pinyin_aux:n #1
+  {
+    \quark_if_recursion_tail_stop_do:nn {#1}
+      {
+        \bool_if:NT \l__xpinyin_first_bool
+          { \tl_set:NV \l__hanzibox_tone_pinyin_tl \l__xpinyin_item_tl }
+      }
+    \__xpinyin_if_number:nTF {#1}
+      {
+        \bool_if:NT \l__xpinyin_first_bool
+          { \bool_set_false:N \l__xpinyin_first_bool }
+        \tl_put_right:NV \l__hanzibox_tone_pinyin_tl \l__xpinyin_pre_tl
+        \tl_put_right:Nx \l__hanzibox_tone_pinyin_tl
+          { \clist_item:cn { c__hanzibox_tone_ \l__xpinyin_tone_tl _clist } {#1} }
+        \tl_put_right:NV \l__hanzibox_tone_pinyin_tl \l__xpinyin_post_tl
+        \bool_if:NF \l__hanzibox_autopinyin_bool
+          {
+            \tl_put_right:Nn \l__hanzibox_tone_pinyin_tl {,}
+          }
+        \__xpinyin_pinyin_init:
+      }
+      {
+        \int_compare:nNnTF
+          { 0 \cs_if_exist_use:c { c__xpinyin_ \tl_to_str:N \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__xpinyin_pre_tl \l__xpinyin_item_tl
+            \tl_clear:N \l__xpinyin_post_tl
+          }
+        \tl_put_right:Nx \l__xpinyin_item_tl { \__xpinyin_replace_v:n {#1} }
+      }
+    \__hanzibox_pinyin_aux:n
+  }
+\cs_new:Npn \__hanzibox_get_tone_pinyin:n #1
+  {
+    \tl_clear:N \l__hanzibox_tone_pinyin_tl
+    \__xpinyin_pinyin_init:
+    \tl_set:Nn \l__hanzibox_save_tl {#1}
+    \bool_set_true:N \l__xpinyin_first_bool
+    \__hanzibox_pinyin_aux:n #1 \q_recursion_tail \q_recursion_stop
+  }
+\cs_generate_variant:Nn  \__hanzibox_get_tone_pinyin:n { V }
+\cs_new:Npn \__hanzibox_get_hanzi_pinyin:n #1
+  {
+    \tl_set_eq:Nc \l_tmpa_tl { c__xpinyin_ \__xpinyin_char_to_unicode:n {#1} _tl }
+    \exp_args:No \tl_if_head_eq_meaning:nNTF { \l_tmpa_tl } \__xpinyin_pinyin:n
+      {
+        \exp_args:Nf \__hanzibox_get_tone_pinyin:n { \exp_after:wN \use_ii:nn \l_tmpa_tl }
+        \tl_set_eq:NN \l__hanzibox_hanzi_pinyin_tl \l__hanzibox_tone_pinyin_tl
+      }
+      { \tl_set_eq:NN \l__hanzibox_hanzi_pinyin_tl \l_tmpa_tl }
+  }
 \clist_set:Nn \l__hanzibox_initials_clist
   {
     {zh} , {ch} , {sh} , {b} , {p} , {m} , {f} ,
@@ -945,7 +1109,6 @@
           }
       }
   }
-\cs_generate_variant:Nn  \__hanzibox_split_pinyin:n { V }
 \cs_new_protected:Npn \__hanzibox_split_pinyin_withouttone:n #1
   {
     \int_zero:N  \l__hanzibox_tone_int
@@ -984,7 +1147,6 @@
           }
       }
   }
-\cs_generate_variant:Nn  \__hanzibox_split_pinyin:n { V }
 %% 
 %%     This package consists of the file  hanzibox.dtx,
 %%                  and the derived files hanzibox.sty,



More information about the tex-live-commits mailing list.