Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
For instance $\skew{5.5}\widehat{\widehat{f}}$ or $\skew{1.2}\widehat{\widehat{g}}$. I'm afraid that one has to fine tune them by hand. –  egreg May 6 '12 at 22:32
    
BTW, TL2012 versions of LuaTeX and XeTeX will support proper positioning for stacked accents like this (for OpenType math fonts only in case of XeTeX). –  Khaled Hosny May 6 '12 at 22:41
add comment

2 Answers

up vote 18 down vote accepted

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.
share|improve this answer
    
Also \hat{\hat{f}} works. The capitalized version remains for compatibility, but double accents are treated well with the normal commands. –  egreg May 6 '12 at 22:44
    
@egreg, so it does, the code also seems to work reasonably with widehat as well, see updated answer –  David Carlisle May 6 '12 at 22:50
    
Out of votes, ATM. :) Maybe @barbarabeeton can take note. –  egreg May 6 '12 at 22:52
    
Thanks for the responses! For completion, I should remark that if I have \usepackage{amsmath, amssymb} in the preamble instead, the above trick reverts to the standard behavior of \widehat{\widehat{f}} that occurs when you do nothing. To get around this, it seems that at least for double widehat-ing single letters one does \widehat{\widehat{f\, }} with the code in the answer above. However, for multiple letters like abcd, using amssymb doesn't affect the output of \widehat{\widehat{abcd}} –  ADF May 7 '12 at 0:18
    
Well no actually, maybe you should give that as an answer. If you use f\, then you don't need the redefinition at all as if the argument to (any) accent command isn't a single character it breaks the automatic shifting due to italic correction, so both accents are simply centered so they line up naturally. –  David Carlisle May 7 '12 at 0:51
show 1 more comment

The MathTime Professional 2 package (mtpro2 for short) provides methods for producing really really wide-hat symbols (as well as wide-tilde and wide-check symbols) and stacking these symbols, i.e., producing doubled widehat symbols.

enter image description here

\documentclass{article}
\usepackage{mtpro2}
\begin{document}
$\widehatdown{1.5pt}{\widehat{aceuvw}}$

\bigskip
$\widehatdown{2.5pt}{\widehat{A+B+C+D+E+F+G }}$
\end{document}

I must confess I hope you have no need for the lower of the two examples... Note also that the mtpro2 package produces Times Roman-type math fonts, which may or may not be a look you like.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.