# Customize the width of \widetilde on letters H, K, M, N, W, and X

For example either

$\widetilde{\bm{H}}$


or

$\widetilde{\boldsymbol{H}}$


would result rather huge tilde over the letter H, K, M, N, W, and X, please see the following alphabet:

I can understand the command adaptively adjust the width for specific letters, but how could I customize this width?

-
I suggest removing the references to \bold... (in title and in tags) since this happens with non-bold symbols as well. –  tohecz Mar 19 '12 at 19:53
@tohecz Sure, thanks for the heads up. –  Shuhao Cao Mar 19 '12 at 20:53

This code defines three macros:

1. \mathcenterto{#1}{#2} that typesets #2 to be centered to the size of #1;
2. \widetildeto{#1}{#2} that put the wide tilde over #2 but it thinks it is of size #1. If you wish to have all wide tildes in the whole document to be the same, you can put \def\widetilde{\widetildeto{X}} or any other letter instead of X;
3. \widehatto{#1}{#2} for \widehat.

Remark: it needs mathtools package besides amsmath!

Warning: the parameters cannot contain active macros, becuase #1 gets expanded twice and #2 get expanded 3 times! You can still use most math macors like \vec, \bm, \frac, ... Prohibited are macros like \newcommand, \addtocounter, ...

\documentclass{article}

\usepackage{amsmath,mathtools}

\makeatletter
\def\mathcenterto#1#2{\mathclap{\phantom{#1}\mathclap{#2}}\phantom{#1}}
\let\old@widetilde\widetilde
\def\widetildeto#1#2{\mathcenterto{#2}{\old@widetilde{\mathcenterto{#1}{#2\,}}}}
\let\old@widehat\widehat
\def\widehatto#1#2{\mathcenterto{#2}{\old@widehat{\mathcenterto{#1}{#2\,}}}}
\makeatother

\begin{document}

$\widetildeto{I}{W} \widetilde{I}$

$\widetilde{W} \widetildeto{W}{I}$

\def\widetilde{\widetildeto{X}}

$\widetilde{W} \widetilde{I}$

\end{document}

-
the mathtools package loads the amsmath package, so you only need to use \usepackage{mathtools} :) –  cmhughes Mar 19 '12 at 21:09
@cmhughes I know, but I tend to load them both. It doesn't hurt and when you use commands from both, it seems to me somehow "cleaner" ... Just a matter of taste –  tohecz Mar 20 '12 at 9:23
@Jon No, I use \def because I grew up using TeX primitives instead of the LaTeX ones. It has nothing to do with the Remark. The Remark just says: Don't put anything like \newcommand (or \def) or such into the patameters of \widetildeto and other 2 defined commands. –  tohecz Mar 20 '12 at 9:25
@tohecz Thanks a lot, I got it! Please pardon my reading comprehension. :'( –  Shuhao Cao Mar 20 '12 at 14:45