New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different formatting for digits resp. before and after decimal point #647
Comments
This is one of those tricky borderline things. The core aim of |
As there is a documented API for \documentclass{article}
\usepackage{siunitx}
\ExplSyntaxOn
\NewDocumentCommand \soldyesisnum { O { } m }
{
\mode_leave_vertical:
\group_begin:
\keys_set:nn { siunitx } { #1 , mode = text }
\soldyesis_number_format:nN {#2} \l__siunitx_tmp_tl
\siunitx_print_number:V \l__siunitx_tmp_tl
\group_end:
}
\cs_new_protected:Npn \soldyesis_number_format:nN #1#2
{
\siunitx_number_parse:nN {#1} \l__siunitx_tmp_tl
\siunitx_number_process:NN \l__siunitx_tmp_tl \l__siunitx_tmp_tl
\tl_set:Nx \l__siunitx_tmp_tl
{ \siunitx_number_output:NN \l__siunitx_tmp_tl \q_nil }
\tl_set:Nx #2
{
\exp_after:wN \__soldyesis_number_format:w \l__siunitx_tmp_tl
\q_stop
}
}
\cs_new:Npn \__soldyesis_number_format:w
#1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_stop
{
\__soldyesis_number_format:nw {#1#2#3#4} #5 \q_stop
}
\cs_new:Npn \__soldyesis_number_format:nw
#1 #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil #8 \q_stop
{
\exp_not:N \textcolor { red } {#1}
\exp_not:N \tiny {#2#3#4#5#6#7}
}
\ExplSyntaxOff
\begin{document}
\soldyesisnum{10.5}
\end{document} |
Many thanks for this complementary answer! 😀 You are right, this is probably the best way to go, given the general philosophy of And your code example will be much helpful to me 🙂, for I am not quite acquainted with the LaTeX3 syntax yet... (Actually I have not managed to test your code yet: as, when I tried to run it, I got a “undefined control sequence Kind regards, |
@Soldyesis If you have v2 of |
@josephwright After installing a more recent TeX distribution so that I could enjoy the most recent versions of |
Hello,
When writing a decimal number, it is a common usage to typeset the digits after the decimal separator differently from the digits of the integral part:
At the time I used the (now unmaintained) package
numprint
(whichsiunitx
takes some of its inspiration from), there was an internal command\nprt@printafter
which could be hacked to get the desired effect. But now that I am usingsiunitx
, I could not find such a feature in the current implementation...Anyway, it would be nice that the
siunitx
would include the possibility (without any internal hacking by the user, I mean) to typeset post-decimal-point digits differently from the integer part (e.g. in a smaller font size, or as a superscript, or as text figures, or without thousand grouping, &c., &c.): for it is a common usage as explained above, and a quite convenient one IMHO!Kind regards,
/Soldyesis
The text was updated successfully, but these errors were encountered: