bold math with hat

I'm struggling with a case of (silently) disappearing hat. It works fine on one computer, but on another I don't see the first accent:

\documentclass[border=3mm,preview]{standalone}

\usepackage[math-style=TeX]{unicode-math}
\setmathfont{xits-math.otf}

\begin{document}
$\mathbf{\hat d}, \mathbf{d}, \hat d$
\end{document}


I've just upgraded to MacTeX 2017 to see if that would help, but no luck. unicode-math just doesn't seem to like the bold math hat. Is there a good workaround? I should mention that I'm using xetex, and the intended main font would be Source Sans Pro.

• Try \symbf instead of \mathbf. – Henri Menke Jul 21 '17 at 4:22
• Or do \setmathfontface\mathbf{xits-bold.otf} and enjoy the misplaced hat. – Henri Menke Jul 21 '17 at 4:24
• actually, both solutions give me a misplaced hat (right and left, respectively). What's going on? – baptiste Jul 21 '17 at 5:02

I'd like to suggest that you do yourself a big favor and download and install the STIX Two text and math fonts. The STIX Two fonts are much nicer and better designed that either the Stix or the XITS fonts.

The following code runs under both XeLaTeX and LuaLaTeX.

\documentclass[border=3mm,preview]{standalone}
\usepackage[math-style=TeX]{unicode-math}
\setmathfont{STIX Two Math}
\begin{document}
$$\mathrm{d}, d, \hat{d}, \symbf{d}, \hat{\symbf{d}}, \symbf{\hat{d}}$$
\end{document}

• thanks! it works well on this example, unfortunately for my longer document I'm getting a dreaded ! Internal error: bad native font flag in map_char_to_glyph' and I'm not even sure which section is the problem – baptiste Jul 21 '17 at 5:34
• @baptiste - Please try to narrow down where the problem is occurring and then post a representative part of the problematic code. – Mico Jul 21 '17 at 5:37
• I found the issue and solved it; I'd inherited some weird {\hat {\mathbf {\theta }}} from somewhere, and those were the problem. The document compiles now, and looks mostly good. One slight issue is the hat's position on bold theta, \symbf{\hat{\theta}} is a bit off. – baptiste Jul 21 '17 at 6:19
• @baptiste I get no displacement with XITS Math. Unfortunately the STIX Two Math font seems to be plagued by small bugs. – egreg Jul 21 '17 at 7:57

You can use the command \boldsymbold which is in the amsmath package.

\documentclass[12pt,a4paper,oneside,titlepage]{scrartcl}
\usepackage{amsmath}
\begin{document}
$\hat{d}$
$\boldsymbol{\hat{d}}$
\end{document}
`

• Welcome to TeX.SX! Thanks for taking your time to answer a question. Here you can find some helpful [tips on how to make your answer great](tex.stackexchange.com/help/how-to-answer great) for the future. – Bobyandbob Jul 21 '17 at 9:41
• thanks, but that doesn't seem to work well with other math fonts – baptiste Jul 23 '17 at 22:32