### Re: [NTG-context] Spacing in \unit - SOLVED

Hans, I made a small mistake in the phys-dim.mkxl file I sent you. I removed a % at the end of lines 469 and 485. Without the %, using alternative=text causes extra space before the unit. A corrected phys-dim.mkxl is attached. Gavin phys-dim.mkxl Description: application/applefile ___ 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 ___

### Re: [NTG-context] Spacing in \unit - SOLVED

Hi Hans, > I'll look into it (with Mikael as some relates to math) once you're done > playing and provide suggestions and tests. I’m done playing. Below are tests and suggestions. Sorry it has taken so long for me to put this together. Tests I attached two test files. The first, units-spacing.tex, is for testing spacing for \unit used in text, inline math, and display math. The second, units-linebreaks.tex, tests line breaks when \unit. is used in text or in inline math. Line breaks were not my primary interest, but Max and Alan were quite interested. My proposed fixes for spacing also fix their concerns about line breaks.I tried to make these tests match the style of the Test Suite. They could be included there if they are useful. Suggestions I attached my my modified phys-dim.mkxl. All of my changes are commented and signed with -GP to make them easy to find. Below are comments on the five issues I addressed (not including line breaks). The first four of these are fixes.I don’t think any of these fixes are controversial or require new options. The fifth, regarding the space around the \times in scientific notation, might be an appropriate option, rather than a universal fix. 1. The \cdot in units should not have space around it. These lines produce the \cdot between units, one is for the default \cdot, the other when the separator=cdot option is used. I’m not entirely sure why they are separate. Now, in math mode, the \cdot is changed to an ord. (ll. 392-393) \protected\def\phys_units_separator {\ifcsname\??unitseparator\unitparameter\c!separator\endcsname\lastnamedcs\else\ifmmode\mathord\cdot\else\cdot\fi\fi} % Made \cdot an "ord" in math mode -GP \installunitsseparator\v!normal{\ifmmode\mathord\cdot\else\cdot\fi} % Made \cdot an "ord" in math mode -GP 2. Space is needed between number and units To get the thin space between the number and the units (ll.412-418) \protected\def\phys_units_space {\ifmmode \thinspace % let the atoms do the work. Right now atoms aren't doing the work, so I put in a \thinspace -GP \else \unskip % weird, why is unskip needed \ifcsname\??unitspace\unitparameter\c!space\endcsname\lastnamedcs\else\unitsmediumspace\fi \fi} 3. Space is needed after the units, before the next relation, binary operator, etc. Right now there seems to be no space added between the new dimension class and the relation and binary operator class. Until the space around the dimension class is fixed, The units should not be assigned to the dimension class, which means removing the code that sets units to this class. (ll. 618-623) \def\phys_units_start {\ifmmode \dostarttagged\t!maction\t!unit % \mathatom % I removed this because the correct spaces after dim haven't been set (e.g. dimbin, dimrel) -GP %\s!leftclass \mathdimensioncode %\s!rightclass \mathdimensioncode \bgroup \else \dostarttagged\t!unit\empty \fi \let\phys_units_finish\phys_units_stop \let\phys_units_start\relax} 4. Remove hardcoded backspace before the solidus in units. (If this space should be tighter, it probably should be dealt with for every solidus, not just the solidus in \unit the unit command.) (ll.412-418) \permanent\protected\def\unitsSOLIDUS {%\ifnum\c_phys_units_state=\plusone % suffix % Removed three lines to eliminate backspace before / -GP % \unitsbackspace %\fi {/}% }%\unitsbackspace} 5. I think the \times in scientific notation should not have extra space. Everyone who commented on the mailing list agreed. However, I’m not sure that this is a universal desire, so it might be good to add an options, like scispace=normal for the usual binop space around the \times and scispace=tight for no extra space around \times. The changed line in phys-dime.mkxl used to add space around the \times in text. Now, instead, it removes the space around the \times in math by making the \times an ord. (ll. 170-172) \permanent\protected\def\digitstextbinop#1% assumes preceding {\ifmmode\mathord#1\else\nobreak#1\fi} % Removed space around binop (\times or \cdot) in \units -GP %{\ifmmode#1\else\fourperemspace\nobreak#1\fourperemspace\fi} % This is the old line with spaces -GP Those are my five suggestions. Thanks for looking at spacing in \units! Gavin units-spacing.tex Description: Binary data units-linebreaks.tex Description: Binary data phys-dim.mkxl Description: Binary data ___ 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 ___

### Re: [NTG-context] Spacing in \unit - SOLVED

On 10/13/2022 1:52 PM, Gavin via ntg-context wrote: Hi Oli, 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. That is a terrific solution that doesn’t require any messing with phys-dim.mkxl. You do not need to define a new unit. I got your result using this line: \setupunits[alternative=text] This fixed the most significant problems with \unit in most situations. I’m still applying some of my solutions as well. I'll look into it (with Mikael as some relates to math) once you're done playing and provide suggestions and tests. 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 ___

### Re: [NTG-context] Spacing in \unit - SOLVED

Hi Oli, > 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. That is a terrific solution that doesn’t require any messing with phys-dim.mkxl. You do not need to define a new unit. I got your result using this line: \setupunits[alternative=text] This fixed the most significant problems with \unit in most situations. I’m still applying some of my solutions as well. Thanks! Gavin ___ 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 ___

### Re: [NTG-context] Spacing in \unit - SOLVED

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 > : > > 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: > > > Output with my modified phys-dim.mkxl: > > > > >> On Oct 10, 2022, at 12:15 AM, Max Chernoff via ntg-context >> 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@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@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 > ___ signature.asc Description: Message signed with OpenPGP ___ 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 ___

### Re: [NTG-context] Spacing in \unit - SOLVED

Hi Max and Rik > On Oct 12, 2022, at 4:49 PM, Max Chernoff wrote: > > This new output looks *much* better than the old one, thanks! Thank you! > My only comment is that the spacing around the multiplication sign looks > a little too tight to me. The original spacing was probably too large, > but I think that a little more space than you currently have would be > better. I haven’t adjusted the space directly. I just changed the \times and \cdot from class binom to class ord. I’m not going to tweak the space. I don’t even use this font. With proportional numbers in Libertinus, I think the \times looks great. PastedGraphic-5.pdf Description: Adobe PDF document With tabular numbers, the \times looks a bit off center due to the extra space around the following 1. >> If anyone wants my changes, either for their own use or to improve the >> distributed phys-dim.mkxl, I’m happy to share. > > Yes, can you please share that to the list? See below for comments, and the full modified phys-dim.mkxl is attached > Hi Rik, > >> It does look like you have introduced additional space before the >> solidus. Was that intentional? > > I believe that that is intentional. From the earlier email: > >> removed an overzealous backspace before division symbols. > > This new spacing looks much more even to me, especially around the > exponents. It was intentional. I didn’t add space. I removed a backspace in the \unit code. Below I list all of my changes to the phys-dim.mkxl code, with some commentary. I have added comments in the code everywhere I made a change, and I signed the changes with -GP, so they are easy to find. Thanks for your encouragement, because my high school physics students certainly do not give a s#!t. I hope some people find this useful! Gavin This used to add space around the \times in text. Now, instead, it removes the space around the \times in math by making the \times an ord. (ll. 170-172) \permanent\protected\def\digitstextbinop#1% assumes preceding {\ifmmode\mathord#1\else\nobreak#1\fi} % Removed space around binop (\times or \cdot) in \units -GP %{\ifmmode#1\else\fourperemspace\nobreak#1\fourperemspace\fi} % This is the old line with spaces -GP These lines produce the \cdot between units, one is for the default \cdot, the other when the separator=cdot option is used. I’m not entirely sure why they are separate. Now, in math mode, the \cdot is changed to an ord. (ll. 392-393 \protected\def\phys_units_separator {\ifcsname\??unitseparator\unitparameter\c!separator\endcsname\lastnamedcs\else\ifmmode\mathord\cdot\else\cdot\fi\fi} % Made \cdot an "ord" in math mode -GP \installunitsseparator\v!normal{\ifmmode\mathord\cdot\else\cdot\fi} % Made \cdot an "ord" in math mode -GP To get the thin space between the number and the units (ll.412-418) \protected\def\phys_units_space {\ifmmode \thinspace % let the atoms do the work. Right now atoms aren't doing the work, so I put in a \thinspace -GP \else \unskip % weird, why is unskip needed \ifcsname\??unitspace\unitparameter\c!space\endcsname\lastnamedcs\else\unitsmediumspace\fi \fi} This had a hardcoded backspace before the solidus. I think it looks better without. Even if this space should be tighter, it probably should be dealt with for every solidus, not just the solidus in \unit the unit command. (ll.412-418) \permanent\protected\def\unitsSOLIDUS {%\ifnum\c_phys_units_state=\plusone % suffix % Removed three lines to eliminate backspace before / -GP % \unitsbackspace %\fi {/}% }%\unitsbackspace} Finally, until the space around the dimension class is fixed, I’m just removing the code that sets units to this class. (ll. 618-623) \def\phys_units_start {\ifmmode \dostarttagged\t!maction\t!unit % \mathatom % I removed this because the correct spaces after dim haven't been set (e.g. dimbin, dimrel) -GP %\s!leftclass \mathdimensioncode %\s!rightclass \mathdimensioncode \bgroup \else \dostarttagged\t!unit\empty \fi \let\phys_units_finish\phys_units_stop \let\phys_units_start\relax} phys-dim.mkxl Description: Binary data ___ 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 ___

### Re: [NTG-context] Spacing in \unit - SOLVED

Hi Gavin, On Wed, 2022-10-12 at 15:54 -0600, Gavin wrote: > 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. This new output looks *much* better than the old one, thanks! My only comment is that the spacing around the multiplication sign looks a little too tight to me. The original spacing was probably too large, but I think that a little more space than you currently have would be better. > If anyone wants my changes, either for their own use or to improve the > distributed phys-dim.mkxl, I’m happy to share. Yes, can you please share that to the list? Hi Rik, > It does look like you have introduced additional space before the > solidus. Was that intentional? I believe that that is intentional. From the earlier email: > removed an overzealous backspace before division symbols. This new spacing looks much more even to me, especially around the exponents. 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 ___

### Re: [NTG-context] Spacing in \unit - SOLVED

On 2022-10-12 17:54, Gavin via ntg-context wrote: 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: Output with my modified phys-dim.mkxl: On Oct 10, 2022, at 12:15 AM, Max Chernoff via ntg-context 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 ___ It does look like you have introduced additional space before the solidus. Was that intentional? -- Rik ___ 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 ___

### Re: [NTG-context] Spacing in \unit - SOLVED

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 Description: Adobe PDF document Output with my modified phys-dim.mkxl: PastedGraphic-2.pdf Description: Adobe PDF document > On Oct 10, 2022, at 12:15 AM, Max Chernoff via ntg-context > 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@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@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 ___