version not working on non math fonts
Description
I am trying to use version to introduce a bold version for some characters in a math font that lacks a bold version, but I do not seem to succeed. See the code samples below.
Add info or delete as appropriate:
- Relevant for LuaTeX
- Issue tracker has been searched for similar issues? Yes
Minimal example demonstrating the issue
This works in getting me a bold math version from another math font, when the main math font doesn't have it.
\documentclass{article}
\usepackage{unicode-math}
\usepackage{amsmath}
\setmathfont{Garamond-Math.otf}
\setmathfont{XITSMath-Bold.otf}[version=bold]
\begin{document}
\[
\boldsymbol{a} \neq a
\]
\end{document}
The first a is in math bold italic (from XITS Math Bold), the second one is in math italic (from Garamond Math, that lacks a bold version).
So, at this point, I was expecting to be able to practice further font substitutions, but this does not work anymore:
\documentclass{article}
\usepackage{unicode-math}
\usepackage{amsmath}
\setmathfont{Garamond-Math.otf}
\setmathfont{XITSMath-Bold.otf}[version=bold]
\setmathfont{CrimsonPro-Bold.otf}[%
version=bold, range=\mathup/{latin,Latin,greek,Greek}]
\setmathfont{CrimsonPro-BoldItalic.otf}[%
version=bold, range=\mathit/{latin,Latin,greek,Greek}]
\begin{document}
\[
\boldsymbol{a} \neq a
\]
\end{document}
For some reason the second a gets identical to the first one in Crimson Pro Bold Italic. Is this expected?
@callegar Not exactly related to your issue, but what make you think Garamond Math does not support bold math? It even allows you to chose with ss 4/5 whether you want bold, semi-bold or extra-bold!
Also you should not use \boldsymbol AFAICS, it’s an old deprecated things for greek only apparently, while \symbf should be used for unicode-math.
@ArchangeGabriel I may well be wrong about Garamond math (this is one of the first times I am dealing with it), but my initial impression is that it does not have a bold version. To the best of my understanding, one thing is to have bold character inside the font (and in this case apparently they exist also with multiple weights, as you observed) and a different thing is to have a bold version. The bold version is usefulf, for instance, if you want to put math in an abstract that is written in a bold font. In this way you get the regular symbols in a font whose weight is consistent with the surrounding text and the bold symbols even heavier (so that they can be recognized as bold even in that very particular context).
If Garamond math has a bold version (I'll double check), then good to know! My impression was that very few math fonts have one (XITS being one of the few).
So, right now, one of my problems is to typeset math properly even in abstracts and section titles that use bold (I know it is not good practice to put math there, but in some occasions you are not the only author).
Incidentally, this is one reason why I used \boldsymbol in my example. Yes the command is old and yes generally it is best avoided. Yet, this command is known to use (abuse?) the bold version of math fonts, so I used it in my example as a way to test it.
Another reason why \boldsymbol and some alternative implementations thereof (think bm) remains useful is in some mathematical notations employing vectors. In some cases, exactly the same literal is used for a vector and the entries of the vector. For the former a bold literal is used, for the latter a regular one, with a sub- or super-script indicating the index of the entry. In these cases, it can be very common to redefine the \vec command to boldify its argument. Using \symbfit as a definition can however be insatisfactory in some cases. For instance suppose that your vector is called $X_{\mathit{out}}$. If you define \vec using \symbfit and you put $X_{\mathit{out}}$ as its argument, then the out will not get in bold. With \boldsymbol (when it works) you get everything in bold, which may be preferable in some cases. In other words, a \vec based on \boldsymbol would boldify all of its argument regardless of what it is, while a \vec based on \symbfit would only boldify the literals.
Apart from these digressions, meant to represent that my original question was not merely speculative but also marginally practical, the question remains. Why does the second code sample also boldify the second $a$? Is that expected or a bug?
Oh, OK, I wasn’t aware about this version bit. I have no idea how this is implemented font-wise, but might not be very hard to do for Garamond considering they already are several weights.
Anyway, according to the unicode-math manual, they are some things that might be of interested to you:
To select a new maths font in a particular version, use the syntax \setmathfont{⟨font name⟩}[version=⟨version name⟩,⟨font features⟩] and to switch between maths versions mid-document use the standard LATEX com- mand \mathversion{⟨version name⟩}. Note there are currently open issues regarding the interaction between the version and the range features, so please proceed with caution.
Especially that last sentence. So I guess this very likely answer your question. ;)
Other than that, I indeed don’t agree with you. I do have bold vectors. But based on typographic rules, one should not bolden the subscript or superscript. So here is my \vec redefinition:
\renewcommand{\vec}{\@ifstar{\vecstar}{\overrightarrow}}
\def\vecstar#1#2{\overrightarrow{#1}_{\mkern-1mu\relax#2}}
Also, you should not use \mathit at all IIRC, and especially in the case you mention: out is a word, it should be typesetted as upgright.
And yes, maths in title is not a very good practice, and abstract should not be bold (actually according to purists bold should not exists in the first place, hence why Garamond did not have any in the first place, but that’s another debate).
@ArchangeGabriel
Note there are currently open issues regarding the interaction between the version and the range features, so please proceed with caution.
I had missed that! It definitely clarifies. Thanks for pointing out!
Other than that, I indeed don’t agree with you. [...] Based on typographic rules, one should not bolden the subscript or superscript. [...] Also, you should not use \mathit at all IIRC, and especially in the case you mention: out is a word, it should be typesetted as upgright.
In fact, we do agree, because you are obviously quite right! My problems emerge from the fact that we do not live in a perfect word. So it happens to find conferences that want the abstracts in bold, and situations where some math goes in them. And you also find situation where you need to use stuff that was developed by others, linking to it with a reference, and in this case you want to be notation-consistent with the original version. So if vectors were in bold including the subscript you keep that and if symbols had subscripts in italic, you keep that too. Incidentally, the latter is extremely frequent as many misuse subscripts as in $V_{out}$ and in this case the best you can do is to try to make it slightly better as $V_{\mathit{out}}$. My regret is that is in some cases the bad, legacy notation that sticks is from a previous version of myself that was more ignorant of typography than I currently am...