# Problem with the zhnumber package

I am trying to write about numerals and the use of symbols. As an example I would like to use chinese/japanese symbols to show a multiplicative system. I have come up with the package zhnumber which works great for \zhdigits but not for \zhnumber. I have copied the examples from the documentation. Still I get the error: Undefined control sequence. Can anyone please help? Is there something wrong with the combination of fonts or other packages? I am using a mac

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[norsk]{babel}
\usepackage[T1]{fontenc}
\usepackage{parskip}
\usepackage{xeCJK}
\setCJKmainfont{STSong}
\usepackage{zhnumber}

\begin{document}
\zhdigits{5} \\
\zhnumber{10}
\end{document}

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Harish Kumar Sep 1 '14 at 7:52
You shouldn't use inputenc with xelatex. Never. –  Ulrike Fischer Sep 1 '14 at 8:02
And you shouldn't use babel. Use polyglossia when necessary. Don't use fontenc unless you know why. –  Leo Liu Sep 1 '14 at 10:40
@LeoLiu: babel is actively maintained and the author and the authors of the language packages are doing a lot to adapt it to the new engines. Depending on the language babel works fine with xelatex and lualatex and is often better than polyglossia. –  Ulrike Fischer Sep 1 '14 at 11:42
@UlrikeFischer: I didn't know that. Since polyglossia now seems inactive, new babel may be better choice. –  Leo Liu Sep 1 '14 at 11:45

You don't say exactly what the undefined control sequence you get is, but I get the error

! Undefined control sequence.
<argument> \__int_get_sign:n
{10}\c_one
l.13 \zhnumber{10}


with your example or a much shorter one

\documentclass{article}
\usepackage{zhnumber}
\begin{document}
\zhdigits{5}
\end{document}


The zhnumber package is using an internal command from expl3, which it shouldn't. That particular internal has been removed, which is within the scope of what the LaTeX3 team can do with internal commands. As such, this is a bug in zhnumber and should be reported to the maintainer.

(I notice some other internal issues in that package, looking at the code. I will raise them with the author later today.)

-
Issue has been reported. to Qing Lee. –  Joseph Wright Sep 1 '14 at 8:10
Any other internal issues? I find only one \__ macro. –  Leo Liu Sep 1 '14 at 9:22
@LeoLiu Not bugs, more style things: for example, take a look at the expandable status of a lot of the functions. –  Joseph Wright Sep 1 '14 at 10:27
Thanks a lot. Hopefully that will be solved –  Per G. Østerlie Sep 1 '14 at 18:17
I use an internal function (\__msg_expandable_error:n) in the new version. I know it is not appropriate. But I really need it to function. –  Qing Lee Sep 10 '14 at 12:13

Before the new version of zhnumber is released, you can use this quick (and dirty) fix:

\documentclass[UTF8]{ctexart}

\usepackage[encoding=UTF8]{zhnumber}% v1.6 2012/11/23

% Quick fix
\ExplSyntaxOn

\cs_set_nopar:Nn \zhnum_integer:n
{
\bool_set_false:N \my_isneg_bool
\my_parse_signs:nw #1 \q_stop
\zhnum_parse_number:f { \zhnum_trim_zeros:f { \zhnum_erase_separator:n {#1} } }
}

\bool_new:N \my_isneg_bool

\cs_new_nopar:Npn \my_parse_signs:nw #1 #2 \q_stop
{
\tl_case:NnF #1
{
+ { \my_parse_signs:nw #2 \q_stop }
- {
\bool_if:NTF \my_isneg_bool
{ \bool_set_false:N \my_isneg_bool }
{ \bool_set_true:N  \my_isneg_bool }
\my_parse_signs:nw #2 \q_stop
}
}
{
\bool_if:NT \my_isneg_bool { \c_zhnum_minus_tl }
}
}

\ExplSyntaxOff

\begin{document}

\zhnumber{-1234567890123}

\end{document}

-
Shouldn't \tl_case:NnF be \str_case:NnF? –  egreg Sep 2 '14 at 17:41
@egreg: What's the difference (in semantics or performance) here? I am not experienced in LaTeX3. And I guess there can be a better implementation of the whole \zhnum_integer:n macro. –  Leo Liu Sep 3 '14 at 5:55
The example doesn't compile for me, with pdflatex: Package CJK Error: Invalid character code –  egreg Sep 3 '14 at 7:09
@egreg: Sorry, I tested it for XeTeX only. Using pdfTeX, encoding option must be specified: \usepackage[encoding=UTF8]{zhnumber}. –  Leo Liu Sep 3 '14 at 7:28
I added the code in my answer (that I will remove; you should be able to see it nonetheless). –  egreg Sep 3 '14 at 8:01

This bug was fixed in the new version (v2.0) of zhnumber. I have submitted it to the CTAN. It is also to be updated in TeX Live.

-
Great! Thank you! –  Per G. Østerlie Sep 12 '14 at 6:53