My goal is to write a \unitvector
command which produces bold upright symbols with a bold circumflex accent. Here's my MWE:
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Bonum}
\setmathfont{texgyrebonum-math.otf}
\newcommand\unitvectorA[1]{\symbfup{\hat{#1}}}
\newcommand\unitvectorB[1]{\text{\textbf{\^{#1}}}}
\begin{document}
% Text versions for reference.
\textbf{\^{x}}
\textbf{\^{ρ}}
% First attempt: circumflex accent is not bold.
$\unitvectorA{x}$
$\unitvectorA{\rho}$
% Second attempt: missing \rho.
$\unitvectorB{x}$
$\unitvectorB{\rho}$
\end{document}
Here's the output:
There are other questions here which are similar to this one, but as far as I can tell, they either do not use unicode-math
, or they do not provide a bold circumflex accent. (If I'm wrong about that, I'd love to know.)
I believe I understand why \symbfup
doesn't do the "right" thing: Unicode does not define a "mathematical bold circumflex accent" (which seems like an oversight to me). I also do not have the luxury of using a math font which has a corresponding bold math font (such as XITS Math), which I believe would also provide a solution. Hence the attempted workaround using \text
which, unfortunately, is not a workaround at all as it does not work.
I attempted to use the range
feature of unicode-math
to switch out fonts in some clever way, but I failed to find an incantation which worked.
Update:
I modified Marcel Krüger's answer by replacing XITS Math Bold with TeX Gyre Bonum Bold and obtained this:
It seems that there should be a way to nudge the accents over, but I don't understand yet how \Umathaccent
works.