ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to add a new unit for \unit{} command?
@ 2013-10-16 11:57 Romain Diss
  2013-10-16 12:47 ` Marco Patzer
  0 siblings, 1 reply; 7+ messages in thread
From: Romain Diss @ 2013-10-16 11:57 UTC (permalink / raw)
  To: ntg-context

Hi all,

I want to add new units to the \unit{} command but I can't find how to do it. I 
found that one can changes existing units with the following luacode:
languages.data.labels.units.whatever = {Meter  = "retem"}
but I found nothing to add new ones.

I would like to have, for exemple:
\unit{50 milli volt per division} to  give: 50 mV/div. 

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] 7+ messages in thread

* Re: How to add a new unit for \unit{} command?
  2013-10-16 11:57 How to add a new unit for \unit{} command? Romain Diss
@ 2013-10-16 12:47 ` Marco Patzer
  2013-10-16 19:21   ` Romain Diss
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Patzer @ 2013-10-16 12:47 UTC (permalink / raw)
  To: ntg-context


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

On 2013–10–16 Romain Diss wrote:

> I would like to have, for exemple:
> \unit{50 milli volt per division} to  give: 50 mV/div. 

  \registerunit [division=div]


Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: 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] 7+ messages in thread

* Re: How to add a new unit for \unit{} command?
  2013-10-16 12:47 ` Marco Patzer
@ 2013-10-16 19:21   ` Romain Diss
  2013-10-17  4:40     ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Romain Diss @ 2013-10-16 19:21 UTC (permalink / raw)
  To: ntg-context

Hi,

Le mercredi 16 octobre 2013 14:47:11 Marco Patzer a écrit :
> On 2013–10–16 Romain Diss wrote:
> > I would like to have, for exemple:
> > \unit{50 milli volt per division} to  give: 50 mV/div.
> 
>   \registerunit [division=div]
Thank you.
It was in fact in a comment in 'phys-dim.mkiv' but I didn't saw it.

This lead to another question linked to these comments in 'phys-dim.mkiv'…

Technically, what's the difference between:
\registerunit[unit][division=div]
and
\registerunit[unit][division=division]
\setupunittext[division=div]
?


-- 
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] 7+ messages in thread

* Re: How to add a new unit for \unit{} command?
  2013-10-16 19:21   ` Romain Diss
@ 2013-10-17  4:40     ` Wolfgang Schuster
  2013-10-18  6:35       ` Romain Diss
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2013-10-17  4:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

> Hi,
> 
> Le mercredi 16 octobre 2013 14:47:11 Marco Patzer a écrit :
>> On 2013–10–16 Romain Diss wrote:
>>> I would like to have, for exemple:
>>> \unit{50 milli volt per division} to  give: 50 mV/div.
>> 
>>  \registerunit [division=div]
> Thank you.
> It was in fact in a comment in 'phys-dim.mkiv' but I didn't saw it.
> 
> This lead to another question linked to these comments in 'phys-dim.mkiv'…
> 
> Technically, what's the difference between:
> \registerunit[unit][division=div]

When you use your new unit "div” is printed because there is no label entry and context prints only the text as fallback.

> and
> \registerunit[unit][division=division]
> \setupunittext[division=div]

Context looks for language dependent value of “division” and prints the value from the unittext entry, with this method you can also set different texts for different languages.

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] 7+ messages in thread

* Re: How to add a new unit for \unit{} command?
  2013-10-17  4:40     ` Wolfgang Schuster
@ 2013-10-18  6:35       ` Romain Diss
  2013-10-18  6:39         ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Romain Diss @ 2013-10-18  6:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Le jeudi 17 octobre 2013 06:40:21 Wolfgang Schuster a écrit :
>> \registerunit[unit][division=division]
>> \setupunittext[division=div]
> Context looks for language dependent value of "division"
> and prints the value from the unittext entry, with this method you can also
> set different texts for different languages.
Thank you for these precisions.

Actually this feature interests me because I wondered how to translate certain
unit labels, like for example:
\unit{2 day} gives: "2 d" but I would like it to gives "2 j" in french.

So if I type this:
\setupunittext[day=j]
I get the correct translation but how can I tell Context that this is the
translation for 'french' only?

-- 
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] 7+ messages in thread

* Re: How to add a new unit for \unit{} command?
  2013-10-18  6:35       ` Romain Diss
@ 2013-10-18  6:39         ` Wolfgang Schuster
  2013-10-18  9:27           ` Romain Diss
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2013-10-18  6:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 18.10.2013 um 08:35 schrieb Romain Diss <romain.diss@yahoo.fr>:

> Le jeudi 17 octobre 2013 06:40:21 Wolfgang Schuster a écrit :
>>> \registerunit[unit][division=division]
>>> \setupunittext[division=div]
>> Context looks for language dependent value of "division"
>> and prints the value from the unittext entry, with this method you can also
>> set different texts for different languages.
> Thank you for these precisions.
> 
> Actually this feature interests me because I wondered how to translate certain
> unit labels, like for example:
> \unit{2 day} gives: "2 d" but I would like it to gives "2 j" in french.
> 
> So if I type this:
> \setupunittext[day=j]
> I get the correct translation but how can I tell Context that this is the
> translation for 'french' only?

You can use the first optional argument for the language specifier, e.g.

\setupunittext[en][day=d]
\setupunittext[fr][day=j]

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] 7+ messages in thread

* Re: How to add a new unit for \unit{} command?
  2013-10-18  6:39         ` Wolfgang Schuster
@ 2013-10-18  9:27           ` Romain Diss
  0 siblings, 0 replies; 7+ messages in thread
From: Romain Diss @ 2013-10-18  9:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Le vendredi 18 octobre 2013 08:39:17 Wolfgang Schuster a écrit :
> > So if I type this:
> > \setupunittext[day=j]
> > I get the correct translation but how can I tell Context that this is the
> > translation for 'french' only?
> 
> You can use the first optional argument for the language specifier, e.g.
> 
> \setupunittext[en][day=d]
> \setupunittext[fr][day=j]
Thanks.
I was not able to figure it out from the source but it was obvious in fact and 
I should have tried first...

-- 
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] 7+ messages in thread

end of thread, other threads:[~2013-10-18  9:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-16 11:57 How to add a new unit for \unit{} command? Romain Diss
2013-10-16 12:47 ` Marco Patzer
2013-10-16 19:21   ` Romain Diss
2013-10-17  4:40     ` Wolfgang Schuster
2013-10-18  6:35       ` Romain Diss
2013-10-18  6:39         ` Wolfgang Schuster
2013-10-18  9:27           ` Romain Diss

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