Hi! I'm wondering if there's a way to have automatic thousands separation in the \unit command? \spaceddigits does that, but it doesn't work inside \unit. And using both would be quite verbose to write. Example: \starttext %% no thousands separation \unit{123456789 volt} %% manual thousands separation works \unit{123,456,789 volt} %% automatic thousands separation, but not using \unit \let\spaceddigitsseparator, \spaceddigits{123456789}\,V %% fails, no output \unit{\spaceddigits{123456789} volt} \stoptext Marco
Hi Marco, Can this give what you wish? \define[2]\myunit{\spaceddigits{#1}\unit{#2}} \starttext \myunit{123456789}{volt} \stoptext
On 31 Jan 2019, at 13:28, Marco Patzer
wrote: Hi!
I'm wondering if there's a way to have automatic thousands separation in the \unit command? \spaceddigits does that, but it doesn't work inside \unit. And using both would be quite verbose to write. Example:
\starttext %% no thousands separation \unit{123456789 volt}
%% manual thousands separation works \unit{123,456,789 volt}
%% automatic thousands separation, but not using \unit \let\spaceddigitsseparator, \spaceddigits{123456789}\,V
%% fails, no output \unit{\spaceddigits{123456789} volt} \stoptext
Marco ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
Maybe this should be a language specific parameter. How would you achieve a
similar result with the Indian numbering system
https://en.wikipedia.org/wiki/Indian_numbering_system , for instance?
Also, decimal and thousands separators vary from country to country. In
France, for example, they use the comma for the decimal separator, and space
for the thousand separator.
Clyde
From: ntg-context [mailto:ntg-context-bounces@ntg.nl] On Behalf Of Otared
Kavian
Sent: Thursday, January 31, 2019 2:43 PM
To: mailing list for ConTeXt users
Subject: Re: [NTG-context] Automatic thousands separation in \unit
Hi Marco,
Can this give what you wish?
\define[2]\myunit{\spaceddigits{#1}\unit{#2}}
\starttext
\myunit{123456789}{volt}
\stoptext
On 31 Jan 2019, at 13:28, Marco Patzer
On 31 Jan 2019, at 15:00, Clyde Johnston
wrote: Maybe this should be a language specific parameter. How would you achieve a similar result with the Indian numbering system, for instance?
It is an additional feature that may or may not be linked to language. For example, in Swedish originally, the comma and stop are reversed relative English, but in modern times, a stop for decimal point might be used. To avoid confusion between commas and stops as decimal points there is an recommendation admitting both, using spaces as separators. And in India, they might prefer digit groups of two instead of three.
Also, decimal and thousands separators vary from country to country. In France, for example, they use the comma for the decimal separator, and space for the thousand separator.
Am 31.01.2019 um 15:00 schrieb Clyde Johnston
: Maybe this should be a language specific parameter. How would you achieve a similar result with the Indian numbering system, for instance?
Also, decimal and thousands separators vary from country to country. In France, for example, they use the comma for the decimal separator, and space for the thousand separator.
Clyde
Shouldn’t \spaceddigits use the separator as defined by \setdigitmode and \setdigitorder? Axel
On Thu, 31 Jan 2019 13:43:13 +0100
Otared Kavian
Can this give what you wish?
\define[2]\myunit{\spaceddigits{#1}\unit{#2}} \starttext \myunit{123456789}{volt} \stoptext
That's a way to solve it, yes. But I'd prefer it to be integrated into the \unit command. It looks cleaner and I don't have to modify the sources to use a different command. Is there a way to hook the \spaceddigits into \unit somehow? Marco
participants (5)
-
Axel Kielhorn
-
Clyde Johnston
-
Hans Åberg
-
Marco Patzer
-
Otared Kavian