1

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

This gives the output below: enter image description here

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?

2
  • Welcome to tex,sx. Aug 27, 2022 at 4:06
  • It does not look as if you are using libertinus-math but some other math font. If you load the libertinus package and compile with lualatex you will get that, and all math will hopefully fit better with your text (and the hat will look different, I think OK).
    – mickep
    Aug 27, 2022 at 9:37

2 Answers 2

2

enter image description here

You want the middle form, with \bm just applied to \hat

\documentclass{book}
\usepackage{bm}

\begin{document}

$\hat{V}\quad \bm{\hat}{V}\quad \bm{\hat{V}}$

\end{document}
0

Hope this will meet the requirement:

\documentclass{book}
\usepackage{mathtools}

\begin{document}

$\hat{V}$\quad$\boldsymbol{\hat{V}}$

\end{document}
1
  • 1
    \boldsymbol makes the V as bold as well, right? I just want the hat to be bold, not the symbols under the hat.
    – Akhil
    Aug 27, 2022 at 4:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .