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.

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.

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)

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

    \thinspace % let the atoms do the work. Right now atoms aren't doing the 
work, so I put in a \thinspace -GP
    \unskip % weird, why is unskip needed

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. 

%     \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

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)

 {%\ifnum\c_phys_units_state=\plusone % suffix  % Removed three lines to 
eliminate backspace before / -GP
  %  \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!


Attachment: units-spacing.tex
Description: Binary data

Attachment: units-linebreaks.tex
Description: Binary data

Attachment: phys-dim.mkxl
Description: Binary data

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

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

Reply via email to