diff options
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx | 204 |
1 files changed, 192 insertions, 12 deletions
diff --git a/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx b/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx index 3a05212a3b9..5124b0376fe 100644 --- a/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx +++ b/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx @@ -7,11 +7,12 @@ Boxed Chinese characters with Pinyin above and translation below based LaTeX3 ======= -`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. +`hanzibox` is a LaTeX package developed in LaTeX3, which provides `\hanzibox`, `\hanzidialog` and `\writegrid` macros. These 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. 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*` 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. +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. The `\writegrid` macro is for write a composition anwser grid. + `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. @@ -37,7 +38,7 @@ Contributing 基于LaTeX3的带注音和译文的汉字练习宏包 ======= -`hanzibox`是一个用LaTeX3开发的LaTeX宏包,它提供了`\hanzibox`和`\hanzidialog` 两个命令。这两个命令分别用于排版汉字学习中带有或不带田字格、米字格等背景格子的汉字,并可以根据需要在汉字正上方显示拼音,在正下方显示译文。其中,`\hanzibox`命令能够根据汉字自动调用`xpinyin`宏包的`\xpinyin*`命令实现汉字注音。并且`\hanzibox`命令提供了`\hanzibox*`星号版本,其注音功能是通过自动调用`xpinyin`宏包的`\pinyin`命令实现的。`\hanzidialog`命令的注音功能是通过在拼音选项中手动插入`xpinyin`宏包`\pinyin`命令实现的。 +`hanzibox`是一个用LaTeX3开发的LaTeX宏包,它提供了`\hanzibox`、`\hanzidialog` 和`\writegrid`三个个命令。这三个命令分别用于排版汉字学习中带有或不带田字格、米字格等背景格子的汉字,并可以根据需要在汉字正上方显示拼音,在正下方显示译文。其中,`\hanzibox`命令能够根据汉字自动调用`xpinyin`宏包的`\xpinyin*`命令实现汉字注音。并且`\hanzibox`命令提供了`\hanzibox*`星号版本,其注音功能是通过自动调用`xpinyin`宏包的`\pinyin`命令实现的。`\hanzidialog`命令的注音功能是通过在拼音选项中手动插入`xpinyin`宏包`\pinyin`命令实现的。`\writegrid`命令用于排版作文题目的答题格子纸。 `hanzibox` 是一个用于学习汉字书写与发音的工具,可以用于汉字学习教案、演示文稿、习题册等文档工作。 @@ -61,7 +62,7 @@ Contributing Copyright and Licence --------------------- - Copyright (C) 2020-2021 by Nan Geng <nangeng@nwafu.edu.cn> + Copyright (C) 2020-2022 by Nan Geng <nangeng@nwafu.edu.cn> ---------------------------------------------------------------------- This work may be distributed and/or modified under the @@ -100,7 +101,7 @@ Copyright and Licence \preamble - Copyright (C) 2020-2021 by Nan Geng <nangeng@nwafu.edu.cn> + Copyright (C) 2020-2022 by Nan Geng <nangeng@nwafu.edu.cn> -------------------------------------------------------------------------- This work may be distributed and/or modified under the @@ -160,7 +161,7 @@ Copyright and Licence %</internal> %<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01] %<package>\RequirePackage{expl3} -%<+package>\GetIdInfo$Id: hanzibox.dtx 2.2.0 2021-10-11 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $ +%<+package>\GetIdInfo$Id: hanzibox.dtx 2.3.0 2022-04-17 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $ %<package> {Boxed Chinese characters with Pinyin above and translation below.} %<package>\ProvidesExplPackage{\ExplFileName} %<package> {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -193,7 +194,7 @@ Copyright and Licence % \changes{v2.0.0}{2021/09/25}{基于l3draw重新设计} % \changes{v2.0.0}{2021/09/28}{重新编写README.md内容} % -% \CheckSum{1222} +% \CheckSum{0} % \GetFileId{hanzibox.sty} % % \CharacterTable @@ -225,13 +226,15 @@ Copyright and Licence % % \begin{abstract} % -% \pkg{hanzibox} 是一个用\LaTeX3开发的 \LaTeX 宏包,它提供了\tn{hanzibox}和\tn{hanzidialog} -% 两个命令。这两个命令用于输出汉字学习中带有或不带田字格、米字格等背景格子的汉字, +% \pkg{hanzibox} 是一个用\LaTeX3开发的 \LaTeX 宏包,它提供 +% 了\tn{hanzibox}、\tn{hanzidialog}和\tn{writegrid}三 +% 个命令。这三个命令用于输出汉字学习中带有或不带田字格、米字格等背景格子的汉字, % 并可以根据需要在汉字正上方显示拼音,在正下方显示译文。 % 其中,\tn{hanzibox}命令能够根据汉字利用\pkg{xpinyin}宏包自动实现汉字注音。 % 同时,\tn{hanzibox}命令还提供了\tn{hanzibox*}星号版本,以实现汉字的手动注音功能。 % \tn{hanzidialog}命令的注音功能则是通过在其拼音选项中手动插入 -% \pkg{xpinyin}宏包的\tn{pinyin}命令实现。 +% \pkg{xpinyin}宏包的\tn{pinyin}命令实现。\tn{writegrid}命令用于排版 +% 作文题目的答题格子纸。 % % \end{abstract} % @@ -316,6 +319,29 @@ Copyright and Licence % \end{SideBySideExample} % \end{function} % +% \subsection{\tn{writegrid}命令} +% +% \begin{function}[added=2022-04-17,updated=2022-04-17]{\writegrid} +% \begin{syntax} +% \tn{writegrid} \oarg{外观选项} \Arg{行数} +% \end{syntax} +% 根据指定的\Arg{行数},用\oarg{外观选项}指定的外观参数和行间距及 +% 列数排版作文题目中的写作格子纸。\\ +% 其中,\oarg{外观选项}用于单个格子盒子外观,但要注意此时, +% \oarg{拼音选项}、\oarg{译文选项}及其相关选项无效。与作文 +% 直接相关的选项有\oarg{gridsepv}用于设置不同格子行的间距, +% \oarg{gridcols}用于设置每行的格子数 +% +% 排版样式可通过\tn{hanziboxset}命令或\tn{writegrid}\oarg{外观选项}的key-value进行设置。 +% +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=5] +% \centering +% \hanziboxset{framecolor=red, +% fillcolor=yellow!30} +% \writegrid{5} +% \end{SideBySideExample} +% \end{function} +% % \subsection{\tn{hanziboxset}命令} % % \begin{function}[added=2021-09-20,updated=2021-09-24]{\hanziboxset} @@ -619,6 +645,30 @@ Copyright and Licence % \end{SideBySideExample} % \end{function} % +% \subsection{作文格式选项} +% +% \begin{function}[added=2022-04-17,updated=2022-04-17]{gridsepv,gridcols} +% \begin{syntax} +% gridsepv = \meta{number} \init{4} +% gridcols = \meta{integer} \init{20} +% \end{syntax} +% \oarg{gridsepv}用于设置作文格子行间间距, +% $\text{行间距}=\text{单个盒子高度}\times\frac{1}{number}$, +% 默认值取4。 +% +% \oarg{gridcols}用于设置格子每行的列数,默认值取20。 +% +% 这两个选项对\tn{hanzibox}和\tn{hanzidialog}命令无效。 +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.50\linewidth,gobble=5] +% \centering +% \hanziboxset{frametype=咪,framecolor=red, +% charf=\large,fillcolor=yellow!40} +% \writegrid{3}\\ +% \writegrid[gridsepv=0.5,gridcols=10]{3}\\ +% \writegrid[gridsepv=1.0,gridcols=15]{3} +% \end{SideBySideExample} +% \end{function} +% % \changes{v2.0.0}{2021/09/28}{在说明文档中添加应用实例} % \changes{v2.2.0}{2021/10/07}{为部分实例添加拼音四线格} % @@ -749,7 +799,7 @@ Copyright and Licence % % \changes{v2.1.1}{2021/10/07}{在格子纸示例中用coffin实现每行格子以提升编译速度} % -% \subsection{生成汉字书写格子纸} +% \subsection{生成汉字字帖格子纸} % % 可以通过将\tn{hanzibox}命令的\Arg{汉字}参数留空,并设置\verb!tran=false!, % 或将\tn{hanzibox}、\tn{hanzibox*}命令的\verb!hanzi!选项置为 @@ -806,6 +856,18 @@ Copyright and Licence % \ExplSyntaxOff % \end{SideBySideExample} % +% \subsection{生成作文题目格子纸} +% +% 可以使用本宏包提供的\tn{writegrid}命令生成作文题目中用于答题的 +% 格式纸。 +% +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.48\linewidth,gobble=5] +% \hanziboxset{frametype=口,framecolor=black, +% charcolor=red,charf=\huge} +% \centering +% \writegrid[gridcols=8]{10} +% \end{SideBySideExample} +% % \subsection{生成诗词注音} % % 可以通过自动注音生成带有注音的诗词排版, @@ -995,7 +1057,20 @@ Copyright and Licence \@@_dialog:nnnn { #1 } { #2 } { #3 } { #4 } \group_end: } - +% \end{macrocode} +% \end{macro} +% +% \changes{v2.3.0}{2022/04/17}{添加\tn{writegrid}作文格子输出命令。} +% +% \begin{macro}{\writegrid} +% 自动注音汉字盒子命令。 +% \begin{macrocode} +\NewDocumentCommand{\writegrid}{ O{} m } + { + \group_begin: + \@@_writegrid:nn { #1 } { #2 } + \group_end: + } % \end{macrocode} % \end{macro} % @@ -1007,6 +1082,7 @@ Copyright and Licence % \changes{v2.2.0}{2021/10/07}{添加拼音线开关及拼音和译文颜色变量} % \changes{v2.2.0}{2021/10/08}{添加字符轮廓类型选择变量} % \changes{v2.2.0}{2021/10/09}{添加拼音汉字coffin变量} +% \changes{v2.3.0}{2022/04/17}{添加作文格子垂直间距系数变量及coffin变量。} % % \begin{variable}{\l_@@_autopinyin_bool, % \l_@@_withinitial_bool, @@ -1040,6 +1116,9 @@ Copyright and Licence % \l_@@_pinyin_hanzi_coffin, % \l_@@_tmpa_coffin, % \l_@@_tmpb_coffin, +% \l_@@_grid_coffin, +% \l_@@_grid_tmpa_coffin, +% \l_@@_grid_tmpb_coffin, % \hanziboxwidth, % \hanziboxheight, % \l_@@_pinyin_tl, @@ -1053,10 +1132,12 @@ Copyright and Licence % \l_@@_character_int, % \l_@@_translation_int, % \l_@@_charstroke_type_int, +% \l_@@_grid_cols_int, % \l_@@_tone_int, % \l_@@_pinyin_str, % \l_@@_initial_tl, % \l_@@_vowel_tl, +% \l_@@_grid_sep_v_tl, % } % 定义变量。 % @@ -1096,6 +1177,9 @@ Copyright and Licence \coffin_new:N \l_@@_pinyin_hanzi_coffin \coffin_new:N \l_@@_tmpa_coffin \coffin_new:N \l_@@_tmpb_coffin +\coffin_new:N \l_@@_grid_coffin +\coffin_new:N \l_@@_grid_tmpa_coffin +\coffin_new:N \l_@@_grid_tmpb_coffin \dim_new:N \hanziboxwidth \dim_new:N \hanziboxheight @@ -1111,11 +1195,13 @@ Copyright and Licence \int_new:N \l_@@_character_int \int_new:N \l_@@_translation_int \int_new:N \l_@@_charstroke_type_int +\int_new:N \l_@@_grid_cols_int \int_new:N \l_@@_tone_int \str_new:N \l_@@_pinyin_str \tl_new:N \l_@@_initial_tl \tl_new:N \l_@@_vowel_tl +\tl_new:N \l_@@_grid_sep_v_tl % \end{macrocode} % \end{variable} @@ -1985,6 +2071,25 @@ Copyright and Licence % \end{macrocode} % \end{macro} % +% \changes{v2.3.0}{2022/04/17}{添加作文格子垂直间距gridsepv选项} +% +% \begin{macro}{gridsepv} +% 作文格子垂直间距 +% \begin{macrocode} + gridsepv .tl_set:N = \l_@@_grid_sep_v_tl , + gridsepv .initial:n = 4.0 , +% \end{macrocode} +% \end{macro} +% +% \changes{v2.3.0}{2022/04/17}{添加作文格子列数gridcols选项} +% +% \begin{macro}{gridsepv} +% 作文格子每行列数 +% \begin{macrocode} + gridcols .int_set:N = \l_@@_grid_cols_int , + gridcols .initial:n = 20 , +% \end{macrocode} +% \end{macro} % % 处理未知选项。 % \begin{macrocode} @@ -2378,6 +2483,81 @@ Copyright and Licence % \end{macrocode} % \end{macro} % +% \changes{v2.3.0}{2022/04/17}{添加作文格子内部命令。} +% +% \begin{macro}{\@@_writegrid:nnn} +% 构造作文格子入口 +% \begin{macrocode} +\cs_new:Npn \@@_writegrid:nn #1#2 + { + \group_begin: + \keys_set:nn { hanzibox } { #1 } + + \tl_if_eq:NnT \l_@@_frame_type_tl { none } + { \tl_set:Nn \l_@@_frame_type_tl { 口 } } + + \hcoffin_set:Nn \l_@@_grid_tmpa_coffin + { + \draw_begin: + \draw_linewidth:n { \l_@@_frame_linewidth_dim } + \@@_aux_color_fill: + \color_stroke:n { hanziboxframecolor } + + \draw_path_scope_begin: + \@@_frame_type_c:n { \l_@@_frame_type_tl } + { 0 } { 0 } { \hanziboxwidth } { \hanziboxheight } { 1.0 } { 1.0 } + \int_decr:N \l_@@_grid_cols_int + \int_step_inline:nn { \l_@@_grid_cols_int } + { + \draw_transform_shift:n {\hanziboxwidth, 0.0 } + \@@_frame_type_c:n { \l_@@_frame_type_tl } + { 0 } { 0 } { \hanziboxwidth } { \hanziboxheight } { 1.0 } { 1.0 } + } + \draw_path_scope_end: + \draw_end: + } + + \hcoffin_set:Nn \l_@@_grid_tmpb_coffin + { + \coffin_typeset:Nnnnn \l_@@_grid_tmpa_coffin + { l } { b } { 0pt } { 0pt } + } + + \int_step_inline:nn { #2 - 1 } + { + \coffin_join:NnnNnnnn \l_@@_grid_tmpb_coffin { hc } { b } + \l_@@_grid_tmpa_coffin { hc } { t } { 0pt } + { -\hanziboxheight * \dim_ratio:nn { 1 pt }{ \l_@@_grid_sep_v_tl pt } } + } + + \dim_set:Nn \l_tmpa_dim + { + \coffin_wd:N \l_@@_grid_tmpb_coffin + } + \dim_set:Nn \l_tmpb_dim + { + \tex_dimexpr:D \coffin_ht:N \l_@@_grid_tmpb_coffin + + \coffin_dp:N \l_@@_grid_tmpb_coffin \scan_stop: + } + + \draw_begin: + \draw_linewidth:n { \l_@@_frame_linewidth_dim * 4 } + \@@_aux_color_fill: + \color_stroke:n { hanziboxframecolor } + + \draw_path_scope_begin: + \draw_path_rectangle_corners:nn { 0cm , 0cm } { \l_tmpa_dim, \l_tmpb_dim } + \draw_path_use_clear:n { draw } + \draw_transform_shift:n {\l_tmpa_dim / 2.0, \l_tmpb_dim / 2.0 } + \draw_coffin_use:Nnn \l_@@_grid_tmpb_coffin { hc } { vc } + \draw_path_scope_end: + \draw_end: + + \group_end: + } +% \end{macrocode} +% \end{macro} +% % \changes{v2.0.0}{2021/09/27}{对于无需分解声韵母的情况, % 直接使用xpinyin宏包的结果排版拼音。} % |