I am using the libertinus font which also has math support. But when I try to place a hat on variables in this font, it seems too "flimsy." How to make the hat appear thicker?
I tried renewing the \hat{}
command to use a bold font, but it also changes the variable.
\let\oldhat\hat
\renewcommand{\hat}[1]{\mathbf{\oldhat{#1}}}
$\hat{\lambda}$ %% This is ok. \lambda does not become bold, and hat looks nice.
$\hat{p}$ %% This is not ok. It makes p also bold.
$\mathbf{\hat{p}}$ %% Ideally I want this to work as expected as well (it works now).
Is there some way to achieve what I want to do? I was thinking of some \ooalign
magic but wasn't able to figure out how to do it.
(Edit)
The question might've been a bit unclear, so here's some more clarification.
I also tried to do something using \ooalign
, but it's not perfect. The following is the basic setup.
\usepackage[T1]{fontenc}
\usepackage{libertinus}
\let\oldhat\hat
\renewcommand{\hat}[1]{{\ooalign{\ensuremath{\mathbf{\oldhat{\phantom{#1}}}}\cr\ensuremath{#1}\cr}}}
$\oldhat{P}\quad$ %% The hat is too flimsy
$\hat{P}\quad$ %% This is ok.
$\hat{\mathbf{P}}\quad$ %% This also works!
$\mathbf{\hat{P}}\quad$ %% Does not work!! ooalign messes up mathbf
As you can see, there are two issues with this.
The first is that the centering is not proper.
I think this is because the \mathbf{\oldhat{\phantom{#1}}}
part puts the variable in boldface, which messes up with the centering.
Another issue is that \mathbf{\hat{P}}
does not work.
How does one solve these two issues?
Another thing I wasn't so sure about was why we need so much \ensuremath
inside \ooalign
. It does not work without those (gives some error). Isn't it already in math mode? Why do we need to use \ensuremath
again? Does \ooalign
put stuff in text mode automatically?