From 4d48af346935c8e1a7c68e737d9e8b064a2685d9 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 7 Oct 2021 20:33:53 +0000 Subject: hanzibox (7oct21) git-svn-id: svn://tug.org/texlive/trunk@60710 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/xelatex/hanzibox/README.md | 3 +- .../texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf | Bin 494235 -> 505041 bytes .../source/xelatex/hanzibox/hanzibox.dtx | 158 ++++++++++++++++----- .../texmf-dist/tex/xelatex/hanzibox/hanzibox.sty | 77 +++++++--- 4 files changed, 179 insertions(+), 59 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/xelatex/hanzibox/README.md b/Master/texmf-dist/doc/xelatex/hanzibox/README.md index 5f7e8d4ee08..0daf1efe0e5 100644 --- a/Master/texmf-dist/doc/xelatex/hanzibox/README.md +++ b/Master/texmf-dist/doc/xelatex/hanzibox/README.md @@ -1,5 +1,5 @@ hanzibox -LaTeX3-based Chinese Character package +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. @@ -24,6 +24,7 @@ Contributing 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). +======= hanzibox 基于LaTeX3的汉字练习宏包 ======= diff --git a/Master/texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf b/Master/texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf index ce083be4f26..de80686c06b 100644 Binary files a/Master/texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf and b/Master/texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf differ diff --git a/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx b/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx index e3099aba20f..c499c05c8d0 100644 --- a/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx +++ b/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx @@ -5,7 +5,7 @@ % %<*readme> hanzibox -LaTeX3-based Chinese Character package +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. @@ -30,6 +30,7 @@ Contributing 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). +======= hanzibox 基于LaTeX3的汉字练习宏包 ======= @@ -153,7 +154,7 @@ Copyright and Licence % %\NeedsTeXFormat{LaTeX2e}[2020/10/01] %\RequirePackage{expl3} -%<+package>\GetIdInfo$Id: hanzibox.dtx 2.1.0 2021-09-30 08:00:00 +0800 Nan Geng $ +%<+package>\GetIdInfo$Id: hanzibox.dtx 2.1.1 2021-10-07 08:00:00 +0800 Nan Geng $ % {Boxed Chinese characters with Pinyin above and translation below.} %\ProvidesExplPackage{\ExplFileName} % {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -186,7 +187,7 @@ Copyright and Licence % \changes{v2.0.0}{2021/09/25}{基于l3draw重新设计} % \changes{v2.0.0}{2021/09/28}{重新编写README.md内容} % -% \CheckSum{1043} +% \CheckSum{1085} % \GetFileId{hanzibox.sty} % % \CharacterTable @@ -445,6 +446,23 @@ Copyright and Licence % 若要去掉 \opt{fillcolor},应将其置为空(\verb|fillcolor={}|),而不是将其设置为white(白色)。 % \end{function} % +% \begin{function}[added=2021-10-07,updated=2021-10-07]{crosscolorratio} +% \begin{syntax} +% crosscolorratio = \meta{integer} \init{20} +% \end{syntax} +% 格子内部十字线或米字线颜色占边框颜色的比例。 +% +% \textcolor[HTML]{AD1457}{注:\textsf{crosscolorratio}选项须在使用\textsf{framecolor}后起效}。 +% +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.25\linewidth,gobble=5] +% \centering +% \hanzibox[frametype=咪,framecolor=red]{十} +% \hanzibox[frametype=咪,crosscolorratio=30,framecolor=red]{田} +% \hanzibox[frametype=咪,crosscolorratio=50,framecolor=red]{米} +% \hanzibox[frametype=咪,crosscolorratio=80,framecolor=red]{咪} +% \end{SideBySideExample} +% \end{function} +% % \begin{function}[added=2021-09-24,updated=2021-09-24]{initial,vowel,tone} % \begin{syntax} % initial = <\TTF> \init{true} @@ -620,6 +638,8 @@ Copyright and Licence % \ExplSyntaxOff % \end{SideBySideExample} % +% \changes{v2.1.1}{2021/10/07}{在格子纸示例中用coffin实现每行格子以提升编译速度} +% % \subsection{生成汉字书写练习格子纸} % % 可以通过将\tn{hanzibox}命令的\Arg{汉字}参数留空, @@ -628,36 +648,46 @@ Copyright and Licence % 再根据需要通过循环的方式生成指定行数和列数的 % 汉字书写练习用格子纸。 % -% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.50\linewidth,gobble=5] +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.43\linewidth,gobble=5] % \hanziboxset{frametype=咪,framecolor=red, -% charcolor=red,charf=\huge} +% charcolor=red,charf=\huge} % \centering % \ExplSyntaxOn -% \int_step_inline:nn {8} +% \hcoffin_set:Nn \l_tmpa_coffin % { % \int_step_inline:nn {6} % { % \hanzibox{} -% \hspace*{-0.4pt} +% \hspace*{-0.35pt} % } -% \par\nointerlineskip\vspace*{-6.0pt} +% } +% \int_step_inline:nn {8} +% { +% \coffin_typeset:Nnnnn +% \l_tmpa_coffin { l } { b } { 0pt } { 0pt } +% \par\nointerlineskip\vspace*{-3.3pt} % } % \ExplSyntaxOff % \end{SideBySideExample} % -% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.50\linewidth,gobble=5] +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.43\linewidth,gobble=5] % \hanziboxset{frametype=咪,framecolor=red, % charcolor=red,charf=\huge,hanzi=false} % \centering % \ExplSyntaxOn -% \int_step_inline:nn {8} +% \hcoffin_set:Nn \l_tmpa_coffin % { % \int_step_inline:nn {6} % { % \hanzibox*{国} -% \hspace*{-0.4pt} +% \hspace*{-0.35pt} % } -% \par\nointerlineskip\vspace*{-6.0pt} +% } +% \int_step_inline:nn {8} +% { +% \coffin_typeset:Nnnnn +% \l_tmpa_coffin { l } { b } { 0pt } { 0pt } +% \par\nointerlineskip\vspace*{-6.30pt} % } % \ExplSyntaxOff % \end{SideBySideExample} @@ -694,7 +724,7 @@ Copyright and Licence % \hanzibox*{故人西辞黄鹤楼}[gu4ren2xi1ci2huang2he2lou2] % \hanzibox*{烟花三月下扬州}[yan1hua1san1yue4] % \hanzibox*{孤帆远影 }[gu1fan1yuan3ying3bi4kong1jin4] -% \hanzibox*{唯见长江天际流}[wei2jian4] +% \hanzibox*{}[wei2jian4chang2jiang1tian1ji4liu2] % \end{SideBySideExample} % % \end{documentation} @@ -755,6 +785,20 @@ Copyright and Licence % % \end{macrocode} % +% \changes{v2.1.1}{2021/10/03}{修订盒子高度计算函数的expl3版本兼容问题} +% +% 判断\tn{box_ht_plus_dp:N}函数是否存在,若不存在,则定义该函数。 +% 为了解决expl3的旧版本兼容问题。 +% 摘录于\url{https://ask.latexstudio.net/ask/question/3773.html}。 +% +% \begin{macrocode} +\cs_if_free:NT \box_ht_plus_dp:N + { + \cs_new_protected:Npn \box_ht_plus_dp:N #1 + { \tex_dimexpr:D \box_ht:N #1 + \box_dp:N #1 \scan_stop: } + } +% \end{macrocode} +% % 检查编译引擎 % % \begin{macrocode} @@ -855,6 +899,7 @@ Copyright and Licence % \l_@@_pinyin_format_tl, % \l_@@_character_format_tl, % \l_@@_translation_format_tl, +% \l_@@_cross_color_ratio_int, % \l_@@_pinyin_int, % \l_@@_character_int, % \l_@@_translation_int, @@ -904,6 +949,7 @@ Copyright and Licence \tl_new:N \l_@@_pinyin_format_tl \tl_new:N \l_@@_character_format_tl \tl_new:N \l_@@_translation_format_tl +\int_new:N \l_@@_cross_color_ratio_int \int_new:N \l_@@_pinyin_int \int_new:N \l_@@_character_int \int_new:N \l_@@_translation_int @@ -1041,14 +1087,18 @@ Copyright and Licence \draw_path_use_clear:n { stroke , fill } } } - +% \end{macrocode} +% +% \changes{v2.1.1}{2021/10/07}{用hanziboxcrosscolor设置内格子线颜色} +% +% \begin{macrocode} \@@_new_frame_construct:nn { 十 } { \tl_if_empty:NF \l_@@_dash_pattern_tl { \exp_args:No \draw_dash_pattern:nn { \l_@@_dash_pattern_tl } { 0pt } } - \color_stroke:n { hanziboxframecolor!30 } + \color_stroke:n { hanziboxcrosscolor } \draw_path_moveto:n { (#3)/2, #2 } \draw_path_lineto:n { #3/2, #4 } \draw_path_moveto:n { #1, (#4)/2 } @@ -1062,7 +1112,7 @@ Copyright and Licence { \exp_args:No \draw_dash_pattern:nn { \l_@@_dash_pattern_tl } { 0pt } } - \color_stroke:n { hanziboxframecolor!30 } + \color_stroke:n { hanziboxcrosscolor } \draw_path_moveto:n { #1, #2 } \draw_path_lineto:n { #3, #4 } \draw_path_moveto:n { #1, #4 } @@ -1265,10 +1315,12 @@ Copyright and Licence { \color_set:nn {#1} {#2} } +\cs_generate_variant:Nn \@@_color_select:nn {nx} \cs_set_nopar:Npn \@@_color_select:nnn #1#2#3 { \color_set:nnn {#1} {#2} {#3} } +\cs_generate_variant:Nn \@@_color_select:nnn {nnx} % \end{macrocode} % \end{macro} % @@ -1411,12 +1463,28 @@ Copyright and Licence % \end{macrocode} % \end{macro} % +% \changes{v2.1.1}{2021/10/07}{添加格子内部十字和米字线颜色与边框颜色比例选项corsscolorratio} +% +% \begin{macro}{crosscolorratio} +% 边框颜色 +% \begin{macrocode} + crosscolorratio .int_set:N = \l_@@_cross_color_ratio_int, + crosscolorratio .initial:n = 20, +% \end{macrocode} +% \end{macro} +% +% \changes{v2.1.1}{2021/10/07}{为格子内部十字和米字线定义hanziboxcrosscolor颜色} +% % \begin{macro}{framecolor} % 边框颜色 % \begin{macrocode} - framecolor .code:n = { \@@_color_select:nn { hanziboxframecolor } {#1} } , + framecolor .code:n = { \tl_set:Nx \l_tmpa_tl { #1 ! \int_use:N \l_@@_cross_color_ratio_int } + \@@_color_select:nn { hanziboxframecolor } {#1} + \@@_color_select:nx{ hanziboxcrosscolor } { \l_tmpa_tl } } , framecolor .initial:n = black , - framecolor* .code:n = { \@@_color_select:nnn { hanziboxframecolor } #1 } , + framecolor* .code:n = { \tl_set:Nx \l_tmpa_tl { #1 ! \int_use:N \l_@@_cross_color_ratio_int } + \@@_color_select:nnn { hanziboxframecolor } #1 + \@@_color_select:nnx { hanziboxcrosscolor } \l_tmpa_tl } , % \end{macrocode} % \end{macro} % @@ -1576,6 +1644,8 @@ Copyright and Licence tranf = \tiny , frametype = none , resize = none , + crosscolorratio = 20, + framecolor = black, } % \end{macrocode} @@ -1856,39 +1926,57 @@ Copyright and Licence % \end{macrocode} % \end{macro} % +% \changes{v2.1.1}{2021/10/02}{修复无汉字手动拼音无法正确处理的问题} +% % \begin{macro}{\@@_null_str_coffin_construct:} % 构造空白汉字(0个汉字)带拼音字符串盒子。 % \begin{macrocode} \cs_new:Npn \@@_null_str_coffin_construct: { - \hcoffin_set:Nn \l_@@_str_box_coffin + \bool_if:NTF \l_@@_autopinyin_bool { - \bool_set_false:N \l_@@_withhanzi_bool - - \hcoffin_set:Nn \l_tmpa_coffin + \hcoffin_set:Nn \l_@@_str_box_coffin { + \bool_set_false:N \l_@@_withhanzi_bool \@@_single_handle:N \c_@@_basechar_tl + \allowbreak } - - \bool_if:NT \l_@@_withpinyin_bool + } + { + \hcoffin_set:Nn \l_@@_str_box_coffin { - \hcoffin_set:Nn \l_@@_pinyin_box_coffin + \bool_if:NTF \l_@@_withpinyin_bool { - \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 + \int_set:Nn \l_tmpa_int {\clist_count:N \l_@@_tone_pinyin_clist} + + \int_step_inline:nn { \l_tmpa_int } + { + \bool_set_false:N \l_@@_withhanzi_bool + + \hcoffin_set:Nn \l_tmpa_coffin + { + \@@_single_handle:N \c_@@_basechar_tl + } + + \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_false:N \l_@@_withhanzi_bool + \@@_single_handle:N \c_@@_basechar_tl + \allowbreak } - \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} diff --git a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty index e86b73715aa..3d9641749d9 100644 --- a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty +++ b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty @@ -27,13 +27,18 @@ %% \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{expl3} -\GetIdInfo$Id: hanzibox.dtx 2.1.0 2021-09-30 08:00:00 +0800 Nan Geng $ +\GetIdInfo$Id: hanzibox.dtx 2.1.1 2021-10-07 08:00:00 +0800 Nan Geng $ {Boxed Chinese characters with Pinyin above and translation below.} \ProvidesExplPackage{\ExplFileName} {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage { xtemplate, l3keys2e, l3draw, xparse } +\cs_if_free:NT \box_ht_plus_dp:N + { + \cs_new_protected:Npn \box_ht_plus_dp:N #1 + { \tex_dimexpr:D \box_ht:N #1 + \box_dp:N #1 \scan_stop: } + } \sys_if_engine_xetex:F { \msg_fatal:nnx { hanzibox } { unsupported-engine } @@ -107,6 +112,7 @@ \tl_new:N \l__hanzibox_pinyin_format_tl \tl_new:N \l__hanzibox_character_format_tl \tl_new:N \l__hanzibox_translation_format_tl +\int_new:N \l__hanzibox_cross_color_ratio_int \int_new:N \l__hanzibox_pinyin_int \int_new:N \l__hanzibox_character_int \int_new:N \l__hanzibox_translation_int @@ -194,14 +200,13 @@ \draw_path_use_clear:n { stroke , fill } } } - \__hanzibox_new_frame_construct:nn { 十 } { \tl_if_empty:NF \l__hanzibox_dash_pattern_tl { \exp_args:No \draw_dash_pattern:nn { \l__hanzibox_dash_pattern_tl } { 0pt } } - \color_stroke:n { hanziboxframecolor!30 } + \color_stroke:n { hanziboxcrosscolor } \draw_path_moveto:n { (#3)/2, #2 } \draw_path_lineto:n { #3/2, #4 } \draw_path_moveto:n { #1, (#4)/2 } @@ -215,7 +220,7 @@ { \exp_args:No \draw_dash_pattern:nn { \l__hanzibox_dash_pattern_tl } { 0pt } } - \color_stroke:n { hanziboxframecolor!30 } + \color_stroke:n { hanziboxcrosscolor } \draw_path_moveto:n { #1, #2 } \draw_path_lineto:n { #3, #4 } \draw_path_moveto:n { #1, #4 } @@ -371,10 +376,12 @@ { \color_set:nn {#1} {#2} } +\cs_generate_variant:Nn \__hanzibox_color_select:nn {nx} \cs_set_nopar:Npn \__hanzibox_color_select:nnn #1#2#3 { \color_set:nnn {#1} {#2} {#3} } +\cs_generate_variant:Nn \__hanzibox_color_select:nnn {nnx} \cs_new:Npn \__hanzibox_debug:n { \bool_if:NTF \l__hanzibox_debug_bool @@ -415,9 +422,15 @@ height .dim_set:N = \l__hanzibox_box_height_dim , linewidth .dim_set:N = \l__hanzibox_linewidth_dim , linewidth .initial:n = 0.4pt , - framecolor .code:n = { \__hanzibox_color_select:nn { hanziboxframecolor } {#1} } , + crosscolorratio .int_set:N = \l__hanzibox_cross_color_ratio_int, + crosscolorratio .initial:n = 20, + framecolor .code:n = { \tl_set:Nx \l_tmpa_tl { #1 ! \int_use:N \l__hanzibox_cross_color_ratio_int } + \__hanzibox_color_select:nn { hanziboxframecolor } {#1} + \__hanzibox_color_select:nx{ hanziboxcrosscolor } { \l_tmpa_tl } } , framecolor .initial:n = black , - framecolor* .code:n = { \__hanzibox_color_select:nnn { hanziboxframecolor } #1 } , + framecolor* .code:n = { \tl_set:Nx \l_tmpa_tl { #1 ! \int_use:N \l__hanzibox_cross_color_ratio_int } + \__hanzibox_color_select:nnn { hanziboxframecolor } #1 + \__hanzibox_color_select:nnx { hanziboxcrosscolor } \l_tmpa_tl } , charcolor .code:n = { \__hanzibox_color_select:nn { hanziboxcharcolor } {#1} } , charcolor .initial:n = black , charcolor* .code:n = { \__hanzibox_color_select:nnn { hanziboxframecolor } {#1} } , @@ -483,6 +496,8 @@ tranf = \tiny , frametype = none , resize = none , + crosscolorratio = 20, + framecolor = black, } \NewDocumentCommand \hanziboxset { m } @@ -724,34 +739,50 @@ } \cs_new:Npn \__hanzibox_null_str_coffin_construct: { - \hcoffin_set:Nn \l__hanzibox_str_box_coffin + \bool_if:NTF \l__hanzibox_autopinyin_bool { - \bool_set_false:N \l__hanzibox_withhanzi_bool - - \hcoffin_set:Nn \l_tmpa_coffin + \hcoffin_set:Nn \l__hanzibox_str_box_coffin { + \bool_set_false:N \l__hanzibox_withhanzi_bool \__hanzibox_single_handle:N \c__hanzibox_basechar_tl + \allowbreak } - - \bool_if:NT \l__hanzibox_withpinyin_bool + } + { + \hcoffin_set:Nn \l__hanzibox_str_box_coffin { - \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin + \bool_if:NTF \l__hanzibox_withpinyin_bool { - \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 + \int_set:Nn \l_tmpa_int {\clist_count:N \l__hanzibox_tone_pinyin_clist} + + \int_step_inline:nn { \l_tmpa_int } + { + \bool_set_false:N \l__hanzibox_withhanzi_bool + + \hcoffin_set:Nn \l_tmpa_coffin + { + \__hanzibox_single_handle:N \c__hanzibox_basechar_tl + } + + \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_false:N \l__hanzibox_withhanzi_bool + \__hanzibox_single_handle:N \c__hanzibox_basechar_tl + \allowbreak } - \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 -- cgit v1.2.3