[NTG-context] \unit parser ignoring case, in some cases.
Gavin
gavinpublic at comcast.net
Tue Mar 14 17:33:07 CET 2023
Hi Alan, Hans, and List,
> On Mar 13, 2023, at 8:10 PM, Alan Braslau via ntg-context <ntg-context at ntg.nl> wrote:
> On Mon, 13 Mar 2023 15:55:50 -0600 Gavin via ntg-context <ntg-context at ntg.nl> wrote:
>>> you can look at phys-dim and see plenty of short and long keys and
>>> making all case insensitive is asking for troubles
>>
>> Indeed, I would like to make NONE of them case insensitive. But
>> currently, when I register an upper case key (C=coulomb) it messes up
>> the lower case prefix (âcm" gets typeset as Câ¢m). I was expecting the
>> parser to distinguish between the âCâ and âcâ, but it doesnât. Is
>> that intended?
>
> Indeed, \unit{} should allow (and presently does not) K, C, etc.
I agree. I added the following lines to phys-dim.lua, following line 461
C = "coulomb",
K = "kelvin",
N = "newton",
This provided the desired capital shortcuts without compromising the lowercase prefixes. Hans, could we get those added to phys-dim.lua in the distribution? I would be happy to do a more comprehensive search for shortcuts to add, but those are the three I and my collaborators are using now.
Looking at why my \registerunit attempt failed, I found that when you register a unit, both your capitalization, and an all lowercase version are registered. Here is an example, where I register âReTeMâ but \unit{1 retem} also works.
\starttext
\registerunit[unit][ReTeM=myunit]
\setupunittext[myunit=reTeM]
\startformula
\unit{1 ReTeM} = \unit{1 retem} \neq \unit{1 reteM}
\stopformula
\stoptext
The results are case sensitive, so \unit{1 reteM} does not work. The lowercase version is produced for all âlongâ units, but not for shortcuts. (See phys-dim.lua, lines 766-771 where the Lua string function âlowerâ is used.) Perhaps we could use a \registershortcut command that does not get the âlower" treatment. I will look into it some more.
Thanks!
Gavin
P.S. I think there is a spelling error in phys-dim.lua, lines 974-981.
local mapping = {
prefix = "prefixes",
unit = "units",
operator = "operators",
suffixe = "suffixes",
symbol = "symbols",
packaged = "packaged",
}
The key âsuffixeâ should probably be âsuffixâ.
More information about the ntg-context
mailing list