0

I am using the Lucida Open Type Fonts, since they contain a bold math version. However, I found out that the command \symbf doesn't actually switch to the bold math font. I checked the embedded fonts with Acrobat Reader.

Is this behaviour by design and if so why? I thought the point of having a bold math font was to use it for typesetting bold math symbols.

Here is a MWE demonstrating the behaviour. It requires the Lucida Fonts to be installed on your system. Compile with LuaLaTeX (or XeLaTeX).

\documentclass{article}

\usepackage{amsmath} \usepackage[bold-style=ISO]{unicode-math} \defaultfontfeatures{Scale=.92} \setmainfont{Lucida Bright OT} \setmathfont{Lucida Bright Math OT} \setmathfont[version=bold]{Lucida Bright Math OT Demibold}

\NewDocumentCommand{\spat}{m}{\hat{\symbf{#1}}} \NewDocumentCommand{\Spat}{m}{\widehat{\symbf{#1}}}

\begin{document}

\begin{equation} \Spat{M} \spat{a} = \spat{f} \end{equation}

\end{document}

marv
  • 2,099
  • 1
  • 7
  • 26
  • 1
    the details depend on the exact font setup but the basic idea is that \mathxx is a font change but \symbf isn't a font change bu a "Unicode shift" up to the Unicode math alphabets in the block starting U+1D400, taking the characters from the current font compare A (a normal A, bold) and which is a Unicode math bold A – David Carlisle Apr 25 '22 at 06:59
  • 1
    the version=bold setting does not affect the font commands in normal math at all, that is setting up the font for bold math formulae, ie in the scope of \boldmath compare $x$ and \boldmath $x$ – David Carlisle Apr 25 '22 at 07:05
  • @DavidCarlisle understand, if I use \mathbf the bold math font is used. However, symbols are now typeset upright. If I use \mathbfit the bold math font is no longer used. This seems very strange to me. What is even the purpose of a specific bold math font then? I think I don't really understand the usecase... – marv Apr 25 '22 at 07:46
  • 1
    \boldmath sets the entire equation in the bold version, some people prefer that as a non-semantic stylistic device for math in headings for example. compare \textbf{some bold text $e=mc^2$ with math} and \textbf{\boldmath some bold text $e=mc^2$ with math} – David Carlisle Apr 25 '22 at 08:50
  • unicode-math uses \mathversion{<versionname>} to switch versions (covering symbols and operators). \symbf{} sets that specific symbol (not operators) to bold in whatever style (upright or italic) has been selected globally by the bold-style= option. And there is a \setoperatorfont command, so combinations and permutations become possible. Note that the Unicode math alphabets (24+: ) can be, and usually are, in the one font file (regular) along with the text Latin (and text Greek). – Cicada Apr 25 '22 at 13:17
  • 1
    Does this help? https://tex.stackexchange.com/questions/595/how-can-i-get-bold-math-symbols/471744#471744 – Davislor Apr 25 '22 at 13:32
  • It works perfectly for me, see this picture (click). In the second line I replicated the definitions but removing \symbf in order to make a comparison. – egreg Apr 25 '22 at 17:04
  • @egreg yes, I get the same results as you. The question was why the Open Type Bold math font wasn't used but instead the bold symbols of the regular weight font. – marv Apr 25 '22 at 17:34

1 Answers1

6

Short Answer

You want \boldsymbol{\hat{#1}}, not \hat{\symbf{#1}} or \hat{mathbf{#1}}.

Long Answer

There are three different commands to use some kind of “bold math” in unicode-math, and each does a different, specific thing. There are also ways to redefine the behavior of all of them.

The \symbf command substitutes alphanumeric symbols with the bold variants in the Mathematical Alphanumeric Symbols block of Unicode, from the same math font. So, $A$ would be by default (U+1D434, Mathematical Italic Capital A), and $\symbfit{A}$ would be (U+1D468, Mathematical Bold Italic Capital A), from the regular math font. Another alias for this symbol is $\mbfitA$. You can change this alphabet with \setmathfont[range=bfit], [range=bfup], etc. It has no effect on symbols other than the ones defined to have variants in Unicode. This is why (as you noticed), \symbf{\hat{#1}} does not work.

The \mathbf command in unicode-math is for bold upright words in math mode. By default, this uses the bold text font, but you can change this with \setmathrm[BoldFont = ...]. There is also a \setboldmathrm command (see the fontspec manual) to change the \mathrm, \mathbf, \mathit etc. fonts in the bold math version. Because you might have to copy over old formatting that uses \mathbf for symbols such as vectors, there is a \usepackage[mathbf=sym]{unicode-math} package option to interpret \mathbf as an alias for \symbfup instead. I personally like to use the amstext commands for words in math mode instead of \mathrm, \mathbf, etc.

Finally, what you seem to want is the bold math version, which loads a heavier OpenType math font. You switch to bold math before entering math mode with \boldmath or \mathversion{bold}, or you can use it within math mode as $\boldsymbol{\hat{x}}$. (The definition of \boldsymbol is in amsbsy.)

Note that the OpenType math font you load with \setmathfont[version=bold] will have its own Mathematical Alphanumeric Symbols block, so $\boldsymbol{\mathbf{A}}$ works and gives you an even heavier symbol (corresponding to \hm in the legacy bm package). This is mainly useful for being able to use bold symbols in titles. If you define your header formatting as \large\bfseries\boldmath, and then define your vector symbols with something like \newcommand\vectorsym[1]{\symbfit{#1}} (and you will thank yourself later for making it easy to change to a different house style), you can now write something like:

\section{Calculating \(m\vectorsym{v}\)}

Also, be warned: as of 2022, you cannot \setmathfont to use both range= and version= at the same time.

Davislor
  • 44,045
  • Thanks for the extensive explanation! To be honest, I don't know if "want" to use the OpenType math font. It was my misconception that it is designed to be used for all usages of bold math. I didn't know that there is a block for bold math symbols in the "non bold" font. If I understood your answer correctly, there is nothing wrong with using\symbf for bold math symbols even though it does not use the bold math font. Is that right`? – marv Apr 25 '22 at 13:56
  • Visually, I can't tell a difference between using \symbf and \boldsymbol. But the bold font is embedded in the pdf when using the latter. – marv Apr 25 '22 at 14:02
  • 1
    @marv It’s very likely that the bold Lucida math font and the bold symbols in the regular-weight Lucida math font use the same glyphs. One difference is that that there are bold symbols other than alphanumerics in the bold font. So, \boldmath{\hat{v}} works but \symbf{\hat{x}} doesn’t. – Davislor Apr 25 '22 at 15:46
  • Sorry, but the short answer is wrong. See my comment to the question and the picture. – egreg Apr 25 '22 at 17:05
  • @egreg It depends on whether you 1: want to use semibold weight instead of the default bold weight of \symbf, and 2: want the weight of the hat accent to match that of the characters beneath. If the desired output is what you posted in the picture, the original MWE does not need to be changed, as you say. – Davislor Apr 25 '22 at 17:23