ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \unit and french
@ 2012-10-09 19:04 Romain Diss
  2012-10-09 20:01 ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Romain Diss @ 2012-10-09 19:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 733 bytes --]

Hi all,

As you know, the french number format is almost opposite to the english one: 
period and comma have opposite roles.

My question concerns the way to render properly numbers in french with the 
\unit command. I already tried different combinations of 
\setupunit[method=,order=] but I can’t find the right way. I tried even to 
type french or english format as input for \unit but none output is right 
(actually I'd prefer to type french format as \unit input).
Also, when there are "three digits" separators on both sides of the decimal 
point, some method outputs are not consistent.

I attached a not so minimal exemple.

Thanks for any idea to solve this.


-- 
Romain Diss
<romain.diss@yahoo.fr>

[-- Attachment #2: test-unit-02.tex --]
[-- Type: text/x-tex, Size: 3004 bytes --]

\starttext

\startbuffer
\starttabulate[|l|l|l|]
\HL
\NC  \NC \tex{unit} input: french format \NC \NR
\HL
\NC method 0 \NC \setupunits[method=0]\unit{12.345,567 kilogram} --- \unit{12.345,567.89 kilogram} --- \unit{345,567.89 kilogram} \NC \NR
\NC method 1 \NC \setupunits[method=1]\unit{12.345,567 kilogram} --- \unit{12.345,567.89 kilogram} --- \unit{345,567.89 kilogram} \NC \NR
\NC method 2 \NC \setupunits[method=2]\unit{12.345,567 kilogram} --- \unit{12.345,567.89 kilogram} --- \unit{345,567.89 kilogram} \NC \NR
\NC method 3 \NC \setupunits[method=3]\unit{12.345,567 kilogram} --- \unit{12.345,567.89 kilogram} --- \unit{345,567.89 kilogram} \NC \NR
\NC method 4 \NC \setupunits[method=4]\unit{12.345,567 kilogram} --- \unit{12.345,567.89 kilogram} --- \unit{345,567.89 kilogram} \NC \NR
\NC method 5 \NC \setupunits[method=5]\unit{12.345,567 kilogram} --- \unit{12.345,567.89 kilogram} --- \unit{345,567.89 kilogram} \NC \NR
\NC method 6 \NC \setupunits[method=6]\unit{12.345,567 kilogram} --- \unit{12.345,567.89 kilogram} --- \unit{345,567.89 kilogram} \NC \NR
\HL
\stoptabulate

\starttabulate[|l|l|l|]
\HL
\NC  \NC \tex{unit} input: english format \NC \NR
\HL
\NC method 0 \NC \setupunits[method=0]\unit{12,345.567 kilogram} --- \unit{12,345.567,89 kilogram} --- \unit{345.567,89 kilogram} \NC \NR
\NC method 1 \NC \setupunits[method=1]\unit{12,345.567 kilogram} --- \unit{12,345.567,89 kilogram} --- \unit{345.567,89 kilogram} \NC \NR
\NC method 2 \NC \setupunits[method=2]\unit{12,345.567 kilogram} --- \unit{12,345.567,89 kilogram} --- \unit{345.567,89 kilogram} \NC \NR
\NC method 3 \NC \setupunits[method=3]\unit{12,345.567 kilogram} --- \unit{12,345.567,89 kilogram} --- \unit{345.567,89 kilogram} \NC \NR
\NC method 4 \NC \setupunits[method=4]\unit{12,345.567 kilogram} --- \unit{12,345.567,89 kilogram} --- \unit{345.567,89 kilogram} \NC \NR
\NC method 5 \NC \setupunits[method=5]\unit{12,345.567 kilogram} --- \unit{12,345.567,89 kilogram} --- \unit{345.567,89 kilogram} \NC \NR
\NC method 6 \NC \setupunits[method=6]\unit{12,345.567 kilogram} --- \unit{12,345.567,89 kilogram} --- \unit{345.567,89 kilogram} \NC \NR
\HL
\stoptabulate
\stopbuffer

\language[en]
What is expected in french:

\language[fr]
\m{12\,345,567}~kg --- \m{12\,345,567\,89}~kg --- \m{345,567\,89}~kg

\language[en]
What would be expected in english:

\language[fr]
\m{12,345.567}~kg --- \m{12,345.567,89}~kg --- \m{345.567,89}~kg

\stoptabulate

\startsection[title=French language]

  \language[fr]

  \startsubsection[title=Normal order]
  
  \setupunit[order=normal]
  \getbuffer

  \stopsubsection

  \startsubsection[title=Reverse order]
  
  \setupunit[order=reverse]
  \getbuffer

  \stopsubsection

\stopsection

\startsection[title=English language]

  \language[en]

  \startsubsection[title=Normal order]
  
  \setupunit[order=normal]
  \getbuffer

  \stopsubsection

  \startsubsection[title=Reverse order]
  
  \setupunit[order=reverse]
  \getbuffer

  \stopsubsection

\stopsection


\stoptext

[-- Attachment #3: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: \unit and french
  2012-10-09 19:04 \unit and french Romain Diss
@ 2012-10-09 20:01 ` Wolfgang Schuster
  2012-10-09 20:06   ` Wolfgang Schuster
  2012-10-09 20:11   ` Marco Patzer
  0 siblings, 2 replies; 11+ messages in thread
From: Wolfgang Schuster @ 2012-10-09 20:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 09.10.2012 um 21:04 schrieb Romain Diss <romain.diss@yahoo.fr>:

> Hi all,
> 
> As you know, the french number format is almost opposite to the english one: 
> period and comma have opposite roles.
> 
> My question concerns the way to render properly numbers in french with the 
> \unit command. I already tried different combinations of 
> \setupunit[method=,order=] but I can’t find the right way. I tried even to 
> type french or english format as input for \unit but none output is right 
> (actually I'd prefer to type french format as \unit input).
> Also, when there are "three digits" separators on both sides of the decimal 
> point, some method outputs are not consistent.
> 
> I attached a not so minimal exemple.
> 
> Thanks for any idea to solve this.

Can you explain which numbers this should represent:

\m{12\,345,567\,89}~kg
\m{345,567\,89}~kg

Wolfgang
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \unit and french
  2012-10-09 20:01 ` Wolfgang Schuster
@ 2012-10-09 20:06   ` Wolfgang Schuster
  2012-10-09 20:11   ` Marco Patzer
  1 sibling, 0 replies; 11+ messages in thread
From: Wolfgang Schuster @ 2012-10-09 20:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 09.10.2012 um 22:01 schrieb Wolfgang Schuster <wolfgang.schuster@gmail.com>:

> 
> Am 09.10.2012 um 21:04 schrieb Romain Diss <romain.diss@yahoo.fr>:
> 
>> Hi all,
>> 
>> As you know, the french number format is almost opposite to the english one: 
>> period and comma have opposite roles.
>> 
>> My question concerns the way to render properly numbers in french with the 
>> \unit command. I already tried different combinations of 
>> \setupunit[method=,order=] but I can’t find the right way. I tried even to 
>> type french or english format as input for \unit but none output is right 
>> (actually I'd prefer to type french format as \unit input).
>> Also, when there are "three digits" separators on both sides of the decimal 
>> point, some method outputs are not consistent.
>> 
>> I attached a not so minimal exemple.
>> 
>> Thanks for any idea to solve this.
> 
> Can you explain which numbers this should represent:
> 
> \m{12\,345,567\,89}~kg
> \m{345,567\,89}~kg

For get about this but you can try what happens when you don’t add a separator
between the number groups in the decimal parts.

Wolfgang
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \unit and french
  2012-10-09 20:01 ` Wolfgang Schuster
  2012-10-09 20:06   ` Wolfgang Schuster
@ 2012-10-09 20:11   ` Marco Patzer
  2012-10-09 20:29     ` Wolfgang Schuster
  1 sibling, 1 reply; 11+ messages in thread
From: Marco Patzer @ 2012-10-09 20:11 UTC (permalink / raw)
  To: ntg-context

2012-10-09 Wolfgang Schuster:

> Can you explain which numbers this should represent:
> 
> \m{12\,345,567\,89}~kg

12345.56789 kg

> \m{345,567\,89}~kg

345.56789 kg


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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \unit and french
  2012-10-09 20:11   ` Marco Patzer
@ 2012-10-09 20:29     ` Wolfgang Schuster
  2012-10-09 20:40       ` Marco Patzer
  2012-10-09 21:08       ` Romain Diss
  0 siblings, 2 replies; 11+ messages in thread
From: Wolfgang Schuster @ 2012-10-09 20:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 09.10.2012 um 22:11 schrieb Marco Patzer <homerow@lavabit.com>:

> 2012-10-09 Wolfgang Schuster:
> 
>> Can you explain which numbers this should represent:
>> 
>> \m{12\,345,567\,89}~kg
> 
> 12345.56789 kg
> 
>> \m{345,567\,89}~kg
> 
> 345.56789 kg

Thanks but I realized it myself (I guess I need sleep), The problem is that Hans number parser doesn’t check for a separator in the decimal numbers.

Wolfgang
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \unit and french
  2012-10-09 20:29     ` Wolfgang Schuster
@ 2012-10-09 20:40       ` Marco Patzer
  2012-10-09 21:08       ` Romain Diss
  1 sibling, 0 replies; 11+ messages in thread
From: Marco Patzer @ 2012-10-09 20:40 UTC (permalink / raw)
  To: ntg-context

2012-10-09 Wolfgang Schuster:

> The problem is that Hans number parser doesn’t check for a
> separator in the decimal numbers.

If the unit code is being touched maybe you can address this one as
well:

http://article.gmane.org/gmane.comp.tex.context/78251


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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: \unit and french
  2012-10-09 20:29     ` Wolfgang Schuster
  2012-10-09 20:40       ` Marco Patzer
@ 2012-10-09 21:08       ` Romain Diss
  2012-10-10 15:41         ` Sietse Brouwer
  1 sibling, 1 reply; 11+ messages in thread
From: Romain Diss @ 2012-10-09 21:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Le mardi 09 octobre 2012, Wolfgang Schuster a écrit :
> Am 09.10.2012 um 22:11 schrieb Marco Patzer <homerow@lavabit.com>:
> > 2012-10-09 Wolfgang Schuster:
> >> Can you explain which numbers this should represent:
> >> 
> >> \m{12\,345,567\,89}~kg
> > 
> > 12345.56789 kg
> > 
> >> \m{345,567\,89}~kg
> > 
> > 345.56789 kg
> 
> Thanks but I realized it myself (I guess I need sleep), The problem is that
> Hans number parser doesn’t check for a separator in the decimal numbers.
Thanks for the response.

The minimal example was suppose to test three numbers: one with a separator in 
the integer part (12345.567), one with a separator in the decimal part 
(345.56789) and one in both (12345.56789).

Anyway, if one forget the problem of the separator in the decimal part which 
is not handle, none of the 'method=', 'order=' and 'language=' combinations in 
\setupunit make it possible to render a number in the french format (a comma 
as the decimal separator and a thin space for the "three digits" separator).

Any idea to get this work?

-- 
Romain Diss
<romain.diss@yahoo.fr>
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \unit and french
  2012-10-09 21:08       ` Romain Diss
@ 2012-10-10 15:41         ` Sietse Brouwer
  2012-10-10 19:25           ` Romain Diss
  0 siblings, 1 reply; 11+ messages in thread
From: Sietse Brouwer @ 2012-10-10 15:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Romain,

If inputting in the English format is an option, this works:

\setupunit[method=3] % comma as decimal mark, thin space for digits seperator
\units{12,345.00} %--> 12 345,00

The problem is that inputting in the French format does not work:
there seems to be a bug when order=reverse.

% doesn't work, of course: unexpected digits seperator after decimal mark (.)
\setupunit[method=3, order=normal]
\units{12.345,00}

% doesn't work correctly: comma is accepted as decimal mark at parse time,
% but then printed as thin space anyway. ?!?
\setupunit[method=3, order=reverse]
\units{12.345,00} %--> 12,345 00

I hope this helps you a bit.

Kind regards,
Sietse
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \unit and french
  2012-10-10 15:41         ` Sietse Brouwer
@ 2012-10-10 19:25           ` Romain Diss
  2012-10-10 19:51             ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Romain Diss @ 2012-10-10 19:25 UTC (permalink / raw)
  To: ntg-context

Hi,

Thanks for the response.

> If inputting in the English format is an option, this works:
> \setupunit[method=3] % comma as decimal mark, thin space for digits
> seperator \units{12,345.00} %--> 12 345,00
Yes, I confirm it works (with \unit{12,345.00}). I'd prefer inputting in 
french but this should do the job.

> % doesn't work correctly: comma is accepted as decimal mark at parse time,
> % but then printed as thin space anyway. ?!?
> \setupunit[method=3, order=reverse]
> \units{12.345,00} %--> 12,345 00
This one should give what I need. Can someone confirm there is a bug here and 
if so, is it possible to fix it?

Thanks in advance.

-- 
Romain Diss
<romain.diss@yahoo.fr>
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \unit and french
  2012-10-10 19:25           ` Romain Diss
@ 2012-10-10 19:51             ` Wolfgang Schuster
  2012-10-10 20:59               ` Sietse Brouwer
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2012-10-10 19:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 10.10.2012 um 21:25 schrieb Romain Diss <romain.diss@yahoo.fr>:

> Hi,
> 
> Thanks for the response.
> 
>> If inputting in the English format is an option, this works:
>> \setupunit[method=3] % comma as decimal mark, thin space for digits
>> seperator \units{12,345.00} %--> 12 345,00
> Yes, I confirm it works (with \unit{12,345.00}). I'd prefer inputting in 
> french but this should do the job.
> 
>> % doesn't work correctly: comma is accepted as decimal mark at parse time,
>> % but then printed as thin space anyway. ?!?
>> \setupunit[method=3, order=reverse]
>> \units{12.345,00} %--> 12,345 00
> This one should give what I need. Can someone confirm there is a bug here and 
> if so, is it possible to fix it?

It is a bug and I know what’s wrong in the code but you have to wait till next week
when Hans is back from the conference. I going to send then a mail to Hans with
a description of this bug and also the one in Marcos link, both are in the Lua part
of the code and it’s no so easy for me to fix them.

Wolfgang
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \unit and french
  2012-10-10 19:51             ` Wolfgang Schuster
@ 2012-10-10 20:59               ` Sietse Brouwer
  0 siblings, 0 replies; 11+ messages in thread
From: Sietse Brouwer @ 2012-10-10 20:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Sietse wrote:
>> % doesn't work correctly: comma is accepted as decimal mark at parse time,
>> % but then printed as thin space anyway. ?!?
>> \setupunit[method=3, order=reverse]
>> \units{12.345,00} %--> 12,345 00

Wolfgang wrote:
> I going to send then a mail to Hans with
> a description of this bug and also the one in Marcos link, both are in the Lua part
> of the code and it’s no so easy for me to fix them.

Actually, this bug is in the ConTeXt part of the code, in phys-dim.lua:

-\unexpanded\def\digitsfinalcomma          {\digitscommasymbol } %
more for tracing
\unexpanded\def\digitsfinalperiod         {\digitsperiodsymbol} % more
for tracing
\unexpanded\def\digitsintermediatecomma   {\digitscommasymbol } % more
for tracing
-\unexpanded\def\digitsintermediateperiod  {\digitsperiodsymbol} %
more for tracing

+\unexpanded\def\digitsfinalcomma          {\digitsperiodsymbol } %
more for tracing
\unexpanded\def\digitsfinalperiod         {\digitsperiodsymbol} % more
for tracing
\unexpanded\def\digitsintermediatecomma   {\digitscommasymbol } % more
for tracing
+\unexpanded\def\digitsintermediateperiod  {\digitscommasymbol} % more
for tracing

The mistake probably arose because \digitscommasymbol always
corresponds to the intermediate mark (the digits separator), not
always to the comma. I know the name wrong-footed me when I was
reading the code.

Romain: you can make this change in phys-dim.lua (around line 220),
then remake the formats with
context --make cont-en

Then this should work correctly:

    % 3: decimal comma, digits space
    % 4: decimal point, digits space

    % English input (order=normal)
    \setupunits[method=3]
    \unit{11,122.13 micro mol per second} \par
    \setupunits[method=4]
    \unit{21,222.23 micro mol per second} \par

    % French input (order=reverse)
    \setupunits[method=3, order=reverse]
    \unit{31.322,33 micro mol per second} \par
    \setupunits[method=4, order=reverse]
    \unit{41.422,43 micro mol per second} \par

Cheers,
Sietse
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2012-10-10 20:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-09 19:04 \unit and french Romain Diss
2012-10-09 20:01 ` Wolfgang Schuster
2012-10-09 20:06   ` Wolfgang Schuster
2012-10-09 20:11   ` Marco Patzer
2012-10-09 20:29     ` Wolfgang Schuster
2012-10-09 20:40       ` Marco Patzer
2012-10-09 21:08       ` Romain Diss
2012-10-10 15:41         ` Sietse Brouwer
2012-10-10 19:25           ` Romain Diss
2012-10-10 19:51             ` Wolfgang Schuster
2012-10-10 20:59               ` Sietse Brouwer

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).