How to add a new unit for \unit{} command?
![](https://secure.gravatar.com/avatar/1d447477da49fe58e8c66937296c304a.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/1d447477da49fe58e8c66937296c304a.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/b79687264c3e06cba13b54d05b12a9f5.jpg?s=120&d=mm&r=g)
Am 16.10.2013 um 21:21 schrieb Romain Diss
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
![](https://secure.gravatar.com/avatar/1d447477da49fe58e8c66937296c304a.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/b79687264c3e06cba13b54d05b12a9f5.jpg?s=120&d=mm&r=g)
Am 18.10.2013 um 08:35 schrieb Romain Diss
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
![](https://secure.gravatar.com/avatar/1d447477da49fe58e8c66937296c304a.jpg?s=120&d=mm&r=g)
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
participants (3)
-
Marco Patzer
-
Romain Diss
-
Wolfgang Schuster