[Tex/LaTex] How does one make a double widehat

symbols

To depict the Fourier transform of the Fourier transform of a function f, I want to make two widehats over each other as in \widehat{\widehat{f}}, however, this makes the widehats not immediately over each other. How would one make the widehats immediately above each other?

Best Answer

Do you need the wide version? AMS provides \Hat accent that shifts when doubled, but the package doesn't provide a wide version that does this.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\[
\Hat{\Hat{f}}
\]
\end{document}

enter image description here

Actually amsmath contains code to make stacked widehat work but it is commented out for some reason. If you copy the code and uncomment widehat you get:

enter image description here

\documentclass{article}
\usepackage{amsmath}


\makeatletter
\def\@tempa#1{\@xp\@tempb\meaning#1\@nil#1}
\def\@tempb#1>#2#3 #4\@nil#5{%
  \@xp\ifx\csname#3\endcsname\mathaccent
    \@tempc#4?"7777\@nil#5%
  \else
    \PackageWarningNoLine{amsmath}{%
      Unable to redefine math accent \string#5}%
  \fi
}
\def\@tempc#1"#2#3#4#5#6\@nil#7{%
  \chardef\@tempd="#3\relax\set@mathaccent\@tempd{#7}{#2}{#4#5}}


\@tempa\widehat
\makeatother
\begin{document}
\[
\widehat{\widehat{f}}
\widehat{\widehat{abcd}}
\]
\end{document}

The amsmath documentation actually mentions why \widehat is omitted, but I think if you don't needed the wider wide hats provided by the amsfonts definition, using the amsmath stacking version is OK.

For widehat and
widetilde, we need to avoid clobbering the definitions done by the
\pkg{amsfonts} package. Arbitrating the contention between
\pkg{amsmath} and \pkg{amsfonts} to allow doubling a widetilde
accent looks tricky, so for the time being [mjd,1999/07/19] we just
leave \cn{widehat} and \cn{widetilde} alone.