[Tex/LaTex] How to put a bar on top of a hat

stacking-symbols

I'm trying to type the conjugate of the fourier transform, so I want a bar over a hat. I only really know one way of doing this but these come out VERY scrambled:
$\overline{hat{f}}$ or $\bar{\hat{f}}$.

Help?

Best Answer

The accents package was designed for exactly the problem of stacking accents:

\documentclass{article}
\usepackage{accents}
\begin{document}
$\bar{\hat f}$
\end{document}

It redefines the way that accents are set up in regular LaTeX. This looks about right to me.

If you are using unicode-math, the OpenType maths fonts should be able to stack their accents well by default:

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{xits-math.otf}
\begin{document}
$\bar{\hat f}$
\end{document}

Well, it's not perfect…