\usepackage{calc}
\newcommand{\styletofont}[1]{%
\ifx\displaystyle#1\let\next\textfont\fi
\ifx\textstyle#1\let\next\textfont\fi
\ifx\scriptstyle#1\let\next\scriptfont\fi
\ifx\scriptscriptstyle#1\let\next\scriptscriptfont\fi}
\newcommand{\innfwhat}[2]{%
\styletofont{#1}%
\dimen0 \fontcharic\next1 \skewchar\next1
\advance\dimen0 -\fontcharic\next1`#2%
\makebox[0pt][l]{$#1#2$}%
\makebox[\widthof{$#1#2$}]{$#1\kern.5\dimen0 \widehat{\vphantom{#2}}$}}
\newcommand{\fwhat}{\mathpalette\innfwhat}
This works only for single characters in normal math italic:
$\fwhat{A}\fwhat{B}_{\fwhat{C}}$
For combinations of characters the solution by Leo Liu is perfect.
The wide accents point automatically to a larger version that is chosen depending on the width of the accentee, so we first of all need to hide its width. However, when the accent is over a single character, it is skewed by computing the difference of the italic correction of this character with a fixed character in the font (the "skewchar").
This computation is done by TeX behind the scenes and it would be necessary a lot of work to accommodate for things such as \fwhat{\mathbf{A}}. However, if the math symbol is upright, there's no need to skew the accent and Leo Liu's solution can be used.
\Whatand\Wtilde. I have many equations with these symbols, the result is pleasing, but it painfully slows down my latex compilation. Is there any way to improve the performance? – Aydin Jan 21 '13 at 14:18\mathchoicemight be somewhat slow. You can delete it and use just a\accentset{\textstyle\lowerwidehatsym}{#1}to define\Whatif you don't need\Whatin the super- or subscripts. But it is still slower than standard\hat. – Leo Liu Apr 12 '13 at 14:26\usepackage{amsmath,unicode-math}at the top of your code, and typeset with xelatex, then an error message arises in accents.sty. If unicode-math is not called it works fine, but this isn't then a viable solution in most cases. – GeoffV Mar 29 '15 at 14:16\accentset. – Gargantuar Jan 27 '24 at 22:22