summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-05-21 23:55:59 +0000
committerKarl Berry <karl@freefriends.org>2012-05-21 23:55:59 +0000
commit902beccca919c220f5d4a9f8edcca098aa7d07fa (patch)
treee3f52a36586bb087abd22f88bc9200bd80c1fb98 /Master/texmf-dist/tex/latex
parent11329d298783368bb1e2bb185886ac21f4f2dcf8 (diff)
new l3 package zhnumber (21may12)
git-svn-id: svn://tug.org/texlive/trunk@26554 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg70
-rw-r--r--Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg70
-rw-r--r--Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty444
3 files changed, 584 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg
new file mode 100644
index 00000000000..ef92991cae4
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg
@@ -0,0 +1,70 @@
+%%
+%% This is file `zhnumber-gbk.cfg',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% zhnumber.dtx (with options: `config-gbk')
+%%
+%% Copyright (C) 2012 by Qing Lee <sobenlee@gmail.com>
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%% The Current Maintainer of this work is Qing Lee.
+%%
+\ExplSyntaxOff
+\ProvidesExplFile {zhnumber-gbk.cfg}
+ {2012/05/21} {1.4}
+ {Chinese numerals with GBK encoding}
+\tl_set:Nn \c_zhnum_minus_tl { \bool_if:NTF \l_zhnum_simp_bool { 负 } { 負 } }
+\tl_set:Nn \c_zhnum_zero_tl { \bool_if:nTF \l_zhnum_null_bool \c_zhnum_null_tl { 零 } }
+\tl_set:Nn \c_zhnum_null_tl { \bool_if:NTF \l_zhnum_normal_bool { 〇 } { 零 } }
+\tl_set:Nn \c_zhnum_one_tl { \bool_if:NTF \l_zhnum_normal_bool { 一 } { 壹 } }
+\tl_set:Nn \c_zhnum_two_tl { \bool_if:NTF \l_zhnum_normal_bool { 二 } { \bool_if:NTF \l_zhnum_simp_bool { 贰 } { 貳 } } }
+\tl_set:Nn \c_zhnum_three_tl { \bool_if:NTF \l_zhnum_normal_bool { 三 } { \bool_if:NTF \l_zhnum_simp_bool { 叁 } { 叄 } } }
+\tl_set:Nn \c_zhnum_four_tl { \bool_if:NTF \l_zhnum_normal_bool { 四 } { 肆 } }
+\tl_set:Nn \c_zhnum_five_tl { \bool_if:NTF \l_zhnum_normal_bool { 五 } { 伍 } }
+\tl_set:Nn \c_zhnum_six_tl { \bool_if:NTF \l_zhnum_normal_bool { 六 } { \bool_if:NTF \l_zhnum_simp_bool { 陆 } { 陸 } } }
+\tl_set:Nn \c_zhnum_seven_tl { \bool_if:NTF \l_zhnum_normal_bool { 七 } { 柒 } }
+\tl_set:Nn \c_zhnum_eight_tl { \bool_if:NTF \l_zhnum_normal_bool { 八 } { 捌 } }
+\tl_set:Nn \c_zhnum_nine_tl { \bool_if:NTF \l_zhnum_normal_bool { 九 } { 玖 } }
+\tl_set:Nn \c_zhnum_ten_tl { \bool_if:NTF \l_zhnum_normal_bool { 十 } { 拾 } }
+\tl_set:Nn \c_zhnum_hundred_tl { \bool_if:NTF \l_zhnum_normal_bool { 百 } { 佰 } }
+\tl_set:Nn \c_zhnum_thousand_tl { \bool_if:NTF \l_zhnum_normal_bool { 千 } { 仟 } }
+\tl_set:Nn \c_zhnum_twenty_tl { 廿 }
+\tl_set:Nn \c_zhnum_thirty_tl { 卅 }
+\tl_set:Nn \c_zhnum_forty_tl { 卌 }
+\tl_set:Nn \c_zhnum_two_hundred_tl { 皕 }
+\tl_set:Nn \c_zhnum_dot_tl { \bool_if:NTF \l_zhnum_simp_bool { 点 } { 點 } }
+\tl_set:Nn \c_zhnum_and_tl { 又 }
+\tl_set:Nn \c_zhnum_over_tl { 分之 }
+\tl_set:Nn \c_zhnum_scale_zero_tl { }
+\tl_set:Nn \c_zhnum_scale_one_tl { \bool_if:NTF \l_zhnum_simp_bool { 万 } { 萬 } }
+\tl_set:Nn \c_zhnum_scale_two_tl { \bool_if:NTF \l_zhnum_simp_bool { 亿 } { 億 } }
+\tl_set:Nn \c_zhnum_scale_three_tl { 兆 }
+\tl_set:Nn \c_zhnum_scale_four_tl { 京 }
+\tl_set:Nn \c_zhnum_scale_five_tl { 垓 }
+\tl_set:Nn \c_zhnum_scale_six_tl { 秭 }
+\tl_set:Nn \c_zhnum_scale_seven_tl { 穰 }
+\tl_set:Nn \c_zhnum_scale_eight_tl { \bool_if:NTF \l_zhnum_simp_bool { 沟 } { 溝 } }
+\tl_set:Nn \c_zhnum_scale_nine_tl { \bool_if:NTF \l_zhnum_simp_bool { 涧 } { 澗 } }
+\tl_set:Nn \c_zhnum_scale_ten_tl { 正 }
+\tl_set:Nn \c_zhnum_scale_eleven_tl { \bool_if:NTF \l_zhnum_simp_bool { 载 } { 載 } }
+\ExplSyntaxOff
+%%
+%% This package consists of the file zhnumber.dtx,
+%% and the derived files zhnumber.pdf,
+%% zhnumber.sty,
+%% zhnumber-utf8.cfg,
+%% zhnumber-gbk.cfg,
+%% zhnumber.ins and
+%% README.txt.
+%%
+%% End of file `zhnumber-gbk.cfg'.
diff --git a/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg
new file mode 100644
index 00000000000..acba3e53cda
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg
@@ -0,0 +1,70 @@
+%%
+%% This is file `zhnumber-utf8.cfg',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% zhnumber.dtx (with options: `config-utf8')
+%%
+%% Copyright (C) 2012 by Qing Lee <sobenlee@gmail.com>
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%% The Current Maintainer of this work is Qing Lee.
+%%
+\ExplSyntaxOff
+\ProvidesExplFile {zhnumber-utf8.cfg}
+ {2012/05/21} {1.4}
+ {Chinese numerals with UTF8 encoding}
+\tl_set:Nn \c_zhnum_minus_tl { \bool_if:NTF \l_zhnum_simp_bool { 璐 } { 璨 } }
+\tl_set:Nn \c_zhnum_zero_tl { \bool_if:nTF \l_zhnum_null_bool \c_zhnum_null_tl { 闆 } }
+\tl_set:Nn \c_zhnum_null_tl { \bool_if:NTF \l_zhnum_normal_bool { 銆 } { 闆 } }
+\tl_set:Nn \c_zhnum_one_tl { \bool_if:NTF \l_zhnum_normal_bool { 涓 } { 澹 } }
+\tl_set:Nn \c_zhnum_two_tl { \bool_if:NTF \l_zhnum_normal_bool { 浜 } { \bool_if:NTF \l_zhnum_simp_bool { 璐 } { 璨 } } }
+\tl_set:Nn \c_zhnum_three_tl { \bool_if:NTF \l_zhnum_normal_bool { 涓 } { \bool_if:NTF \l_zhnum_simp_bool { 鍙 } { 鍙 } } }
+\tl_set:Nn \c_zhnum_four_tl { \bool_if:NTF \l_zhnum_normal_bool { 鍥 } { 鑲 } }
+\tl_set:Nn \c_zhnum_five_tl { \bool_if:NTF \l_zhnum_normal_bool { 浜 } { 浼 } }
+\tl_set:Nn \c_zhnum_six_tl { \bool_if:NTF \l_zhnum_normal_bool { 鍏 } { \bool_if:NTF \l_zhnum_simp_bool { 闄 } { 闄 } } }
+\tl_set:Nn \c_zhnum_seven_tl { \bool_if:NTF \l_zhnum_normal_bool { 涓 } { 鏌 } }
+\tl_set:Nn \c_zhnum_eight_tl { \bool_if:NTF \l_zhnum_normal_bool { 鍏 } { 鎹 } }
+\tl_set:Nn \c_zhnum_nine_tl { \bool_if:NTF \l_zhnum_normal_bool { 涔 } { 鐜 } }
+\tl_set:Nn \c_zhnum_ten_tl { \bool_if:NTF \l_zhnum_normal_bool { 鍗 } { 鎷 } }
+\tl_set:Nn \c_zhnum_hundred_tl { \bool_if:NTF \l_zhnum_normal_bool { 鐧 } { 浣 } }
+\tl_set:Nn \c_zhnum_thousand_tl { \bool_if:NTF \l_zhnum_normal_bool { 鍗 } { 浠 } }
+\tl_set:Nn \c_zhnum_twenty_tl { 寤 }
+\tl_set:Nn \c_zhnum_thirty_tl { 鍗 }
+\tl_set:Nn \c_zhnum_forty_tl { 鍗 }
+\tl_set:Nn \c_zhnum_two_hundred_tl { 鐨 }
+\tl_set:Nn \c_zhnum_dot_tl { \bool_if:NTF \l_zhnum_simp_bool { 鐐 } { 榛 } }
+\tl_set:Nn \c_zhnum_and_tl { 鍙 }
+\tl_set:Nn \c_zhnum_over_tl { 鍒嗕箣 }
+\tl_set:Nn \c_zhnum_scale_zero_tl { }
+\tl_set:Nn \c_zhnum_scale_one_tl { \bool_if:NTF \l_zhnum_simp_bool { 涓 } { 钀 } }
+\tl_set:Nn \c_zhnum_scale_two_tl { \bool_if:NTF \l_zhnum_simp_bool { 浜 } { 鍎 } }
+\tl_set:Nn \c_zhnum_scale_three_tl { 鍏 }
+\tl_set:Nn \c_zhnum_scale_four_tl { 浜 }
+\tl_set:Nn \c_zhnum_scale_five_tl { 鍨 }
+\tl_set:Nn \c_zhnum_scale_six_tl { 绉 }
+\tl_set:Nn \c_zhnum_scale_seven_tl { 绌 }
+\tl_set:Nn \c_zhnum_scale_eight_tl { \bool_if:NTF \l_zhnum_simp_bool { 娌 } { 婧 } }
+\tl_set:Nn \c_zhnum_scale_nine_tl { \bool_if:NTF \l_zhnum_simp_bool { 娑 } { 婢 } }
+\tl_set:Nn \c_zhnum_scale_ten_tl { 姝 }
+\tl_set:Nn \c_zhnum_scale_eleven_tl { \bool_if:NTF \l_zhnum_simp_bool { 杞 } { 杓 } }
+\ExplSyntaxOff
+%%
+%% This package consists of the file zhnumber.dtx,
+%% and the derived files zhnumber.pdf,
+%% zhnumber.sty,
+%% zhnumber-utf8.cfg,
+%% zhnumber-gbk.cfg,
+%% zhnumber.ins and
+%% README.txt.
+%%
+%% End of file `zhnumber-utf8.cfg'.
diff --git a/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty b/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty
new file mode 100644
index 00000000000..387b52eb429
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty
@@ -0,0 +1,444 @@
+%%
+%% This is file `zhnumber.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% zhnumber.dtx (with options: `package')
+%%
+%% Copyright (C) 2012 by Qing Lee <sobenlee@gmail.com>
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%% The Current Maintainer of this work is Qing Lee.
+%%
+\NeedsTeXFormat{LaTeX2e}
+\RequirePackage{expl3}
+\ProvidesExplPackage {zhnumber}
+ {2012/05/21} {1.4}
+ {package for typesetting numbers with Chinese glyphs}
+\msg_new:nnn { zhnumber } { l3-too-old }
+ {
+ Support~package~'expl3'~too~old. \\\\
+ Please~update~an~up~to~date~version~of~the~bundles\\\\
+ 'l3kernel'~and~'l3packages'\\\\
+ using~your~TeX~package~manager~or~from~CTAN.
+ }
+\@ifpackagelater { expl3 } { 2012/02/19 } { }
+ { \msg_error:nn { zhnumber } { l3-too-old } }
+\RequirePackage{xparse}
+\RequirePackage{l3keys2e}
+\DeclareExpandableDocumentCommand \zhnumber { o m }
+ { \zhnum_number_aux:nNn {#1} \zhnum_number:n {#2} }
+\cs_new_nopar:Nn \zhnum_number:n { \zhnum_number:w #1 . \q_nil . \q_stop }
+\cs_new_nopar:Nn \zhnum_number_aux:nNn
+ {
+ \IfNoValueTF {#1} { #2 {#3} }
+ { \group_begin: \zhnumsetup {#1} #2 {#3} \group_end: }
+ }
+\cs_new_nopar:Npn \zhnum_number:w #1.#2.#3 \q_stop
+ {
+ \quark_if_nil:nTF {#2}
+ { \zhnum_integer_or_fraction:w #1 / \q_nil / \q_stop }
+ { \zhnum_decimal:nn {#1} {#2} }
+ }
+\cs_new_nopar:Npn \zhnum_integer_or_fraction:w #1/#2/#3 \q_stop
+ {
+ \quark_if_nil:nTF {#2}
+ { \zhnum_integer:f {#1} }
+ { \zhnum_fraction:w #2 \q_mark #1 ; \q_nil ; \q_stop }
+ }
+\cs_new_nopar:Npn \zhnum_fraction:w #1 \q_mark #2;#3;#4 \q_stop
+ {
+ \quark_if_nil:nTF {#3}
+ {
+ \zhnum_blank_to_zero:f {#1} \c_zhnum_over_tl
+ \zhnum_blank_to_zero:f {#2}
+ }
+ {
+ \tl_if_blank:fF {#2} { \zhnumber {#2} \c_zhnum_and_tl }
+ \zhnum_blank_to_zero:f {#1} \c_zhnum_over_tl
+ \zhnum_blank_to_zero:f {#3}
+ }
+ }
+\cs_generate_variant:Nn \tl_if_blank:nF { f }
+\cs_new_nopar:Nn \zhnum_decimal:nn
+ {
+ \zhnum_blank_to_zero:f {#1} \c_zhnum_dot_tl
+ \tl_if_blank:fTF {#2} { \zhnum_digit_map:n \c_zero } { \zhdigits * {#2} }
+ }
+\cs_generate_variant:Nn \tl_if_blank:nTF { f }
+\cs_new_nopar:Nn \zhnum_blank_to_zero:n
+ { \tl_if_blank:nTF {#1} { \zhnum_digit_map:n \c_zero } { \zhnumber {#1} } }
+\cs_generate_variant:Nn \zhnum_blank_to_zero:n { f }
+\DeclareExpandableDocumentCommand \zhnum { o m }
+ { \zhnum_number_aux:nNn {#1} \zhnum_counter:n {#2} }
+\cs_new_nopar:Nn \zhnum_counter:n
+ {
+ \exp_args:Nc \token_if_int_register:NTF { c@#1 }
+ { \zhnum_integer:v { c@#1 } }
+ { \@nocounterr {#1} }
+ }
+\cs_new_nopar:Nn \zhnum_integer:n
+ { \zhnum_integer_aux:f { \zhnum_erase_separator:n {#1} } }
+\cs_new_nopar:Nn \zhnum_integer_aux:n
+ {
+ \int_compare:nNnT { \int_get_sign:n {#1} \c_one } < \c_zero
+ { \zhnum_digit_map:n \c_minus_one }
+ \zhnum_parse_number:f { \zhnum_trim_zeros:f { \int_get_digits:n {#1} } }
+ }
+\cs_generate_variant:Nn \zhnum_integer:n { f , v }
+\cs_generate_variant:Nn \zhnum_integer_aux:n { f }
+\cs_new_nopar:Nn \zhnum_erase_separator:n
+ { \cs_to_str:c { \tl_map_function:nN {#1} \zhnum_erase_separator_aux:N } }
+\cs_new_nopar:Nn \zhnum_erase_separator_aux:N
+ { \str_if_eq:xxF {#1} \c_zhnum_separator_tl {#1} }
+\cs_new_nopar:Nn \zhnum_trim_zeros:n
+ {
+ \tl_if_empty:nTF {#1} \c_zero
+ {
+ \int_compare:nNnTF { \tl_head:n {#1} } = \c_zero
+ { \zhnum_trim_zeros:o { \use_none:n #1 } } {#1}
+ }
+ }
+\cs_generate_variant:Nn \zhnum_trim_zeros:n { f , o }
+\cs_generate_variant:Nn \cs_to_str:N { c }
+\cs_new_nopar:Nn \zhnum_parse_number:n
+ { \zhnum_parse_number:nf {#1} { \tl_length:n {#1} } }
+\cs_new_nopar:Nn \zhnum_parse_number:nn
+ {
+ \int_compare:nNnTF {#2} < \c_five
+ {
+ \int_compare:nNnTF {#1} = \c_zero
+ { \zhnum_digit_map:n \c_zero }
+ { \zhnum_process_number:NNn \c_true_bool \c_true_bool {#1} }
+ }
+ {
+ \int_compare:nNnTF { \int_mod:nn {#2} \c_four } = \c_zero
+ {
+ \zhnum_split_number:nNNnfn {#1} \c_true_bool \c_true_bool { \c_zero }
+ { \int_div_truncate:nn { #2 - \c_one } \c_four }
+ { \c_zero }
+ }
+ {
+ \zhnum_parse_number:nnf {#1} {#2}
+ {
+ \use:c
+ {
+ zhnum_use_
+ \int_to_roman:n { \int_mod:nn {#2} \c_four }
+ _delimit_by_q_stop:w
+ }
+ #1 \q_stop
+ }
+ }
+ }
+ }
+\cs_new_nopar:Nn \zhnum_parse_number:nnn
+ {
+ \zhnum_process_number:NNn \c_true_bool \c_true_bool {#3}
+ \zhnum_scale_map:n { \int_div_truncate:nn { #2 - \c_one } \c_four }
+ \int_compare:nNnTF { \int_mod:nn {#3} \c_ten } = \c_zero
+ { \zhnum_split_number:nNNffn {#1} \c_false_bool \c_true_bool }
+ { \zhnum_split_number:nNNffn {#1} \c_true_bool \c_false_bool }
+ { \int_mod:nn {#2} \c_four }
+ { \int_eval:n { \int_div_truncate:nn { #2 - \c_one } \c_four - \c_one } }
+ { \c_zero }
+ }
+\cs_generate_variant:Nn \zhnum_parse_number:n { f }
+\cs_generate_variant:Nn \zhnum_parse_number:nn { nf }
+\cs_generate_variant:Nn \zhnum_parse_number:nnn { nnf }
+\cs_new_nopar:Npn \zhnum_use_i_delimit_by_q_stop:w #1#2 \q_stop {#1}
+\cs_new_nopar:Npn \zhnum_use_ii_delimit_by_q_stop:w #1#2#3 \q_stop {#1#2}
+\cs_new_nopar:Npn \zhnum_use_iii_delimit_by_q_stop:w #1#2#3#4 \q_stop {#1#2#3}
+\cs_new_nopar:Nn \zhnum_split_number:nNNnnn
+ {
+ \exp_args:Nf \zhnum_split_number_aux:nnnnnnn
+ { \zhnum_number_item:nn {#1} { \c_one + #4 + #6 * \c_four } }
+ {#1} {#2} {#3} {#4} {#5} {#6}
+ }
+\cs_new_nopar:Nn \zhnum_split_number_aux:nnnnnnn
+ {
+ \int_compare:nNnTF {#1} = \c_zero { \use_i_ii:nnn }
+ {
+ \bool_if:NF #3 { \zhnum_digit_map:n \c_zero }
+ \zhnum_process_number:NNn {#3} {#4} {#1}
+ \zhnum_scale_map:n { #6 - #7 }
+ \int_compare:nNnTF { \int_mod:nn {#1} \c_ten } = \c_zero
+ { \use_i_ii:nnn } { \zhnum_use_i_iii:nnn }
+ }
+ { \int_compare:nNnF { #6 - #7 } = \c_zero }
+ { {
+ \zhnum_split_number:nNNnnf
+ {#2} \c_false_bool \c_true_bool {#5} {#6} { \int_eval:n { #7 + \c_one } }
+ } }
+ { {
+ \zhnum_split_number:nNNnnf
+ {#2} \c_true_bool \c_false_bool {#5} {#6} { \int_eval:n { #7 + \c_one } }
+ } }
+ }
+\cs_new_nopar:Nn \zhnum_use_i_iii:nnn {#1#3}
+\cs_generate_variant:Nn \zhnum_split_number:nNNnnn { nNNnf , nNNff , nNNnnf }
+\cs_new_nopar:Nn \zhnum_number_item:nn
+ {
+ \zhnum_number_item_aux:nN {#2} #1
+ \q_recursion_tail
+ \prg_break_point:n { }
+ }
+\cs_new_nopar:Nn \zhnum_number_item_aux:nN
+ {
+ \quark_if_recursion_tail_break:n {#2}
+ \int_compare:nNnTF {#1} = \c_one
+ { \zhnum_recursion_break:NNNNw #2 }
+ { \zhnum_number_item_aux:fN { \int_eval:n { #1 - \c_one } } }
+ }
+\cs_generate_variant:Nn \zhnum_number_item_aux:nN { f }
+\cs_new_nopar:Npn \zhnum_recursion_break:NNNNw #1#2#3#4#5 \prg_break_point:n #6 {#1#2#3#4}
+\cs_new_nopar:Nn \zhnum_process_number:NNn
+ {
+ \zhnum_process_number:ffffNN
+ { \int_mod:nn {#3} \c_ten }
+ { \int_mod:nn { \int_div_truncate:nn {#3} \c_ten } \c_ten }
+ { \int_mod:nn { \int_div_truncate:nn {#3} \c_one_hundred } \c_ten }
+ { \int_div_truncate:nn {#3} \c_one_thousand }
+ {#1} {#2}
+ }
+\cs_new_nopar:Nn \zhnum_process_number:NNNNNN
+ {
+ \int_compare:nNnTF {#4} = \c_zero
+ { \bool_if:NF #6 { \zhnum_digit_map:n \c_zero } }
+ { \zhnum_digit_map:n {#4} \zhnum_digit_map:n \c_one_thousand }
+ \int_compare:nNnTF {#3} = \c_zero
+ { \int_compare:nNnT { #4 * (#2#1) } > \c_zero { \zhnum_digit_map:n \c_zero } }
+ {
+ \bool_if:nTF
+ { \l_zhnum_ancient_bool && \int_compare_p:nNn {#3} = \c_two }
+ { \zhnum_digit_map:n { #3 * \c_one_hundred } }
+ { \zhnum_digit_map:n {#3} \zhnum_digit_map:n \c_one_hundred }
+ }
+ \int_compare:nNnTF {#2} = \c_zero
+ { \int_compare:nNnT { #3 * #1 } > \c_zero { \zhnum_digit_map:n \c_zero } }
+ {
+ \bool_if:nF
+ {
+ \int_compare_p:nNn {#2} = \c_one &&
+ \int_compare_p:nNn {#4#3} = \c_zero && #6 && #5
+ }
+ {
+ \bool_if:nTF
+ {
+ \l_zhnum_ancient_bool &&
+ ( \int_compare_p:nNn {#2} = \c_two ||
+ \int_compare_p:nNn {#2} = \c_three ||
+ \int_compare_p:nNn {#2} = \c_four )
+ }
+ {
+ \zhnum_digit_map:n { #2 * \c_ten }
+ \use_none:nn
+ }
+ { \zhnum_digit_map:n {#2} }
+ }
+ \zhnum_digit_map:n \c_ten
+ }
+ \int_compare:nNnF {#1} = \c_zero { \zhnum_digit_map:n {#1} }
+ }
+\cs_generate_variant:Nn \zhnum_process_number:NNn { NNf }
+\cs_generate_variant:Nn \zhnum_process_number:NNNNNN { ffff }
+\DeclareExpandableDocumentCommand \zhdigits { s o m }
+ {
+ \IfBooleanTF {#1}
+ { \zhnum_digits_aux:nnN {#2} {#3} \zhnum_digits_zero_aux:N }
+ { \zhnum_digits_aux:nnN {#2} {#3} \zhnum_digits_null_aux:N }
+ }
+\cs_new_nopar:Nn \zhnum_digits_aux:nnN
+ {
+ \IfNoValueTF {#1} { \tl_map_function:fN {#2} #3 }
+ { \group_begin: \zhnumsetup {#1} \tl_map_function:fN {#2} #3 \group_end: }
+ }
+\cs_generate_variant:Nn \tl_map_function:nN { f }
+\cs_new_nopar:Nn \zhnum_digits_null_aux:N { \zhnum_digits_aux:nn \c_zhnum_null_int {#1} }
+\cs_new_nopar:Nn \zhnum_digits_zero_aux:N { \zhnum_digits_aux:nn \c_zero {#1} }
+\cs_new_nopar:Nn \zhnum_digits_aux:nn
+ {
+ \str_if_eq:xxF {#2} \c_zhnum_separator_tl
+ {
+ \str_if_eq:xxTF {#2} . \c_zhnum_dot_tl
+ {
+ \zhnum_digit_map:n
+ {
+ \str_if_eq:xxTF {#2} - \c_minus_one
+ {
+ \bool_if:nTF
+ {
+ \int_compare_p:nNn {#2} = \c_zero &&
+ \int_compare_p:nNn {#1} = \c_zhnum_null_int
+ }
+ { \c_zhnum_null_int } {#2}
+ }
+ }
+ }
+ }
+ }
+\int_const:Nn \c_zhnum_null_int { -10 }
+\cs_new_nopar:Nn \zhnum_digit_map:n
+ {
+ \prg_case_int:nnn {#1}
+ {
+ { \c_minus_one } { \c_zhnum_minus_tl }
+ { \c_zero } { \c_zhnum_zero_tl }
+ { \c_one } { \c_zhnum_one_tl }
+ { \c_two } { \c_zhnum_two_tl }
+ { \c_three } { \c_zhnum_three_tl }
+ { \c_four } { \c_zhnum_four_tl }
+ { \c_five } { \c_zhnum_five_tl }
+ { \c_six } { \c_zhnum_six_tl }
+ { \c_seven } { \c_zhnum_seven_tl }
+ { \c_eight } { \c_zhnum_eight_tl }
+ { \c_nine } { \c_zhnum_nine_tl }
+ { \c_ten } { \c_zhnum_ten_tl }
+ { \c_one_hundred } { \c_zhnum_hundred_tl }
+ { \c_one_thousand } { \c_zhnum_thousand_tl }
+ { \c_zhnum_null_int } { \c_zhnum_null_tl }
+ { 20 } { \c_zhnum_twenty_tl }
+ { 30 } { \c_zhnum_thirty_tl }
+ { 40 } { \c_zhnum_forty_tl }
+ { 200 } { \c_zhnum_two_hundred_tl }
+ }
+ { \prg_do_nothing: }
+ }
+\cs_new_nopar:Nn \zhnum_scale_map:n
+ {
+ \prg_case_int:nnn {#1}
+ {
+ { \c_zero } { \c_zhnum_scale_zero_tl }
+ { \c_one } { \c_zhnum_scale_one_tl }
+ { \c_two } { \c_zhnum_scale_two_tl }
+ { \c_three } { \c_zhnum_scale_three_tl }
+ { \c_four } { \c_zhnum_scale_four_tl }
+ { \c_five } { \c_zhnum_scale_five_tl }
+ { \c_six } { \c_zhnum_scale_six_tl }
+ { \c_seven } { \c_zhnum_scale_seven_tl }
+ { \c_eight } { \c_zhnum_scale_eight_tl }
+ { \c_nine } { \c_zhnum_scale_nine_tl }
+ { \c_ten } { \c_zhnum_scale_ten_tl }
+ { \c_eleven } { \c_zhnum_scale_eleven_tl }
+ }
+ { \zhnum_scale_map_hook:n {#1} }
+ }
+\cs_new_nopar:Nn \zhnum_scale_map_hook:n
+ { \zhnum_scale_map:n { \int_mod:nn {#1} \c_eleven } }
+
+\keys_define:nn { zhnum / options }
+ {
+ - .tl_set:N = \c_zhnum_minus_tl ,
+ -0 .tl_set:N = \c_zhnum_null_tl ,
+ 0 .tl_set:N = \c_zhnum_zero_tl ,
+ 1 .tl_set:N = \c_zhnum_one_tl ,
+ 2 .tl_set:N = \c_zhnum_two_tl ,
+ 3 .tl_set:N = \c_zhnum_three_tl ,
+ 4 .tl_set:N = \c_zhnum_four_tl ,
+ 5 .tl_set:N = \c_zhnum_five_tl ,
+ 6 .tl_set:N = \c_zhnum_six_tl ,
+ 7 .tl_set:N = \c_zhnum_seven_tl ,
+ 8 .tl_set:N = \c_zhnum_eight_tl ,
+ 9 .tl_set:N = \c_zhnum_nine_tl ,
+ 10 .tl_set:N = \c_zhnum_ten_tl ,
+ 20 .tl_set:N = \c_zhnum_twenty_tl ,
+ 30 .tl_set:N = \c_zhnum_thirty_tl ,
+ 40 .tl_set:N = \c_zhnum_forty_tl ,
+ 200 .tl_set:N = \c_zhnum_two_hundred_tl ,
+ E2 .tl_set:N = \c_zhnum_hundred_tl ,
+ E3 .tl_set:N = \c_zhnum_thousand_tl ,
+ E4 .tl_set:N = \c_zhnum_scale_one_tl ,
+ E8 .tl_set:N = \c_zhnum_scale_two_tl ,
+ E12 .tl_set:N = \c_zhnum_scale_three_tl ,
+ E16 .tl_set:N = \c_zhnum_scale_four_tl ,
+ E20 .tl_set:N = \c_zhnum_scale_five_tl ,
+ E24 .tl_set:N = \c_zhnum_scale_six_tl ,
+ E28 .tl_set:N = \c_zhnum_scale_seven_tl ,
+ E32 .tl_set:N = \c_zhnum_scale_eight_tl ,
+ E36 .tl_set:N = \c_zhnum_scale_nine_tl ,
+ E40 .tl_set:N = \c_zhnum_scale_ten_tl ,
+ E44 .tl_set:N = \c_zhnum_scale_eleven_tl ,
+ }
+\cs_new:Nn \zhnum_load_cfg:
+ {
+ \cs_if_exist:NT \CJK@makeActive
+ {
+ \int_compare:nNnTF { \char_value_catcode:n {"080} } = \active
+ { \bool_set_false:N \l_zhnum_set_CJK_active_bool }
+ { \bool_set_true:N \l_zhnum_set_CJK_active_bool \CJK@makeActive }
+ }
+ \file_input:n { zhnumber - \bool_if:NTF \g_zhnum_gbk_bool { gbk } { utf8 } .cfg }
+ \bool_if:nT { \cs_if_exist_p:N \CJK@makeInactive && \l_zhnum_set_CJK_active_bool }
+ { \CJK@makeInactive }
+ }
+\keys_define:nn { zhnum / options }
+ {
+ encoding .choice: ,
+ encoding / UTF8 .code:n = { \bool_gset_false:N \g_zhnum_gbk_bool \zhnum_load_cfg: } ,
+ encoding / GBK .code:n = { \bool_gset_true:N \g_zhnum_gbk_bool \zhnum_load_cfg: } ,
+ encoding .default:n = { GBK } ,
+ style .multichoice: ,
+ style / Normal .code:n =
+ {
+ \bool_set_false:N \l_zhnum_ancient_bool
+ \bool_set_true:N \l_zhnum_normal_bool
+ } ,
+ style / Financial .code:n =
+ {
+ \bool_set_false:N \l_zhnum_ancient_bool
+ \bool_set_false:N \l_zhnum_normal_bool
+ } ,
+ style / Ancient .code:n =
+ {
+ \bool_set_true:N \l_zhnum_ancient_bool
+ \bool_set_true:N \l_zhnum_normal_bool
+ } ,
+ style / Simplified .code:n = { \bool_set_true:N \l_zhnum_simp_bool } ,
+ style / Traditional .code:n = { \bool_set_false:N \l_zhnum_simp_bool } ,
+ style .default:n = { Normal , Simplified } ,
+ null .bool_set:N = \l_zhnum_null_bool ,
+ reset .code:n = \zhnum_load_cfg: ,
+ dot .tl_set:N = \c_zhnum_dot_tl ,
+ and .tl_set:N = \c_zhnum_and_tl ,
+ parts .tl_set:N = \c_zhnum_over_tl ,
+ separator .tl_set:N = \c_zhnum_separator_tl ,
+ }
+\NewDocumentCommand \zhnumsetup { m }
+ {
+ \keys_set:nn { zhnum / options } {#1}
+ \tex_ignorespaces:D
+ }
+\keys_set:nn { zhnum / options } { style , null = false , separator = {,} }
+\ProcessKeysOptions { zhnum / options }
+\ExplSyntaxOn
+\bool_if_exist:NF \g_zhnum_gbk_bool
+ {
+ \exp_args:Nnx \keys_set:nn { zhnum / options }
+ {
+ encoding =
+ {
+ \bool_if:nTF { \xetex_if_engine_p: || \luatex_if_engine_p: }
+ { UTF8 } { GBK }
+ }
+ }
+ }
+\ExplSyntaxOff
+%%
+%% This package consists of the file zhnumber.dtx,
+%% and the derived files zhnumber.pdf,
+%% zhnumber.sty,
+%% zhnumber-utf8.cfg,
+%% zhnumber-gbk.cfg,
+%% zhnumber.ins and
+%% README.txt.
+%%
+%% End of file `zhnumber.sty'.