1

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} 
8
  • 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 Commented Apr 25, 2022 at 6: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$ Commented Apr 25, 2022 at 7: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... Commented Apr 25, 2022 at 7: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} Commented Apr 25, 2022 at 8:50
  • 1
    Does this help? tex.stackexchange.com/questions/595/… Commented Apr 25, 2022 at 13:32

1 Answer 1

7

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.

5
  • 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`? Commented Apr 25, 2022 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. Commented Apr 25, 2022 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. Commented Apr 25, 2022 at 15:46
  • Sorry, but the short answer is wrong. See my comment to the question and the picture. Commented Apr 25, 2022 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. Commented Apr 25, 2022 at 17:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.