On 1/27/2022 9:36 AM, Mikael Sundqvist via ntg-context wrote:
Dear all,

While discussing spacing in math with Hans, we have come to the
conclusion that to have better control and cleaner code there might be
a good idea to have more math classes than the usual ones in TeX (ord,
op, bin, rel, open, close, punct, inner (and some that we need not to
think about)).

So far, Hans has implemented frac and rad for fractions and radicals.
The fractions has been a funny construction, being put inside empty
delimiters, and so surrounded by the \nulldelimiterspace (which has
been set to 1.2pt, independent of font size). Now we have better
control of the spacing around fractions.

Hans has opened up (even in the code) for the addition of more
classes. The overall aim is to have a more coherent and logical way of
typing math, without manual adding of (arbitrary) spaces every now and
then. For example, we have always written \int f(x)\, dx to have a
thin space between the closing parenthesis and the d in integrals.
There will (most likely) be a differential class. Since the d might
occur in other places in a formula with integrals, one cannot just
simply give the letter d the differential class, and we are currently
discussing the correct way for the user to type it. If you have
suggestions, please let us hear!

Some further suggestions by Hans are (see below for two more)

13 imaginary
14 differential
15 exponential
16 function

Q1: Do you have any further suggestions on new classes (or comments on
these)? It might be good to think about situations where you have felt
that you need to insert manual spaces such as \, or \! to obtain a
better result.

I give one contribution: I asked a colleague to look in his TeX files
for manual spaces, and he came up with several \, (usually before the
d in integrals) but also with \!. This \! occurred mostly in fencing
situations to have the exponent come a bit closer to the closing
parenthesis.

\left( \frac{x}{2} \right)^{\! k+2n}

I have seen this in many places before, so no originality is claimed.

Two more classes that we thought of are under and over. Say that we
have a\overbar{bc}d. Should the spacing between a and the \overbar{bc}
and the spacing between \overbar{bc} and d always be tight? If so,
these might just be ord, and no new class needed (although one could
argue for adding the classes now, set them up as ord, and thus being
able to configure them according to taste/need).

Q2: Do you have any real examples of constructions with \overbar,
\underbar, \overbrace, ... or if you have any strong opinion, please
raise your voice!
Here is a teaser:

\starttext

% in context we put digits in their own class, the next is the default:

\letmathspacing \mathdigitcode \mathordinarycode \mathordinarycode \mathordinarycode \mathordinarycode

% but we can adapt the inter digit spacing (\mathdigitcode == 20 in context, \mathordinarycode is one fo the traditional class codes):

\setmathspacing \mathdigitcode \mathdigitcode \allmathstyles = 2mu

% and also change it when needed

\startTEXpage[offset=10pt]
    $ x = 1234 = z $\par
    \begingroup
        \setmathspacing \mathdigitcode \mathdigitcode \allmathstyles = 4mu
        $ x = 1234 = z $\par
    \endgroup
    $ x = 1234 = z $\par
\stopTEXpage

\stoptext

The result is attached. So maybe Mikaels explanation above and this example will trigger demand.

One of the possibilities is that users define their own classes and put characters in it. (this can be domain specific and domains is something that has been on the todo for quite a while.)

For that reason we might bump the current number of classes (we have 32 classes compared to the 8 that regular tex has) to 64 (which is possible when we bring down the number of families to 64 (currently 128 compared to 256 in luatex and 16 in regular tex) which is still plenty and way more than we ever need (so if needed we can borrow bits for the math unicode range which is now limited to 0xFFFFF; it was already limited anyway).

This move also makes it possible to remove some other hacks (with the usual 'a pity to throw nice code away syndrome' side effect) and can have some 'initialization of old school ascii' side effects (neglectable because we can set it up via the emacro package).

For the record: the \Umath<class><class>spacing primitives have been dropped but can be emulated easily (in the end it saves hundreds of primitives).

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

Attachment: math.pdf
Description: Adobe PDF document

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to