[NTG-context] Spacing in \unit - SOLVED

Gavin gavinpublic at comcast.net
Thu Oct 13 02:11:32 CEST 2022


Hi Max and Rik

> On Oct 12, 2022, at 4:49 PM, Max Chernoff <mseven at telus.net> 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-5.pdf
Type: application/pdf
Size: 14851 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20221012/0e7aa3f8/attachment-0001.pdf>
-------------- next part --------------


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}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: phys-dim.mkxl
Type: application/octet-stream
Size: 30281 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20221012/0e7aa3f8/attachment-0001.obj>
-------------- next part --------------



More information about the ntg-context mailing list