I would like to replace the usual \hat in maths with a larger one, but I do not want it to stretch. The size I want is "the smallest \widehat" (as in $\widehat{.}$). Is there a way to put that one above a wide character like M ($\widehat{M}$ would stretch and give be an even wider hat).

I guess I have a lack of understanding for the mechanism behind accents that extend, so feel free to explain.

3 Answers 3


This is a bit tricky. I'm sorry. But the result is well.



\[ \fixwidehat{abc} \]

enter image description here

  • Aha, your \lowerwidehatsym did the trick. Thanks.
    – Martin
    Jun 11, 2011 at 16:26
  • 1
    @Liu I used this code to define new wide symbols \What and \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, 2013 at 14:18
  • @Aydin: \mathchoice might be somewhat slow. You can delete it and use just a \accentset{\textstyle\lowerwidehatsym}{#1} to define \What if you don't need \What in the super- or subscripts. But it is still slower than standard \hat.
    – Leo Liu
    Apr 12, 2013 at 14:26
  • @LeoLiu Is there a version of this solution that works with xelatex? Thanks.
    – GeoffV
    Mar 29, 2015 at 13:56
  • To clarify, if I add the line \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, 2015 at 14:16

  \dimen0 \fontcharic\next1 \skewchar\next1
  \advance\dimen0 -\fontcharic\next1`#2%
  \makebox[\widthof{$#1#2$}]{$#1\kern.5\dimen0 \widehat{\vphantom{#2}}$}}

This works only for single characters in normal math italic:


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.


Horizontally smash the object that is going to wear the hat. Then TeX will treat it as if it has no width.

\widehat{.} \quad \widehat{M} \quad \widehat{\mathclap{M}}

See the mathtools package documentation for more details of \mathclap and related commands.


Actually this is harder than I thought, as the smashed object will overlap with adjacent characters. To get around this, one could try something like this:

\hbox to \myboxwidth{\ensuremath{\hspace*{\fill}\widehat{\mathclap{#1}}}\hspace*{\fill}}
\widehat{.} \quad \widehat{M} \quad \mywidehat{M} \quad

However, as Leo says, the position of the accent may not be perfect, so his solution is probably better.

  • It's neet and smart. But the problem is that the position is not quite right: symbols are slanted thus the accents should be moved right a bit.
    – Leo Liu
    Jun 11, 2011 at 15:09
  • 2
    @Leo --- indeed. This is a lot harder than I thought at first. Jun 11, 2011 at 15:18
  • This is more or less how I started out, too... And then I gave up, and posted the question.
    – Martin
    Jun 11, 2011 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .