TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 8 down vote accepted

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



\[ \fixwidehat{abc} \]

enter image description here

share|improve this answer
Aha, your \lowerwidehatsym did the trick. Thanks. – Martin Jun 11 '11 at 16:26
@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 '13 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 '13 at 14:26
@Liu, thanks for clarification. – Aydin Apr 16 '13 at 12:32
@LeoLiu Is there a version of this solution that works with xelatex? Thanks. – GeoffV Mar 29 '15 at 13:56

  \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.

share|improve this answer

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.

share|improve this answer
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 '11 at 15:09
@Leo --- indeed. This is a lot harder than I thought at first. – Ian Thompson Jun 11 '11 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 '11 at 15:36

Your Answer


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.