# How to produce a longer \sim with a small letter on top

I am able to produce a standard length \sim with a tiny S above it, but I would like the \sim tilde to be longer (maybe one and half times as wide as a capital letter). Any tips on how to change the width/length of \sim?

-

\usepackage{amsmath,graphicx}
\newcommand{\widesim}[2][1.5]{
\mathrel{\overset{#2}{\scalebox{#1}[1]{$\sim$}}}
}

$A \widesim{S} B$

$A \widesim[2]{SS} B$


If the scaling is not excessive, the symbol should render well. The optional argument, that tells LaTeX how much to scale horizontally, should not be more than 2.5, otherwise some artifacts will appear. The default value is, as you requested, 1.5.

-