Formatting numbers with smaller glyphs for decimals

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I am currently writing up a coursebook in which I handle sets of decimal numbers. As the language of the coursebook is French, the decimal separator has to be a comma and the thousands separator a thin space. But then, it becomes difficult for the reader to distinguish between the set of four integers 0, 1, 2, 3 and the set of two decimal numbers 0.1, 2.3. See the following code:



documentclassminimal
usepackage[french]babel
usepackage[autolanguage]numprint
begindocument
noindent $numprint0.1, numprint2.3$\
$0, 1, 2, 3$
enddocument


which is rendered by



enter image description here



which is not quite fine…



What I would like to do is to print the comma and the decimals in a smaller font than the digits before the decimal separator (this is a rather common usage in France, for instance to typeset prices), like in



documentclassminimal
usepackageamsmath
usepackagerelsize
begindocument
$text$0$smaller$mathord,1$,
text$2$smaller$mathord,3$$\
enddocument


(yes, this is a quite ugly code :-S), which yields the much more easy-to-read



enter image description here



Now my question is: how to do that neatly with a simple command like numprint from the numprint package? Changing the font for decimals does not seem to be a feature implemented in numprint, nor in siunitx; and I am not skilled enough in (La)TeX to build my own solution…



(Post-Scriptum: If possible, I would like to have a solution which also allows for inserting automatically the thousand separators, and rendering “1.2e3” with a power of ten…)










share|improve this question

















  • 4




    With the constraints given, I'd use a semicolon instead of a comma for lists.
    – egreg
    3 hours ago






  • 1




    Or, considered that you already need to type numprint everywhere, you could just insert manual space after each comma in the list $numprint0.1,, numprint2.3$.
    – Ruixi Zhang
    2 hours ago










  • @egreg Indeed, I already had that idea in mind, but I do not like it much… :-| Also, I would find it quite frustrating that numprint and siunitx do implement some very sharp features to display formatted numbers, but that there would be no reasonable way to specify different fonts for pre- and post-comma digits… :-(
    – Rémi Peyre
    2 hours ago










  • @RuixiZhang This is an idea worth being considered :-)
    – Rémi Peyre
    2 hours ago










  • It might be frustrating; but I'm inclined to think that your readers will be more frustrated by the unreadable mess.
    – egreg
    2 hours ago














up vote
3
down vote

favorite












I am currently writing up a coursebook in which I handle sets of decimal numbers. As the language of the coursebook is French, the decimal separator has to be a comma and the thousands separator a thin space. But then, it becomes difficult for the reader to distinguish between the set of four integers 0, 1, 2, 3 and the set of two decimal numbers 0.1, 2.3. See the following code:



documentclassminimal
usepackage[french]babel
usepackage[autolanguage]numprint
begindocument
noindent $numprint0.1, numprint2.3$\
$0, 1, 2, 3$
enddocument


which is rendered by



enter image description here



which is not quite fine…



What I would like to do is to print the comma and the decimals in a smaller font than the digits before the decimal separator (this is a rather common usage in France, for instance to typeset prices), like in



documentclassminimal
usepackageamsmath
usepackagerelsize
begindocument
$text$0$smaller$mathord,1$,
text$2$smaller$mathord,3$$\
enddocument


(yes, this is a quite ugly code :-S), which yields the much more easy-to-read



enter image description here



Now my question is: how to do that neatly with a simple command like numprint from the numprint package? Changing the font for decimals does not seem to be a feature implemented in numprint, nor in siunitx; and I am not skilled enough in (La)TeX to build my own solution…



(Post-Scriptum: If possible, I would like to have a solution which also allows for inserting automatically the thousand separators, and rendering “1.2e3” with a power of ten…)










share|improve this question

















  • 4




    With the constraints given, I'd use a semicolon instead of a comma for lists.
    – egreg
    3 hours ago






  • 1




    Or, considered that you already need to type numprint everywhere, you could just insert manual space after each comma in the list $numprint0.1,, numprint2.3$.
    – Ruixi Zhang
    2 hours ago










  • @egreg Indeed, I already had that idea in mind, but I do not like it much… :-| Also, I would find it quite frustrating that numprint and siunitx do implement some very sharp features to display formatted numbers, but that there would be no reasonable way to specify different fonts for pre- and post-comma digits… :-(
    – Rémi Peyre
    2 hours ago










  • @RuixiZhang This is an idea worth being considered :-)
    – Rémi Peyre
    2 hours ago










  • It might be frustrating; but I'm inclined to think that your readers will be more frustrated by the unreadable mess.
    – egreg
    2 hours ago












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I am currently writing up a coursebook in which I handle sets of decimal numbers. As the language of the coursebook is French, the decimal separator has to be a comma and the thousands separator a thin space. But then, it becomes difficult for the reader to distinguish between the set of four integers 0, 1, 2, 3 and the set of two decimal numbers 0.1, 2.3. See the following code:



documentclassminimal
usepackage[french]babel
usepackage[autolanguage]numprint
begindocument
noindent $numprint0.1, numprint2.3$\
$0, 1, 2, 3$
enddocument


which is rendered by



enter image description here



which is not quite fine…



What I would like to do is to print the comma and the decimals in a smaller font than the digits before the decimal separator (this is a rather common usage in France, for instance to typeset prices), like in



documentclassminimal
usepackageamsmath
usepackagerelsize
begindocument
$text$0$smaller$mathord,1$,
text$2$smaller$mathord,3$$\
enddocument


(yes, this is a quite ugly code :-S), which yields the much more easy-to-read



enter image description here



Now my question is: how to do that neatly with a simple command like numprint from the numprint package? Changing the font for decimals does not seem to be a feature implemented in numprint, nor in siunitx; and I am not skilled enough in (La)TeX to build my own solution…



(Post-Scriptum: If possible, I would like to have a solution which also allows for inserting automatically the thousand separators, and rendering “1.2e3” with a power of ten…)










share|improve this question













I am currently writing up a coursebook in which I handle sets of decimal numbers. As the language of the coursebook is French, the decimal separator has to be a comma and the thousands separator a thin space. But then, it becomes difficult for the reader to distinguish between the set of four integers 0, 1, 2, 3 and the set of two decimal numbers 0.1, 2.3. See the following code:



documentclassminimal
usepackage[french]babel
usepackage[autolanguage]numprint
begindocument
noindent $numprint0.1, numprint2.3$\
$0, 1, 2, 3$
enddocument


which is rendered by



enter image description here



which is not quite fine…



What I would like to do is to print the comma and the decimals in a smaller font than the digits before the decimal separator (this is a rather common usage in France, for instance to typeset prices), like in



documentclassminimal
usepackageamsmath
usepackagerelsize
begindocument
$text$0$smaller$mathord,1$,
text$2$smaller$mathord,3$$\
enddocument


(yes, this is a quite ugly code :-S), which yields the much more easy-to-read



enter image description here



Now my question is: how to do that neatly with a simple command like numprint from the numprint package? Changing the font for decimals does not seem to be a feature implemented in numprint, nor in siunitx; and I am not skilled enough in (La)TeX to build my own solution…



(Post-Scriptum: If possible, I would like to have a solution which also allows for inserting automatically the thousand separators, and rendering “1.2e3” with a power of ten…)







fontsize siunitx numprint decimal-number






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 3 hours ago









Rémi Peyre

33827




33827







  • 4




    With the constraints given, I'd use a semicolon instead of a comma for lists.
    – egreg
    3 hours ago






  • 1




    Or, considered that you already need to type numprint everywhere, you could just insert manual space after each comma in the list $numprint0.1,, numprint2.3$.
    – Ruixi Zhang
    2 hours ago










  • @egreg Indeed, I already had that idea in mind, but I do not like it much… :-| Also, I would find it quite frustrating that numprint and siunitx do implement some very sharp features to display formatted numbers, but that there would be no reasonable way to specify different fonts for pre- and post-comma digits… :-(
    – Rémi Peyre
    2 hours ago










  • @RuixiZhang This is an idea worth being considered :-)
    – Rémi Peyre
    2 hours ago










  • It might be frustrating; but I'm inclined to think that your readers will be more frustrated by the unreadable mess.
    – egreg
    2 hours ago












  • 4




    With the constraints given, I'd use a semicolon instead of a comma for lists.
    – egreg
    3 hours ago






  • 1




    Or, considered that you already need to type numprint everywhere, you could just insert manual space after each comma in the list $numprint0.1,, numprint2.3$.
    – Ruixi Zhang
    2 hours ago










  • @egreg Indeed, I already had that idea in mind, but I do not like it much… :-| Also, I would find it quite frustrating that numprint and siunitx do implement some very sharp features to display formatted numbers, but that there would be no reasonable way to specify different fonts for pre- and post-comma digits… :-(
    – Rémi Peyre
    2 hours ago










  • @RuixiZhang This is an idea worth being considered :-)
    – Rémi Peyre
    2 hours ago










  • It might be frustrating; but I'm inclined to think that your readers will be more frustrated by the unreadable mess.
    – egreg
    2 hours ago







4




4




With the constraints given, I'd use a semicolon instead of a comma for lists.
– egreg
3 hours ago




With the constraints given, I'd use a semicolon instead of a comma for lists.
– egreg
3 hours ago




1




1




Or, considered that you already need to type numprint everywhere, you could just insert manual space after each comma in the list $numprint0.1,, numprint2.3$.
– Ruixi Zhang
2 hours ago




Or, considered that you already need to type numprint everywhere, you could just insert manual space after each comma in the list $numprint0.1,, numprint2.3$.
– Ruixi Zhang
2 hours ago












@egreg Indeed, I already had that idea in mind, but I do not like it much… :-| Also, I would find it quite frustrating that numprint and siunitx do implement some very sharp features to display formatted numbers, but that there would be no reasonable way to specify different fonts for pre- and post-comma digits… :-(
– Rémi Peyre
2 hours ago




@egreg Indeed, I already had that idea in mind, but I do not like it much… :-| Also, I would find it quite frustrating that numprint and siunitx do implement some very sharp features to display formatted numbers, but that there would be no reasonable way to specify different fonts for pre- and post-comma digits… :-(
– Rémi Peyre
2 hours ago












@RuixiZhang This is an idea worth being considered :-)
– Rémi Peyre
2 hours ago




@RuixiZhang This is an idea worth being considered :-)
– Rémi Peyre
2 hours ago












It might be frustrating; but I'm inclined to think that your readers will be more frustrated by the unreadable mess.
– egreg
2 hours ago




It might be frustrating; but I'm inclined to think that your readers will be more frustrated by the unreadable mess.
– egreg
2 hours ago










2 Answers
2






active

oldest

votes

















up vote
3
down vote













How is this for a start?



documentclassarticle

defnumX#1.#2relaxmbox$#1$small$mathord,#2$
newcommandnum[1]numX#1relax

begindocument
$num0.1, num2.3$
enddocument





share|improve this answer




















  • I do like it! :-) I had forgotten about this defmycs#1.#2 TeX feature…
    – Rémi Peyre
    2 hours ago










  • I'd consider ensuremath#1,mathsmaller#2 exploiting relsize (but the result is ugly nonetheless).
    – egreg
    2 hours ago

















up vote
1
down vote













You might do like this:



documentclassarticle
usepackage[T1]fontenc
usepackage[french]babel
usepackagesiunitx,relsize

sisetuplocale=FR

ExplSyntaxOn
NewDocumentCommandhnum>SplitArgument1.m

hnumA#1

NewDocumentCommandhnumAmm

num#1
IfValueT#2hnumB#2

NewDocumentCommandhnumB>SplitArgument1em

hnumC#1

NewDocumentCommandhnumCmm

ensuremath

,mathsmallernum[add-integer-zero=false,output-decimal-marker=].#1
IfValueT#2timesnume#2


ExplSyntaxOff

begindocument

$hnum0.1,hnum2.3,hnum4.5e10$

bigskip

$num0.1;num2.3;num4.5e10$

enddocument


However the result is really ugly and difficult to interpret. Much better to use a semicolon.



enter image description here






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f451611%2fformatting-numbers-with-smaller-glyphs-for-decimals%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote













    How is this for a start?



    documentclassarticle

    defnumX#1.#2relaxmbox$#1$small$mathord,#2$
    newcommandnum[1]numX#1relax

    begindocument
    $num0.1, num2.3$
    enddocument





    share|improve this answer




















    • I do like it! :-) I had forgotten about this defmycs#1.#2 TeX feature…
      – Rémi Peyre
      2 hours ago










    • I'd consider ensuremath#1,mathsmaller#2 exploiting relsize (but the result is ugly nonetheless).
      – egreg
      2 hours ago














    up vote
    3
    down vote













    How is this for a start?



    documentclassarticle

    defnumX#1.#2relaxmbox$#1$small$mathord,#2$
    newcommandnum[1]numX#1relax

    begindocument
    $num0.1, num2.3$
    enddocument





    share|improve this answer




















    • I do like it! :-) I had forgotten about this defmycs#1.#2 TeX feature…
      – Rémi Peyre
      2 hours ago










    • I'd consider ensuremath#1,mathsmaller#2 exploiting relsize (but the result is ugly nonetheless).
      – egreg
      2 hours ago












    up vote
    3
    down vote










    up vote
    3
    down vote









    How is this for a start?



    documentclassarticle

    defnumX#1.#2relaxmbox$#1$small$mathord,#2$
    newcommandnum[1]numX#1relax

    begindocument
    $num0.1, num2.3$
    enddocument





    share|improve this answer












    How is this for a start?



    documentclassarticle

    defnumX#1.#2relaxmbox$#1$small$mathord,#2$
    newcommandnum[1]numX#1relax

    begindocument
    $num0.1, num2.3$
    enddocument






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 2 hours ago









    Peter Selinger

    13813




    13813











    • I do like it! :-) I had forgotten about this defmycs#1.#2 TeX feature…
      – Rémi Peyre
      2 hours ago










    • I'd consider ensuremath#1,mathsmaller#2 exploiting relsize (but the result is ugly nonetheless).
      – egreg
      2 hours ago
















    • I do like it! :-) I had forgotten about this defmycs#1.#2 TeX feature…
      – Rémi Peyre
      2 hours ago










    • I'd consider ensuremath#1,mathsmaller#2 exploiting relsize (but the result is ugly nonetheless).
      – egreg
      2 hours ago















    I do like it! :-) I had forgotten about this defmycs#1.#2 TeX feature…
    – Rémi Peyre
    2 hours ago




    I do like it! :-) I had forgotten about this defmycs#1.#2 TeX feature…
    – Rémi Peyre
    2 hours ago












    I'd consider ensuremath#1,mathsmaller#2 exploiting relsize (but the result is ugly nonetheless).
    – egreg
    2 hours ago




    I'd consider ensuremath#1,mathsmaller#2 exploiting relsize (but the result is ugly nonetheless).
    – egreg
    2 hours ago










    up vote
    1
    down vote













    You might do like this:



    documentclassarticle
    usepackage[T1]fontenc
    usepackage[french]babel
    usepackagesiunitx,relsize

    sisetuplocale=FR

    ExplSyntaxOn
    NewDocumentCommandhnum>SplitArgument1.m

    hnumA#1

    NewDocumentCommandhnumAmm

    num#1
    IfValueT#2hnumB#2

    NewDocumentCommandhnumB>SplitArgument1em

    hnumC#1

    NewDocumentCommandhnumCmm

    ensuremath

    ,mathsmallernum[add-integer-zero=false,output-decimal-marker=].#1
    IfValueT#2timesnume#2


    ExplSyntaxOff

    begindocument

    $hnum0.1,hnum2.3,hnum4.5e10$

    bigskip

    $num0.1;num2.3;num4.5e10$

    enddocument


    However the result is really ugly and difficult to interpret. Much better to use a semicolon.



    enter image description here






    share|improve this answer


























      up vote
      1
      down vote













      You might do like this:



      documentclassarticle
      usepackage[T1]fontenc
      usepackage[french]babel
      usepackagesiunitx,relsize

      sisetuplocale=FR

      ExplSyntaxOn
      NewDocumentCommandhnum>SplitArgument1.m

      hnumA#1

      NewDocumentCommandhnumAmm

      num#1
      IfValueT#2hnumB#2

      NewDocumentCommandhnumB>SplitArgument1em

      hnumC#1

      NewDocumentCommandhnumCmm

      ensuremath

      ,mathsmallernum[add-integer-zero=false,output-decimal-marker=].#1
      IfValueT#2timesnume#2


      ExplSyntaxOff

      begindocument

      $hnum0.1,hnum2.3,hnum4.5e10$

      bigskip

      $num0.1;num2.3;num4.5e10$

      enddocument


      However the result is really ugly and difficult to interpret. Much better to use a semicolon.



      enter image description here






      share|improve this answer
























        up vote
        1
        down vote










        up vote
        1
        down vote









        You might do like this:



        documentclassarticle
        usepackage[T1]fontenc
        usepackage[french]babel
        usepackagesiunitx,relsize

        sisetuplocale=FR

        ExplSyntaxOn
        NewDocumentCommandhnum>SplitArgument1.m

        hnumA#1

        NewDocumentCommandhnumAmm

        num#1
        IfValueT#2hnumB#2

        NewDocumentCommandhnumB>SplitArgument1em

        hnumC#1

        NewDocumentCommandhnumCmm

        ensuremath

        ,mathsmallernum[add-integer-zero=false,output-decimal-marker=].#1
        IfValueT#2timesnume#2


        ExplSyntaxOff

        begindocument

        $hnum0.1,hnum2.3,hnum4.5e10$

        bigskip

        $num0.1;num2.3;num4.5e10$

        enddocument


        However the result is really ugly and difficult to interpret. Much better to use a semicolon.



        enter image description here






        share|improve this answer














        You might do like this:



        documentclassarticle
        usepackage[T1]fontenc
        usepackage[french]babel
        usepackagesiunitx,relsize

        sisetuplocale=FR

        ExplSyntaxOn
        NewDocumentCommandhnum>SplitArgument1.m

        hnumA#1

        NewDocumentCommandhnumAmm

        num#1
        IfValueT#2hnumB#2

        NewDocumentCommandhnumB>SplitArgument1em

        hnumC#1

        NewDocumentCommandhnumCmm

        ensuremath

        ,mathsmallernum[add-integer-zero=false,output-decimal-marker=].#1
        IfValueT#2timesnume#2


        ExplSyntaxOff

        begindocument

        $hnum0.1,hnum2.3,hnum4.5e10$

        bigskip

        $num0.1;num2.3;num4.5e10$

        enddocument


        However the result is really ugly and difficult to interpret. Much better to use a semicolon.



        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 1 hour ago

























        answered 1 hour ago









        egreg

        683k8418193065




        683k8418193065



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f451611%2fformatting-numbers-with-smaller-glyphs-for-decimals%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery