I'm using the code from Tianren Liu's answer to How do I robustly typeset a double-hat? to typeset double-hat accents in math mode, but sometimes the horizontal alignment is off. To wit:

    $$\hat\bfbeta \quad \hat\bfu$$
    $$\doublehat\bfbeta \quad \doublehat\bfu$$

This yields:

Example output

The double hat on the u is fine, but that on the beta is much further to the left than it should be, and doesn't look good. I lack the TeX skills to fix this, but would much appreciate the help of any wizard. Thanks!


You can measure the result of math-accent \hat (which is positioned by kern of nucleus with \skewchar). The \skewchar is not important in the following macro, we do only measuring the result by un-boxing boxes:

   \setbox0=\hbox{\unhbox1 \unskip\unpenalty\unskip \global\setbox2=\lastbox}%
   \setbox0=\vbox{\unvbox2 \setbox0=\lastbox}%
   \measurehat{#1}\dimen0=\wd0 \measurehat{\kern0pt#1}%

% try this:
$$\hat\bfbeta \quad \hat\bfu$$
$$\doublehat\bfbeta \quad \doublehat\bfu$$
  • Wow, excellent. That is exactly the kind of deep wizardry I was hoping for!
    – chsk
    Mar 11 at 19:59

This is not really a satisfying answer, because it requires the user to do two things: indicate whether the glyph to be hatted is rm or it in shape, and also to specify the tangent of the font's italic slant angle in the macro \tanslant.

With that, I introduce \hatsrm[<n>]{<token>} and \hatsit[<n>]{<token>} to place n hats (default 2) over the roman or italic token, respectively.

This is only set up currently for text or display style. If it is needed in the smaller math styles, let me know...perhaps something could be done.


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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