85

Is there any way to get a hat wider than widehat?

Why doesn't

\widehat{abcdefghijklmnopqrstuvwxyz}

really go over all of it?

hmmmm
  • 1,115
  • 4
    Wouldn't you prefer $(abcdefgh)^{\wedge}$? – Benjamin McKay Mar 02 '13 at 14:51
  • 4
    tilde version http://tex.stackexchange.com/questions/63545/big-tilde-in-math-mode – percusse Mar 02 '13 at 14:53
  • @BenjaminMcKay that just gives me a little wedge at the end? – hmmmm Mar 02 '13 at 15:10
  • 3
    @hmmmm Yes, exactly! I'm not sure what you want it for, I'm sure that the result won't be nice, no matter how much you try. Putting the whole thing in parenthesis, and the symbol as an exponent in the very end is quite a common way to do that (e.g. with open sets, word reversals etc.). IMHO \wedge is not the best option, and $(abcdefg)\widehat{\phantom{x}}$ would do a better job, but that it a matter of choice. – yo' Mar 02 '13 at 15:18
  • @tohecz I want it for the Fourier coefficients of two functions i.e $\widehat {f(x-y)g(p-q)} I don't actually want it for something quite that big. I'm also not really that concerned with how it looks, in my lectures notes it is done! – hmmmm Mar 02 '13 at 15:26
  • $\Bigl[f(x-y)g(p-q)\Bigr]^{\raisebox{-1ex}{$\mathchar"0362$}}$ – yo' Mar 02 '13 at 15:29
  • 2
    @hmmmm Yes, a little wedge at the end. As a mathematician, I would prefer Fourier transforms or series written with a hat or wedge (or check) at the end of the expression, if the expression is long, because otherwise the symbol looks too big to me. – Benjamin McKay Mar 02 '13 at 15:55
  • 2
    You can also write \mathcal{F}(f) for the Fourier transform of f; this is how I'd do it for longer expressions. – Hendrik Vogt Mar 03 '13 at 15:52
  • There's another, rather elegant, solution over here. – Thruston Apr 14 '15 at 20:51

4 Answers4

65

The question wasn't "should it be done?" But, for the same reason men climb mountains, "could it be done?" The answer, with the scalerel package, is yes. Thus, we introduce \reallywidehat [EDITED to add phantom rule below argument, so that baseline of result matches baseline of original argument. RE-EDITED to \ensuremath on the \widthof calculation (thanks to Thruston)]

See also my answer at Serious problem with \widebar for a related approach.

NEW ANSWER WITH stackengine

This answer is an improvement because it handles vertical space much better than the earlier solution.

\documentclass{article}
\usepackage{scalerel,stackengine}
\stackMath
\newcommand\reallywidehat[1]{%
\savestack{\tmpbox}{\stretchto{%
  \scaleto{%
    \scalerel*[\widthof{\ensuremath{#1}}]{\kern-.6pt\bigwedge\kern-.6pt}%
    {\rule[-\textheight/2]{1ex}{\textheight}}%WIDTH-LIMITED BIG WEDGE
  }{\textheight}% 
}{0.5ex}}%
\stackon[1pt]{#1}{\tmpbox}%
}
\parskip 1ex
\begin{document}

$\reallywidehat{zbcdefghijklm}$

$\reallywidehat{zbcdefghijk}$

$\reallywidehat{zbcdefghi}$

$\reallywidehat{zbcdefg}$

$\reallywidehat{zbcde}$

$\reallywidehat{zbc}$

$\reallywidehat{zb}$

$x\cdot\reallywidehat{a_1+a_2}\cdot y$

\end{document}

enter image description here

ALTERNATE ANSWER USING \mathchar"0362 (the \widehat accent) RATHER THAN \bigwedge

EDITED to use \mathchar"0362 rather than the normal carat accent (\mathchar"305E)

A comment requested this alternate form, which is perhaps superior to the given form above.

\documentclass{article}
\usepackage{scalerel,stackengine}
\stackMath
\newcommand\reallywidehat[1]{%
\savestack{\tmpbox}{\stretchto{%
  \scaleto{%
    \scalerel*[\widthof{\ensuremath{#1}}]{\kern.1pt\mathchar"0362\kern.1pt}%
    {\rule{0ex}{\textheight}}%WIDTH-LIMITED CIRCUMFLEX
  }{\textheight}% 
}{2.4ex}}%
\stackon[-6.9pt]{#1}{\tmpbox}%
}
\parskip 1ex
\begin{document}

$\reallywidehat{zbcdefghijklm}$

$\reallywidehat{zbcdefghijk}$

$\reallywidehat{zbcdefghi}$

$\reallywidehat{zbcdefg}$

$\reallywidehat{zbcde}$

$\reallywidehat{zbc}$

$\reallywidehat{zb}$

$x\cdot\reallywidehat{a_1+a_2}\cdot y$

$\widehat{zb}$ is actual widehat

\end{document}

enter image description here

EARLIER ANSWER WITH array

\documentclass{article}
\usepackage{scalerel}

\newcommand\reallywidehat[1]{\arraycolsep=0pt\relax%
\begin{array}{c}
\stretchto{
  \scaleto{
    \scalerel*[\widthof{\ensuremath{#1}}]{\kern-.5pt\bigwedge\kern-.5pt}
    {\rule[-\textheight/2]{1ex}{\textheight}} %WIDTH-LIMITED BIG WEDGE
  }{\textheight} % 
}{0.5ex}\\           % THIS SQUEEZES THE WEDGE TO 0.5ex HEIGHT
#1\\                 % THIS STACKS THE WEDGE ATOP THE ARGUMENT
\rule{-1ex}{0ex}
\end{array}
}

\begin{document}

$\reallywidehat{zbcdefghijklm}$

$\reallywidehat{zbcdefghijk}$

$\reallywidehat{zbcdefghi}$

$\reallywidehat{zbcdefg}$

$\reallywidehat{zbcde}$

$\reallywidehat{zbc}$

$\reallywidehat{zb}$

$x\cdot\reallywidehat{a_1+a_2}\cdot y$

\end{document}

enter image description here

  • @rmh, I have provided an alternate version to address your need. – Steven B. Segletes Apr 03 '18 at 15:31
  • Thanks a lot! But this does not look at all like the normal symbol used by \widehat. In fact it looks much worse than the \bigwedge solution. – Rupert Hölzl Apr 04 '18 at 16:24
  • @rmh I have edited to use the same glyph as \widehat, rather than the normal carat. Is this more to your liking? – Steven B. Segletes Apr 04 '18 at 16:37
  • Thanks once more! This is the best looking solution so far and I am happy to use it on my slides. // But for info: \widehat seems to be using two different symbols depending on the width. Up to a certain width (say for a single character) it uses the symbol you now use. Starting from a certain width, it uses a different version with rounded endpoints, as the diagonal lines become too slanted and start looking a little strange. Anyway, just pointing it out; I am happy with the current solution. Thanks again! – Rupert Hölzl Apr 09 '18 at 08:02
  • 1
    @user49915 See https://tex.stackexchange.com/questions/171907/serious-problem-with-widebar/171959#171959 and let me know if that solves your issue. – Steven B. Segletes Jan 28 '19 at 23:52
  • 1
    @user49915 Please return to that answer, and see the SUPPLEMENT I added to the answer to address the newtxmath issue. – Steven B. Segletes Jan 29 '19 at 17:57
23

An alternative (and very simple) solution consists in using the package yhmath (which, as far as I was able to understand from its documentation, requires the amsmath package).

With such a package (i.e. the yhmath) a "really" wide hat can be obtained by simply using the very same command

\widehat{}

As a beginner in LaTeX, I find this other possibility a little bit more friendly.

Vincent
  • 20,157
  • 1
    I think this should be the accepted answer. Much simpler than the others. – Adrian Keister Dec 07 '21 at 16:09
  • 1
    If you don't want to load the entire yhmath package, e.g. because of incompatibilities to other packages, you can also just load its widehat accent and place it onto a command like yhwidehat: \DeclareSymbolFont{yhlargesymbols}{OMX}{yhex}{m}{n} \DeclareMathAccent{\yhwidehat}{\mathord}{yhlargesymbols}{"62} – Felix Emanuel Feb 08 '22 at 11:12
20

While echoing the sentiment expressed in the earlier answer -- "this stuff really shouldn't be encouraged" -- I can't resist pointing out that \widehat can easily be made super-wide with the help of the mtpro2 (MathTime Professional II) package. Note that this package isn't free of charge and can't be downloaded from the CTAN. However, its "lite" subset -- which is all that's needed to create superwide "widehat" accents -- is free of charge and may be downloaded from this site.

enter image description here

\documentclass{article}
\usepackage[lite]{mtpro2}
\begin{document}
$ \widehat{abcdefghijklmnopqrstuvwxyz} $
\end{document}
Mico
  • 506,678
8

I tried some of these except the {mtpro2} since for submitting articles that might not be acceptable by publishers!

As I was not satisfied by the previous methods mentioned above, I tried to tailor another method, you can apply the following code, play with the scale factors and positions and choose which one you prefer. The last two I recommend but I myself prefer the last, which I am going to use myself:

\documentclass{article}

\usepackage{amsmath} \usepackage{amssymb} \usepackage[ngerman]{babel} \usepackage{stackengine} \usepackage{scalerel}

\begin{document}

[\widehat{ABCDEF}]

[\stackon[0pt]{ABCDEF}{\hstretch{7.0}{\wedge}}]

[\stackon[-8pt]{ABCDEF}{\vstretch{1.5}{\hstretch{9.0}{\widehat{\phantom{;}}}}}]

[\stackon[-8pt]{ABCDEF}{\vstretch{1.5}{\hstretch{2.4}{\widehat{\phantom{;;;;;;;;}}}}}]

\end{document}

The result would be something like this:

enter image description here

luchonacho
  • 4,161