ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Spacing in \unit
@ 2022-09-25 13:30 Gavin via ntg-context
  2022-09-25 15:19 ` Hans Hagen via ntg-context
  2022-09-25 16:31 ` Bruce Horrocks via ntg-context
  0 siblings, 2 replies; 8+ messages in thread
From: Gavin via ntg-context @ 2022-09-25 13:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Gavin

Hello list,

I have a few questions about space produced by the unit command. Consider this MWE

\starttext
\unit{3.00e8 kg m/s}

$\unit{3.00e8 kg m/s}$
\stoptext

The dot between “kg” and “m” has different spacing depending on whether the \unit command is in text or math mode. I think that the tighter spacing in the first one, in text, is correct.

I personally would also like less space around the \times. To me, the number 3.00e8 should be typeset more like a single number, rather than like a product of 3.00 and 10^8. I am probably in the minority here. If \unit and \digit had an option for tighter spacing around the \times, I’d use it, but the current output with more space is probably what most people expect and want. Perhaps something like [scispace=tight].

Finally, \unit does not play nicely with surrounding spaces. For example:

    $2\pi\,\unit{3.00e8 kg m/s}$

causes a fatal error:

tex error       > tex error on line 9 in file ./Untitled.tex: Incompatible glue units (case 1)

<macro> \phys_units_direct 
    #1->\begingroup \the \everyunits \ifdim \lastskip 
    >\zeropoint \settrue \c_phys_units_dospace \removelastskip \fi \c_phys_digits_method \unitparameter \c!method \relax \ifmmode \else \dontleavehmode \fi \edef \currentunit {#1}\always\edef \unitlanguag
<line 3.9> 
    $2\pi\,\unit
    {3.00e8 kg m/s}$

Using \thinspace produces the same fatal error.

Putting the 2\pi after the \unit{…} can also cause surprises.

    $\unit{3.00e8 kg m/s}\times 2\pi$

produces a \times that is right up against the “s”.

I am very happy with all of the work done on spacing in math. I hope that my observations above are helpful in fine-tuning the excellent system.

Thanks!
Gavin

P.S. I am on as M1 Mac, using ConTeXt  ver: 2022.09.11 20:44 LMTX  fmt: 2022.9.25  int: english/english.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spacing in \unit
  2022-09-25 13:30 Spacing in \unit Gavin via ntg-context
@ 2022-09-25 15:19 ` Hans Hagen via ntg-context
  2022-09-25 15:29   ` Gavin via ntg-context
  2022-09-25 16:31 ` Bruce Horrocks via ntg-context
  1 sibling, 1 reply; 8+ messages in thread
From: Hans Hagen via ntg-context @ 2022-09-25 15:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen, Mikael Sundqvist

On 9/25/2022 3:30 PM, Gavin via ntg-context wrote:
> Hello list,
> 
> I have a few questions about space produced by the unit command. Consider this MWE
> 
> \starttext
> \unit{3.00e8 kg m/s}
> 
> $\unit{3.00e8 kg m/s}$
> \stoptext
> 
> The dot between “kg” and “m” has different spacing depending on whether the \unit command is in text or math mode. I think that the tighter spacing in the first one, in text, is correct.
> 
> I personally would also like less space around the \times. To me, the number 3.00e8 should be typeset more like a single number, rather than like a product of 3.00 and 10^8. I am probably in the minority here. If \unit and \digit had an option for tighter spacing around the \times, I’d use it, but the current output with more space is probably what most people expect and want. Perhaps something like [scispace=tight].

that's for the math todo

> Finally, \unit does not play nicely with surrounding spaces. For example:
> 
>      $2\pi\,\unit{3.00e8 kg m/s}$
> 
> causes a fatal error:
> 
> tex error       > tex error on line 9 in file ./Untitled.tex: Incompatible glue units (case 1)
that's an interesting case for the engine (Mixing regular and mu skips 
and so) ... we mighth finaly have a valid case for a primitive zero test

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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 / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spacing in \unit
  2022-09-25 15:19 ` Hans Hagen via ntg-context
@ 2022-09-25 15:29   ` Gavin via ntg-context
  2022-09-25 15:39     ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 8+ messages in thread
From: Gavin via ntg-context @ 2022-09-25 15:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Gavin, Mikael Sundqvist

Hi Hans,

I also just noticed that the space between the number and the unit is missing when I typeset with ConTeXt ver: 2022.09.11 20:44 LMTX fmt: 2022.9.25. This space was present in with the ConTeXt version I was using earlier, from a couple months ago. Thanks for putting it on the math todo list!

Gavin

(I sent the above message to Hans, but failed to cc the mailing list. Sorry if some of you get this twice.)

> On Sep 25, 2022, at 9:19 AM, Hans Hagen <j.hagen@freedom.nl> wrote:
> 
> On 9/25/2022 3:30 PM, Gavin via ntg-context wrote:
>> Hello list,
>> I have a few questions about space produced by the unit command. Consider this MWE
>> \starttext
>> \unit{3.00e8 kg m/s}
>> $\unit{3.00e8 kg m/s}$
>> \stoptext
>> The dot between “kg” and “m” has different spacing depending on whether the \unit command is in text or math mode. I think that the tighter spacing in the first one, in text, is correct.
>> I personally would also like less space around the \times. To me, the number 3.00e8 should be typeset more like a single number, rather than like a product of 3.00 and 10^8. I am probably in the minority here. If \unit and \digit had an option for tighter spacing around the \times, I’d use it, but the current output with more space is probably what most people expect and want. Perhaps something like [scispace=tight].
> 
> that's for the math todo
> 
>> Finally, \unit does not play nicely with surrounding spaces. For example:
>>     $2\pi\,\unit{3.00e8 kg m/s}$
>> causes a fatal error:
>> tex error       > tex error on line 9 in file ./Untitled.tex: Incompatible glue units (case 1)
> that's an interesting case for the engine (Mixing regular and mu skips and so) ... we mighth finaly have a valid case for a primitive zero test
> 
> Hans
> 
> -----------------------------------------------------------------
>                                          Hans Hagen | PRAGMA ADE
>              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>       tel: 038 477 53 69 | www.pragma-ade.nl | 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 / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spacing in \unit
  2022-09-25 15:29   ` Gavin via ntg-context
@ 2022-09-25 15:39     ` Hans Hagen via ntg-context
  0 siblings, 0 replies; 8+ messages in thread
From: Hans Hagen via ntg-context @ 2022-09-25 15:39 UTC (permalink / raw)
  To: Gavin via ntg-context; +Cc: Hans Hagen

On 9/25/2022 5:29 PM, Gavin via ntg-context wrote:
> Hi Hans,
> 
> I also just noticed that the space between the number and the unit is missing when I typeset with ConTeXt ver: 2022.09.11 20:44 LMTX fmt: 2022.9.25. This space was present in with the ConTeXt version I was using earlier, from a couple months ago. Thanks for putting it on the math todo list!
i can probably clean up the code a bit in lmtx ... units are not that 
(rapidly) evolving and much is rather old code so best collect all 
issues and make a test file that mikael and i can use (as wer then do 
math and text at the same time)

maybe we also need to add units (are there new ones anyway?)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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 / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spacing in \unit
  2022-09-25 13:30 Spacing in \unit Gavin via ntg-context
  2022-09-25 15:19 ` Hans Hagen via ntg-context
@ 2022-09-25 16:31 ` Bruce Horrocks via ntg-context
  1 sibling, 0 replies; 8+ messages in thread
From: Bruce Horrocks via ntg-context @ 2022-09-25 16:31 UTC (permalink / raw)
  To: ntg-context mailing list; +Cc: Bruce Horrocks



> On 25 Sep 2022, at 14:30, Gavin via ntg-context <ntg-context@ntg.nl> wrote:
> 
> Hello list,
> 
> I have a few questions about space produced by the unit command. Consider this MWE
> 
> \starttext
> \unit{3.00e8 kg m/s}
> 
> $\unit{3.00e8 kg m/s}$
> \stoptext
> 
> The dot between “kg” and “m” has different spacing depending on whether the \unit command is in text or math mode. I think that the tighter spacing in the first one, in text, is correct.
> 
> I personally would also like less space around the \times. To me, the number 3.00e8 should be typeset more like a single number, rather than like a product of 3.00 and 10^8. I am probably in the minority here. If \unit and \digit had an option for tighter spacing around the \times, I’d use it, but the current output with more space is probably what most people expect and want. Perhaps something like [scispace=tight].

I too would prefer less space around the times e.g. \starttext 3.00×10\high{8} \stoptext is fine (except for the 8 which is nicer in \unit).

—
Bruce Horrocks
Hampshire, UK

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spacing in \unit
  2022-10-10  1:32 ` Alan Braslau via ntg-context
@ 2022-10-10  6:15   ` Max Chernoff via ntg-context
  0 siblings, 0 replies; 8+ messages in thread
From: Max Chernoff via ntg-context @ 2022-10-10  6:15 UTC (permalink / raw)
  To: ntg-context; +Cc: Max Chernoff

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@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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spacing in \unit
  2022-10-08 17:59 Gavin via ntg-context
@ 2022-10-10  1:32 ` Alan Braslau via ntg-context
  2022-10-10  6:15   ` Max Chernoff via ntg-context
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Braslau via ntg-context @ 2022-10-10  1:32 UTC (permalink / raw)
  To: Gavin via ntg-context; +Cc: Alan Braslau

On Sat, 8 Oct 2022 11:59:04 -0600
Gavin via ntg-context <ntg-context@ntg.nl> wrote:

> I’m trying to fix four issues:
>   - No space between the number and the following units. Should be a
> thin space.
>   - No space between the units and the following symbol (+ and =
> above). Should be appropriate “bin" or “rel" space.
>   - Too much space around the \cdot in the units. Should be treated
> like an “ord" when used to separate units.
>   - Too much space around the \times in the scientific notation.
> Should be treated like an "ord" when used in scientific notation.
> (I'm not sure there is consensus on this.)

Gavin (and the mailing list),

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.

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. 

Perhaps others feel differently?

Alan
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Spacing in \unit
@ 2022-10-08 17:59 Gavin via ntg-context
  2022-10-10  1:32 ` Alan Braslau via ntg-context
  0 siblings, 1 reply; 8+ messages in thread
From: Gavin via ntg-context @ 2022-10-08 17:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Gavin

Hi list,

I made a small example with all of the issues I am trying to fix for the \units command. The first formula below uses the \unit command, but produces strange spacing. The second formula produces the desired spacing, without using the \unit command.

\showmakeup[mathglue] %\mathspacingmode=1

\starttext
\startformula
 \unit{1.23e5 kg m^2/s^2} + \unit{8.64e5 W s} = \unit{9.87e5 newton m}
\stopformula
\startformula
 1.23\mathord\times10^5\,{\rm kg\mathord\cdot m^2/s^2} + 8.64\mathord\times10^5\,{\rm W\mathord{\cdot}s} = 9.87\mathord\times10^5\,{\rm N\mathord{\cdot}m}
\stopformula
\stoptext

I’m trying to fix four issues:
  - No space between the number and the following units. Should be a thin space.
  - No space between the units and the following symbol (+ and = above). Should be appropriate “bin" or “rel" space.
  - Too much space around the \cdot in the units. Should be treated like an “ord" when used to separate units.
  - Too much space around the \times in the scientific notation. Should be treated like an "ord" when used in scientific notation. (I'm not sure there is consensus on this.)

Some of these seemed like things I could fix myself, so I dug into phys-dim.mkxl to see what I could do. The good news is that I didn’t break anything. The bad news is that nothing I did seemed to have any effect – including deleting phys-dim.mkxl entirely! I double checked that I was working on the same installation used for typesetting. Is the code used for \unit now somewhere else?

These issues only occur in math mode, and \unit handles comma separators correctly, unlike \digit.

I’d like to get some sort of temporary patch for at least some of these issues, even if I need to write it myself. I use \unit everywhere in physics problems sets for students and in keys that I share other teachers.

Any guidance is appreciated!

Gavin

P.S. I’m working on a more comprehensive test file, but its not ready yet.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-10-10  6:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-25 13:30 Spacing in \unit Gavin via ntg-context
2022-09-25 15:19 ` Hans Hagen via ntg-context
2022-09-25 15:29   ` Gavin via ntg-context
2022-09-25 15:39     ` Hans Hagen via ntg-context
2022-09-25 16:31 ` Bruce Horrocks via ntg-context
2022-10-08 17:59 Gavin via ntg-context
2022-10-10  1:32 ` Alan Braslau via ntg-context
2022-10-10  6:15   ` Max Chernoff via ntg-context

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