ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Suggestions for more math classes?
@ 2022-01-27  8:36 Mikael Sundqvist via ntg-context
  2022-01-27 18:43 ` Hans Hagen via ntg-context
  2022-02-16 14:29 ` Gavin via ntg-context
  0 siblings, 2 replies; 4+ messages in thread
From: Mikael Sundqvist via ntg-context @ 2022-01-27  8:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Mikael Sundqvist

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!

/Mikael
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Suggestions for more math classes?
  2022-01-27  8:36 Suggestions for more math classes? Mikael Sundqvist via ntg-context
@ 2022-01-27 18:43 ` Hans Hagen via ntg-context
  2022-02-16 14:29 ` Gavin via ntg-context
  1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen via ntg-context @ 2022-01-27 18:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

[-- Attachment #1: Type: text/plain, Size: 4904 bytes --]

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 #2: math.pdf --]
[-- Type: application/pdf, Size: 9577 bytes --]

[-- Attachment #3: Type: text/plain, Size: 493 bytes --]

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

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

* Re: Suggestions for more math classes?
  2022-01-27  8:36 Suggestions for more math classes? Mikael Sundqvist via ntg-context
  2022-01-27 18:43 ` Hans Hagen via ntg-context
@ 2022-02-16 14:29 ` Gavin via ntg-context
  2022-02-16 15:14   ` Hans Hagen via ntg-context
  1 sibling, 1 reply; 4+ messages in thread
From: Gavin via ntg-context @ 2022-02-16 14:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Gavin, Mikael Sundqvist

Hi Mikael,

A while back you asked the list about math class ideas.

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

Three things came to mind:

1) Units, where I use:
     \, to separate units from the number
     \rm to get the text font
     \!\cdot\!  to get something like kg•m/s

2) Digits, where I use {,} to get a thousands separator

3) Chemical equations, which seem to be in their own strange world right now

Thanks for working on CoTeXt math!

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

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

* Re: Suggestions for more math classes?
  2022-02-16 14:29 ` Gavin via ntg-context
@ 2022-02-16 15:14   ` Hans Hagen via ntg-context
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen via ntg-context @ 2022-02-16 15:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

[-- Attachment #1: Type: text/plain, Size: 1696 bytes --]

On 2/16/2022 3:29 PM, Gavin via ntg-context wrote:
> Hi Mikael,
> 
> A while back you asked the list about math class ideas.
> 
>> 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.
> 
> Three things came to mind:
> 
> 1) Units, where I use:
>       \, to separate units from the number
>       \rm to get the text font
>       \!\cdot\!  to get something like kg•m/s

there is a units module (always has been, but it moved to the physics 
domain)

> 2) Digits, where I use {,} to get a thousands separator

idem, there are mechanisms for that (independent of math)

> 3) Chemical equations, which seem to be in their own strange world right now

that belongs in the chemical modules (i probably need to check 
prescritps and spacing there)

> Thanks for working on CoTeXt math!
attached a teaser that abuses digit classes ... there is now (on our 
machines) a rather extensive mechasm for pairing classes (of any kind), 
inheritance, penalties, edge slack handling, native integrals (large 
operators), optimized linebreaks wrt math, scaled fenced stuff breaking 
across line

(we're now ironing out some crazy symbols that no one ever bothered 
about but that annoy us)

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 #2: demo.pdf --]
[-- Type: application/pdf, Size: 19488 bytes --]

[-- Attachment #3: Type: text/plain, Size: 493 bytes --]

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

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

end of thread, other threads:[~2022-02-16 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27  8:36 Suggestions for more math classes? Mikael Sundqvist via ntg-context
2022-01-27 18:43 ` Hans Hagen via ntg-context
2022-02-16 14:29 ` Gavin via ntg-context
2022-02-16 15:14   ` Hans Hagen 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).