latex3 / unicode-math

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

\symbf does not play nice with \hat, \tilde, etc. #501

Open callegar opened 5 years ago

callegar commented 5 years ago

Description

  1. \symbf does not work on identifiers with hats, tildes, etc. For instance, \symbf{\hat{\alpha}} produces a bold alpha with a regular hat, that looks bad.

  2. Now, \mathbf{\hat{A}} works fine with the hat, giving you a bold hat over a bold A. This shows that \mathbf is OK in boldifying the hat.

  3. Point 1, would not be such a big issue if \mathbf also worked with non latin alphabets. Unfortunately, as is \mathbf{\alpha} does not work. It does not error out, but as in standard latex it does not print the alpha at all.

  4. With the above points, the only way to produce a bold symbol with a bold hat, tilde etc. is to do something in the lines of \mathbf{\hat{\symbf{\alpha}}} which is not just overly complicated: it also makes impossible to write a command to wrap a general identifier resulting in its bold version, because to make a bold alpha with a bold hat you need to insert the \symbf between the \hat and the \alpha (rather than having something that can be wrapped around it).

  5. One may think that \symbf{\mathbf{\hat{\alpha}}} could be a solution. It is not. For some reason, rather than being a no-op on the hat, the outer \symbf forces it back to not being bold.

As possible solutions:

I think that \symbf should be made capable to make bold the decorators (hats, tildes, etc) attached to a symbol if the idea is to have it work as a semantic piece of markup, but it is unclear to me if this kind of behavior could be easy or impossible to achieve.

I also tend to think that with unicode-math things would be much easier if \mathbf could be made to work with greek letters. In the end, if \mathbf is meant to offer a way to use "use text bold- face in math" (as said in the manual), once you are working in unicode which offers text greek letters, it would be nice to be able to use them in math mode, either in italics or in bold, etc. Additionally, this change would break nothing, given that \mathbf with greek letters does not work in regular latex. This too, would offer an easy way to get a bold symbol with a bold accent as in \mathbf{\hat{\alpha}}, which currently produces only the bold hat. But again it is unclear to me if this kind of behavior an be easily achieved or is impossible at all.

If none of the above is possible, I think that at least \symbf should be made a true no-op on what it cannot be made bold, so that at least something like \symbf{\mathbf{\hat{\alpha}}} could deliver a bold accent over a bold alpha by a mere wrapping of the \hat{\alpha}.

Check/indicate

stone-zeng commented 5 years ago

IMHO, there is no need to use "bold" symbols (I mean non-letters or non-digits) in mathematical context. So \symbf command or \mathbf with mathbf=sym option will only make letters in bold version.

Note that a unicode/opentype math font will have special tricks on the accents (like TopAccentHorizontal value) to keep the position correct, while a normal text font will not do that. Therefore, simply use \mathbf will not give the thing you want:

image

\documentclass{article}
\usepackage{unicode-math}

\setmainfont{TeX Gyre Heros}
\setmathfont{XITS Math}

\begin{document}
\[ \symbf{H}+\symbf{\hat{H}}+\mathbf{H}+\mathbf{\hat{H}} \]
\end{document}

The most ideal solution that I can find, is to create a real bold version of a unicode/opentype math font:

image

\documentclass{article}
\usepackage{unicode-math}

\setmainfont{TeX Gyre Heros}
\setmathfont{XITS Math}
\setmathfont{XITS Math Bold}[version=bold]

\begin{document}
\[ \hat{H}+\symbf{\hat{\symit{H}}}+\symbf{H}+\symbf{\hat{H}}+\mathbf{H}+\mathbf{\hat{H}} \]
\mathversion{bold}
\[ \hat{H}+\symbf{\hat{\symit{H}}}+\symbf{H}+\symbf{\hat{H}}+\mathbf{H}+\mathbf{\hat{H}} \]
\end{document}

However, I still can't find an elegant way to create "a regular version symbol with a bold accent". Maybe we should add these symbols in the same font. But is it really necessary?

callegar commented 5 years ago

IMHO, there is no need to use "bold" symbols (I mean non-letters or non-digits) in mathematical context.

While I tend to agree that some notations are overly complicated, unfortunately, this tends to depend more on the practices of different communities in different scientific fields than on individual opinions.

The most ideal solution that I can find, is to create a real bold version of a unicode/opentype math font

This is still not enough, because you may that bold italic H with a bold accent in an equation where all the rest of the equation is not bold and because you can only switch to the bold math version outside math mode, mixing the bold and the non-bold version in an equation is quite hard to do. For instance, try to place a non-bold subscript on the side of that bold italic H keeping the correct spacing.

Most important, in some notation you need to get the bold version of something to indicate some variant or some specific instance of it. So you need to be able to wrap in a command something that is not bold and get its bold version by the wrapping. Which is the problem that bm tried to solve with plain latex.