latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
243 stars 28 forks source link

New symbol alphabets commands reset the math class to 0 #409

Closed bgvoisin closed 6 years ago

bgvoisin commented 6 years ago

The new symbol alphabet commands such as \symbf seem to reset the math class to the default, 0 (ordinary). As a consequence the spacing of the output is wrong when \symbf is applied to an operator or a relation. Take $\symbf{a}\symbf{\cdot}\symbf{b}$ which doesn't come out right, and need to be replaced by $\symbf{a}\mathbin{\symbf{\cdot}}\symbf{b}$ I noticed that as a long-time user of \boldsymbol (from the amsmath package) and \bm (from the bm package), which do preserve the class.

See more examples in the attachment. (It uses the Lucida OpenType fonts which are non-free, sorry: this is in order to get an OT math font existing in both regular and bold versions, for comparison with \boldsymbol.)

mathclasstest.zip

davidcarlisle commented 6 years ago

\symbf works by translating the supplied character to a bold character in the Unicode math alphanumerics block It should probably warn (or give an error?) if given anything else, such as \cdot. so \symbf{\cdot} at best would be the same as \cdot but it does seem to be equivalent to {\cdot}` currently which probably means some {} should be \begingroup \endgroup, somewhere... although giving an errror and not outputting at all would be another option.

David

On 5 October 2017 at 08:24, bgvoisin notifications@github.com wrote:

The new symbol alphabet commands such as \symbf seem to reset the math class to the default, 0 (ordinary). As a consequence the spacing of the output is wrong when \symbf is applied to an operator or a relation. Take $\symbf{a}\symbf{\cdot}\symbf{b}$ which doesn't come out right, and need to be replaced by $\symbf{a}\mathbin{\symbf{\cdot}}\symbf{b}$ I noticed that as a long-time user of \boldsymbol (from the amsmath package) and \bm (from the bm package), which do preserve the class.

See more examples in the attachment. (It uses the Lucida OpenType fonts which are non-free, sorry: this is in order to get an OT math font existing in both regular and bold versions, for comparison with \boldsymbol.)

mathclasstest.zip https://github.com/wspr/unicode-math/files/1358323/mathclasstest.zip

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wspr/unicode-math/issues/409, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNcAh4yana_869ibYQZMzqi8_aNobqaks5spIQZgaJpZM4PuqGU .

bgvoisin commented 6 years ago

Thanks for the clarification, about \symbf and the like being only meant for alphanumeric characters.

This is precisely what I was looking at, after realizing the difference between \symbf{\cdot} (ie small dot) and \boldsymbol{\cdot} (ie bigger dot) in my example. I had not realized before, that the Unicode math blocks for different weights and shapes included only alphanumeric characters, hence that \symbf{\cdot} was identical to {\cdot}.

So right now when your message arrived I was looking at section II.H of the doc unicode-math.pdf, trying to understand the difference between math alphabets and styles (so far it's still fuzzy), to figure out where the named ranges are defined (apparently it's in lines 500 ff. of unicode-math.sty, with \usv_set:nnn{it}{Latin}{"1D434} and the like), and finally to figure out whether there's provision for a command to say: if a given named character (say \cdot) doesn't exist in the alphanumeric range for a given alphabet (say bf), take it, for this alphabet, from that given version (say bold) of the font, and only if that version isn't found then revert to the default alphabet (ie up).

By the way, are there still plans for bmx.sty, or did it turn out to be a dead end?

Bruno

On 5 Oct 2017, at 15:04, David Carlisle notifications@github.com wrote:

\symbf works by translating the supplied character to a bold character in the Unicode math alphanumerics block It should probably warn (or give an error?) if given anything else, such as \cdot. so \symbf{\cdot} at best would be the same as \cdot but it does seem to be equivalent to {\cdot}` currently which probably means some {} should be \begingroup \endgroup, somewhere... although giving an errror and not outputting at all would be another option.

David

On 5 October 2017 at 08:24, bgvoisin notifications@github.com wrote:

The new symbol alphabet commands such as \symbf seem to reset the math class to the default, 0 (ordinary). As a consequence the spacing of the output is wrong when \symbf is applied to an operator or a relation. Take $\symbf{a}\symbf{\cdot}\symbf{b}$ which doesn't come out right, and need to be replaced by $\symbf{a}\mathbin{\symbf{\cdot}}\symbf{b}$ I noticed that as a long-time user of \boldsymbol (from the amsmath package) and \bm (from the bm package), which do preserve the class.

See more examples in the attachment. (It uses the Lucida OpenType fonts which are non-free, sorry: this is in order to get an OT math font existing in both regular and bold versions, for comparison with \boldsymbol.)

mathclasstest.zip https://github.com/wspr/unicode-math/files/1358323/mathclasstest.zip

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wspr/unicode-math/issues/409, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNcAh4yana_869ibYQZMzqi8_aNobqaks5spIQZgaJpZM4PuqGU .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

davidcarlisle commented 6 years ago

On 5 October 2017 at 14:29, bgvoisin notifications@github.com wrote:

Thanks for the clarification, about \symbf and the like being only meant for alphanumeric characters.

This is precisely what I was looking at, after realizing the difference between \symbf{\cdot} (ie small dot) and \boldsymbol{\cdot} (ie bigger dot) in my example. I had not realized before, that the Unicode math blocks for different weights and shapes included only alphanumeric characters, hence that \symbf{\cdot} was identical to {\cdot}.

So right now when your message arrived I was looking at section II.H of the doc unicode-math.pdf, trying to understand the difference between math alphabets and styles (so far it's still fuzzy),

an easy way to see which characters are in each of the math alphabets is to look at the pages linked from section 4 of:

https://w3c.github.io/xml-entities/#alphabets

to figure out where the named ranges are defined (apparently it's in lines 500 ff. of unicode-math.sty, with \usv_set:nnn{it}{Latin}{"1D434} and the like), and finally to figure out whether there's provision for a command to say: if a given named character (say \cdot) doesn't exist in the alphanumeric range for a given alphabet (say bf), take it, for this alphabet, from that given version (say bold) of the font, and only if that version isn't found then revert to the default alphabet (ie up).

up to Will, but that's essentially saying \symbf {\foo} if defined else \mathbf{\foo}if there is a bold font or \foo otherwise, not sure if that will help the end user or make an already confusing situation more confusing.

By the way, are there still plans for bmx.sty, or did it turn out to be a dead end?

I have somewhere a version of bm that works with classic fonts with luatex (that is just avoids the "interesting" syntax changes in \mathcode handling required) but doing anything for opentype fonts and unicode-math is a bit tricky as \symbf covers most use cases and \mathbf covers some more and for the other things that users might hope \bm to do something it will fail as there is no matching bold math font, so it's parked for a while: other priorities:-)

Bruno

David

wspr commented 6 years ago

I did think about having \symbf and \mathbf intersect in some way (e.g., single token input into \mathbf is typeset with \symbf, but I changed my mind).

I'm not keen on a dynamic lookup. However, I (think I) would be happy to add symbols to the remapping definitions for \symbf. Won't happen in the immediate future but I do have a plan for a big revamp of this package at some point.

wspr commented 6 years ago

@davidcarlisle The ord atom is because I use \math@bgroup/\math@egroup — not my fault :) Perhaps I should be a bit more flexible here though.

I've decided that I won't currently consider extending \symbf to support things like \boldsymbol or \bm — so I've added some documentation around this, and also fixed up the ord atom problem above.

Hope that's okay for now!