# horizontal alignment of dot over hat over bold greek letter!

For some strange reason, this:

\hat{\dot{\bm{\phi}}}


prints the dot and the hat slightly off the left of the phi letter. Any ideas if this can be fixed? thanks. Using bm package for bold symbols.

-
@sfrancky: if you don't mind having the accent bold, you can simply do \bm{{\hat{\dot{\phi}}}}. –  Philippe Goutet Feb 8 '11 at 21:57

$\mkern4mu\hat{\mkern-4mu\dot{\bm{\phi}}}$

$\skew{3}{\hat}{\skew{3}{\dot}{\bm{\phi}}}$

-
thanks for the reply! i was hoping for a somewhat more "official" solution, though..also, this aligns only the dot, not the hat! –  sfranky Jan 18 '11 at 19:07
you can use \skew, but it needs also a manual setting –  Herbert Jan 18 '11 at 19:18
it's great!! I made a new command in my preamble so that i don't need to type it every time! thanks very much! –  sfranky Jan 18 '11 at 19:40
@sfranky: In the first version, \mkern4mu should be inserted before the \hat (which I just did). @Herbert: I took the freedom to make this change. Hope you agree. –  Hendrik Vogt Jan 19 '11 at 10:08

As to why this happens: TeX handles accents over single characters differently, using the \skewchar of the font. Thus you get nicely aligned math accents only over single characters, and \dot{\bm{\phi}} is already a composed symbol.

If you want double accents, you can use the amsmath or the accents package. However, both packages don't work together well with bm, so the simple \hat{\dot{\bm{\phi}}} won't work with \usepackage{accents}. It took me forever to find out what happens, but here's a fix:

\documentclass{minimal}
\usepackage{bm,accents}

\makeatletter
\newcommand\accbm[1]{\use@mathgroup{\M@OMS}{5}{\bm{#1}}}
\makeatother

\begin{document}
$\hat{\dot{\accbm{\phi}}}$
\end{document}


This gives you . Thus, whenever you want to put accents over \bmed characters, you just have to use \accbm. I should add a few words of caution: 1. It works with \M@OMS, but I don't know if it's the Right Way. 2. In this example, it works with font family 5 in the \use@mathgroup, but I don't know if it'll always work with 5.

UPDATE: Philippe Goutet's great answer to my question How do I identify the encoding and family of a new math font? provides a solution that determines the font family automatically.

-
thanks for this, it's really useful, I ll embed it. Your words of caution though, I don't have the slightest idea what you are talking about :( –  sfranky Jan 19 '11 at 16:24
@sfranky: It's not necessary that you understand them; just keep in mind that it might not always work. (I don't fully understand the solution myself.) If it doesn't work in your file, please tell me! –  Hendrik Vogt Jan 19 '11 at 16:28

It's easier to get accent positioning right if the accents are bold as well as the base. Also if \bm does get confused by its argument adding an extra set of {} stops it trying to disassemble the math construct and instead it sets the entire argumant as a sing;e expression (using \boldmath, essentially) this is a lot simpler (but slower). Note the extra set of braces, and the better accent positioning in row 9.

\documentclass{article}

\usepackage{amsmath}

\usepackage{bm}

\begin{document}

1 $\mathcal{A} \bm{\mathcal{A}}$

2 $\hat{\mathcal{A}} \bm{\hat{\mathcal{A}}}$

3 $\mathcal{\hat{A}} \bm{\mathcal{\hat{A}}}$

4 $\hat{\hat{\mathcal{A}}} \bm{\hat{\hat{\mathcal{A}}}}$

5 $\mathcal{\hat{\hat{A}}} \bm{\mathcal{\hat{\hat{A}}}}$

6 $\phi \bm{\phi}$

7 $\hat{\phi} \bm{\hat{\phi}}$

8 $\hat{\hat{\phi}} \bm{\hat{\hat{\phi}}}$

9 $\hat{\hat{\phi}} \bm{{\hat{\hat{\phi}}}}$

\end{document}

-
Nice and simple, greatly appreciated! –  eacousineau Jan 22 at 16:57