diff options
author | Karl Berry <karl@freefriends.org> | 2015-06-19 22:32:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-06-19 22:32:13 +0000 |
commit | 28cb2b214ad9bcb5ac65fdf512b438f388a68b1e (patch) | |
tree | 227bd9a8b0f9f68f9ecfd2ccb5806418e8f71a40 /Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx | |
parent | 4c01004cc15017d68eb0b9697c07010ea62ea23f (diff) |
zhnumber (19jun15)
git-svn-id: svn://tug.org/texlive/trunk@37614 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx | 428 |
1 files changed, 363 insertions, 65 deletions
diff --git a/Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx b/Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx index 303221c5477..218c0fee1e7 100644 --- a/Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx +++ b/Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx @@ -57,16 +57,15 @@ Email: sobenlee@gmail.com If you are interested in the process of development you may observe - http://code.google.com/p/ctex-kit/ + https://github.com/CTeX-org/ctex-kit Installation ------------ The package is supplied in dtx format and as a pre-extracted zip file, zhnumber.tds.zip. The later is most convenient for most users: simply unzip this in your local texmf directory and run texhash to update the -database of file locations. If you want to unpack the dtx yourself, please -ensure that the "iconv" program is installed and working properly, then -running "xetex -shell-escape zhnumber.dtx" will extract the package whereas +database of file locations. If you want to unpack the dtx yourself, +running "xetex zhnumber.dtx" will extract the package whereas "xelatex zhnumber.dtx" will typeset the documentation. The package requires LaTeX3 support as provided in the l3kernel and l3packages @@ -80,20 +79,58 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). %<*internal> \fi \begingroup - \edef\tempa{\fmtname} - \edef\tempb{plain} -\expandafter\endgroup -\ifx\tempa\tempb + \def\temp{LaTeX2e} +\expandafter\endgroup\ifx\temp\fmtname\else \csname fi\endcsname %</internal> %<*install> +\newread\inputcheck +\openin\inputcheck=zhnumber.ver +\ifeof\inputcheck + \def\zhnumberPutVersion{\string\GetIdInfo$Id$} +\else + \input zhnumber.ver +\fi +\closein\inputcheck + \input l3docstrip.tex + +\def\checkOption<#1{% + \ifcase + \ifx*#10\else \ifx/#11\else + \ifx+#12\else \ifx-#13\else + \ifx<#14\else \ifx @#15\else + \ifx.#16\else + 7\fi\fi\fi\fi\fi\fi\fi\relax + \expandafter\starOption\or + \expandafter\slashOption\or + \expandafter\plusOption\or + \expandafter\minusOption\or + \expandafter\verbOption\or + \expandafter\moduleOption\or + \expandafter\expOption\or + \expandafter\doOption\fi + #1% +} +\def\expOption .#1>#2\endLine{% + \maybeMsg{<.#1 . >}% + \Evaluate{#1}% + \begingroup + \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\ =10 + \xdef\expandedLineStuff{\scantokens{#2\noexpand}}% + \endgroup + \def\do##1##2##3{% + \if1\Expr{##2}\StreamPut##1{\expandedLineStuff}\fi + }% + \activefiles +} + \keepsilent \askforoverwritefalse \preamble - Copyright (C) 2012, 2014 by Qing Lee <sobenlee@gmail.com> + Copyright (C) 2012, 2014, 2015 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 @@ -119,13 +156,6 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). README. \endpostamble -\ifnum\shellescape=1 \else - \errmessage{ - Shell escape is disabled. Please use ^^J^^J - xetex -shell-escape \jobname.ins(dtx)^^J} - \expandafter\endbatchfile -\fi - \generate { \usedir{source/latex/zhnumber} @@ -141,11 +171,6 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). \file{README.txt} {\from{\jobname.dtx}{readme}} } -\immediate\write18{iconv -f utf-8 -t big-5 zhnumber-big5.cfg > zhnumber-big5.temp} -\immediate\write18{iconv -f utf-8 -t gbk zhnumber-gbk.cfg > zhnumber-gbk.temp} -\immediate\write18{mv -f zhnumber-big5.temp zhnumber-big5.cfg} -\immediate\write18{mv -f zhnumber-gbk.temp zhnumber-gbk.cfg} - \endbatchfile %</install> %<*internal> @@ -157,8 +182,11 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} %</!config> -\GetIdInfo$Id: zhnumber.dtx 718 2014-09-13 09:13:29Z sobenlee $ +%<.!driver>\zhnumberPutVersion %<*driver> +\InputIfFileExists{zhnumber.ver}{}{ + \def\zhnumberGetVersionInfo{\GetIdInfo$Id$}} +\zhnumberGetVersionInfo {zhnumber source file} \ProvidesExplFile{\ExplFileName.\ExplFileExtension} %</driver> @@ -172,7 +200,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). %<config&utf8> {\ExplFileName-utf8.cfg} %<config&big5> {\ExplFileName-big5.cfg} %<config&gbk> {\ExplFileName-gbk.cfg} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} %</driver|package|config> %<*driver> \ExplSyntaxOff @@ -200,7 +228,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). \setCJKmonofont{Adobe Kaiti Std} \xeCJKsetup{PunctStyle=kaiming} \def\ctexkitrev#1{% - \href{http://code.google.com/p/ctex-kit/source/detail?r=#1}{\texttt{ctex-kit} rev#1}} + \href{https://github.com/CTeX-org/ctex-kit/commit/#1}{\texttt{ctex-kit} rev. #1}} \makeatletter \def\LaTeX{\hologo{LaTeX}} \def\upTeX{up\!\hologo{TeX}} @@ -208,12 +236,12 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). \def\pdfLaTeX{\hologo{pdfLaTeX}} \def\LuaLaTeX{\hologo{LuaLaTeX}} \def\XeLaTeX{\hologo{XeLaTeX}} -\def\TF{true\orvar{}false} -\def\TTF{\defaultvar{true}\orvar false} -\def\TFF{true\orvar\defaultvar{false}} -\def\orvar{\textup{\textbar}} -\def\defaultvar{\textbf} -\def\argbrace#1{\{#1\}} +\def\TF{true\orbar false} +\def\TTF{\defaultval{true}\orbar false} +\def\TFF{true\orbar\defaultval{false}} +\def\defaultval#1{\textbf{\textup{#1}}} +\def\defaultvalaux#1){\defaultval{#1}} +\def\orbar{\textup{\textbar}} \preto\MacroFont{\linespread{1}} \appto\MacroFont{\hyphenchar\font\m@ne} \preto\AltMacroFont{\linespread{1}} @@ -241,8 +269,32 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). hdclindex{\the\c@HD@hypercount}{#5} } } +\DeclareDocumentCommand \cs { O{} m } + { \__codedoc_cmd_aux:no {#1} { \c__codedoc_backslash_tl #2 } } +\DeclareDocumentCommand \tn { O{} m } + { + \__codedoc_cmd_aux:no + { index = TeX , replace = false , #1 } + { \c__codedoc_backslash_tl #2 } + } +\DeclareDocumentCommand \meta { +m } + { \__codedoc_meta_aux:n {#1} } +\DeclareExpandableDocumentCommand \bookmarkcstn { O{} m } + { \tl_to_str:n {#2} } +\cs_new:Npn \bookmarkmeta #1 { < \tl_to_str:n {#1} > } +\cs_generate_variant:Nn \__codedoc_cmd_aux:nn { no } +\AtBeginEnvironment { syntax } + { + \char_set_active_eq:NN \| \orbar + \char_set_active_eq:NN \( \defaultvalaux + } \ExplSyntaxOff \makeatother +\pdfstringdefDisableCommands{% + \let\cs\bookmarkcstn + \let\tn\bookmarkcstn + \let\meta\bookmarkmeta + \let\path\detokenize} \def\indexname{代码索引} \IndexPrologue{% \section*{\indexname} @@ -257,7 +309,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). %</driver> % \fi % -% \CheckSum{1055} +% \CheckSum{1194} % \GetFileInfo{\jobname.sty} % % \title{\bfseries\pkg{zhnumber} 宏包} @@ -279,7 +331,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % % \begin{function}[updated=2014-09-09]{encoding} % \begin{syntax} -% encoding = \meta{GBK\orvar{}Big5\orvar{}UTF8} +% encoding = <GBK|Big5|UTF8> % \end{syntax} % 用于指定编码的宏包选项,可以在调用宏包的时候设定,也可以用 \tn{zhnumsetup} % 在导言区内设定。对于 \upLaTeX、\XeLaTeX{} 和 \LuaLaTeX,不用指定编码,宏包将 @@ -375,9 +427,53 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % \end{SideBySideExample} % \end{function} % +% \begin{function}[rEXP, added=2015-05-20]{\zhtiangan} +% \begin{syntax} +% \tn{zhtiangan} \Arg{number} +% \end{syntax} +% 输出对应的天干计数。\meta{number} 的正常范围是 1--10,超出范围的数字将输出空值。例如 +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.4\linewidth,gobble=5] +% \zhtiangan{1} \zhtiangan{2} \zhtiangan{3} +% \zhtiangan{4} \zhtiangan{5} \zhtiangan{10} +% \end{SideBySideExample} +% \end{function} +% +% \begin{function}[rEXP, added=2015-05-20]{\zhdizhi} +% \begin{syntax} +% \tn{zhdizhi} \Arg{number} +% \end{syntax} +% 输出对应的地支计数。\meta{number} 的正常范围是 1--12,超出范围的数字将输出空值。例如 +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.4\linewidth,gobble=5] +% \zhdizhi{1} \zhdizhi{2} \zhdizhi{3} +% \zhdizhi{4} \zhdizhi{5} \zhdizhi{12} +% \end{SideBySideExample} +% \end{function} +% +% \begin{function}[rEXP, added=2015-05-20]{\zhganzhi} +% \begin{syntax} +% \tn{zhganzhi} \Arg{number} +% \end{syntax} +% 输出对应的干支计数。\meta{number} 的正常范围是 1--60,超出范围的数字将输出空值。例如 +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.4\linewidth,gobble=5] +% \zhganzhi{1} \zhganzhi{2} \zhganzhi{3} \\ +% \zhganzhi{4} \zhganzhi{5} \zhganzhi{60} +% \end{SideBySideExample} +% \end{function} +% +% \begin{function}[rEXP, added=2015-05-20]{\zhganzhinian} +% \begin{syntax} +% \tn{zhganzhinian} \Arg{year} +% \end{syntax} +% 输出公元纪年 \meta{year} 对应的干支纪年。公元前的年份用负数表示。例如 +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.4\linewidth,gobble=5] +% \zhganzhinian{1898} \zhganzhinian{-246} \\ +% \zhganzhinian{-2697} \zhganzhinian{\year} +% \end{SideBySideExample} +% \end{function} +% % \begin{function}[added=2012-05-25]{\zhnumExtendScaleMap} % \begin{syntax} -% \tn{zhnumExtendScaleMap} \oarg{character} \argbrace{\meta{character_1}, \meta{character_2}, ..., \meta{character_n}} +% \tn{zhnumExtendScaleMap} \oarg{character} \{<character_1>, <character_2>, ..., <character_n>\} % \end{syntax} % 缺省状态下 \tn{zhnumber} 能正确中文格式化的最大整数是 $10^{48}-1$,\tn{zhdigits} 不受 % 这个大小的限制。可以通过 \tn{zhnumExtendScaleMap} 来扩展 \tn{zhnumber}。 @@ -387,17 +483,18 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % % \begin{function}{\zhnumsetup} % \begin{syntax} -% \tn{zhnumsetup} \argbrace{\meta{key_1}=\meta{val_1}, \meta{key_2}=\meta{val_2}, ...} +% \tn{zhnumsetup} \{<key_1>=<val_1>, <key_2>=<val_2>, ...\} % \end{syntax} % 用于在导言区或文档中,设置中文数字的输出格式。目前可以设置的 \meta{key} 如下介绍。 +% 以\textbf{粗体}表示选项的默认值。 % \end{function} % % \begin{function}[added=2012-05-25]{time} % \begin{syntax} -% time = \argbrace{\meta{Arabic}\orvar\meta{Chinese}} +% time = <(Arabic)|Chinese> % \end{syntax} % 设置日期和时间的数字格式,\meta{Arabic} 为阿拉伯数字,而 \meta{Chinese} 为中文数字。 -% 默认使用阿拉伯数字。例如 +% 例如 % \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.6\linewidth,gobble=5] % \zhnumsetup{time=Chinese} % \zhtoday\zhcurrtime @@ -406,11 +503,12 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % % \begin{function}[updated=2012-05-25]{style} % \begin{syntax} -% style = \argbrace{\meta{Simplified}\orvar\meta{Traditional}\orvar\meta{Normal}\orvar\meta{Financial}\orvar\meta{Ancient}} +% style = <(Simplified)|Traditional|(Normal)|Financial|Ancient> % \end{syntax} % 意义分别为 % -% \begin{description}[font=\mdseries\ttfamily,align=right,labelsep=1em,labelindent=-1em,leftmargin=*] +% \begin{description}[font=\mdseries\ttfamily\small,align=right,leftmargin=*, +% labelsep=\marginparsep,labelindent=-\marginparsep] % \item[Simplified] 以简体中文输出数字(对 |Big5| 编码无效); % \item[Traditional] 以繁体中文输出数字(对 |Big5| 编码无效); % \item[Normal] 以小写形式输出中文数字; @@ -429,23 +527,46 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % % \begin{function}{null} % \begin{syntax} -% null = \meta{\TFF} +% null = <\TFF> % \end{syntax} % 缺省状态下,除了 \tn{zhdigits} 外,其它的格式转换命令,将 0 映射成零,如果需要将 0 映射 -% 成〇,可以使用这个选项。\strut +% 成〇,可以使用这个选项。 % \end{function} % +% \begin{function}[added=2015-05-20]{ganzhi-cyclic} +% \begin{syntax} +% ganzhi-cyclic = <\TFF> +% \end{syntax} +% 天干、地支和干支的数字都有一定范围。若参数大于这个范围,\tn{tiangan} 等将输出空值。 +% 可以将本选项设置为 |true|,对超出范围的数字取相应的模。 +% 请注意,数字 |0| 的结果总是为空值。例如 +% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.3\linewidth,gobble=5] +% \zhnumsetup{ganzhi-cyclic} +% \zhtiangan{11} \zhtiangan{12} \zhtiangan{209} +% \zhtiangan{-1} \zhtiangan{-2} \zhtiangan{-683} \\ +% \zhdizhi{13} \zhdizhi{24} \zhdizhi{1211} +% \zhdizhi{-1} \zhdizhi{-2} \zhdizhi{-8199} \\ +% \zhganzhi{61} \zhganzhi{72} \zhganzhi{2158} \\ +% \zhganzhi{-1} \zhganzhi{-2} \zhganzhi{-789} +% \end{SideBySideExample} +% \end{function} +% +%\bigskip % \pkg{zhnumber} 提供下列选项来控制阿拉伯数字的中文映射。 % \begin{verbatim}[frame=single] % - -0 0 1 2 3 4 5 6 7 8 9 10 20 30 40 100 200 1000 % E2 E3 E4 E8 E12 E16 E20 E24 E28 E32 E36 E40 E44 % F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F100 F1000 FE2 FE3 +% T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 +% D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 +% GZ1 GZ2 GZ3 GZ4 GZ5 GZ6 GZ7 GZ8 GZ9 GZ10 ... GZ60 % dot and parts % year month day hour minute weekday mon tue wed thu fri sat sun % \end{verbatim} % 其中 |-| 设置负,|-0| 设置〇,|dot| 设置小数的点,|and| 和 |parts| 分别设置分数 -% 的“又”和“分之”,|E|$n$ 设置 $10^n$,而 |F|$n$ 设置数字 $n$ 的大写。其它的选项同 -% 字面意思,不再赘述。例如 +% 的“又”和“分之”,|E|$n$ 设置 $10^n$,|F|$n$ 设置数字 $n$ 的大写,|T|$n$ 设置 +% 数字 $n$ 的天干,|D|$n$ 设置数字 $n$ 的地支,而 |GZ|$n$ 设置数字 $n$ 的干支。 +% 其它的选项同字面意思,不再赘述。例如 % \begin{verbatim}[frame=single] % \zhnumsetup{2={两}} % \end{verbatim} @@ -462,7 +583,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % % \begin{function}[added=2014-09-09]{activechar} % \begin{syntax} -% activechar = \meta{\TTF} +% activechar = <\TTF> % \end{syntax} % 在 \LaTeX{} 或者 \pdfLaTeX{} 下面输出汉字,传统的办法需要将汉字的首字节设置为 % 活动字符,然后再通过特殊的宏技巧来实现。因此,\pkg{zhnumber} 在载入配置文件的 @@ -527,7 +648,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % \end{macrocode} % \end{macro} % -% \begin{macro}{\zhnumberwithoptions} +% \begin{macro}[internal]{\zhnumberwithoptions} % 带选项的用户函数。 % \begin{macrocode} \NewDocumentCommand \zhnumberwithoptions { +m +m } @@ -816,7 +937,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % \begin{macro}[internal]{\zhnum_split_number:NNnNNNNw} % 将输入的整数由高位到低位,以四位为一段进行处理。 % \begin{macrocode} -\cs_new:Npn \zhnum_split_number:NNnNNNNw #1#2#3#4#5#6#7#8 \q_recursion_stop +\cs_new:Npn \zhnum_split_number:NNnNNNNw #1#2#3#4#5#6#7 { \quark_if_recursion_tail_stop:N #4 \int_compare:nNnTF { #4#5#6#7 } = \c_zero @@ -829,7 +950,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). } { \zhnum_split_number:NNfNNNNw \c_false_bool \c_true_bool } { \zhnum_split_number:NNfNNNNw \c_true_bool \c_false_bool } - { \int_eval:n { #3 - \c_one } } #8 \q_recursion_stop + { \int_eval:n { #3 - \c_one } } } \cs_generate_variant:Nn \zhnum_split_number:NNnNNNNw { NNf } % \end{macrocode} @@ -1183,7 +1304,111 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). } % \end{macrocode} % \end{macro} - +% +% \begin{macro}[internal]{\zhnum_ganzhi_normal:nnn} +% 保证干支的参数为正数。 +% \begin{macrocode} +\cs_new:Npn \zhnum_ganzhi_normal:nnn #1#2#3 + { + \int_compare:nNnF {#1} < \c_one + { \cs_if_exist_use:c { c_@@_ #2 _ #1 _tl } } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[internal]{\zhnum_ganzhi_cyclic:nnn} +% \begin{macro}[aux]{\@@_ganzhi_cyclic_mod:nnnn} +% 对超出范围的数字取模,参数 |0| 的结果是空值。 +% \begin{macrocode} +\cs_new:Npn \zhnum_ganzhi_cyclic:nnn #1#2#3 + { + \int_compare:nNnF {#1} = \c_zero + { + \cs_if_exist_use:cF { c_@@_ #2 _ #1 _tl } + { + \@@_ganzhi_cyclic_mod:fnnn + { \int_mod:nn {#1} {#3} } {#1} {#2} {#3} + } + } + } +\cs_new:Npn \@@_ganzhi_cyclic_mod:nnnn #1#2#3#4 + { + \int_compare:nNnTF {#2} > \c_zero + { \use:c { c_@@_ #3 _ #1 _tl } } + { + \int_compare:nNnTF {#1} = \c_zero + { \use:c { c_@@_ #3 _ 1 _tl } } + { \use:c { c_@@_ #3 _ \int_eval:n { #1 + #4 + 1 } _tl } } + } + } +\cs_generate_variant:Nn \@@_ganzhi_cyclic_mod:nnnn { f } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[internal]{\zhnum_ganzhi:nnn} +% 默认不对超出范围的数字取模。 +% \begin{macrocode} +\cs_new_eq:NN \zhnum_ganzhi:nnn \zhnum_ganzhi_normal:nnn +\cs_generate_variant:Nn \zhnum_ganzhi:nnn { f } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\zhtiangan} +% 天干。 +% \begin{macrocode} +\cs_new:Npn \zhtiangan #1 + { \zhnum_ganzhi:fnn { \int_eval:n {#1} } { tiangan } { 10 } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\zhdizhi} +% 地支。 +% \begin{macrocode} +\cs_new:Npn \zhdizhi #1 + { \zhnum_ganzhi:fnn { \int_eval:n {#1} } { dizhi } { 12 } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\zhganzhi} +% 干支。 +% \begin{macrocode} +\cs_new:Npn \zhganzhi #1 + { \zhnum_ganzhi:fnn { \int_eval:n {#1} } { ganzhi } { 60 } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\zhganzhinian} +% 干支纪年。 +% \begin{macrocode} +\cs_new:Npn \zhganzhinian #1 + { \zhnum_ganzhi_nian:f { \int_eval:n {#1} } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[internal]{\zhnum_ganzhi_nian:n} +% 干支纪年。公元元年是 |\zhganzhi{58}|。 +% \begin{macrocode} +\cs_new:Npn \zhnum_ganzhi_nian:n #1 + { + \int_compare:nNnTF {#1} > \c_zero + { \use:c { c_@@_ganzhi_ \int_mod:nn { #1 + 57 } { 60 } _tl } } + { + \int_compare:nNnF {#1} = \c_zero + { + \use:c + { + c_@@_ganzhi_ + \int_eval:n { \int_mod:nn { #1 - 2 } { 60 } + 60 } + _tl + } + } + } + } +\cs_generate_variant:Nn \zhnum_ganzhi_nian:n { f } +% \end{macrocode} +% \end{macro} +% % 根据需要设置中文阿拉伯数字。 % \begin{macrocode} \group_begin: @@ -1198,27 +1423,40 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). E3 .tl_set:N = \exp_not:c { l_@@_ 1000 _tl } , FE2 .tl_set:N = \exp_not:c { l_@@_financial_ 100 _tl } , FE3 .tl_set:N = \exp_not:c { l_@@_financial_ 1000 _tl } , + D11 .tl_set:N = \exp_not:c { l_@@_dizhi_ 11 _tl } , + D12 .tl_set:N = \exp_not:c { l_@@_dizhi_ 12 _tl } , + E44 .tl_set:N = \exp_not:c { l_@@_ s11 _tl } , } - \clist_map_inline:nn - { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 100 , 1000 } + \int_step_inline:nnnn { 1 } { 1 } { 10 } { \tl_put_right:Nx \l_tmpa_tl { - #1 .tl_set:N = \exp_not:c { l_@@_ #1 _tl } , - F#1 .tl_set:N = \exp_not:c { l_@@_financial_ #1 _tl } , + #1 .tl_set:N = \exp_not:c { l_@@_ #1 _tl } , + F#1 .tl_set:N = \exp_not:c { l_@@_financial_ #1 _tl } , + T#1 .tl_set:N = \exp_not:c { l_@@_tiangan_ #1 _tl } , + D#1 .tl_set:N = \exp_not:c { l_@@_dizhi_ #1 _tl } , + GZ#1 .tl_set:N = \exp_not:c { l_@@_ganzhi_ #1 _tl } , + E \int_eval:n { #1 * 4 } + .tl_set:N = \exp_not:c { l_@@_ s#1 _tl } , } } - \clist_map_inline:nn - { 20 , 30 , 40 , 200 } + \int_step_inline:nnnn { 11 } { 1 } { 60 } { \tl_put_right:Nx \l_tmpa_tl - { #1 .tl_set:N = \exp_not:c { l_@@_ #1 _tl } , } + { GZ#1 .tl_set:N = \exp_not:c { l_@@_ganzhi_ #1 _tl } , } } - \clist_map_inline:nn - { 4 , 8 , 12 , 16 , 20 , 24 , 28 , 32 , 36 , 40 , 44 } + \clist_map_inline:nn { 0 , 100 , 1000 } + { + \tl_put_right:Nx \l_tmpa_tl + { + #1 .tl_set:N = \exp_not:c { l_@@_ #1 _tl } , + F#1 .tl_set:N = \exp_not:c { l_@@_financial_ #1 _tl } , + } + } + \clist_map_inline:nn { 20 , 30 , 40 , 200 } { \tl_put_right:Nx \l_tmpa_tl - { E#1 .tl_set:N = \exp_not:c { l_@@_ s \int_eval:n { #1 / 4 } _tl } , } + { #1 .tl_set:N = \exp_not:c { l_@@_ #1 _tl } , } } \clist_map_inline:nn { @@ -1242,9 +1480,12 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). % \zhnum_set_digits_map:nnn, % \zhnum_set_financial_map:nn, % \zhnum_set_financial_map:nnn, +% \zhnum_set_tiangan_map:nn, +% \zhnum_set_dizhi_map:nn, % \l_@@_cfg_map_prop, % \l_@@_cfg_map_var_prop, -% \l_@@_cfg_map_finan_prop +% \l_@@_cfg_map_finan_prop, +% \l_@@_cfg_map_ganzhi_prop % } % 将配置文件中的中文数字保存到 \texttt{prop} 变量中。 % \begin{macrocode} @@ -1262,9 +1503,14 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). \prop_put_if_new:Nnn \l_@@_cfg_map_finan_prop {#1} {#3} \prop_put:Nnn \l_@@_cfg_map_var_prop { financial_#1_#2 } {#3} } +\cs_new_protected:Npn \zhnum_set_tiangan_map:nn #1#2 + { \prop_put:Nnn \l_@@_cfg_map_ganzhi_prop { tiangan_#1 } {#2} } +\cs_new_protected:Npn \zhnum_set_dizhi_map:nn #1#2 + { \prop_put:Nnn \l_@@_cfg_map_ganzhi_prop { dizhi_#1 } {#2} } \prop_new:N \l_@@_cfg_map_prop \prop_new:N \l_@@_cfg_map_var_prop \prop_new:N \l_@@_cfg_map_finan_prop +\prop_new:N \l_@@_cfg_map_ganzhi_prop % \end{macrocode} % \end{macro} % @@ -1281,6 +1527,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). \cs_new_protected_nopar:Npn \zhnum_parse_config: { \prop_map_function:NN \l_@@_cfg_map_prop \zhnum_check_simp:nn + \prop_map_function:NN \l_@@_cfg_map_ganzhi_prop \zhnum_assgin_ganzhi:nn \zhnum_set_zero: \zhnum_set_week_day: \bool_if:NF \l_@@_reset_bool @@ -1357,9 +1604,31 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). } \clist_map_inline:nn { mon , tue , wed , thu , fri , sat , sun } { \tl_const:cx { c_@@_ #1 _tl } { \exp_not:c { l_@@_ #1 _tl } } } +\cs_new_protected:Npn \zhnum_assgin_ganzhi:nn #1#2 + { \tl_set:cn { l_@@_ #1 _tl } {#2} } +\cs_new:Npn \zhnum_zero_mod:nn #1#2 + { \exp_args:Nf \@@_zero_mod_aux:nn { \int_mod:nn {#1} {#2} } {#2} } +\cs_new:Npn \@@_zero_mod_aux:nn #1#2 + { \int_compare:nNnTF {#1} = \c_zero {#2} {#1} } +\int_step_inline:nnnn { 1 } { 1 } { 60 } + { + \tl_const:cx { c_@@_ganzhi_ #1 _tl } { \exp_not:c { l_@@_ganzhi_ #1 _tl } } + \tl_set:cx { l_@@_ganzhi_ #1 _tl } + { + \exp_not:c { l_@@_tiangan_ \zhnum_zero_mod:nn {#1} { 10 } _tl } + \exp_not:c { l_@@_dizhi_ \zhnum_zero_mod:nn {#1} { 12 } _tl } + } + } +\cs_new_eq:cc { c_@@_ganzhi_ 0 _tl } { c_@@_ganzhi_ 60 _tl } \cs_new_eq:NN \zhnum_assgin_const_tl:cx \tl_const:cx \AtEndOfPackage - { \cs_set_eq:NN \zhnum_assgin_const_tl:cx \tl_set:cx } + { + \prop_map_inline:Nn \l_@@_cfg_map_ganzhi_prop + { \tl_const:cx { c_@@_ #1 _tl } { \exp_not:c { l_@@_ #1 _tl } } } + \cs_new_eq:cc { c_@@_tiangan_ 0 _tl } { c_@@_tiangan_ 10 _tl } + \cs_new_eq:cc { c_@@_dizhi_ 0 _tl } { c_@@_dizhi_ 12 _tl } + \cs_set_eq:NN \zhnum_assgin_const_tl:cx \tl_set:cx + } % \end{macrocode} % \end{macro} % @@ -1398,7 +1667,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). { \prop_if_exist:cTF { g_@@_cfg_ \l_@@_cfg_tl _prop } { \tl_set_eq:NN \l_@@_last_cfg_tl \l_@@_cfg_tl } - { \zhnum_input_cfg:n {#1} } + { \zhnum_input_cfg:n {#1} } \@@_update_cfg_prop:N \prop_set_eq:Nc } \cs_new_protected:Npn \zhnum_input_cfg:n #1 @@ -1419,9 +1688,10 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). } \cs_new_protected:Npn \@@_update_cfg_prop:N #1 { - #1 \l_@@_cfg_map_prop { g_@@_cfg_ \l_@@_cfg_tl _prop } - #1 \l_@@_cfg_map_var_prop { g_@@_cfg_var_ \l_@@_cfg_tl _prop } - #1 \l_@@_cfg_map_finan_prop { g_@@_cfg_finan_ \l_@@_cfg_tl _prop } + #1 \l_@@_cfg_map_prop { g_@@_cfg_ \l_@@_cfg_tl _prop } + #1 \l_@@_cfg_map_var_prop { g_@@_cfg_var_ \l_@@_cfg_tl _prop } + #1 \l_@@_cfg_map_finan_prop { g_@@_cfg_finan_ \l_@@_cfg_tl _prop } + #1 \l_@@_cfg_map_ganzhi_prop { g_@@_cfg_ganzhi_ \l_@@_cfg_tl _prop } } \cs_new_protected:Npn \@@_prop_initial:Nn #1#2 { @@ -1528,8 +1798,8 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). encoding .choices:nn = { UTF8 , GBK , Big5 } { - \tl_set:Nx \l_@@_encoding_tl - { \exp_args:No \tl_expandable_lowercase:n { \l_keys_choice_tl } } + \exp_args:Nx \tex_lowercase:D + { \tl_set:Nn \exp_not:N \l_@@_encoding_tl { \l_keys_choice_tl } } \zhnum_load_cfg:o { \l_@@_encoding_tl } } , encoding .default:n = { GBK } , @@ -1562,6 +1832,12 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). time .default:n = { Arabic } , reset .code:n = { \zhnum_reset_config: } , activechar .bool_set:N = \l_@@_active_char_bool , + ganzhi-cyclic .choice: , + ganzhi-cyclic / true .code:n = + { \cs_set_eq:NN \zhnum_ganzhi:nnn \zhnum_ganzhi_cyclic:nnn } , + ganzhi-cyclic / false.code:n = + { \cs_set_eq:NN \zhnum_ganzhi:nnn \zhnum_ganzhi_normal:nnn } , + ganzhi-cyclic .default:n = { true } , } \tl_new:N \l_@@_encoding_tl \msg_new:nnnn { zhnumber } { encoding-invalid } @@ -1719,6 +1995,28 @@ and some specific Chinese Simplified fonts (TrueType or OpenType). \zhnum_set_financial_map:nn { 10 } { 拾 } \zhnum_set_financial_map:nn { 100 } { 佰 } \zhnum_set_financial_map:nn { 1000 } { 仟 } +\zhnum_set_tiangan_map:nn { 1 } { 甲 } +\zhnum_set_tiangan_map:nn { 2 } { 乙 } +\zhnum_set_tiangan_map:nn { 3 } { 丙 } +\zhnum_set_tiangan_map:nn { 4 } { 丁 } +\zhnum_set_tiangan_map:nn { 5 } { 戊 } +\zhnum_set_tiangan_map:nn { 6 } { 己 } +\zhnum_set_tiangan_map:nn { 7 } { 庚 } +\zhnum_set_tiangan_map:nn { 8 } { 辛 } +\zhnum_set_tiangan_map:nn { 9 } { 壬 } +\zhnum_set_tiangan_map:nn { 10 } { 癸 } +\zhnum_set_dizhi_map:nn { 1 } { 子 } +\zhnum_set_dizhi_map:nn { 2 } { 丑 } +\zhnum_set_dizhi_map:nn { 3 } { 寅 } +\zhnum_set_dizhi_map:nn { 4 } { 卯 } +\zhnum_set_dizhi_map:nn { 5 } { 辰 } +\zhnum_set_dizhi_map:nn { 6 } { 巳 } +\zhnum_set_dizhi_map:nn { 7 } { 午 } +\zhnum_set_dizhi_map:nn { 8 } { 未 } +\zhnum_set_dizhi_map:nn { 9 } { 申 } +\zhnum_set_dizhi_map:nn { 10 } { 酉 } +\zhnum_set_dizhi_map:nn { 11 } { 戌 } +\zhnum_set_dizhi_map:nn { 12 } { 亥 } % \end{macrocode} % % \begin{macrocode} |