[NTG-context] Spacing in \unit - SOLVED
Oliver Sieber
context-ml at privly.pm
Thu Oct 13 09:03:29 CEST 2022
Hi Gavin
Thank four your effort. I found out, that the following definition of a new unit, i called it SI, results also in a correct spaceing in the math environment:
\defineunit[SI][alternative=text]
It seems, that the option alternative=text solves the problem with no spaces between value and unit in the math environment.
Maybe this can be used to solve it easier in the code. I will have a look at phys-dim to solve it directly, if I find the time.
Best regards
Oli
> Am 12.10.2022 um 23:54 schrieb Gavin via ntg-context - ntg-context at ntg.nl <ntg-context_at_ntg_nl_vqmpumt at simplelogin.co>:
>
> Hi Max, Alan, Bruce, Hans, et.al
>
> I solved my four issues with \unit spacing. In the process, I prevented unwanted line breaks and removed an overzealous backspace before division symbols. Below is a MWE that shows all of these issues, as well as pictures of the result with the unmodified phys-dim.mkxl and with my modified phys-dim.mkxl. The final result is exactly what I wanted.
>
> If anyone wants my changes, either for their own use or to improve the distributed phys-dim.mkxl, Iām happy to share.
>
> Thanks for all of your comments!
> Gavin
>
>
> MWE:
>
> \setuppapersize[A5]
>
> \starttext
>
> The \type{\unit} command in text produces \unit{1.23e5 kg m^2/s^2}.
>
> Inline math \type{$\unit$} produces $\unit{1.23e5 kg m^2/s^2}$.
>
> Display math produces
> \startformula
> \unit{1.23e5 kg m^2/s^2} + \unit{8.64e5 newton m} = \unit{987,000 joule}
> \stopformula
>
> Line breaking in math:
>
> {\hsize=0pt $G = \unit{6.6743e-11 m3 kg-1 s-2}$}
>
> \blank
> Line breaking in text:
>
> {\hsize=0pt \unit{6.6743e-11 m3 kg-1 s-2}}
>
> \stoptext
>
> Output with unmodified phys-dim.mkxl:
> <PastedGraphic-3.pdf>
>
> Output with my modified phys-dim.mkxl:
> <PastedGraphic-2.pdf>
>
>
>
>> On Oct 10, 2022, at 12:15 AM, Max Chernoff via ntg-context <ntg-context at ntg.nl> wrote:
>>
>> Hi Alan,
>>
>>> I would very strongly argue that the space between the number and the
>>> following units be UNBREAKABLE. Perhaps a thin space (preference), but
>>> most certainly non-breakable.
>>>
>>> Similarly around the times in scientific notation.
>>>
>>> I further cannot imagine that a line break be acceptable around a \cdot
>>> in composite units.
>>>
>>> This can possibly lead to overfill and underfill, something that I find
>>> *infinitely* more acceptable then breaking numbers and units.
>>
>> Yes, I agree completely here.
>>
>>> I do not know or use the \units command. Maybe it uses unbreakable
>>> spaces, maybe not. I would never use it unless it could be configured
>>> to only use nonbreakable spaces.
>>
>> The current behaviour doesn't break the unit from the number, but it
>> does split the scientific notation.
>>
>> This test file:
>>
>> \starttext
>> \hsize=0pt Math: $G = \unit{6.6743e-11 m3 kg-1 s-2}$
>>
>> \hsize=0pt Text: \unit{6.6743e-11 m3 kg-1 s-2}
>> \stoptext
>>
>> gives:
>>
>> Math:
>> šŗ=
>> 6.6743Ć
>> 10ā11m3ā
kgā1ā
sā2
>> Text:
>> 6.6743
>> Ć
>> 10ā11 m3ā
kgā1ā
sā2
>>
>> which isn't great. In my opinion, the \unit command should be typeset in an
>> \hbox (or similar) since I can't think of any circumstances where breaking
>> it would be reasonable.
>>
>> Thanks,
>> -- Max
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context at ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage : https://www.pragma-ade.nl / http://context.aanhet.net
>> archive : https://bitbucket.org/phg/context-mirror/commits/
>> wiki : https://contextgarden.net
>> ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context at ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : https://www.pragma-ade.nl / http://context.aanhet.net
> archive : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> ___________________________________________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20221013/08640127/attachment.sig>
More information about the ntg-context
mailing list