ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Automatic thousands separation in \unit
@ 2019-01-31 12:28 Marco Patzer
  2019-01-31 12:43 ` Otared Kavian
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Patzer @ 2019-01-31 12:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Automatic thousands separation in \unit
  2019-01-31 12:28 Automatic thousands separation in \unit Marco Patzer
@ 2019-01-31 12:43 ` Otared Kavian
  2019-01-31 14:00   ` Clyde Johnston
  2019-02-05 11:22   ` Marco Patzer
  0 siblings, 2 replies; 7+ messages in thread
From: Otared Kavian @ 2019-01-31 12:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1337 bytes --]

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 <lists@homerow.info> 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
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 3054 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Automatic thousands separation in \unit
  2019-01-31 12:43 ` Otared Kavian
@ 2019-01-31 14:00   ` Clyde Johnston
  2019-01-31 14:54     ` Hans Åberg
  2019-02-02 10:59     ` Axel Kielhorn
  2019-02-05 11:22   ` Marco Patzer
  1 sibling, 2 replies; 7+ messages in thread
From: Clyde Johnston @ 2019-01-31 14:00 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'


[-- Attachment #1.1: Type: text/plain, Size: 1877 bytes --]

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 <lists@homerow.info> 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
____________________________________________________________________________
_______

 


[-- Attachment #1.2: Type: text/html, Size: 6166 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Automatic thousands separation in \unit
  2019-01-31 14:00   ` Clyde Johnston
@ 2019-01-31 14:54     ` Hans Åberg
  2019-02-02 10:59     ` Axel Kielhorn
  1 sibling, 0 replies; 7+ messages in thread
From: Hans Åberg @ 2019-01-31 14:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> On 31 Jan 2019, at 15:00, Clyde Johnston <context@couthies.com> 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. 


___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Automatic thousands separation in \unit
  2019-01-31 14:00   ` Clyde Johnston
  2019-01-31 14:54     ` Hans Åberg
@ 2019-02-02 10:59     ` Axel Kielhorn
  1 sibling, 0 replies; 7+ messages in thread
From: Axel Kielhorn @ 2019-02-02 10:59 UTC (permalink / raw)
  To: ntg-context


> Am 31.01.2019 um 15:00 schrieb Clyde Johnston <context@couthies.com>:
> 
> 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

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Automatic thousands separation in \unit
  2019-01-31 12:43 ` Otared Kavian
  2019-01-31 14:00   ` Clyde Johnston
@ 2019-02-05 11:22   ` Marco Patzer
  2019-02-09 20:22     ` Marco Patzer
  1 sibling, 1 reply; 7+ messages in thread
From: Marco Patzer @ 2019-02-05 11:22 UTC (permalink / raw)
  To: ntg-context

On Thu, 31 Jan 2019 13:43:13 +0100
Otared Kavian <otared@gmail.com> wrote:

Sorry for the late response.

> 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
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Automatic thousands separation in \unit
  2019-02-05 11:22   ` Marco Patzer
@ 2019-02-09 20:22     ` Marco Patzer
  0 siblings, 0 replies; 7+ messages in thread
From: Marco Patzer @ 2019-02-09 20:22 UTC (permalink / raw)
  To: ntg-context

On Tue, 5 Feb 2019 12:22:29 +0100
Marco Patzer <lists@homerow.info> wrote:

> Is there a way to hook the \spaceddigits into \unit somehow?

I tried to add \spaceddigits to the \unit command, but it didn't
work. If someone has an idea how to do that, I'd greatly appreciate.

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-02-09 20:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-31 12:28 Automatic thousands separation in \unit Marco Patzer
2019-01-31 12:43 ` Otared Kavian
2019-01-31 14:00   ` Clyde Johnston
2019-01-31 14:54     ` Hans Åberg
2019-02-02 10:59     ` Axel Kielhorn
2019-02-05 11:22   ` Marco Patzer
2019-02-09 20:22     ` Marco Patzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).