\unit problem with powers of ten.
Hi all,
I got some problems to express powers of ten in the \unit command. See the
strange behaviour with these two minimal examples.
\starttext
\unit{10^2 meter}\\
\unit{10^{-12} second}
\stoptext
However, there is no problem with this one: \unit{1e-4 kilogram}.
Is this a bug or are these expressions not supported?
Thanks.
--
Romain Diss
Le lundi 19 novembre 2012, Romain Diss a écrit :
I got some problems to express powers of ten in the \unit command. See the strange behaviour with these two minimal examples.
\starttext \unit{10^2 meter}\\ \unit{10^{-12} second} \stoptext Is this a bug or are these expressions not supported?
I'm not an expert neither in TeX nor Lua, but I quickly glance at the source
code (phys-dim.*) and here is what I understand:
— the brackets { } are not recognized (a comment in the lua code mentioned
it), so \unit{10^{-12} second} should be \unit{10^-12 second};
— the hat sign '^' is recognized as 'e' so it means "… times ten to the
power…" instead of "to the power…" as one should expect.
So I come back to my problem. I want to write 10⁻¹² s (ten to the negative
twelfth power second). Actually, I'm typing \math{10^{-12} \unit{second}} but
I'd prefer to type \unit{10^-12 second} (for coherence). Is it possible to
modify phys-dim.lua in that way or is this to much work (I have no idea if
this is a matter of changing one line or a hundred lines in phys-dim.lua.
Maybe also this is a too specific request, I don't know…
Anyway, thank you in advance.
All the best.
--
Romain Diss
Hi all, Le mardi 20 novembre 2012, Romain Diss a écrit :
Le lundi 19 novembre 2012, Romain Diss a écrit :
I got some problems to express powers of ten in the \unit command. See the strange behaviour with these two minimal examples.
\starttext \unit{10^2 meter}\\ \unit{10^{-12} second} \stoptext Is this a bug or are these expressions not supported?
I'm not an expert neither in TeX nor Lua, but I quickly glance at the source code (phys-dim.*) and here is what I understand: — the brackets { } are not recognized (a comment in the lua code mentioned it), so \unit{10^{-12} second} should be \unit{10^-12 second}; — the hat sign '^' is recognized as 'e' so it means "… times ten to the power…" instead of "to the power…" as one should expect.
So I come back to my problem. I want to write 10⁻¹² s (ten to the negative twelfth power second). Actually, I'm typing \math{10^{-12} \unit{second}} but I'd prefer to type \unit{10^-12 second} (for coherence). Is it possible to modify phys-dim.lua in that way or is this to much work (I have no idea if this is a matter of changing one line or a hundred lines in phys-dim.lua. Maybe also this is a too specific request, I don't know…
Nobody seems very enthusiastic concerning this thread so I tried to go further
in the comprehension of the phys-dim.lua code. I now have found an approximate
solution to my problem :
\unit{$10^{-12}$ second}
give the right result. It is not very satisfactory because I'm now used to use
\m{} instead of $ $. In the phys-dim.lua code, the line 64 shows that \m{} can
be used inside \unit{} but this doesn't work for:
\unit{\m{10^{-12}} second}
because the pattern doesn't handle nested curly braces.
Is there any Lua expert to find a pattern to handle exponents?
Thank you.
--
Romain Diss
At least me have seen your post and tried some solutions, but nothing
useful....
On Thu, Nov 22, 2012 at 3:45 PM, Romain Diss
Hi all,
Le mardi 20 novembre 2012, Romain Diss a écrit :
Le lundi 19 novembre 2012, Romain Diss a écrit :
I got some problems to express powers of ten in the \unit command. See the strange behaviour with these two minimal examples.
\starttext \unit{10^2 meter}\\ \unit{10^{-12} second} \stoptext Is this a bug or are these expressions not supported?
I'm not an expert neither in TeX nor Lua, but I quickly glance at the source code (phys-dim.*) and here is what I understand: — the brackets { } are not recognized (a comment in the lua code mentioned it), so \unit{10^{-12} second} should be \unit{10^-12 second}; — the hat sign '^' is recognized as 'e' so it means "… times ten to the power…" instead of "to the power…" as one should expect.
So I come back to my problem. I want to write 10⁻¹² s (ten to the negative twelfth power second). Actually, I'm typing \math{10^{-12} \unit{second}} but I'd prefer to type \unit{10^-12 second} (for coherence). Is it possible to modify phys-dim.lua in that way or is this to much work (I have no idea if this is a matter of changing one line or a hundred lines in phys-dim.lua. Maybe also this is a too specific request, I don't know…
Nobody seems very enthusiastic concerning this thread so I tried to go further in the comprehension of the phys-dim.lua code. I now have found an approximate solution to my problem : \unit{$10^{-12}$ second} give the right result. It is not very satisfactory because I'm now used to use \m{} instead of $ $. In the phys-dim.lua code, the line 64 shows that \m{} can be used inside \unit{} but this doesn't work for: \unit{\m{10^{-12}} second} because the pattern doesn't handle nested curly braces.
Is there any Lua expert to find a pattern to handle exponents?
Thank you.
-- Romain Diss
___________________________________________________________________________________ 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
___________________________________________________________________________________
-- luigi
On 11/19/2012 11:44 PM, Romain Diss wrote:
Hi all,
I got some problems to express powers of ten in the \unit command. See the strange behaviour with these two minimal examples.
\starttext \unit{10^2 meter}\\ \unit{10^{-12} second} \stoptext
However, there is no problem with this one: \unit{1e-4 kilogram}.
Is this a bug or are these expressions not supported?
not supported .. i've added it to the upcoming beta: \starttext \startlines \unit{10^12 meter} \unit{10^{-12} second} \unit{10^{12} second} \unit{10e12 meter} \unit{10e{-12} second} \unit{10e{12} second} \stoplines \stoptext needs testing as usual (and wiki adaption as well) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
needs testing as usual (and wiki adaption as well)
http://wiki.contextgarden.net/Command/unit
Wiki: adapted. (Page created, actually, as there was none.) Using the
fancy-schmancy {{since|2012|text=nov 2012}} template, which (1) marks
this as a recent feature, and as such not in the stable yet, and
(2) sticks it in the hidden categories [Since] and [Since 2012], so
that we may review (and remove) those tags when the new stable comes
out next year.
--Sietse
On Thu, Nov 22, 2012 at 7:09 PM, Hans Hagen
On 11/19/2012 11:44 PM, Romain Diss wrote:
Hi all,
I got some problems to express powers of ten in the \unit command. See the strange behaviour with these two minimal examples.
\starttext \unit{10^2 meter}\\ \unit{10^{-12} second} \stoptext
However, there is no problem with this one: \unit{1e-4 kilogram}.
Is this a bug or are these expressions not supported?
not supported .. i've added it to the upcoming beta:
\starttext
\startlines \unit{10^12 meter} \unit{10^{-12} second} \unit{10^{12} second} \unit{10e12 meter} \unit{10e{-12} second} \unit{10e{12} second} \stoplines
\stoptext
needs testing as usual (and wiki adaption as well)
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
___________________________________________________________________________________ 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 ___________________________________________________________________________________
Hi, Le jeudi 22 novembre 2012, Hans Hagen a écrit :
On 11/19/2012 11:44 PM, Romain Diss wrote:
Hi all,
I got some problems to express powers of ten in the \unit command. See the strange behaviour with these two minimal examples.
\starttext \unit{10^2 meter}\\ \unit{10^{-12} second} \stoptext Is this a bug or are these expressions not supported?
not supported .. i've added it to the upcoming beta: Thank you very much.
needs testing as usual (and wiki adaption as well) I have upgraded my context version few minutes ago: $ context --version mtx-context | ConTeXt Process Management 0.60 mtx-context | current version: 2012.11.23 17:35
but your following code doesn't work completely:
\starttext
\startlines \unit{10^12 meter} \unit{10^{-12} second} \unit{10^{12} second} \unit{10e12 meter} \unit{10e{-12} second} \unit{10e{12} second} \stoplines
\stoptext
The '^' and 'e' all print a '10 ×' at the begining. It's what is expected for
'e' but not for '^'. Did I miss something?
--
Romain Diss
On 11/23/2012 8:25 PM, Romain Diss wrote:
Hi,
Le jeudi 22 novembre 2012, Hans Hagen a écrit :
On 11/19/2012 11:44 PM, Romain Diss wrote:
Hi all,
I got some problems to express powers of ten in the \unit command. See the strange behaviour with these two minimal examples.
\starttext \unit{10^2 meter}\\ \unit{10^{-12} second} \stoptext Is this a bug or are these expressions not supported?
not supported .. i've added it to the upcoming beta: Thank you very much.
needs testing as usual (and wiki adaption as well) I have upgraded my context version few minutes ago: $ context --version mtx-context | ConTeXt Process Management 0.60 mtx-context | current version: 2012.11.23 17:35
but your following code doesn't work completely:
\starttext
\startlines \unit{10^12 meter} \unit{10^{-12} second} \unit{10^{12} second} \unit{10e12 meter} \unit{10e{-12} second} \unit{10e{12} second} \stoplines
\stoptext
The '^' and 'e' all print a '10 ×' at the begining. It's what is expected for 'e' but not for '^'. Did I miss something?
well, until now ^ and e were equivalent so if that has to change (say ^ no 10) then there need to be agreement about this as it's an incompatible change i only added support for {..} ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
The '^' and 'e' all print a '10 ×' at the begining. It's what is expected for 'e' but not for '^'. Did I miss something?
well, until now ^ and e were equivalent so if that has to change (say ^ no 10) then there need to be agreement about this as it's an incompatible change
I, for one, would expect 2^3 to mean '2 cubed', not 2x10^3. So I'd be in favour of this change. Then again, I have no code that depends on the old meaning... --Sietse P.s. Isn't MkIV known to be unstable? I thought the official advice was "If you want stability, use (a) MkII, or (b) a stable version of MkIV, or (c) a dedicated standalone install that you do not update.
Le samedi 24 novembre 2012, Sietse Brouwer a écrit :
The '^' and 'e' all print a '10 ×' at the begining. It's what is expected for 'e' but not for '^'.
well, until now ^ and e were equivalent so if that has to change (say ^ no 10) then there need to be agreement about this as it's an incompatible change
I, for one, would expect 2^3 to mean '2 cubed', not 2x10^3. So I'd be in favour of this change. Then again, I have no code that depends on the old meaning... Of course, I'm also in favour of 2^3 to mean '2 cubed'.
--
Romain Diss
On 11/24/2012 1:48 AM, Sietse Brouwer wrote:
The '^' and 'e' all print a '10 ×' at the begining. It's what is expected for 'e' but not for '^'. Did I miss something?
well, until now ^ and e were equivalent so if that has to change (say ^ no 10) then there need to be agreement about this as it's an incompatible change
I, for one, would expect 2^3 to mean '2 cubed', not 2x10^3. So I'd be in favour of this change. Then again, I have no code that depends on the old meaning...
interesting so then we need a list of more ^2 ^3 ^4 ^5 ... and what about ^1.2 then, what will be the escape for the texlike 2^3? maybe $2^3$, so $ will leave scanning mode the 2^3 is probably not used that much
--Sietse
P.s. Isn't MkIV known to be unstable? I thought the official advice was "If you want stability, use (a) MkII, or (b) a stable version of MkIV, or (c) a dedicated standalone install that you do not update.
so you want instability to be a leading design principle ... i'll think about it Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Le samedi 24 novembre 2012, Hans Hagen a écrit :
On 11/24/2012 1:48 AM, Sietse Brouwer wrote:
The '^' and 'e' all print a '10 ×' at the begining. It's what is expected for 'e' but not for '^'. Did I miss something?
well, until now ^ and e were equivalent so if that has to change (say ^ no 10) then there need to be agreement about this as it's an incompatible change
I, for one, would expect 2^3 to mean '2 cubed', not 2x10^3. So I'd be in favour of this change. Then again, I have no code that depends on the old meaning...
interesting so then we need a list of more ^2 ^3 ^4 ^5 ... and what about ^1.2 I don't know everyone's use of \units but for physicists I think that the only case where it should be usefull is for 10^something (like \unit{10^-12 second} ;). Maybe the informaticians need 2^something… The other cases are probably marginals.
then, what will be the escape for the texlike 2^3? maybe $2^3$, so $ will leave scanning mode That's already working and this should be the way when one need something unusual. Maybe a support for \m{} should be usefull for those who do not use $...$ anymore. For the moment nested curly brackets aren't supported inside a \m{} which himself is inside a \unit{}.
All the best.
--
Romain Diss
participants (4)
-
Hans Hagen
-
luigi scarso
-
Romain Diss
-
Sietse Brouwer